示例#1
0
 /**
  * Mark this attempt as now overdue.
  * @param int $timestamp the time to deem as now.
  * @param bool $studentisonline is the student currently interacting with Moodle?
  */
 public function process_going_overdue($timestamp, $studentisonline)
 {
     global $DB;
     $transaction = $DB->start_delegated_transaction();
     $this->attempt->timemodified = $timestamp;
     $this->attempt->state = self::OVERDUE;
     // If we knew the attempt close time, we could compute when the graceperiod ends.
     // Instead we'll just fix it up through cron.
     $this->attempt->timecheckstate = $timestamp;
     $DB->update_record('quiz_attempts', $this->attempt);
     $this->fire_state_transition_event('\\mod_quiz\\event\\attempt_becameoverdue', $timestamp);
     $transaction->allow_commit();
     quiz_send_overdue_message($this);
 }
示例#2
0
/**
 * Handle the quiz_attempt_overdue event.
 *
 * For quizzes with applicable settings, this sends a message to the user, reminding
 * them that they forgot to submit, and that they have another chance to do so.
 *
 * @param object $event the event object.
 */
function quiz_attempt_overdue_handler($event) {
    global $DB;

    $course  = $DB->get_record('course', array('id' => $event->courseid));
    $quiz    = $DB->get_record('quiz', array('id' => $event->quizid));
    $cm      = get_coursemodule_from_id('quiz', $event->cmid, $event->courseid);
    $attempt = $DB->get_record('quiz_attempts', array('id' => $event->attemptid));

    if (!($course && $quiz && $cm && $attempt)) {
        // Something has been deleted since the event was raised. Therefore, the
        // event is no longer relevant.
        return true;
    }

    return quiz_send_overdue_message($course, $quiz, $attempt,
            context_module::instance($cm->id), $cm);
}