MDL-86860 course: Replace course_set_marker calls
The function course_set_marker has been replaced. Logic that previously used course_set_marker must now be updated to use either sectionactions::set_marker or sectionactions::remove_all_markers, based on the desired behavior of the original call.
This commit is contained in:
@@ -1826,7 +1826,7 @@ abstract class base {
|
||||
|
||||
// Remove the marker if it points to this section.
|
||||
if ($section->section == $course->marker) {
|
||||
course_set_marker($course->id, 0);
|
||||
\core_courseformat\formatactions::section($course->id)->remove_all_markers();
|
||||
}
|
||||
|
||||
$lastsection = $DB->get_field_sql('SELECT max(section) from {course_sections}
|
||||
|
||||
@@ -399,7 +399,8 @@ final class sectionactions_test extends \advanced_testcase {
|
||||
);
|
||||
|
||||
// Remove marked section.
|
||||
course_set_marker($course->id, 1);
|
||||
$sectioninfo = get_fast_modinfo($course->id)->get_section_info(1);
|
||||
\core_courseformat\formatactions::section($course->id)->set_marker($sectioninfo, true);
|
||||
$this->assertTrue(course_get_format($course)->is_section_current(1));
|
||||
$this->assertTrue($sectionactions->delete(
|
||||
get_fast_modinfo($course)->get_section_info(1),
|
||||
|
||||
@@ -68,7 +68,8 @@ class stateactions extends stateactions_base {
|
||||
}
|
||||
|
||||
// Mark the new one.
|
||||
course_set_marker($course->id, $section->section);
|
||||
$sectioninfo = get_fast_modinfo($course->id)->get_section_info($section->section);
|
||||
\core_courseformat\formatactions::section($course->id)->set_marker($sectioninfo, true);
|
||||
$updates->add_section_put($section->id);
|
||||
if ($previousmarker) {
|
||||
$section = $modinfo->get_section_info($previousmarker);
|
||||
@@ -103,7 +104,7 @@ class stateactions extends stateactions_base {
|
||||
// Get the previous marked section and unmark it.
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
$previousmarker = $DB->get_field("course", "marker", ['id' => $course->id]);
|
||||
course_set_marker($course->id, 0);
|
||||
\core_courseformat\formatactions::section($course->id)->remove_all_markers();
|
||||
$section = $modinfo->get_section_info($previousmarker, MUST_EXIST);
|
||||
$updates->add_section_put($section->id);
|
||||
|
||||
|
||||
@@ -44,7 +44,12 @@ $context = context_course::instance($course->id);
|
||||
|
||||
if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
|
||||
$course->marker = $marker;
|
||||
course_set_marker($course->id, $marker);
|
||||
if ($marker == 0) {
|
||||
\core_courseformat\formatactions::section($course->id)->remove_all_markers();
|
||||
} else {
|
||||
$sectioninfo = get_fast_modinfo($course->id)->get_section_info($marker);
|
||||
\core_courseformat\formatactions::section($course->id)->set_marker($sectioninfo, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure section 0 is created.
|
||||
|
||||
@@ -388,7 +388,12 @@ class format_topics extends core_courseformat\base {
|
||||
if ($section->section && ($action === 'setmarker' || $action === 'removemarker')) {
|
||||
// Format 'topics' allows to set and remove markers in addition to common section actions.
|
||||
require_capability('moodle/course:setcurrentsection', context_course::instance($this->courseid));
|
||||
course_set_marker($this->courseid, ($action === 'setmarker') ? $section->section : 0);
|
||||
if ($action === 'setmarker') {
|
||||
$sectioninfo = get_fast_modinfo($this->courseid)->get_section_info($section->section);
|
||||
\core_courseformat\formatactions::section($this->courseid)->set_marker($sectioninfo, true);
|
||||
} else {
|
||||
\core_courseformat\formatactions::section($this->courseid)->remove_all_markers();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,8 @@ final class stateactions_test extends \advanced_testcase {
|
||||
);
|
||||
|
||||
// Highlight section 1.
|
||||
course_set_marker($course->id, 1);
|
||||
$sectioninfo = get_fast_modinfo($course->id)->get_section_info(1);
|
||||
\core_courseformat\formatactions::section($course->id)->set_marker($sectioninfo, true);
|
||||
|
||||
$this->enrol_user($course, $rolename);
|
||||
|
||||
|
||||
@@ -972,11 +972,14 @@ function move_section_to($course, $section, $destination, $ignorenumsections = f
|
||||
// If we move the highlighted section itself, then just highlight the destination.
|
||||
// Adjust the higlighted section location if we move something over it either direction.
|
||||
if ($section == $course->marker) {
|
||||
course_set_marker($course->id, $destination);
|
||||
$sectioninfo = get_fast_modinfo($course->id)->get_section_info($destination);
|
||||
formatactions::section($course->id)->set_marker($sectioninfo, true);
|
||||
} else if ($section > $course->marker && $course->marker >= $destination) {
|
||||
course_set_marker($course->id, $course->marker+1);
|
||||
$sectioninfo = get_fast_modinfo($course->id)->get_section_info($course->marker + 1);
|
||||
formatactions::section($course->id)->set_marker($sectioninfo, true);
|
||||
} else if ($section < $course->marker && $course->marker <= $destination) {
|
||||
course_set_marker($course->id, $course->marker-1);
|
||||
$sectioninfo = get_fast_modinfo($course->id)->get_section_info($course->marker - 1);
|
||||
formatactions::section($course->id)->set_marker($sectioninfo, true);
|
||||
}
|
||||
|
||||
$transaction->allow_commit();
|
||||
|
||||
@@ -1046,7 +1046,9 @@ final class courselib_test extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('numsections'=>10), array('createsections'=>true));
|
||||
|
||||
// Set course marker to the section we are going to move..
|
||||
course_set_marker($course->id, 2);
|
||||
$sectioninfo = get_fast_modinfo($course->id)->get_section_info(2);
|
||||
\core_courseformat\formatactions::section($course->id)->set_marker($sectioninfo, true);
|
||||
|
||||
// Verify that the course marker is set correctly.
|
||||
$course = $DB->get_record('course', array('id' => $course->id));
|
||||
$this->assertEquals(2, $course->marker);
|
||||
@@ -1266,7 +1268,8 @@ final class courselib_test extends advanced_testcase {
|
||||
3 => array($assign5->cmid)), get_fast_modinfo($course)->sections);
|
||||
|
||||
// Remove marked section.
|
||||
course_set_marker($course->id, 1);
|
||||
$sectioninfo = get_fast_modinfo($course->id)->get_section_info(1);
|
||||
\core_courseformat\formatactions::section($course->id)->set_marker($sectioninfo, true);
|
||||
$this->assertTrue(course_get_format($course)->is_section_current(1));
|
||||
$this->assertTrue(course_delete_section($course, 1, true));
|
||||
$this->assertFalse(course_get_format($course)->is_section_current(1));
|
||||
|
||||
@@ -228,7 +228,13 @@ if ($PAGE->user_allowed_editing()) {
|
||||
'The marker param in course view is deprecated. Please use course/format/update.php instead.',
|
||||
DEBUG_DEVELOPER
|
||||
);
|
||||
course_set_marker($course->id, $marker);
|
||||
if ($marker == 0) {
|
||||
\core_courseformat\formatactions::section($course->id)->remove_all_markers();
|
||||
} else {
|
||||
$sectioninfo = get_fast_modinfo($course->id)->get_section_info($marker);
|
||||
\core_courseformat\formatactions::section($course->id)->set_marker($sectioninfo, true);
|
||||
}
|
||||
|
||||
if ($sectionid) {
|
||||
redirect(course_get_url($course, $section, ['navigation' => true]));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user