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


PHP quiz_attempt::get_quizid方法代码示例

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


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

示例1: redirect

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()), '');
} 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';
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:summary.php

示例2: process_submitted_data

 protected function process_submitted_data()
 {
     global $DB;
     $qubaids = optional_param('qubaids', null, PARAM_SEQUENCE);
     $assumedslotforevents = optional_param('slot', null, PARAM_INT);
     if (!$qubaids) {
         return;
     }
     $qubaids = clean_param_array(explode(',', $qubaids), PARAM_INT);
     $attempts = $this->load_attempts_by_usage_ids($qubaids);
     $events = array();
     $transaction = $DB->start_delegated_transaction();
     foreach ($qubaids as $qubaid) {
         $attempt = $attempts[$qubaid];
         $attemptobj = new quiz_attempt($attempt, $this->quiz, $this->cm, $this->course);
         $attemptobj->process_submitted_actions(time());
         // Add the event we will trigger later.
         $params = array('objectid' => $attemptobj->get_question_attempt($assumedslotforevents)->get_question()->id, 'courseid' => $attemptobj->get_courseid(), 'context' => context_module::instance($attemptobj->get_cmid()), 'other' => array('quizid' => $attemptobj->get_quizid(), 'attemptid' => $attemptobj->get_attemptid(), 'slot' => $assumedslotforevents));
         $events[] = \mod_quiz\event\question_manually_graded::create($params);
     }
     $transaction->allow_commit();
     // Trigger events for all the questions we manually marked.
     foreach ($events as $event) {
         $event->trigger();
     }
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:26,代码来源:report.php

示例3: array

$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);
}
/// Print the comment form.
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:comment.php

示例4: 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());
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:processattempt.php

示例5: notify

        notify($accessmanager->cannot_review_message($attemptobj->get_review_options()));
        close_window_button();
    }
}
/// Load the questions and states.
$questionids = array($questionid);
$attemptobj->load_questions($questionids);
$attemptobj->load_question_states($questionids);
/// If it was asked for, load another state, instead of the latest.
if ($stateid) {
    $attemptobj->load_specific_question_state($questionid, $stateid);
}
/// Work out the base URL of this page.
$baseurl = $CFG->wwwroot . '/mod/quiz/reviewquestion.php?attempt=' . $attemptobj->get_attemptid() . '&question=' . $questionid;
/// Log this review.
add_to_log($attemptobj->get_courseid(), 'quiz', 'review', 'reviewquestion.php?attempt=' . $attemptobj->get_attemptid() . '&question=' . $questionid . ($stateid ? '&state=' . $stateid : ''), $attemptobj->get_quizid(), $attemptobj->get_cmid());
/// Print the page header
$headtags = $attemptobj->get_question_html_head_contributions($questionid);
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.
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:reviewquestion.php

示例6: check_attempt_results

 /**
  * Check that attempt results are as specified in $result.
  *
  * @param array        $result             row of data read from csv file.
  * @param quiz_attempt $attemptobj         the attempt object loaded from db.
  * @throws coding_exception
  */
 protected function check_attempt_results($result, $attemptobj)
 {
     foreach ($result as $fieldname => $value) {
         if ($value === '!NULL!') {
             $value = null;
         }
         switch ($fieldname) {
             case 'quizattempt':
                 break;
             case 'attemptnumber':
                 $this->assertEquals($value, $attemptobj->get_attempt_number());
                 break;
             case 'slots':
                 foreach ($value as $slotno => $slottests) {
                     foreach ($slottests as $slotfieldname => $slotvalue) {
                         switch ($slotfieldname) {
                             case 'mark':
                                 $this->assertEquals(round($slotvalue, 2), $attemptobj->get_question_mark($slotno), "Mark for slot {$slotno} of attempt {$result['quizattempt']}.");
                                 break;
                             default:
                                 throw new coding_exception('Unknown slots sub field column in csv file ' . s($slotfieldname));
                         }
                     }
                 }
                 break;
             case 'finished':
                 $this->assertEquals((bool) $value, $attemptobj->is_finished());
                 break;
             case 'summarks':
                 $this->assertEquals($value, $attemptobj->get_sum_marks(), "Sum of marks of attempt {$result['quizattempt']}.");
                 break;
             case 'quizgrade':
                 // Check quiz grades.
                 $grades = quiz_get_user_grades($attemptobj->get_quiz(), $attemptobj->get_userid());
                 $grade = array_shift($grades);
                 $this->assertEquals($value, $grade->rawgrade, "Quiz grade for attempt {$result['quizattempt']}.");
                 break;
             case 'gradebookgrade':
                 // Check grade book.
                 $gradebookgrades = grade_get_grades($attemptobj->get_courseid(), 'mod', 'quiz', $attemptobj->get_quizid(), $attemptobj->get_userid());
                 $gradebookitem = array_shift($gradebookgrades->items);
                 $gradebookgrade = array_shift($gradebookitem->grades);
                 $this->assertEquals($value, $gradebookgrade->grade, "Gradebook grade for attempt {$result['quizattempt']}.");
                 break;
             default:
                 throw new coding_exception('Unknown column in csv file ' . s($fieldname));
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:56,代码来源:attempt_walkthrough_from_csv_test.php

示例7: array

$userinfo = $DB->get_record('user', array('username' => $qca->username));
if (!empty($qca)) {
    /// If the attempt is closed, results can be view, Otherwise NO.
    if ($attemptobj->is_finished()) {
        /// Get the list of questions needed by this page.
        $questionids = $attemptobj->get_question_ids($page);
        /// Check.
        if (empty($questionids)) {
            quiz_error($quiz, 'noquestionsfound');
        }
        /// Load those questions and the associated states.
        $attemptobj->load_questions($questionids);
        $attemptobj->load_question_states($questionids);
        //print_container_start();
        echo "<table class='grades boxwidthwide boxaligncenter generalbox' border='0' cellpadding='5' cellspacing='5'>";
        $quiz = $DB->get_record('quiz', array('id' => $attemptobj->get_quizid()));
        echo "<caption>" . $attemptobj->get_quiz_name() . ": " . $qca->username . "</caption>";
        echo "<thead>";
        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);
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:31,代码来源:view_attempt.php


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