mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
MDL-36017 Fields numsections, hiddensections and coursedisplay are now format-specific options
- Fields added to format_legacy as default course format options; - Upgrade script copies fields values from table course to course_format_options; - Fields removed from table course; - Fields removed from edit course form; - Since front-page course has a 'numsections' setting, format_site defines it as it's option; - Removed accessing those fields in core code unless we know that format supports them and in this case instead of $course = $DB->get_record('course'); we use: $course = course_get_format($courseorid)->get_course(); This way all format-specific options are added to the $course object
This commit is contained in:
parent
7b7d2f4d12
commit
b5cf83f080
@ -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<br />';
|
||||
continue;
|
||||
}
|
||||
$sql = "SELECT *
|
||||
FROM {course_sections}
|
||||
WHERE course=? AND section>?
|
||||
|
@ -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',
|
||||
|
@ -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') {
|
||||
|
@ -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);
|
||||
|
@ -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');
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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'));
|
||||
}
|
||||
|
||||
|
@ -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!');
|
||||
|
@ -82,16 +82,14 @@
|
||||
<FIELD NAME="sectioncache" TYPE="text" NOTNULL="false" SEQUENCE="false" PREVIOUS="showgrades" NEXT="modinfo"/>
|
||||
<FIELD NAME="modinfo" TYPE="text" NOTNULL="false" SEQUENCE="false" PREVIOUS="sectioncache" NEXT="newsitems"/>
|
||||
<FIELD NAME="newsitems" TYPE="int" LENGTH="5" NOTNULL="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="modinfo" NEXT="startdate"/>
|
||||
<FIELD NAME="startdate" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="newsitems" NEXT="numsections"/>
|
||||
<FIELD NAME="numsections" TYPE="int" LENGTH="5" NOTNULL="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="startdate" NEXT="marker"/>
|
||||
<FIELD NAME="marker" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="numsections" NEXT="maxbytes"/>
|
||||
<FIELD NAME="startdate" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="newsitems" NEXT="marker"/>
|
||||
<FIELD NAME="marker" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="startdate" NEXT="maxbytes"/>
|
||||
<FIELD NAME="maxbytes" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="marker" NEXT="legacyfiles"/>
|
||||
<FIELD NAME="legacyfiles" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="course files are not necessary any more: 0 no legacy files, 1 legacy files disabled, 2 legacy files enabled" PREVIOUS="maxbytes" NEXT="showreports"/>
|
||||
<FIELD NAME="showreports" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="legacyfiles" NEXT="visible"/>
|
||||
<FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="showreports" NEXT="visibleold"/>
|
||||
<FIELD NAME="visibleold" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="the state of visible field when hiding parent category, this helps us to recover hidden states when unhiding the parent category later" PREVIOUS="visible" NEXT="hiddensections"/>
|
||||
<FIELD NAME="hiddensections" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="visibleold" NEXT="groupmode"/>
|
||||
<FIELD NAME="groupmode" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="hiddensections" NEXT="groupmodeforce"/>
|
||||
<FIELD NAME="visibleold" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="the state of visible field when hiding parent category, this helps us to recover hidden states when unhiding the parent category later" PREVIOUS="visible" NEXT="groupmode"/>
|
||||
<FIELD NAME="groupmode" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="visibleold" NEXT="groupmodeforce"/>
|
||||
<FIELD NAME="groupmodeforce" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="groupmode" NEXT="defaultgroupingid"/>
|
||||
<FIELD NAME="defaultgroupingid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="default grouping used in course modules, does not have key intentionally" PREVIOUS="groupmodeforce" NEXT="lang"/>
|
||||
<FIELD NAME="lang" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" PREVIOUS="defaultgroupingid" NEXT="theme"/>
|
||||
@ -101,8 +99,7 @@
|
||||
<FIELD NAME="requested" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timemodified" NEXT="enablecompletion"/>
|
||||
<FIELD NAME="enablecompletion" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="1 = allow use of 'completion' progress-tracking on this course. 0 = disable completion tracking on this course." PREVIOUS="requested" NEXT="completionstartonenrol"/>
|
||||
<FIELD NAME="completionstartonenrol" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="1 = allow use of 'activty completion' progress-tracking on this course. 0 = disable activity completion tracking on this course." PREVIOUS="enablecompletion" NEXT="completionnotify"/>
|
||||
<FIELD NAME="completionnotify" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Notify users when they complete this course" PREVIOUS="completionstartonenrol" NEXT="coursedisplay"/>
|
||||
<FIELD NAME="coursedisplay" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="How is the course displayed" PREVIOUS="completionnotify"/>
|
||||
<FIELD NAME="completionnotify" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Notify users when they complete this course" PREVIOUS="completionstartonenrol"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -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) {
|
||||
|
@ -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[] = '<ul class="navmenulist"><li class="jumpto section"><span>'.$strjumpto.'</span><ul>';
|
||||
@ -2196,7 +2197,7 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($mod->sectionnum > $course->numsections) { /// Don't show excess hidden sections
|
||||
if (isset($course->numsections) && $mod->sectionnum > $course->numsections) { /// Don't show excess hidden sections
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2207,7 +2208,7 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid
|
||||
if ($mod->sectionnum >= 0 and $section != $mod->sectionnum) {
|
||||
$thissection = $sections[$mod->sectionnum];
|
||||
|
||||
if ($thissection->visible or !$course->hiddensections or
|
||||
if ($thissection->visible or (isset($course->hiddensections) && !$course->hiddensections) or
|
||||
has_capability('moodle/course:viewhiddensections', $coursecontext)) {
|
||||
$thissection->summary = strip_tags(format_string($thissection->summary,true));
|
||||
if (!$doneheading) {
|
||||
|
@ -30,7 +30,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$version = 2012110200.00; // YYYYMMDD = weekly release date of this DEV branch
|
||||
$version = 2012110201.00; // YYYYMMDD = weekly release date of this DEV branch
|
||||
// RR = release increments - 00 in DEV branches
|
||||
// .XX = incremental changes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user