MDL-29108: support for returnurl in rubriceditor

This commit is contained in:
Marina Glancy 2011-10-24 11:03:48 +08:00
parent 5060997ba5
commit ed709412c2
2 changed files with 10 additions and 5 deletions

View File

@ -47,14 +47,17 @@ $PAGE->requires->js('/grade/grading/form/rubric/js/rubriceditor.js');
//TODO freeze rubric editor if needed
$mform = new gradingform_rubric_editrubric(null, array('areaid' => $areaid, 'context' => $context, 'freezerubric' => optional_param('freeze', 0, PARAM_INT)));
$mform->set_data($controller->get_definition_for_editing());
$data = $controller->get_definition_for_editing();
$returnurl = optional_param('returnurl', $manager->get_management_url(), PARAM_LOCALURL);
$data->returnurl = $returnurl;
$mform->set_data($data);
if ($mform->is_cancelled()) {
// todo process editing cancel in a better way
redirect($manager->get_management_url());
} else if ($data = $mform->get_data()) {
redirect($returnurl);
} else if ($mform->is_submitted() && $mform->is_validated()) {
$data = $mform->get_data();
$controller->update_definition($data);
redirect($PAGE->url);
redirect($returnurl);
}
echo $OUTPUT->header();

View File

@ -44,6 +44,8 @@ class gradingform_rubric_editrubric extends moodleform {
$form->addElement('hidden', 'areaid');
$form->setType('areaid', PARAM_INT);
$form->addElement('hidden', 'returnurl');
// name
$form->addElement('text', 'name', get_string('name', 'gradingform_rubric'), array('size'=>52));
$form->addRule('name', get_string('required'), 'required');