mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
6792a40924
The page course/section.php has been created, to display the content of a single section. This page will only accept sectionid (to get rid of the legacy sectionnumber). Some features of this page: - The General section won't be displayed anymore above the selected section. - In the main course page content, regardless of the Course layout ("All sections on one page" vs "One section per page"), all the section names will link to the new page (except when editing mode is on).
147 lines
5.1 KiB
PHP
147 lines
5.1 KiB
PHP
<?php
|
|
// This file is part of Moodle - http://moodle.org/
|
|
//
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
/**
|
|
* This file contains main class for the course format Social
|
|
*
|
|
* @since Moodle 2.0
|
|
* @package format_social
|
|
* @copyright 2009 Sam Hemelryk
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
*/
|
|
|
|
defined('MOODLE_INTERNAL') || die();
|
|
require_once($CFG->dirroot. '/course/format/lib.php');
|
|
|
|
/**
|
|
* Main class for the Social course format
|
|
*
|
|
* @package format_social
|
|
* @copyright 2012 Marina Glancy
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
*/
|
|
class format_social extends core_courseformat\base {
|
|
|
|
/**
|
|
* The URL to use for the specified course
|
|
*
|
|
* @param int|stdClass $section Section object from database or just field course_sections.section
|
|
* if null the course view page is returned
|
|
* @param array $options options for view URL. At the moment core uses:
|
|
* 'navigation' (bool) ignored by this format
|
|
* 'sr' (int) ignored by this format
|
|
* @return null|moodle_url
|
|
*/
|
|
public function get_view_url($section, $options = array()) {
|
|
return new moodle_url('/course/view.php', ['id' => $this->courseid]);
|
|
}
|
|
|
|
/**
|
|
* Loads all of the course sections into the navigation
|
|
*
|
|
* @param global_navigation $navigation
|
|
* @param navigation_node $node The course node within the navigation
|
|
*/
|
|
public function extend_course_navigation($navigation, navigation_node $node) {
|
|
// Social course format does not extend navigation, it uses social_activities block instead
|
|
}
|
|
|
|
/**
|
|
* Returns the list of blocks to be automatically added for the newly created course
|
|
*
|
|
* @return array of default blocks, must contain two keys BLOCK_POS_LEFT and BLOCK_POS_RIGHT
|
|
* each of values is an array of block names (for left and right side columns)
|
|
*/
|
|
public function get_default_blocks() {
|
|
return array(
|
|
BLOCK_POS_LEFT => array(),
|
|
BLOCK_POS_RIGHT => array('social_activities')
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Definitions of the additional options that this course format uses for course
|
|
*
|
|
* social format uses the following options:
|
|
* - numdiscussions
|
|
*
|
|
* @param bool $foreditform
|
|
* @return array of options
|
|
*/
|
|
public function course_format_options($foreditform = false) {
|
|
static $courseformatoptions = false;
|
|
if ($courseformatoptions === false) {
|
|
$courseformatoptions = array(
|
|
'numdiscussions' => array(
|
|
'default' => 10,
|
|
'type' => PARAM_INT,
|
|
)
|
|
);
|
|
}
|
|
|
|
if ($foreditform && !isset($courseformatoptions['numdiscussions']['label'])) {
|
|
$courseformatoptionsedit = array(
|
|
'numdiscussions' => array(
|
|
'label' => new lang_string('numberdiscussions', 'format_social'),
|
|
'help' => 'numberdiscussions',
|
|
'help_component' => 'format_social',
|
|
'element_type' => 'text',
|
|
)
|
|
);
|
|
$courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsedit);
|
|
}
|
|
return $courseformatoptions;
|
|
}
|
|
|
|
/**
|
|
* Returns whether this course format allows the activity to
|
|
* have "triple visibility state" - visible always, hidden on course page but available, hidden.
|
|
*
|
|
* @param stdClass|cm_info $cm course module (may be null if we are displaying a form for adding a module)
|
|
* @param stdClass|section_info $section section where this module is located or will be added to
|
|
* @return bool
|
|
*/
|
|
public function allow_stealth_module_visibility($cm, $section) {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Return the plugin configs for external functions.
|
|
*
|
|
* @return array the list of configuration settings
|
|
* @since Moodle 3.5
|
|
*/
|
|
public function get_config_for_external() {
|
|
// Return everything (nothing to hide).
|
|
return $this->get_format_options();
|
|
}
|
|
|
|
/**
|
|
* Returns the information about the ajax support in the given source format.
|
|
*
|
|
* The returned object's property (boolean)capable indicates that
|
|
* the course format supports Moodle course ajax features.
|
|
*
|
|
* @return stdClass
|
|
*/
|
|
public function supports_ajax() {
|
|
$ajaxsupport = new stdClass();
|
|
$ajaxsupport->capable = true;
|
|
return $ajaxsupport;
|
|
}
|
|
|
|
}
|