We've created a quiz with randomly added questions. When we try to override the grade of an individual answer via the "Make comment or override grade" link, we cannot save the modified grade but get the error message "Could not insert entry in question_sessions".
It seems that the link "Make comment or ovveride grade" uses the wrong question-id for overriding the grade and therefore choses incorrect (or non-existent) question_state entries in the question_states table which later causes the described error message ($state->id is null).
Our solution was to change line 481 in moodle/question/type/questiontype.php
$commentlink = '<div class="commentlink">'.link_to_popup_window ($options->questioncommentlink.'?attempt='.$state->attempt.'&question='.$question->id,
'commentquestion', $strcomment, 450, 650, $strcomment, 'none', true).'</div>';
to
$commentlink = '<div class="commentlink">'.link_to_popup_window ($options->questioncommentlink.'?attempt='.$state->attempt.'&question='.$state->question,
'commentquestion', $strcomment, 450, 650, $strcomment, 'none', true).'</div>';
i.e.: $question->id was replaced by $state->question.
As far as we could figure out, $state->question holds the correct questionid for randomly added questions.
which seems to work.
- duplicates
-
MDL-4004 Make the manual grading report work with random questions that pick manually graded questions
- Closed