Skip to content

Commit

Permalink
StudentQuiz: The question state automatically changes to Disapproved …
Browse files Browse the repository at this point in the history
…when no state is selected. #737244
  • Loading branch information
hieuvu authored and timhunt committed Nov 16, 2023
1 parent f4aaf49 commit 5f4f62d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions changestate.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,15 @@
$approveselected = required_param('approveselected', PARAM_RAW);
$state = required_param('state', PARAM_INT);
if ($confirm == md5($approveselected)) {
if ($questionlist = explode(',', $approveselected)) {
foreach ($questionlist as $questionid) {
$questionid = (int) $questionid;
$question = question_bank::load_question($questionid);
$studentquizquestion = studentquiz_question::get_studentquiz_question_from_question($question);
update_question_state::execute($course->id, $cmid, $studentquizquestion->get_id(), $state);
// We should not change the state if state is not being changed.
if ($state !== -1) {
if ($questionlist = explode(',', $approveselected)) {
foreach ($questionlist as $questionid) {
$questionid = (int) $questionid;
$question = question_bank::load_question($questionid);
$studentquizquestion = studentquiz_question::get_studentquiz_question_from_question($question);
update_question_state::execute($course->id, $cmid, $studentquizquestion->get_id(), $state);
}
}
}
redirect($returnurl);
Expand Down Expand Up @@ -127,7 +130,7 @@
$questionlist = rtrim($questionlist, ',');

// Add an explanation about questions in use.
$approveurl = new \moodle_url($url, ['approveselected' => $questionlist, 'state' => 0,
$approveurl = new \moodle_url($url, ['approveselected' => $questionlist, 'state' => -1,
'confirm' => md5($questionlist), 'sesskey' => sesskey(), 'returnurl' => $returnurl,
'cmid' => $cmid, 'courseid' => $courseid]);

Expand Down

0 comments on commit 5f4f62d

Please sign in to comment.