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:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user