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


PHP quiz_attempt::get_courseid方法代码示例

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


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

示例1: 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

示例2: user_picture

 public function user_picture()
 {
     global $DB;
     if ($this->attemptobj->get_quiz()->showuserpicture == QUIZ_SHOWIMAGE_NONE) {
         return null;
     }
     $user = $DB->get_record('user', array('id' => $this->attemptobj->get_userid()));
     $userpicture = new user_picture($user);
     $userpicture->courseid = $this->attemptobj->get_courseid();
     if ($this->attemptobj->get_quiz()->showuserpicture == QUIZ_SHOWIMAGE_LARGE) {
         $userpicture->size = true;
     }
     return $userpicture;
 }
开发者ID:elie89,项目名称:moodle,代码行数:14,代码来源:attemptlib.php

示例3: dirname

// $Id: summary.php,v 1.8 2009/03/11 07:10:57 tjhunt Exp $
/**
 * This page prints a summary of a quiz attempt before it is submitted.
 *
 * @author Tim Hunt others.
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package quiz
 */
require_once dirname(__FILE__) . '/../../config.php';
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());
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:30,代码来源:summary.php

示例4: user_picture

    public function user_picture() {
        global $DB;

        if (!$this->attemptobj->get_quiz()->showuserpicture) {
            return null;
        }

        $user = $DB->get_record('user', array('id' => $this->attemptobj->get_userid()));
        $userpicture = new user_picture($user);
        $userpicture->courseid = $this->attemptobj->get_courseid();
        return $userpicture;
    }
开发者ID:JP-Git,项目名称:moodle,代码行数:12,代码来源:attemptlib.php

示例5:

$timeup = optional_param('timeup', 0, PARAM_BOOL);
// True if form was submitted by timer.
$attemptobj = new quiz_attempt($attemptid);
/// Set $nexturl now. It will be updated if a particular question was sumbitted in
/// adaptive mode.
if ($nextpage == -1) {
    $nexturl = $attemptobj->summary_url();
} else {
    $nexturl = $attemptobj->attempt_url(0, $nextpage);
}
/// We treat automatically closed attempts just like normally closed attempts
if ($timeup) {
    $finishattempt = 1;
}
/// Check login.
require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
confirm_sesskey();
/// Check that this attempt belongs to this user.
if ($attemptobj->get_userid() != $USER->id) {
    quiz_error($attemptobj->get_quiz(), 'notyourattempt');
}
/// Check capabilites.
if (!$attemptobj->is_preview_user()) {
    $attemptobj->require_capability('mod/quiz:attempt');
}
/// If the attempt is already closed, send them to the review page.
if ($attemptobj->is_finished()) {
    quiz_error($attemptobj->get_quiz(), 'attemptalreadyclosed');
}
/// Don't log - we will end with a redirect to a page that is logged.
/// Get the list of questions needed by this page.
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:processattempt.php

示例6: array

 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package quiz
 */
require_once '../../config.php';
require_once 'locallib.php';
$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)) {
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:comment.php

示例7: get_user_picture

 protected function get_user_picture()
 {
     global $DB, $OUTPUT;
     $user = $DB->get_record('user', array('id' => $this->attemptobj->get_userid()));
     $output = '';
     $output .= '<div id="user-picture" class="clearfix">';
     $output .= $OUTPUT->user_picture($user, array('courseid' => $this->attemptobj->get_courseid()));
     $output .= ' ' . fullname($user);
     $output .= '</div>';
     return $output;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:11,代码来源:attemptlib.php

示例8: dirname

 *
 * @author Martin Dougiamas, Tim Hunt and many others.
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package quiz
 */
require_once dirname(__FILE__) . '/../../config.php';
require_once 'locallib.php';
$attemptid = required_param('attempt', PARAM_INT);
// attempt id
$questionid = required_param('question', PARAM_INT);
// question id
$stateid = optional_param('state', 0, PARAM_INT);
// state id
$attemptobj = new quiz_attempt($attemptid);
/// Check login.
require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
$attemptobj->check_review_capability();
/// Permissions checks for normal users who do not have quiz:viewreports capability.
if (!$attemptobj->has_capability('mod/quiz:viewreports')) {
    /// Can't review during the attempt - send them back to the attempt page.
    if (!$attemptobj->is_finished()) {
        notify(get_string('cannotreviewopen', 'quiz'));
        close_window_button();
    }
    /// Can't review other users' attempts.
    if (!$attemptobj->is_own_attempt()) {
        notify(get_string('notyourattempt', 'quiz'));
        close_window_button();
    }
    /// Can't review unless Students may review -> Responses option is turned on.
    if (!$options->responses) {
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:reviewquestion.php

示例9: 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

示例10: dirname

/**
 * This page prints a review of a particular quiz attempt
 *
 * @author Martin Dougiamas and many others.
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package quiz
 */
require_once dirname(__FILE__) . '/../../config.php';
require_once $CFG->dirroot . '/mod/quiz/locallib.php';
require_once $CFG->dirroot . '/mod/quiz/report/reportlib.php';
$attemptid = required_param('attempt', PARAM_INT);
$page = optional_param('page', 0, PARAM_INT);
$showall = optional_param('showall', 0, PARAM_BOOL);
$attemptobj = new quiz_attempt($attemptid);
/// Check login.
require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
$attemptobj->check_review_capability();
/// Create an object to manage all the other (non-roles) access rules.
$accessmanager = $attemptobj->get_access_manager(time());
$options = $attemptobj->get_review_options();
/// Permissions checks for normal users who do not have quiz:viewreports capability.
if (!$attemptobj->has_capability('mod/quiz:viewreports')) {
    /// Can't review other users' attempts.
    if (!$attemptobj->is_own_attempt()) {
        quiz_error($attemptobj->get_quiz(), 'notyourattempt');
    }
    /// Can't review during the attempt - send them back to the attempt page.
    if (!$attemptobj->is_finished()) {
        redirect($attemptobj->attempt_url(0, $page));
    }
    /// Can't review unless Students may review -> Responses option is turned on.
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:review.php

示例11: dirname

 *
 * @author Martin Dougiamas and many others. This has recently been completely
 *         rewritten by Alex Smith, Julian Sedding and Gustav Delius as part of
 *         the Serving Mathematics project
 *         {@link http://maths.york.ac.uk/serving_maths}
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package quiz
 */
require_once dirname(__FILE__) . '/../../config.php';
require_once $CFG->dirroot . '/mod/quiz/locallib.php';
/// Get submitted parameters.
$attemptid = required_param('attempt', PARAM_INT);
$page = optional_param('page', 0, PARAM_INT);
$attemptobj = new quiz_attempt($attemptid);
/// Check login.
require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
/// Check if the User is an Admin - to review Answers
$userRole = $DB->get_record('role_assignments', array('userid' => $USER->id));
$admin = false;
if (!empty($userRole)) {
    if ($userRole->roleid == 1 || $userRole->roleid == 2 || $userRole->roleid == 3) {
        $admin = true;
    } else {
        /// Check that this attempt belongs to this user.
        if ($attemptobj->get_userid() != $USER->id) {
            redirect("{$CFG->wwwroot}/index.php");
        }
    }
}
require_js(array('yui_yahoo', 'yui_event'));
require_js('mod/quiz/quiz.js');
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:31,代码来源:view_attempt.php


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