本文整理汇总了PHP中quiz_attempt::load_question_states方法的典型用法代码示例。如果您正苦于以下问题:PHP quiz_attempt::load_question_states方法的具体用法?PHP quiz_attempt::load_question_states怎么用?PHP quiz_attempt::load_question_states使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类quiz_attempt
的用法示例。
在下文中一共展示了quiz_attempt::load_question_states方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$attemptid = required_param('attempt', PARAM_INT);
// attempt id
$questionid = required_param('question', PARAM_INT);
// question id
$attemptobj = new quiz_attempt($attemptid);
/// Can only grade finished attempts.
if (!$attemptobj->is_finished()) {
print_error('attemptclosed', 'quiz');
}
/// Check login and permissions.
require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
$attemptobj->require_capability('mod/quiz:grade');
/// Load the questions and states.
$questionids = array($questionid);
$attemptobj->load_questions($questionids);
$attemptobj->load_question_states($questionids);
/// Log this action.
add_to_log($attemptobj->get_courseid(), 'quiz', 'manualgrade', 'comment.php?attempt=' . $attemptobj->get_attemptid() . '&question=' . $questionid, $attemptobj->get_quizid(), $attemptobj->get_cmid());
/// Print the page header
print_header();
print_heading(format_string($attemptobj->get_question($questionid)->name));
/// Process any data that was submitted.
if ($data = data_submitted() and confirm_sesskey()) {
$error = $attemptobj->process_comment($questionid, $data->response['comment'], $data->response['grade']);
/// If success, notify and print a close button.
if (!is_string($error)) {
notify(get_string('changessaved'), 'notifysuccess');
close_window(2, true);
}
/// Otherwise, display the error and fall throug to re-display the form.
notify($error);
示例2: redirect
/// 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()), '');
} else {
print_header_simple(format_string($attemptobj->get_quiz_name()), '', $attemptobj->navigation($title), '', '', true, $attemptobj->update_module_button());
}
/// Print tabs if they should be there.
if ($attemptobj->is_preview_user()) {
$currenttab = 'preview';
include 'tabs.php';
}
/// Print heading.
print_heading(format_string($attemptobj->get_quiz_name()));
示例3: explode
/// Don't log - we will end with a redirect to a page that is logged.
/// Get the list of questions needed by this page.
if (!empty($submittedquestionids)) {
$submittedquestionids = explode(',', $submittedquestionids);
} else {
$submittedquestionids = array();
}
if ($finishattempt) {
$questionids = $attemptobj->get_question_ids();
} else {
$questionids = $submittedquestionids;
}
/// Load those questions we need, and just the submitted states for now.
$attemptobj->load_questions($questionids);
if (!empty($submittedquestionids)) {
$attemptobj->load_question_states($submittedquestionids);
}
/// Process the responses /////////////////////////////////////////////////
if (!($responses = data_submitted())) {
quiz_error($attemptobj->get_quiz(), 'nodatasubmitted');
}
/// Set the default event. This can be overruled by individual buttons.
if ($finishattempt) {
$event = QUESTION_EVENTCLOSE;
} else {
$event = QUESTION_EVENTSAVE;
}
/// Unset any variables we know are not responses
unset($responses->id);
unset($responses->q);
unset($responses->oldpage);