Skip to content

Commit

Permalink
Merge branch 'MDL-76614' of https://github.com/timhunt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jan 11, 2023
2 parents 9e21e8a + 7e4972a commit 6f1c9d3
Show file tree
Hide file tree
Showing 141 changed files with 7,212 additions and 6,578 deletions.
11 changes: 7 additions & 4 deletions admin/tool/recyclebin/tests/course_bin_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

namespace tool_recyclebin;

use mod_quiz\quiz_attempt;
use stdClass;

/**
* Recycle bin course tests.
*
Expand Down Expand Up @@ -237,7 +240,7 @@ public function test_coursemodule_restore_with_userdata($settings) {
$attempts = quiz_get_user_attempts($cm->instance, $student->id);
$this->assertEquals(1, count($attempts));
$attempt = array_pop($attempts);
$attemptobj = \quiz_attempt::create($attempt->id);
$attemptobj = quiz_attempt::create($attempt->id);
$this->assertEquals($student->id, $attemptobj->get_userid());
$this->assertEquals(true, $attemptobj->is_finished());
}
Expand Down Expand Up @@ -300,17 +303,17 @@ private function create_quiz_attempt($quiz, $student) {
quiz_add_quiz_question($numq->id, $quiz);

// Create quiz attempt.
$quizobj = \quiz::create($quiz->id, $student->id);
$quizobj = \mod_quiz\quiz_settings::create($quiz->id, $student->id);
$quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj->get_context());
$quba->set_preferred_behaviour($quizobj->get_quiz()->preferredbehaviour);
$timenow = time();
$attempt = quiz_create_attempt($quizobj, 1, false, $timenow, false, $student->id);
quiz_start_new_attempt($quizobj, $quba, $attempt, 1, $timenow);
quiz_attempt_save_started($quizobj, $quba, $attempt);
$attemptobj = \quiz_attempt::create($attempt->id);
$attemptobj = quiz_attempt::create($attempt->id);
$tosubmit = array(1 => array('answer' => '0'));
$attemptobj->process_submitted_actions($timenow, false, $tosubmit);
$attemptobj = \quiz_attempt::create($attempt->id);
$attemptobj = quiz_attempt::create($attempt->id);
$attemptobj->process_finish($timenow, false);
}
}
10 changes: 6 additions & 4 deletions backup/moodle2/tests/restore_stepslib_date_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace core_backup;

use mod_quiz\quiz_attempt;

defined('MOODLE_INTERNAL') || die();

global $CFG;
Expand Down Expand Up @@ -379,7 +381,7 @@ public function test_question_attempt_steps_date_restore() {
// Make a user to do the quiz.
$user1 = $this->getDataGenerator()->create_user();

$quizobj = \quiz::create($quiz->id, $user1->id);
$quizobj = \mod_quiz\quiz_settings::create($quiz->id, $user1->id);

// Start the attempt.
$quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj->get_context());
Expand All @@ -393,7 +395,7 @@ public function test_question_attempt_steps_date_restore() {
quiz_attempt_save_started($quizobj, $quba, $attempt);

// Process some responses from the student.
$attemptobj = \quiz_attempt::create($attempt->id);
$attemptobj = quiz_attempt::create($attempt->id);

$prefix1 = $quba->get_field_prefix(1);
$prefix2 = $quba->get_field_prefix(2);
Expand All @@ -404,7 +406,7 @@ public function test_question_attempt_steps_date_restore() {
$attemptobj->process_submitted_actions($timenow, false, $tosubmit);

// Finish the attempt.
$attemptobj = \quiz_attempt::create($attempt->id);
$attemptobj = quiz_attempt::create($attempt->id);
$attemptobj->process_finish($timenow, false);

$questionattemptstepdates = [];
Expand All @@ -419,7 +421,7 @@ public function test_question_attempt_steps_date_restore() {

// Get the quiz for this new restored course.
$quizdata = $DB->get_record('quiz', ['course' => $newcourseid]);
$quizobj = \quiz::create($quizdata->id, $user1->id);
$quizobj = \mod_quiz\quiz_settings::create($quizdata->id, $user1->id);

$questionusage = $DB->get_record('question_usages', [
'component' => 'mod_quiz',
Expand Down
2 changes: 1 addition & 1 deletion lib/questionlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ function question_move_category_to_context($categoryid, $oldcontextid, $newconte
/**
* Given a list of ids, load the basic information about a set of questions from
* the questions table. The $join and $extrafields arguments can be used together
* to pull in extra data. See, for example, the usage in mod/quiz/attemptlib.php, and
* to pull in extra data. See, for example, the usage in {@see \mod_quiz\quiz_attempt}, and
* read the code below to see how the SQL is assembled. Throws exceptions on error.
*
* @param array $questionids array of question ids to load. If null, then all
Expand Down
Loading

0 comments on commit 6f1c9d3

Please sign in to comment.