Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-33767 Course: The actions on default section redirect to the corr…

…ect section
  • Loading branch information...
commit 483d768bc0a0bbc357c302389d4e5bad0eaabf20 1 parent 3240c71
@FMCorz FMCorz authored nebgor committed
View
10 course/editsection.php
@@ -33,9 +33,9 @@
require_once('editsection_form.php');
$id = required_param('id',PARAM_INT); // Week/topic ID
-$sectionreturn = optional_param('sectionreturn', 0, PARAM_BOOL);
+$sectionreturn = optional_param('sr', 0, PARAM_INT);
-$PAGE->set_url('/course/editsection.php', array('id'=>$id, 'sectionreturn'=> $sectionreturn));
+$PAGE->set_url('/course/editsection.php', array('id'=>$id, 'sr'=> $sectionreturn));
$section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $section->course), '*', MUST_EXIST);
@@ -60,11 +60,7 @@
'cs' => $section, 'showavailability' => $section->showavailability));
$mform->set_data($section); // set current value
-if ($sectionreturn) {
- $returnurl = course_get_url($course, $section->section);
-} else {
- $returnurl = course_get_url($course);
-}
+$returnurl = course_get_url($course, $sectionreturn);
/// If data submitted, then process and store.
if ($mform->is_cancelled()){
View
22 course/format/renderer.php
@@ -122,9 +122,10 @@ protected function section_left_content($section, $course, $onsectionpage) {
* @param stdClass $section The course_section entry from DB
* @param stdClass $course The course entry from DB
* @param bool $onsectionpage true if being printed on a single-section page
+ * @param int $sectionreturn The section to return to after an action
* @return string HTML to output.
*/
- protected function section_header($section, $course, $onsectionpage) {
+ protected function section_header($section, $course, $onsectionpage, $sectionreturn=0) {
global $PAGE;
$o = '';
@@ -159,12 +160,7 @@ protected function section_header($section, $course, $onsectionpage) {
$context = context_course::instance($course->id);
if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $context)) {
- $url = new moodle_url('/course/editsection.php', array('id'=>$section->id));
-
- if ($onsectionpage) {
- $url->param('sectionreturn', 1);
- }
-
+ $url = new moodle_url('/course/editsection.php', array('id'=>$section->id, 'sr'=>$sectionreturn));
$o.= html_writer::link($url,
html_writer::empty_tag('img', array('src' => $this->output->pix_url('t/edit'), 'class' => 'iconsmall edit')),
array('title' => get_string('editsummary')));
@@ -560,10 +556,10 @@ public function print_single_section_page($course, $sections, $mods, $modnames,
$thissection = $sections[0];
if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
echo $this->start_section_list();
- echo $this->section_header($thissection, $course, true);
- print_section($course, $thissection, $mods, $modnamesused, true);
+ echo $this->section_header($thissection, $course, true, $displaysection);
+ print_section($course, $thissection, $mods, $modnamesused, true, "100%", false, $displaysection);
if ($PAGE->user_is_editing()) {
- print_section_add_menus($course, 0, $modnames, false, false, true);
+ print_section_add_menus($course, 0, $modnames, false, false, $displaysection);
}
echo $this->section_footer();
echo $this->end_section_list();
@@ -592,14 +588,14 @@ public function print_single_section_page($course, $sections, $mods, $modnames,
// The requested section page.
$thissection = $sections[$displaysection];
- echo $this->section_header($thissection, $course, true);
+ echo $this->section_header($thissection, $course, true, $displaysection);
// Show completion help icon.
$completioninfo = new completion_info($course);
echo $completioninfo->display_help_icon();
- print_section($course, $thissection, $mods, $modnamesused, true, '100%', false, true);
+ print_section($course, $thissection, $mods, $modnamesused, true, '100%', false, $displaysection);
if ($PAGE->user_is_editing()) {
- print_section_add_menus($course, $displaysection, $modnames, false, false, true);
+ print_section_add_menus($course, $displaysection, $modnames, false, false, $displaysection);
}
echo $this->section_footer();
echo $this->end_section_list();
View
28 course/lib.php
@@ -1376,8 +1376,9 @@ function get_print_section_cm_text(cm_info $cm, $course) {
/**
* Prints a section full of activity modules
+ * @param int $sectionreturn The section to return to
*/
-function print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%", $hidecompletion=false, $sectionreturn = false) {
+function print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%", $hidecompletion=false, $sectionreturn=0) {
global $CFG, $USER, $DB, $PAGE, $OUTPUT;
static $initialised;
@@ -1637,12 +1638,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
$mod->groupmode = false;
}
echo '  ';
-
- if ($sectionreturn) {
- echo make_editing_buttons($mod, $absolute, true, $mod->indent, $section->section);
- } else {
- echo make_editing_buttons($mod, $absolute, true, $mod->indent, 0);
- }
+ echo make_editing_buttons($mod, $absolute, true, $mod->indent, $sectionreturn);
echo $mod->get_after_edit_icons();
}
@@ -1761,8 +1757,9 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
/**
* Prints the menus to add activities and resources.
+ * @param int $sectionreturn The section to link back to
*/
-function print_section_add_menus($course, $section, $modnames, $vertical=false, $return=false, $sectionreturn = false) {
+function print_section_add_menus($course, $section, $modnames, $vertical=false, $return=false, $sectionreturn=0) {
global $CFG, $OUTPUT;
// check to see if user can add menus
@@ -1778,14 +1775,7 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
$activities = array();
// We need to add the section section to the link for each module
- $sectionlink = '&section=' . $section;
-
- // We need to add the section to return to
- if ($sectionreturn) {
- $sectionreturnlink = '&sr=' . $section;
- } else {
- $sectionreturnlink = '&sr=0';
- }
+ $sectionlink = '&section=' . $section . '&sr=' . $sectionreturn;
foreach ($modules as $module) {
if (isset($module->types)) {
@@ -1793,7 +1783,7 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
// NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
$subtypes = array();
foreach ($module->types as $subtype) {
- $subtypes[$subtype->link . $sectionlink . $sectionreturnlink] = $subtype->title;
+ $subtypes[$subtype->link . $sectionlink] = $subtype->title;
}
// Sort module subtypes into the list
@@ -1815,11 +1805,11 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
} else {
// This module has no subtypes
if ($module->archetype == MOD_ARCHETYPE_RESOURCE) {
- $resources[$module->link . $sectionlink . $sectionreturnlink] = $module->title;
+ $resources[$module->link . $sectionlink] = $module->title;
} else if ($module->archetype === MOD_ARCHETYPE_SYSTEM) {
// System modules cannot be added by user, do not add to dropdown
} else {
- $activities[$module->link . $sectionlink . $sectionreturnlink] = $module->title;
+ $activities[$module->link . $sectionlink] = $module->title;
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.