本文整理汇总了PHP中quiz_attempt::handle_if_time_expired方法的典型用法代码示例。如果您正苦于以下问题:PHP quiz_attempt::handle_if_time_expired方法的具体用法?PHP quiz_attempt::handle_if_time_expired怎么用?PHP quiz_attempt::handle_if_time_expired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类quiz_attempt
的用法示例。
在下文中一共展示了quiz_attempt::handle_if_time_expired方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_overdue_attempts
/**
* Do the processing required.
* @param int $timenow the time to consider as 'now' during the processing.
* @param int $processfrom the value of $processupto the last time update_overdue_attempts was
* called called and completed successfully.
* @param int $processto only process attempt modifed longer ago than this.
*/
public function update_overdue_attempts($timenow, $processfrom, $processto) {
global $DB;
$attemptstoprocess = $this->get_list_of_overdue_attempts($processfrom, $processto);
$course = null;
$quiz = null;
$cm = null;
foreach ($attemptstoprocess as $attempt) {
// If we have moved on to a different quiz, fetch the new data.
if (!$quiz || $attempt->quiz != $quiz->id) {
$quiz = $DB->get_record('quiz', array('id' => $attempt->quiz), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('quiz', $attempt->quiz);
}
// If we have moved on to a different course, fetch the new data.
if (!$course || $course->id != $quiz->course) {
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
}
// Make a specialised version of the quiz settings, with the relevant overrides.
$quizforuser = clone($quiz);
$quizforuser->timeclose = $attempt->usertimeclose;
$quizforuser->timelimit = $attempt->usertimelimit;
// Trigger any transitions that are required.
$attemptobj = new quiz_attempt($attempt, $quizforuser, $cm, $course);
$attemptobj->handle_if_time_expired($timenow, false);
}
$attemptstoprocess->close();
}
示例2: update_overdue_attempts
/**
* Do the processing required.
* @param int $timenow the time to consider as 'now' during the processing.
* @param int $processfrom the value of $processupto the last time update_overdue_attempts was
* called called and completed successfully.
* @param int $processto only process attempt modifed longer ago than this.
* @return array with two elements, the number of attempt considered, and how many different quizzes that was.
*/
public function update_overdue_attempts($timenow, $processfrom, $processto) {
global $DB;
$attemptstoprocess = $this->get_list_of_overdue_attempts($processfrom, $processto);
$course = null;
$quiz = null;
$cm = null;
$count = 0;
$quizcount = 0;
foreach ($attemptstoprocess as $attempt) {
try {
// If we have moved on to a different quiz, fetch the new data.
if (!$quiz || $attempt->quiz != $quiz->id) {
$quiz = $DB->get_record('quiz', array('id' => $attempt->quiz), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('quiz', $attempt->quiz);
$quizcount += 1;
}
// If we have moved on to a different course, fetch the new data.
if (!$course || $course->id != $quiz->course) {
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
}
// Make a specialised version of the quiz settings, with the relevant overrides.
$quizforuser = clone($quiz);
$quizforuser->timeclose = $attempt->usertimeclose;
$quizforuser->timelimit = $attempt->usertimelimit;
// Trigger any transitions that are required.
$attemptobj = new quiz_attempt($attempt, $quizforuser, $cm, $course);
$attemptobj->handle_if_time_expired($timenow, false);
$count += 1;
} catch (moodle_exception $e) {
// If an error occurs while processing one attempt, don't let that kill cron.
mtrace("Error while processing attempt {$attempt->id} at {$attempt->quiz} quiz:");
mtrace($e->getMessage());
mtrace($e->getTraceAsString());
}
}
$attemptstoprocess->close();
return array($count, $quizcount);
}