MDL-18004 Redirecting report preference forms to their respective reports when submitted or cancelled

This commit is contained in:
nicolasconnault 2009-02-17 09:12:25 +00:00
parent 54c4a2cb4f
commit d4a93c208a
2 changed files with 12 additions and 8 deletions

View File

@ -44,12 +44,8 @@ require_capability('gradereport/grader:view', $context);
require('preferences_form.php');
$mform = new grader_report_preferences_form('preferences.php', compact('course'));
if ($mform->is_cancelled()){
redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid);
}
// If data submitted, then process and store.
if ($data = $mform->get_data()) {
if (!$mform->is_cancelled() && $data = $mform->get_data()) {
foreach ($data as $preference => $value) {
if (substr($preference, 0, 6) !== 'grade_') {
continue;
@ -66,6 +62,11 @@ if ($data = $mform->get_data()) {
exit;
}
if ($mform->is_cancelled()){
redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid);
}
print_grade_page_head($courseid, 'preferences', 'grader', get_string('preferences', 'gradereport_grader'));
// If USER has admin capability, print a link to the site config page for this report

View File

@ -69,24 +69,27 @@ if ($data = $mform->get_data()) {
set_user_preference($preference, $value);
}
}
redirect($CFG->wwwroot . '/grade/report/visual/index.php?id='.$courseid); // message here breaks accessability and is sloooowww
exit;
}
/// If cancelled go back to report
if ($mform->is_cancelled()){
redirect($CFG->wwwroot . '/grade/report/visual/index.php?id='.$courseid);
}
$strvisualreport = get_string('modulename', 'gradereport_visual');
print_grade_page_head($courseid, 'preferences', 'visual', get_string('preferences', 'gradereport_visual'));
print_grade_page_head($COURSE->id, 'settings', 'visual', $strvisualreport . ' ' . get_string('preferences'));
/// If USER has admin capability, print a link to the site config page for this report
/// TODO: Add admin config page for this report
/*
if (has_capability('moodle/site:config', $systemcontext)) {
echo '<div id="siteconfiglink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradereportvisual">';
echo get_string('changereportdefaults', 'grades');
echo "</a></div>\n";
}
*/
print_simple_box_start("center");