Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.9
-
Fix Version/s: 1.9.3
-
Component/s: Questions, Roles / Access
-
Labels:None
-
Affected Branches:MOODLE_19_STABLE
-
Fixed Branches:MOODLE_19_STABLE
Description
Using moodle 1.9.
1- As Admin,
a. create a new role called CanCreateSystemQuestions with Allowed permissions: moodle/question:add; moodle/question:editmine.
b. create a new role called CanUseSystemQuestions with Allowed permission: moodle/question:useall
Assign these 2 roles to all teachers on your moodle site.
2- Log in as teacher A
a. create question "Question A" in System default and save it.
b. try to edit "Question A" : you can click the Edit icon, you see the Edit question screen which says:
You have permission to :
- Edit this question
- Save this as a new question
Edit your question and click on the Save changes to save it in the same (System) category. You see an error message:
Sorry, but you do not currently have permissions to do that (move).
There seems to be a contradiction of "permissions" somewhere...
Joseph
PS.-- Clicking on the "More information about this error link" takes me to the http://docs.moodle.org/en/error/moodle/nopermissions page which informs me that "If you believe that your roles for that user DO allow that action you were attempting, then you may have found a bug. Congratulations!" Hence this bug report...
Issue Links
| This issue duplicates: | ||||
| CONTRIB-485 | It is not possible for students to edit questions that they have created. They can only save these questions 'as new'. |
|
|
|
Can you look at this part of code in question.php to see if it conflicts with what you are doing
// Validate the question category.
if (!$category = get_record('question_categories', 'id', $question->category)) {
print_error('categorydoesnotexist', 'question', $returnurl);
}
//permissions
$question->formoptions = new object();
$categorycontext = get_context_instance_by_id($category->contextid);
$addpermission = has_capability('moodle/question:add', $categorycontext);
if ($id) {
$canview = question_has_capability_on($question, 'view');
if ($movecontext){ $question->formoptions->canedit = false; $question->formoptions->canmove = (question_has_capability_on($question, 'move') && $contexts->have_cap('moodle/question:add')); $question->formoptions->cansaveasnew = false; $question->formoptions->repeatelements = false; $question->formoptions->movecontext = true; $formeditable = true; question_require_capability_on($question, 'view'); } else {
$question->formoptions->canedit = question_has_capability_on($question, 'edit');
$question->formoptions->canmove = (question_has_capability_on($question, 'move') && $addpermission);
$question->formoptions->cansaveasnew = (($canview ||question_has_capability_on($question, 'edit')) && $addpermission);
$question->formoptions->repeatelements = ($question->formoptions->canedit || $question->formoptions->cansaveasnew);
$formeditable = $question->formoptions->canedit || $question->formoptions->cansaveasnew || $question->formoptions->canmove;
$question->formoptions->movecontext = false;
if (!$formeditable){ question_require_capability_on($question, 'view'); }
}
I notice that you don'it have permission to move although $question->formoptions->canmove is necessary in all cases...