MDL-44894 question editing: fix validation with odd permissions

For users with edit permissions, but not add permissions, it was
impossible to save the editing form. The validation assuemd this value
was present, but it was not. Other code checks this field too, so I
added it rather than changing the validation and all the other uses.
This commit is contained in:
Tim Hunt
2014-08-14 11:26:50 +01:00
parent e95c5eed2c
commit 82e46ef9ea
+6 -1
View File
@@ -146,12 +146,17 @@ abstract class question_edit_form extends question_wizard_form {
// Editing question with no permission to move from category.
$mform->addElement('questioncategory', 'category', get_string('category', 'question'),
array('contexts' => array($this->categorycontext)));
$mform->addElement('hidden', 'usecurrentcat', 1);
$mform->setType('usecurrentcat', PARAM_BOOL);
$mform->setConstant('usecurrentcat', 1);
} else if ($this->question->formoptions->movecontext) {
// Moving question to another context.
$mform->addElement('questioncategory', 'categorymoveto',
get_string('category', 'question'),
array('contexts' => $this->contexts->having_cap('moodle/question:add')));
$mform->addElement('hidden', 'usecurrentcat', 1);
$mform->setType('usecurrentcat', PARAM_BOOL);
$mform->setConstant('usecurrentcat', 1);
} else {
// Editing question with permission to move from category or save as new q.
$currentgrp = array();