Skip to content

Commit 76055f5

Browse files
author
Frederic Massart
committed
MDL-33442 Course: actions bring you back where you came from
1 parent 7781217 commit 76055f5

File tree

6 files changed

+41
-31
lines changed

6 files changed

+41
-31
lines changed

course/format/renderer.php

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -271,20 +271,27 @@ protected function section_edit_controls($course, $section, $onsectionpage = fal
271271
* @return string HTML to output.
272272
*/
273273
protected function section_summary($section, $course, $mods) {
274+
$classattr = 'section main section-summary clearfix';
275+
$linkclasses = '';
276+
274277
// If section is hidden then display grey section link
275-
$classattr = 'section-summary clearfix';
276-
If (!$section->visible) {
277-
$classattr .= ' dimmed_text';
278+
if (!$section->visible) {
279+
$classattr .= ' hidden';
280+
$linkclasses .= ' dimmed_text';
281+
} else if ($this->is_section_current($section, $course)) {
282+
$classattr .= ' current';
278283
}
279284

280285
$o = '';
281-
$o.= html_writer::start_tag('li', array('id' => 'section-'.$section->section,
282-
'class' => $classattr));
286+
$o .= html_writer::start_tag('li', array('id' => 'section-'.$section->section, 'class' => $classattr));
283287

284-
$title = get_section_name($course, $section);
285-
$o.= html_writer::start_tag('a', array('href' => course_get_url($course, $section->section)));
286-
$o.= $this->output->heading($title, 3, 'header section-title');
287-
$o.= html_writer::end_tag('a');
288+
$o .= html_writer::tag('div', '', array('class' => 'left side'));
289+
$o .= html_writer::tag('div', '', array('class' => 'right side'));
290+
$o .= html_writer::start_tag('div', array('class' => 'content'));
291+
292+
$title = html_writer::tag('a', get_section_name($course, $section),
293+
array('href' => course_get_url($course, $section->section), 'class' => $linkclasses));
294+
$o .= $this->output->heading($title, 3, 'section-title');
288295

289296
$o.= html_writer::start_tag('div', array('class' => 'summarytext'));
290297
$o.= $this->format_summary_text($section);
@@ -293,7 +300,8 @@ protected function section_summary($section, $course, $mods) {
293300

294301
$o.= $this->section_availability_message($section);
295302

296-
$o.= html_writer::end_tag('li');
303+
$o .= html_writer::end_tag('div');
304+
$o .= html_writer::end_tag('li');
297305

298306
return $o;
299307
}
@@ -384,12 +392,10 @@ protected function course_activity_clipboard($course, $sectionno = 0) {
384392
)
385393
);
386394

387-
$strcancel= get_string('cancel');
388-
389-
$o.= html_writer::start_tag('li', array('class' => 'clipboard'));
395+
$o.= html_writer::start_tag('div', array('class' => 'clipboard'));
390396
$o.= strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
391397
$o.= ' ('.html_writer::link($url, get_string('cancel')).')';
392-
$o.= html_writer::end_tag('li');
398+
$o.= html_writer::end_tag('div');
393399
}
394400

395401
return $o;
@@ -518,6 +524,9 @@ public function print_single_section_page($course, $sections, $mods, $modnames,
518524
return;
519525
}
520526

527+
// Copy activity clipboard..
528+
echo $this->course_activity_clipboard($course, $displaysection);
529+
521530
// General section if non-empty.
522531
$thissection = $sections[0];
523532
if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
@@ -549,9 +558,6 @@ public function print_single_section_page($course, $sections, $mods, $modnames,
549558
$sectiontitle .= html_writer::end_tag('div');
550559
echo $sectiontitle;
551560

552-
// Copy activity clipboard..
553-
echo $this->course_activity_clipboard($course, $displaysection);
554-
555561
// Now the list of sections..
556562
echo $this->start_section_list();
557563

course/mod.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@
104104
echo $OUTPUT->confirm(
105105
get_string('duplicateconfirm', 'core', $a),
106106
new single_button(
107-
new moodle_url('/course/modduplicate.php', array('cmid' => $cm->id, 'course' => $course->id)),
107+
new moodle_url('/course/modduplicate.php', array(
108+
'cmid' => $cm->id, 'course' => $course->id, 'sr' => $sectionreturn)),
108109
get_string('continue'),
109110
'post'),
110111
new single_button(
@@ -130,8 +131,7 @@
130131
if (!$confirm or !confirm_sesskey()) {
131132
$fullmodulename = get_string('modulename', $cm->modname);
132133

133-
$optionsyes = array('confirm'=>1, 'delete'=>$cm->id, 'sesskey'=>sesskey());
134-
$optionsno = array('id'=>$cm->course);
134+
$optionsyes = array('confirm'=>1, 'delete'=>$cm->id, 'sesskey'=>sesskey(), 'sr' => $sectionreturn);
135135

136136
$strdeletecheck = get_string('deletecheck', '', $fullmodulename);
137137
$strdeletecheckfull = get_string('deletecheckfull', '', "$fullmodulename '$cm->name'");
@@ -145,7 +145,7 @@
145145
// print_simple_box_start('center', '60%', '#FFAAAA', 20, 'noticebox');
146146
echo $OUTPUT->box_start('noticebox');
147147
$formcontinue = new single_button(new moodle_url("$CFG->wwwroot/course/mod.php", $optionsyes), get_string('yes'));
148-
$formcancel = new single_button(new moodle_url($return, $optionsno), get_string('no'), 'get');
148+
$formcancel = new single_button($return, get_string('no'), 'get');
149149
echo $OUTPUT->confirm($strdeletecheckfull, $formcontinue, $formcancel);
150150
echo $OUTPUT->box_end();
151151
echo $OUTPUT->footer();
@@ -226,9 +226,11 @@
226226

227227
moveto_module($cm, $section, $beforecm);
228228

229+
$sectionreturn = $USER->activitycopysectionreturn;
229230
unset($USER->activitycopy);
230231
unset($USER->activitycopycourse);
231232
unset($USER->activitycopyname);
233+
unset($USER->activitycopysectionreturn);
232234

233235
rebuild_course_cache($section->course);
234236

@@ -340,9 +342,10 @@
340342

341343
$section = $DB->get_record('course_sections', array('id'=>$cm->section), '*', MUST_EXIST);
342344

343-
$USER->activitycopy = $copy;
344-
$USER->activitycopycourse = $cm->course;
345-
$USER->activitycopyname = $cm->name;
345+
$USER->activitycopy = $copy;
346+
$USER->activitycopycourse = $cm->course;
347+
$USER->activitycopyname = $cm->name;
348+
$USER->activitycopysectionreturn = $sectionreturn;
346349

347350
redirect(course_get_url($course, $sectionreturn));
348351

course/modduplicate.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
3333
require_once($CFG->libdir . '/filelib.php');
3434

35-
$cmid = required_param('cmid', PARAM_INT);
36-
$courseid = required_param('course', PARAM_INT);
35+
$cmid = required_param('cmid', PARAM_INT);
36+
$courseid = required_param('course', PARAM_INT);
37+
$sectionreturn = optional_param('sr', 0, PARAM_INT);
3738

3839
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
3940
$cm = get_coursemodule_from_id('', $cmid, $course->id, true, MUST_EXIST);
@@ -131,16 +132,14 @@
131132
get_string('duplicatecontedit'),
132133
'get'),
133134
new single_button(
134-
new moodle_url('/course/view.php#section-' . $cm->sectionnum, array('id' => $cm->course)),
135+
course_get_url($course, $sectionreturn),
135136
get_string('duplicatecontcourse'),
136137
'get')
137138
);
138139

139140
} else {
140141
echo $output->notification(get_string('duplicatesuccess', 'core', $a), 'notifysuccess');
141-
echo $output->continue_button(
142-
new moodle_url('/course/view.php#section-' . $cm->sectionnum, array('id' => $course->id))
143-
);
142+
echo $output->continue_button(course_get_url($course, $sectionreturn));
144143
}
145144

146145
echo $output->footer();

lang/en/moodle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
$string['activities'] = 'Activities';
3333
$string['activities_help'] = 'Activities, such as forums, quizzes and wikis, enable interactive content to be added to the course.';
3434
$string['activity'] = 'Activity';
35-
$string['activityclipboard'] = 'Moving this activity: <b>{$a}</b>';
35+
$string['activityclipboard'] = 'Moving this activity: {$a}';
3636
$string['activityiscurrentlyhidden'] = 'Sorry, this activity is currently hidden';
3737
$string['activitymodule'] = 'Activity module';
3838
$string['activitymodules'] = 'Activity modules';

theme/base/style/course.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
.course-content .section-summary .section-title { margin: 2px 5px 2px 5px; }
1414
.course-content .section-summary .summarytext { margin: 2px 5px 2px 5px; }
1515
.course-content .section-summary .section-summary-activities .activity-count {margin-right: 10px;color: #AAA; font-size: 12px; margin-right: 15px;}
16+
.course-content .section-summary .summary { margin-top: 5px; }
1617
.course-content .single-section { margin-top: 1em; }
1718
.course-content .single-section .section-navigation { display: block; padding: 0.5em; margin-bottom: -0.5em; }
1819
.course-content .single-section .section-navigation .title { font-weight: bold; font-size: 108%; }

theme/standard/style/course.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
.path-course-view .weeks .current,
4141
.path-course-view .topics .current,
4242
.path-course-view .current td.side {background: #FFD991;}
43+
.path-course-view .section-summary.current {border-color: #FFD991;}
4344
.path-course-view .weeks .hidden,
4445
.path-course-view .topics .hidden,
4546
.path-course-view .hidden td.side {background: #DDDDDD;}

0 commit comments

Comments
 (0)