MDL-33442 Course: actions bring you back where you came from

This commit is contained in:
Frederic Massart 2012-06-07 09:29:40 +08:00
parent 778121751d
commit 76055f5de4
6 changed files with 41 additions and 31 deletions

View file

@ -271,20 +271,27 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
* @return string HTML to output.
*/
protected function section_summary($section, $course, $mods) {
$classattr = 'section main section-summary clearfix';
$linkclasses = '';
// If section is hidden then display grey section link
$classattr = 'section-summary clearfix';
If (!$section->visible) {
$classattr .= ' dimmed_text';
if (!$section->visible) {
$classattr .= ' hidden';
$linkclasses .= ' dimmed_text';
} else if ($this->is_section_current($section, $course)) {
$classattr .= ' current';
}
$o = '';
$o.= html_writer::start_tag('li', array('id' => 'section-'.$section->section,
'class' => $classattr));
$o .= html_writer::start_tag('li', array('id' => 'section-'.$section->section, 'class' => $classattr));
$title = get_section_name($course, $section);
$o.= html_writer::start_tag('a', array('href' => course_get_url($course, $section->section)));
$o.= $this->output->heading($title, 3, 'header section-title');
$o.= html_writer::end_tag('a');
$o .= html_writer::tag('div', '', array('class' => 'left side'));
$o .= html_writer::tag('div', '', array('class' => 'right side'));
$o .= html_writer::start_tag('div', array('class' => 'content'));
$title = html_writer::tag('a', get_section_name($course, $section),
array('href' => course_get_url($course, $section->section), 'class' => $linkclasses));
$o .= $this->output->heading($title, 3, 'section-title');
$o.= html_writer::start_tag('div', array('class' => 'summarytext'));
$o.= $this->format_summary_text($section);
@ -293,7 +300,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
$o.= $this->section_availability_message($section);
$o.= html_writer::end_tag('li');
$o .= html_writer::end_tag('div');
$o .= html_writer::end_tag('li');
return $o;
}
@ -384,12 +392,10 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
)
);
$strcancel= get_string('cancel');
$o.= html_writer::start_tag('li', array('class' => 'clipboard'));
$o.= html_writer::start_tag('div', array('class' => 'clipboard'));
$o.= strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
$o.= ' ('.html_writer::link($url, get_string('cancel')).')';
$o.= html_writer::end_tag('li');
$o.= html_writer::end_tag('div');
}
return $o;
@ -518,6 +524,9 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
return;
}
// Copy activity clipboard..
echo $this->course_activity_clipboard($course, $displaysection);
// General section if non-empty.
$thissection = $sections[0];
if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
@ -549,9 +558,6 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
$sectiontitle .= html_writer::end_tag('div');
echo $sectiontitle;
// Copy activity clipboard..
echo $this->course_activity_clipboard($course, $displaysection);
// Now the list of sections..
echo $this->start_section_list();

View file

@ -104,7 +104,8 @@ if (!empty($add)) {
echo $OUTPUT->confirm(
get_string('duplicateconfirm', 'core', $a),
new single_button(
new moodle_url('/course/modduplicate.php', array('cmid' => $cm->id, 'course' => $course->id)),
new moodle_url('/course/modduplicate.php', array(
'cmid' => $cm->id, 'course' => $course->id, 'sr' => $sectionreturn)),
get_string('continue'),
'post'),
new single_button(
@ -130,8 +131,7 @@ if (!empty($add)) {
if (!$confirm or !confirm_sesskey()) {
$fullmodulename = get_string('modulename', $cm->modname);
$optionsyes = array('confirm'=>1, 'delete'=>$cm->id, 'sesskey'=>sesskey());
$optionsno = array('id'=>$cm->course);
$optionsyes = array('confirm'=>1, 'delete'=>$cm->id, 'sesskey'=>sesskey(), 'sr' => $sectionreturn);
$strdeletecheck = get_string('deletecheck', '', $fullmodulename);
$strdeletecheckfull = get_string('deletecheckfull', '', "$fullmodulename '$cm->name'");
@ -145,7 +145,7 @@ if (!empty($add)) {
// print_simple_box_start('center', '60%', '#FFAAAA', 20, 'noticebox');
echo $OUTPUT->box_start('noticebox');
$formcontinue = new single_button(new moodle_url("$CFG->wwwroot/course/mod.php", $optionsyes), get_string('yes'));
$formcancel = new single_button(new moodle_url($return, $optionsno), get_string('no'), 'get');
$formcancel = new single_button($return, get_string('no'), 'get');
echo $OUTPUT->confirm($strdeletecheckfull, $formcontinue, $formcancel);
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
@ -226,9 +226,11 @@ if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
moveto_module($cm, $section, $beforecm);
$sectionreturn = $USER->activitycopysectionreturn;
unset($USER->activitycopy);
unset($USER->activitycopycourse);
unset($USER->activitycopyname);
unset($USER->activitycopysectionreturn);
rebuild_course_cache($section->course);
@ -340,9 +342,10 @@ if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
$section = $DB->get_record('course_sections', array('id'=>$cm->section), '*', MUST_EXIST);
$USER->activitycopy = $copy;
$USER->activitycopycourse = $cm->course;
$USER->activitycopyname = $cm->name;
$USER->activitycopy = $copy;
$USER->activitycopycourse = $cm->course;
$USER->activitycopyname = $cm->name;
$USER->activitycopysectionreturn = $sectionreturn;
redirect(course_get_url($course, $sectionreturn));

View file

@ -32,8 +32,9 @@ require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
require_once($CFG->libdir . '/filelib.php');
$cmid = required_param('cmid', PARAM_INT);
$courseid = required_param('course', PARAM_INT);
$cmid = required_param('cmid', PARAM_INT);
$courseid = required_param('course', PARAM_INT);
$sectionreturn = optional_param('sr', 0, PARAM_INT);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$cm = get_coursemodule_from_id('', $cmid, $course->id, true, MUST_EXIST);
@ -131,16 +132,14 @@ if ($newcmid) {
get_string('duplicatecontedit'),
'get'),
new single_button(
new moodle_url('/course/view.php#section-' . $cm->sectionnum, array('id' => $cm->course)),
course_get_url($course, $sectionreturn),
get_string('duplicatecontcourse'),
'get')
);
} else {
echo $output->notification(get_string('duplicatesuccess', 'core', $a), 'notifysuccess');
echo $output->continue_button(
new moodle_url('/course/view.php#section-' . $cm->sectionnum, array('id' => $course->id))
);
echo $output->continue_button(course_get_url($course, $sectionreturn));
}
echo $output->footer();