redirect($readerobj->edit_url()); } // Look for an existing attempt. $attempts = reader_get_user_attempts($reader->id, $USER->id, 'all'); $lastattempt = end($attempts); // If an in-progress attempt exists, check password then redirect to it. if ($lastattempt && !$lastattempt->timefinish) { redirect($readerobj->attempt_url($lastattempt->id, $page)); } // Get number for the next or unfinished attempt опнбепхрэ онякедмхи юррелор гдеяэ $lastattempt = false; $attemptnumber = 1; $quba = question_engine::make_questions_usage_by_activity('mod_reader', $readerobj->get_context()); $quba->set_preferred_behaviour('deferredfeedback'); // Create the new attempt and initialize the question sessions $attempt = reader_create_attempt($reader, $attemptnumber, $book); if (!($reader->attemptonlast && $lastattempt)) { // Starting a normal, new, reader attempt. // Fully load all the questions in this reader. $readerobj->preload_questions(); $readerobj->load_questions(); // Add them all to the $quba. $idstoslots = array(); $questionsinuse = array_keys($readerobj->get_questions()); foreach ($readerobj->get_questions() as $i => $questiondata) { if ($questiondata->qtype != 'random') { if (!$reader->shuffleanswers) { $questiondata->options->shuffleanswers = false; } $question = question_bank::make_question($questiondata); } else {
} add_to_log($course->id, "reader", substr("AA-goal userid: {$coursestudent->id}, goal={$changeallcurrentgoal}", 0, 39), "admin.php?id={$id}", "{$cm->instance}"); } } /* * Award Extra Points */ if (has_capability('mod/reader:manage', $contextmodule) && $act == "assignpointsbookshavenoquizzes" && $book) { $useridold = $USER->id; if ($bookdata = $DB->get_record("reader_noquiz", array("id" => $book))) { foreach ($noqstudents as $student_) { if (!($attemptnumber = (int) $DB->get_field_sql('SELECT MAX(attempt)+1 FROM ' . "{reader_attempts} WHERE reader = ? AND " . "userid = ? AND timefinish > 0", array($reader->id, $student_)))) { $attemptnumber = 1; } $USER->id = $student_; $attempt = reader_create_attempt($reader, $attemptnumber, $bookdata->id); $attempt->ip = getremoteaddr(); $lastattemptid = $DB->get_field_sql('SELECT uniqueid FROM {reader_attempts} ORDER BY uniqueid DESC'); $attempt->uniqueid = $lastattemptid + 1; // Save the attempt if (!($attempt->id = $DB->insert_record('reader_attempts', $attempt))) { print_error('Could not create new attempt'); } $totalgrade = 0; $answersgrade = $DB->get_records("reader_question_instances", array("quiz" => $bookdata->id)); // Count Grades (TotalGrade) foreach ($answersgrade as $answersgrade_) { $totalgrade += $answersgrade_->grade; } $attemptnew = new stdClass(); $attemptnew->id = $attempt->id;