Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From the <code>attempt.php</code> file (Moodle 1.9.7):</p> <pre><code>$attempt = quiz_create_attempt($quiz, $attemptnumber); </code></pre> <p>Then:</p> <pre><code>if (!$attempt-&gt;id = insert_record('quiz_attempts', $attempt)) { error('Could not create new attempt'); } </code></pre> <p>From <code>locallib.php</code>:</p> <pre><code>/** * Creates an object to represent a new attempt at a quiz * * Creates an attempt object to represent an attempt at the quiz by the current * user starting at the current time. The -&gt;id field is not set. The object is * NOT written to the database. * @return object The newly created attempt object. * @param object $quiz The quiz to create an attempt for. * @param integer $attemptnumber The sequence number for the attempt. */ function quiz_create_attempt($quiz, $attemptnumber) { global $USER, $CFG; if (!$attemptnumber &gt; 1 or !$quiz-&gt;attemptonlast or !$attempt = get_record('quiz_attempts', 'quiz', $quiz-&gt;id, 'userid', $USER-&gt;id, 'attempt', $attemptnumber-1)) { // we are not building on last attempt so create a new attempt $attempt-&gt;quiz = $quiz-&gt;id; $attempt-&gt;userid = $USER-&gt;id; $attempt-&gt;preview = 0; if ($quiz-&gt;shufflequestions) { $attempt-&gt;layout = quiz_repaginate($quiz-&gt;questions, $quiz-&gt;questionsperpage, true); } else { $attempt-&gt;layout = $quiz-&gt;questions; } } $timenow = time(); $attempt-&gt;attempt = $attemptnumber; $attempt-&gt;sumgrades = 0.0; $attempt-&gt;timestart = $timenow; $attempt-&gt;timefinish = 0; $attempt-&gt;timemodified = $timenow; $attempt-&gt;uniqueid = question_new_attempt_uniqueid(); return $attempt; } </code></pre> <p>Please refer to the source code for major details.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload