$attemptid)); } /** * Used by {create()} and {create_from_usage_id()}. * @param array $conditions passed to $DB->get_record('quiz_attempts', $conditions). */ protected static function create_helper($conditions) { global $DB; $attempt = $DB->get_record('quiz_attempts', $conditions, '*', MUST_EXIST); $quiz = quiz_access_manager::load_quiz_and_settings($attempt->quiz); $course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id, false, MUST_EXIST); // Update quiz with override information $quiz = quiz_update_effective_access($quiz, $attempt->userid); return new sloodle_quiz_attempt($attempt, $quiz, $cm, $course); } /** * Process all the actions that were submitted as part of the current request. * Based on process_all_actions(), but targetted at a particular slot. * * @param int $timestamp the timestamp that should be stored as the modifed * time in the database for these actions. If null, will use the current time. */ public function process_all_actions_for_slot($slot, $submitteddata, $timestamp) { global $DB; // Moodle's process_all_actions originally did: // $this->quba->process_all_actions($timestamp, $postdata); // ...extracted submitteddata, figured out which slots it wanted to deal with and for each one called: //$DB->set_debug(true); $this->quba->process_action($slot, $submitteddata, $timestamp); question_engine::save_questions_usage_by_activity($this->quba); $this->attempt->timemodified = $timestamp; if ($this->attempt->timefinish) { $this->attempt->sumgrades = $this->quba->get_total_mark(); } $DB->update_record('quiz_attempts', $this->attempt); if (!$this->is_preview() && $this->attempt->timefinish) { quiz_save_best_grade($this->get_quiz(), $this->get_userid()); } } }