MDL-66764 quiz: redo question should not repeat random questions

Before this fix, it was only considering questions seen in previous attempts.

It should avoid the questions in the current attmept too.
This commit is contained in:
Tim Hunt
2019-09-25 11:05:24 +01:00
parent 6709fdbb6d
commit a29971b021
3 changed files with 17 additions and 7 deletions
+7 -3
View File
@@ -1925,8 +1925,12 @@ class quiz_attempt {
}
/**
* Replace a question in an attempt with a new attempt at the same qestion.
* @param int $slot the questoin to restart.
* Replace a question in an attempt with a new attempt at the same question.
*
* Well, for randomised questions, it won't be the same question, it will be
* a different randomised selection.
*
* @param int $slot the question to restart.
* @param int $timestamp the timestamp to record for this action.
*/
public function process_redo_question($slot, $timestamp) {
@@ -1938,7 +1942,7 @@ class quiz_attempt {
}
$qubaids = new \mod_quiz\question\qubaids_for_users_attempts(
$this->get_quizid(), $this->get_userid());
$this->get_quizid(), $this->get_userid(), 'all', true);
$transaction = $DB->start_delegated_transaction();
@@ -128,11 +128,16 @@ Feature: Allow students to redo questions in a practice quiz, without starting a
And quiz "Quiz 2" contains the following questions:
| question | page |
| Random (Test questions) | 1 |
And user "student" has started an attempt at quiz "Quiz 2" randomised as follows:
| slot | actualquestion |
| 1 | TF1 |
And I log in as "student"
And I am on "Course 1" course homepage
When I follow "Quiz 2"
And I press "Attempt quiz now"
And I press "Continue the last attempt"
And I should see "First question"
And I click on "False" "radio"
And I click on "Check" "button"
And I press "Try another question like this one"
Then "Check" "button" should exist
Then I should see "Second question"
And "Check" "button" should exist
+3 -2
View File
@@ -628,7 +628,8 @@ class behat_mod_quiz extends behat_question_base {
* random questions. If so, this will let you control which actual
* question gets picked when this slot is 'randomised' at the
* start of the attempt. If you don't specify, then one will be picked
* at random (which might make the reponse meaningless).
* at random (which might make the response meaningless).
* Give the question name.
* variant This column is similar, and also options. It is only needed if
* the question that ends up in this slot returns something greater
* than 1 for $question->get_num_variants(). Like with actualquestion,
@@ -705,7 +706,7 @@ class behat_mod_quiz extends behat_question_base {
* @param string $username the username of the user that will attempt.
* @param string $quizname the name of the quiz the user will attempt.
* @param TableNode $attemptinfo information about the questions to add, as above.
* @Given /^user "([^"]*)" has started an attempt at quiz "([^"]*) randomised as follows:"$/
* @Given /^user "([^"]*)" has started an attempt at quiz "([^"]*)" randomised as follows:$/
*/
public function user_has_started_an_attempt_at_quiz_with_details($username, $quizname, TableNode $attemptinfo) {
global $DB;