当前位置: 首页>>代码示例>>PHP>>正文


PHP quiz_attempt::get_question方法代码示例

本文整理汇总了PHP中quiz_attempt::get_question方法的典型用法代码示例。如果您正苦于以下问题:PHP quiz_attempt::get_question方法的具体用法?PHP quiz_attempt::get_question怎么用?PHP quiz_attempt::get_question使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在quiz_attempt的用法示例。


在下文中一共展示了quiz_attempt::get_question方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

/// 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);
}
/// Print the comment form.
echo '<form method="post" class="mform" id="manualgradingform" action="' . $CFG->wwwroot . '/mod/quiz/comment.php">';
$attemptobj->question_print_comment_fields($questionid, 'response');
?>
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:comment.php

示例2: array

/// 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();
echo $OUTPUT->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)) {
        echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess');
        close_window(2, true);
    }
    /// Otherwise, display the error and fall throug to re-display the form.
    echo $OUTPUT->notification($error);
}
/// Print the comment form.
echo '<form method="post" class="mform" id="manualgradingform" action="' . $CFG->wwwroot . '/mod/quiz/comment.php">';
$attemptobj->question_print_comment_fields($questionid, 'response');
?>
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:comment.php

示例3: array

print_header('', '', '', '', $headtags);
echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>';
// for overlib
/// Print infobox
$rows = array();
/// User picture and name.
if ($attemptobj->get_userid() != $USER->id) {
    // Print user picture and name
    $student = $DB->get_record('user', array('id' => $attemptobj->get_userid()));
    $picture = print_user_picture($student, $attemptobj->get_courseid(), $student->picture, false, true);
    $rows[] = '<tr><th scope="row" class="cell">' . $picture . '</th><td class="cell"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $student->id . '&amp;course=' . $attemptobj->get_courseid() . '">' . fullname($student, true) . '</a></td></tr>';
}
/// Quiz name.
$rows[] = '<tr><th scope="row" class="cell">' . get_string('modulename', 'quiz') . '</th><td class="cell">' . format_string($attemptobj->get_quiz_name()) . '</td></tr>';
/// Question name.
$rows[] = '<tr><th scope="row" class="cell">' . get_string('question', 'quiz') . '</th><td class="cell">' . format_string($attemptobj->get_question($questionid)->name) . '</td></tr>';
/// Other attempts at the quiz.
if ($attemptobj->has_capability('mod/quiz:viewreports')) {
    $attemptlist = $attemptobj->links_to_other_attempts($baseurl);
    if ($attemptlist) {
        $rows[] = '<tr><th scope="row" class="cell">' . get_string('attempts', 'quiz') . '</th><td class="cell">' . $attemptlist . '</td></tr>';
    }
}
/// Timestamp of this action.
$timestamp = $attemptobj->get_question_state($questionid)->timestamp;
if ($timestamp) {
    $rows[] = '<tr><th scope="row" class="cell">' . get_string('completedon', 'quiz') . '</th><td class="cell">' . userdate($timestamp) . '</td></tr>';
}
/// Now output the summary table, if there are any rows to be shown.
if (!empty($rows)) {
    echo '<table class="generaltable generalbox quizreviewsummary"><tbody>', "\n";
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:reviewquestion.php

示例4: array

$actions = question_extract_responses($attemptobj->get_questions($submittedquestionids), $responses, $event);
/// Process each question in turn
$success = true;
$attempt = $attemptobj->get_attempt();
foreach ($submittedquestionids as $id) {
    if (!isset($actions[$id])) {
        $actions[$id]->responses = array('' => '');
        $actions[$id]->event = QUESTION_EVENTOPEN;
    }
    $actions[$id]->timestamp = $timenow;
    /// If a particular question was submitted, update the nexturl to go back to that question.
    if ($actions[$id]->event == QUESTION_EVENTSUBMIT) {
        $nexturl = $attemptobj->attempt_url($id);
    }
    $state = $attemptobj->get_question_state($id);
    if (question_process_responses($attemptobj->get_question($id), $state, $actions[$id], $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));
}
/// If we do not have to finish the attempts (if we are only processing responses)
/// save the attempt and redirect to the next page.
if (!$finishattempt) {
    $attempt->timemodified = $timenow;
    $DB->update_record('quiz_attempts', $attempt);
    redirect($nexturl);
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:processattempt.php

示例5: foreach

 echo "<tr>";
 echo "<th>Question</th>";
 echo "<th>Answer</th>";
 echo "<th>Score</th>";
 echo "</tr>";
 echo "</thead>";
 echo "<tbody>";
 $cnt = 0;
 $score = 0;
 // Print Quiz Attempt Review
 foreach ($attemptobj->get_question_ids($page) as $id) {
     $cnt++;
     $score += $attemptobj->get_question_score($id);
     $actual = $attemptobj->get_actual_id($id, false, $attemptobj->attempt_url($id, $page));
     $question = $DB->get_record('question', array('id' => $actual));
     $responses = get_question_actual_response($attemptobj->get_question($id), $attemptobj->get_question_state($id));
     echo "<tr class='odd'><td colspan='3'>Question: " . $cnt . "</td></tr>";
     echo "<tr>";
     // Question
     echo "<td>" . replace_keywords($attemptid, $question->questiontext) . "</td>";
     echo "<td>";
     // Answer
     foreach ($responses as $r) {
         echo replace_keywords($attemptid, $r);
     }
     echo "</td>";
     // Score
     echo "<td>" . $attemptobj->get_question_score($id) . "</td>";
     echo "</tr>";
 }
 echo "</tbody>";
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:31,代码来源:view_attempt.php


注:本文中的quiz_attempt::get_question方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。