MDL-60422 core_calendar: do not lose track of the selected course

This commit is contained in:
Mark Nelson 2017-10-20 15:13:41 +08:00
parent 849405177f
commit 72c4cacfa3
4 changed files with 10 additions and 6 deletions

View File

@ -239,7 +239,7 @@ class calendar_day_exporter extends exporter {
*/
protected function get_course_filter_selector(renderer_base $output) {
$langstr = get_string('upcomingeventsfor', 'calendar');
return $output->course_filter_selector($this->url, $langstr);
return $output->course_filter_selector($this->url, $langstr, $this->calendar->course->id);
}
/**

View File

@ -151,7 +151,7 @@ class calendar_upcoming_exporter extends exporter {
*/
protected function get_course_filter_selector(renderer_base $output) {
$langstr = get_string('upcomingeventsfor', 'calendar');
return $output->course_filter_selector($this->url, $langstr);
return $output->course_filter_selector($this->url, $langstr, $this->calendar->course->id);
}
/**

View File

@ -231,7 +231,8 @@ class month_exporter extends exporter {
*/
protected function get_course_filter_selector(renderer_base $output) {
$content = '';
$content .= $output->course_filter_selector($this->url, get_string('detailedmonthviewfor', 'calendar'));
$content .= $output->course_filter_selector($this->url, get_string('detailedmonthviewfor', 'calendar'),
$this->calendar->course->id);
return $content;
}

View File

@ -237,10 +237,11 @@ class core_calendar_renderer extends plugin_renderer_base {
*
* @param moodle_url $returnurl The URL that the user should be taken too upon selecting a course.
* @param string $label The label to use for the course select.
* @param int $courseid The id of the course to be selected.
* @return string
*/
public function course_filter_selector(moodle_url $returnurl, $label=null) {
global $USER, $SESSION, $CFG;
public function course_filter_selector(moodle_url $returnurl, $label = null, $courseid = null) {
global $CFG;
if (!isloggedin() or isguestuser()) {
return '';
@ -261,7 +262,9 @@ class core_calendar_renderer extends plugin_renderer_base {
$courseoptions[$course->id] = format_string($course->shortname, true, array('context' => $coursecontext));
}
if ($this->page->course->id !== SITEID) {
if ($courseid) {
$selected = $courseid;
} else if ($this->page->course->id !== SITEID) {
$selected = $this->page->course->id;
} else {
$selected = '';