當前位置: 首頁>>代碼示例>>PHP>>正文


PHP quiz::attempt_url方法代碼示例

本文整理匯總了PHP中quiz::attempt_url方法的典型用法代碼示例。如果您正苦於以下問題:PHP quiz::attempt_url方法的具體用法?PHP quiz::attempt_url怎麽用?PHP quiz::attempt_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在quiz的用法示例。


在下文中一共展示了quiz::attempt_url方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: time

/// Check capabilites.
if (!$quizobj->is_preview_user()) {
    $quizobj->require_capability('mod/quiz:attempt');
}
/// Check to see if a new preview was requested.
if ($quizobj->is_preview_user() && $forcenew) {
    /// To force the creation of a new preview, we set a finish time on the
    /// current attempt (if any). It will then automatically be deleted below
    $DB->set_field('quiz_attempts', 'timefinish', time(), array('quiz' => $quiz->id, 'userid' => $USER->id));
}
/// Look for an existing attempt.
$lastattempt = quiz_get_latest_attempt_by_user($quiz->id, $USER->id);
if ($lastattempt && !$lastattempt->timefinish) {
    /// Continuation of an attempt - check password then redirect.
    $accessmanager->do_password_check($quizobj->is_preview_user());
    redirect($quizobj->attempt_url($lastattempt->id));
}
/// Get number for the next or unfinished attempt
if ($lastattempt && !$lastattempt->preview && !$quizobj->is_preview_user()) {
    $lastattemptid = $lastattempt->id;
    $attemptnumber = $lastattempt->attempt + 1;
} else {
    $lastattempt = false;
    $lastattemptid = false;
    $attemptnumber = 1;
}
/// Check access.
$messages = $accessmanager->prevent_access() + $accessmanager->prevent_new_attempt($attemptnumber - 1, $lastattempt);
if (!$quizobj->is_preview_user() && $messages) {
    print_error('attempterror', 'quiz', $quizobj->view_url(), $accessmanager->print_messages($messages, true));
}
開發者ID:nicolasconnault,項目名稱:moodle2.0,代碼行數:31,代碼來源:startattempt.php


注:本文中的quiz::attempt_url方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。