diff --git a/admin/oacleanup.php b/admin/oacleanup.php
index fe2e444472b..6f563556b32 100644
--- a/admin/oacleanup.php
+++ b/admin/oacleanup.php
@@ -59,6 +59,12 @@ function online_assignment_cleanup($output=false) {
if ($output) echo $OUTPUT->heading($fullname);
/// retrieve a list of sections beyond what is currently being shown
+ $course = course_get_format($course)->get_course();
+ if (!isset($course->numsections)) {
+ // Course format does not use numsections
+ if ($output) echo 'No extra sections
';
+ continue;
+ }
$sql = "SELECT *
FROM {course_sections}
WHERE course=? AND section>?
diff --git a/backup/moodle2/backup_stepslib.php b/backup/moodle2/backup_stepslib.php
index 0c7df0c7481..1a033d98d85 100644
--- a/backup/moodle2/backup_stepslib.php
+++ b/backup/moodle2/backup_stepslib.php
@@ -437,10 +437,10 @@ class backup_course_structure_step extends backup_structure_step {
$course = new backup_nested_element('course', array('id', 'contextid'), array(
'shortname', 'fullname', 'idnumber',
- 'summary', 'summaryformat', 'format', 'coursedisplay', 'showgrades',
- 'newsitems', 'startdate', 'numsections',
+ 'summary', 'summaryformat', 'format', 'showgrades',
+ 'newsitems', 'startdate',
'marker', 'maxbytes', 'legacyfiles', 'showreports',
- 'visible', 'hiddensections', 'groupmode', 'groupmodeforce',
+ 'visible', 'groupmode', 'groupmodeforce',
'defaultgroupingid', 'lang', 'theme',
'timecreated', 'timemodified',
'requested',
diff --git a/blocks/section_links/block_section_links.php b/blocks/section_links/block_section_links.php
index a8a0a93fe46..c0b8b335908 100644
--- a/blocks/section_links/block_section_links.php
+++ b/blocks/section_links/block_section_links.php
@@ -71,7 +71,7 @@ class block_section_links extends block_base {
return $this->content;
}
- $course = $this->page->course;
+ $course = course_get_format($this->page->course)->get_course();
$context = context_course::instance($course->id);
if ($course->format == 'weeks' or $course->format == 'weekscss') {
diff --git a/course/changenumsections.php b/course/changenumsections.php
index 3354f1c38b9..7cc4b618963 100644
--- a/course/changenumsections.php
+++ b/course/changenumsections.php
@@ -30,7 +30,7 @@ require_once($CFG->dirroot.'/course/lib.php');
$courseid = required_param('courseid', PARAM_INT);
$increase = optional_param('increase', true, PARAM_BOOL);
-$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
+$course = course_get_format($courseid)->get_course();
$PAGE->set_url('/course/changenumsections.php', array('courseid' => $courseid));
@@ -39,18 +39,20 @@ require_login($course);
require_capability('moodle/course:update', context_course::instance($course->id));
require_sesskey();
-if ($increase) {
- // Add an additional section.
- $course->numsections++;
-} else {
- // Remove a section.
- $course->numsections--;
-}
+if (isset($course->numsections)) {
+ if ($increase) {
+ // Add an additional section.
+ $course->numsections++;
+ } else {
+ // Remove a section.
+ $course->numsections--;
+ }
-// Don't go less than 0, intentionally redirect silently (for the case of
-// double clicks).
-if ($course->numsections >= 0) {
- $DB->update_record('course', $course);
+ // Don't go less than 0, intentionally redirect silently (for the case of
+ // double clicks).
+ if ($course->numsections >= 0) {
+ course_get_format($course)->update_course_format_options(array('numsections' => $course->numsections));
+ }
}
$url = course_get_url($course);
diff --git a/course/edit_form.php b/course/edit_form.php
index 2231cc4474c..70b709a9978 100644
--- a/course/edit_form.php
+++ b/course/edit_form.php
@@ -126,29 +126,10 @@ class course_edit_form extends moodleform {
$mform->registerNoSubmitButton('updatecourseformat');
$mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
- $mform->addElement('select', 'coursedisplay', get_string('coursedisplay'),
- array(COURSE_DISPLAY_SINGLEPAGE => get_string('coursedisplay_single'),
- COURSE_DISPLAY_MULTIPAGE => get_string('coursedisplay_multi')));
- $mform->addHelpButton('coursedisplay', 'coursedisplay');
- $mform->setDefault('coursedisplay', $courseconfig->coursedisplay);
-
- for ($i = 0; $i <= $courseconfig->maxsections; $i++) {
- $sectionmenu[$i] = "$i";
- }
- $mform->addElement('select', 'numsections', get_string('numberweeks'), $sectionmenu);
- $mform->setDefault('numsections', $courseconfig->numsections);
-
$mform->addElement('date_selector', 'startdate', get_string('startdate'));
$mform->addHelpButton('startdate', 'startdate');
$mform->setDefault('startdate', time() + 3600 * 24);
- $choices = array();
- $choices['0'] = get_string('hiddensectionscollapsed');
- $choices['1'] = get_string('hiddensectionsinvisible');
- $mform->addElement('select', 'hiddensections', get_string('hiddensections'), $choices);
- $mform->addHelpButton('hiddensections', 'hiddensections');
- $mform->setDefault('hiddensections', $courseconfig->hiddensections);
-
$options = range(0, 10);
$mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options);
$mform->addHelpButton('newsitems', 'newsitemsnumber');
diff --git a/course/format/formatlegacy.php b/course/format/formatlegacy.php
index 470e414fedc..e6141a3bd7e 100644
--- a/course/format/formatlegacy.php
+++ b/course/format/formatlegacy.php
@@ -98,8 +98,46 @@ class format_legacy extends format_base {
}
}
- // else, default behavior:
- return parent::get_view_url($section, $options);
+ // if function is not defined
+ if (!$this->uses_sections() ||
+ !array_key_exists('coursedisplay', $this->course_format_options())) {
+ // default behaviour
+ return parent::get_view_url($section, $options);
+ }
+
+ $course = $this->get_course();
+ $url = new moodle_url('/course/view.php', array('id' => $course->id));
+
+ $sr = null;
+ if (array_key_exists('sr', $options)) {
+ $sr = $options['sr'];
+ }
+ if (is_object($section)) {
+ $sectionno = $section->section;
+ } else {
+ $sectionno = $section;
+ }
+ if ($sectionno !== null) {
+ if ($sr !== null) {
+ if ($sr) {
+ $usercoursedisplay = COURSE_DISPLAY_MULTIPAGE;
+ $sectionno = $sr;
+ } else {
+ $usercoursedisplay = COURSE_DISPLAY_SINGLEPAGE;
+ }
+ } else {
+ $usercoursedisplay = $course->coursedisplay;
+ }
+ if ($sectionno != 0 && $usercoursedisplay == COURSE_DISPLAY_MULTIPAGE) {
+ $url->param('section', $sectionno);
+ } else {
+ if (!empty($options['navigation'])) {
+ return null;
+ }
+ $url->set_anchor('section-'.$sectionno);
+ }
+ }
+ return $url;
}
/**
diff --git a/course/format/lib.php b/course/format/lib.php
index f4f785c959d..0b2cbd5d1d5 100644
--- a/course/format/lib.php
+++ b/course/format/lib.php
@@ -355,35 +355,20 @@ abstract class format_base {
public function get_view_url($section, $options = array()) {
$course = $this->get_course();
$url = new moodle_url('/course/view.php', array('id' => $course->id));
-
- $sr = null;
+
if (array_key_exists('sr', $options)) {
- $sr = $options['sr'];
- }
- if (is_object($section)) {
+ $sectionno = $options['sr'];
+ } else if (is_object($section)) {
$sectionno = $section->section;
} else {
$sectionno = $section;
}
- if ($sectionno !== null) {
- if ($sr !== null) {
- if ($sr) {
- $usercoursedisplay = COURSE_DISPLAY_MULTIPAGE;
- $sectionno = $sr;
- } else {
- $usercoursedisplay = COURSE_DISPLAY_SINGLEPAGE;
- }
- } else {
- $usercoursedisplay = $course->coursedisplay;
- }
- if ($sectionno != 0 && $usercoursedisplay == COURSE_DISPLAY_MULTIPAGE) {
- $url->param('section', $sectionno);
- } else {
- if (!empty($options['navigation'])) {
- return null;
- }
- $url->set_anchor('section-'.$sectionno);
- }
+ if (!empty($options['navigation']) && $sectionno !== null) {
+ // by default assume that sections are never displayed on separate pages
+ return null;
+ }
+ if ($this->uses_sections() && $sectionno !== null) {
+ $url->set_anchor('section-'.$sectionno);
}
return $url;
}
@@ -796,5 +781,33 @@ class format_site extends format_base {
public function get_view_url($section, $options = array()) {
return new moodle_url('/');
}
-}
+ /**
+ * Returns the list of blocks to be automatically added on the site frontpage when moodle is installed
+ *
+ * @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 blocks_get_default_site_course_blocks();
+ }
+
+ /**
+ * Definitions of the additional options that site uses
+ *
+ * @param bool $foreditform
+ * @return array of options
+ */
+ public function course_format_options($foreditform = false) {
+ static $courseformatoptions = false;
+ if ($courseformatoptions === false) {
+ $courseformatoptions = array(
+ 'numsections' => array(
+ 'default' => 1,
+ 'type' => PARAM_INT,
+ ),
+ );
+ }
+ return $courseformatoptions;
+ }
+}
diff --git a/course/format/renderer.php b/course/format/renderer.php
index 26f28c213b2..ea83ace3053 100644
--- a/course/format/renderer.php
+++ b/course/format/renderer.php
@@ -448,6 +448,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
*/
protected function get_nav_links($course, $sections, $sectionno) {
// FIXME: This is really evil and should by using the navigation API.
+ $course = course_get_format($course)->get_course();
$canviewhidden = has_capability('moodle/course:viewhiddensections', context_course::instance($course->id))
or !$course->hiddensections;
@@ -542,6 +543,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
global $PAGE;
$modinfo = get_fast_modinfo($course);
+ $course = course_get_format($course)->get_course();
// Can we view the section in question?
if (!($sectioninfo = $modinfo->get_section_info($displaysection))) {
@@ -637,6 +639,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
global $PAGE;
$modinfo = get_fast_modinfo($course);
+ $course = course_get_format($course)->get_course();
$context = context_course::instance($course->id);
// Title with completion help icon.
diff --git a/course/format/topics/format.php b/course/format/topics/format.php
index 5108a863e79..cf2c0527411 100644
--- a/course/format/topics/format.php
+++ b/course/format/topics/format.php
@@ -45,6 +45,7 @@ if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context)
}
// make sure all sections are created
+$course = course_get_format($course)->get_course();
course_create_sections_if_missing($course, range(0, $course->numsections));
$renderer = $PAGE->get_renderer('format_topics');
diff --git a/course/format/weeks/format.php b/course/format/weeks/format.php
index 86fac1e647d..2f988551ab8 100644
--- a/course/format/weeks/format.php
+++ b/course/format/weeks/format.php
@@ -38,6 +38,7 @@ if ($week = optional_param('week', 0, PARAM_INT)) {
// End backwards-compatible aliasing..
// make sure all sections are created
+$course = course_get_format($course)->get_course();
course_create_sections_if_missing($course, range(0, $course->numsections));
$renderer = $PAGE->get_renderer('format_weeks');
diff --git a/course/lib.php b/course/lib.php
index d47fc22e768..40270a96e63 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -2939,7 +2939,8 @@ function move_section($course, $section, $move) {
$sectiondest = $section + $move;
- if ($sectiondest > $course->numsections or $sectiondest < 1) {
+ $course = course_get_format($course)->get_course();
+ if (isset($course->numsections) && $sectiondest > $course->numsections or $sectiondest < 1) {
return false;
}
@@ -2965,7 +2966,8 @@ function move_section_to($course, $section, $destination) {
return true;
}
- if (($destination > $course->numsections) || ($destination < 1)) {
+ $course = course_get_format($course)->get_course();
+ if ((isset($course->numsections) && ($destination > $course->numsections)) || ($destination < 1)) {
return false;
}
@@ -4232,8 +4234,6 @@ class course_request {
// Apply course default settings
$data->format = $courseconfig->format;
- $data->numsections = $courseconfig->numsections;
- $data->hiddensections = $courseconfig->hiddensections;
$data->newsitems = $courseconfig->newsitems;
$data->showgrades = $courseconfig->showgrades;
$data->showreports = $courseconfig->showreports;
diff --git a/enrol/database/lib.php b/enrol/database/lib.php
index 4ae2cfb6cf3..398dfee6d39 100644
--- a/enrol/database/lib.php
+++ b/enrol/database/lib.php
@@ -753,6 +753,7 @@ class enrol_database_plugin extends enrol_plugin {
$template = false;
if ($templatecourse) {
if ($template = $DB->get_record('course', array('shortname'=>$templatecourse))) {
+ $template = fullclone(course_get_format($template)->get_course());
unset($template->id);
unset($template->fullname);
unset($template->shortname);
@@ -769,8 +770,6 @@ class enrol_database_plugin extends enrol_plugin {
$template->summary = '';
$template->summaryformat = FORMAT_HTML;
$template->format = $courseconfig->format;
- $template->numsections = $courseconfig->numsections;
- $template->hiddensections = $courseconfig->hiddensections;
$template->newsitems = $courseconfig->newsitems;
$template->showgrades = $courseconfig->showgrades;
$template->showreports = $courseconfig->showreports;
diff --git a/enrol/database/tests/sync_test.php b/enrol/database/tests/sync_test.php
index f094a47b254..46caefbedc9 100644
--- a/enrol/database/tests/sync_test.php
+++ b/enrol/database/tests/sync_test.php
@@ -682,9 +682,10 @@ class enrol_database_testcase extends advanced_testcase {
$this->assertEquals(2+1+4+1+count(self::$courses), $DB->count_records('course'));
$course8['category'] = $defcat->id;
- $course8['numsections'] = 666;
- $this->assertTrue($DB->record_exists('course', $course8));
-
+ $record = $DB->get_record('course', $course8);
+ $this->assertFalse(empty($record));
+ $createdcourse = course_get_format($record)->get_course();
+ $this->assertEquals($createdcourse->numsections, 666);
// Test invalid category.
diff --git a/enrol/imsenterprise/lib.php b/enrol/imsenterprise/lib.php
index f70b07f3fad..9d11e00be2b 100644
--- a/enrol/imsenterprise/lib.php
+++ b/enrol/imsenterprise/lib.php
@@ -386,8 +386,6 @@ function process_group_tag($tagcontents) {
$course->idnumber = $coursecode;
$course->format = $courseconfig->format;
$course->visible = $courseconfig->visible;
- $course->numsections = $courseconfig->numsections;
- $course->hiddensections = $courseconfig->hiddensections;
$course->newsitems = $courseconfig->newsitems;
$course->showgrades = $courseconfig->showgrades;
$course->showreports = $courseconfig->showreports;
diff --git a/enrol/ldap/lib.php b/enrol/ldap/lib.php
index 6f3392710af..ca7fa8e5b0b 100644
--- a/enrol/ldap/lib.php
+++ b/enrol/ldap/lib.php
@@ -900,8 +900,6 @@ class enrol_ldap_plugin extends enrol_plugin {
$template->summary = '';
$template->summaryformat = FORMAT_HTML;
$template->format = $courseconfig->format;
- $template->numsections = $courseconfig->numsections;
- $template->hiddensections = $courseconfig->hiddensections;
$template->newsitems = $courseconfig->newsitems;
$template->showgrades = $courseconfig->showgrades;
$template->showreports = $courseconfig->showreports;
diff --git a/index.php b/index.php
index b416975c341..de9421689c1 100644
--- a/index.php
+++ b/index.php
@@ -98,6 +98,7 @@
echo $OUTPUT->header();
/// Print Section or custom info
+ $site = course_get_format($SITE)->get_course();
$modinfo = get_fast_modinfo($SITE);
$modnames = get_module_types_names();
$modnamesplural = get_module_types_names(true);
@@ -107,7 +108,7 @@
if (!empty($CFG->customfrontpageinclude)) {
include($CFG->customfrontpageinclude);
- } else {
+ } else if ($site->numsections > 0) {
if ($editing) {
// make sure section with number 1 exists
course_create_sections_if_missing($SITE, 1);
diff --git a/lib/adminlib.php b/lib/adminlib.php
index deef07ed2e7..0bf564999e4 100644
--- a/lib/adminlib.php
+++ b/lib/adminlib.php
@@ -3174,7 +3174,7 @@ class admin_setting_sitesetselect extends admin_setting_configselect {
* @return string The site name of the selected site
*/
public function get_setting() {
- $site = get_site();
+ $site = course_get_format(get_site())->get_course();
return $site->{$this->name};
}
@@ -3196,6 +3196,7 @@ class admin_setting_sitesetselect extends admin_setting_configselect {
$record->timemodified = time();
// update $SITE
$SITE->{$this->name} = $data;
+ course_get_format($SITE)->update_course_format_options($record);
return ($DB->update_record('course', $record) ? '' : get_string('errorsetting', 'admin'));
}
}
@@ -3366,7 +3367,7 @@ class admin_setting_sitesetcheckbox extends admin_setting_configcheckbox {
* @return string
*/
public function get_setting() {
- $site = get_site();
+ $site = course_get_format(get_site())->get_course();
return $site->{$this->name};
}
@@ -3384,6 +3385,7 @@ class admin_setting_sitesetcheckbox extends admin_setting_configcheckbox {
$record->timemodified = time();
// update $SITE
$SITE->{$this->name} = $data;
+ course_get_format($SITE)->update_course_format_options($record);
return ($DB->update_record('course', $record) ? '' : get_string('errorsetting', 'admin'));
}
}
@@ -3401,7 +3403,7 @@ class admin_setting_sitesettext extends admin_setting_configtext {
* @return mixed string or null
*/
public function get_setting() {
- $site = get_site();
+ $site = course_get_format(get_site())->get_course();
return $site->{$this->name} != '' ? $site->{$this->name} : NULL;
}
@@ -3443,6 +3445,7 @@ class admin_setting_sitesettext extends admin_setting_configtext {
$record->timemodified = time();
// update $SITE
$SITE->{$this->name} = $data;
+ course_get_format($SITE)->update_course_format_options($record);
return ($DB->update_record('course', $record) ? '' : get_string('dbupdatefailed', 'error'));
}
}
@@ -3467,7 +3470,7 @@ class admin_setting_special_frontpagedesc extends admin_setting {
* @return string The current setting
*/
public function get_setting() {
- $site = get_site();
+ $site = course_get_format(get_site())->get_course();
return $site->{$this->name};
}
@@ -3484,6 +3487,7 @@ class admin_setting_special_frontpagedesc extends admin_setting {
$record->{$this->name} = $data;
$record->timemodified = time();
$SITE->{$this->name} = $data;
+ course_get_format($SITE)->update_course_format_options($record);
return ($DB->update_record('course', $record) ? '' : get_string('errorsetting', 'admin'));
}
diff --git a/lib/db/install.php b/lib/db/install.php
index 2e401fe817a..824813bee76 100644
--- a/lib/db/install.php
+++ b/lib/db/install.php
@@ -86,6 +86,10 @@ function xmldb_main_install() {
$newsite->id = $DB->insert_record('course', $newsite);
define('SITEID', $newsite->id);
}
+ // set the field 'numsections'. We can not use format_site::update_format_options() because
+ // the file is not loaded
+ $DB->insert_record('course_format_options', array('courseid' => SITEID, 'format' => 'site',
+ 'sectionid' => 0, 'name' => 'numsections', 'value' => $newsite->numsections));
$SITE = get_site();
if ($newsite->id != $SITE->id) {
throw new moodle_exception('generalexceptionmessage', 'error', '', 'Unexpected new site course id!');
diff --git a/lib/db/install.xml b/lib/db/install.xml
index f2261748dcf..96dc090f9db 100644
--- a/lib/db/install.xml
+++ b/lib/db/install.xml
@@ -82,16 +82,14 @@
-
-
-
+
+
-
-
-
+
+
@@ -101,8 +99,7 @@
-
-
+
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index c467d2d3edf..8ade318b874 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -1347,5 +1347,57 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012110200.00);
}
+ if ($oldversion < 2012110201.00) {
+
+ // Copy fields 'coursedisplay', 'numsections', 'hiddensections' from table {course}
+ // to table {course_format_options} as the additional format options
+ $fields = array();
+ $table = new xmldb_table('course');
+ foreach (array('coursedisplay', 'numsections', 'hiddensections') as $fieldname) {
+ // first check that fields still exist
+ $field = new xmldb_field($fieldname);
+ if ($dbman->field_exists($table, $field)) {
+ $fields[] = $fieldname;
+ }
+ }
+
+ if (!empty($fields)) {
+ $transaction = $DB->start_delegated_transaction();
+ $rs = $DB->get_recordset_sql('SELECT id, format, '. join(',', $fields).'
+ FROM {course}
+ WHERE format <> ? AND format <> ?',
+ array('scorm', 'social'));
+ // (do not copy fields from scrom and social formats, we already know that they are not used)
+ foreach ($rs as $rec) {
+ foreach ($fields as $field) {
+ try {
+ $DB->insert_record('course_format_options',
+ array(
+ 'courseid' => $rec->id,
+ 'format' => $rec->format,
+ 'sectionid' => 0,
+ 'name' => $field,
+ 'value' => $rec->$field
+ ));
+ } catch (dml_exception $e) {
+ // index 'courseid,format,sectionid,name' violation
+ // continue; the entry in course_format_options already exists, use it
+ }
+ }
+ }
+ $rs->close();
+ $transaction->allow_commit();
+
+ // Drop fields from table course
+ foreach ($fields as $fieldname) {
+ $field = new xmldb_field($fieldname);
+ $dbman->drop_field($table, $field);
+ }
+ }
+
+ // Main savepoint reached
+ upgrade_main_savepoint(true, 2012110201.00);
+ }
+
return true;
}
diff --git a/lib/filelib.php b/lib/filelib.php
index a9a49d9b7d5..a747672d063 100644
--- a/lib/filelib.php
+++ b/lib/filelib.php
@@ -3977,13 +3977,6 @@ function file_pluginfile($relativepath, $forcedownload, $preview = null) {
send_file_not_found();
}
- if ($course->numsections < $section->section) {
- if (!has_capability('moodle/course:update', $context)) {
- // block access to unavailable sections if can not edit course
- send_file_not_found();
- }
- }
-
$filename = array_pop($args);
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
if (!$file = $fs->get_file($context->id, 'course', 'section', $sectionid, $filepath, $filename) or $file->is_directory()) {
diff --git a/lib/navigationlib.php b/lib/navigationlib.php
index c445b38e567..ba6a8287141 100644
--- a/lib/navigationlib.php
+++ b/lib/navigationlib.php
@@ -1886,8 +1886,12 @@ class global_navigation extends navigation_node {
global $CFG;
require_once($CFG->dirroot.'/course/lib.php');
+ $course = course_get_format($course)->get_course(); // retrieve all format options as well
$modinfo = get_fast_modinfo($course);
- $sections = array_slice($modinfo->get_section_info_all(), 0, $course->numsections+1, true);
+ $sections = $modinfo->get_section_info_all();
+ if (isset($course->numsections)) {
+ $sections = array_slice($sections, 0, $course->numsections+1, true);
+ }
$activities = array();
foreach ($sections as $key => $section) {
diff --git a/lib/weblib.php b/lib/weblib.php
index 3c0dc19e982..957a8704923 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -2187,6 +2187,7 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid
$menu = array();
$doneheading = false;
+ $course = course_get_format($course)->get_course();
$coursecontext = context_course::instance($course->id);
$menu[] = '