本文整理汇总了PHP中quiz_attempt::get_access_manager方法的典型用法代码示例。如果您正苦于以下问题:PHP quiz_attempt::get_access_manager方法的具体用法?PHP quiz_attempt::get_access_manager怎么用?PHP quiz_attempt::get_access_manager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类quiz_attempt
的用法示例。
在下文中一共展示了quiz_attempt::get_access_manager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirect
require_once $CFG->dirroot . '/mod/quiz/locallib.php';
$attemptid = required_param('attempt', PARAM_INT);
// The attempt to summarise.
$attemptobj = new quiz_attempt($attemptid);
/// Check login.
require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
/// If this is not our own attempt, display an error.
if ($attemptobj->get_userid() != $USER->id) {
print_error('notyourattempt', 'quiz', $attemptobj->view_url());
}
/// If the attempt is alreadyuj closed, redirect them to the review page.
if ($attemptobj->is_finished()) {
redirect($attemptobj->review_url());
}
/// Check access.
$accessmanager = $attemptobj->get_access_manager(time());
$messages = $accessmanager->prevent_access();
if (!$attemptobj->is_preview_user() && $messages) {
print_error('attempterror', 'quiz', $attemptobj->view_url(), $accessmanager->print_messages($messages, true));
}
$accessmanager->do_password_check($attemptobj->is_preview_user());
/// Log this page view.
add_to_log($attemptobj->get_courseid(), 'quiz', 'view summary', 'summary.php?attempt=' . $attemptobj->get_attemptid(), $attemptobj->get_quizid(), $attemptobj->get_cmid());
/// Load the questions and states.
$attemptobj->load_questions();
$attemptobj->load_question_states();
/// Print the page header
require_js('mod/quiz/quiz.js');
$title = get_string('summaryofattempt', 'quiz');
if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) {
$accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' . format_string($attemptobj->get_quiz_name()), '');
示例2: finish_review_link
/**
* Returns either a liink or button
*
* @param quiz_attempt $attemptobj instance of quiz_attempt
*/
public function finish_review_link(quiz_attempt $attemptobj) {
$url = $attemptobj->view_url();
if ($attemptobj->get_access_manager(time())->attempt_must_be_in_popup()) {
$this->page->requires->js_init_call('M.mod_quiz.secure_window.init_close_button',
array($url), quiz_get_js_module());
return html_writer::empty_tag('input', array('type' => 'button',
'value' => get_string('finishreview', 'quiz'),
'id' => 'secureclosebutton'));
} else {
return html_writer::link($url, get_string('finishreview', 'quiz'));
}
}
示例3: stdClass
$action = new stdClass();
$action->event = QUESTION_EVENTCLOSE;
$action->responses = $state->responses;
$action->responses['_flagged'] = $state->flagged;
$action->timestamp = $state->timestamp;
if (question_process_responses($attemptobj->get_question($id), $state, $action, $attemptobj->get_quiz(), $attempt)) {
save_question_session($attemptobj->get_question($id), $state);
} else {
$success = false;
}
}
if (!$success) {
print_error('errorprocessingresponses', 'question', $attemptobj->attempt_url(0, $page));
}
/// Log the end of this attempt.
add_to_log($attemptobj->get_courseid(), 'quiz', 'close attempt', 'review.php?attempt=' . $attemptobj->get_attemptid(), $attemptobj->get_quizid(), $attemptobj->get_cmid());
/// Update the quiz attempt record.
$attempt->timemodified = $timenow;
$attempt->timefinish = $timenow;
$DB->update_record('quiz_attempts', $attempt);
if (!$attempt->preview) {
/// Record this user's best grade (if this is not a preview).
quiz_save_best_grade($attemptobj->get_quiz());
/// Send any notification emails (if this is not a preview).
$attemptobj->quiz_send_notification_emails();
}
/// Clear the password check flag in the session.
$accessmanager = $attemptobj->get_access_manager($timenow);
$accessmanager->clear_password_access();
/// Send the user to the review page.
redirect($attemptobj->review_url());