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


PHP quiz::get_courseid方法代码示例

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


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

示例1: quiz_fire_attempt_started_event

/**
 * Fire an event to tell the rest of Moodle a quiz attempt has started.
 *
 * @param object $attempt
 * @param quiz   $quizobj
 */
function quiz_fire_attempt_started_event($attempt, $quizobj) {
    // Trigger event.
    $eventdata = array();
    $eventdata['context'] = $quizobj->get_context();
    $eventdata['courseid'] = $quizobj->get_courseid();
    $eventdata['relateduserid'] = $attempt->userid;
    $eventdata['objectid'] = $attempt->id;
    $event = \mod_quiz\event\attempt_started::create($eventdata);
    $event->add_record_snapshot('quiz', $quizobj->get_quiz());
    $event->add_record_snapshot('quiz_attempts', $attempt);
    $event->trigger();
}
开发者ID:rwijaya,项目名称:moodle,代码行数:18,代码来源:locallib.php

示例2: quiz

$id = required_param('cmid', PARAM_INT);
// Course Module ID
$forcenew = optional_param('forcenew', false, PARAM_BOOL);
// Used to force a new preview
if (!($cm = get_coursemodule_from_id('quiz', $id))) {
    print_error('invalidcoursemodule');
}
if (!($course = $DB->get_record('course', array('id' => $cm->course)))) {
    print_error("coursemisconf");
}
if (!($quiz = $DB->get_record('quiz', array('id' => $cm->instance)))) {
    print_error('invalidcoursemodule');
}
$quizobj = new quiz($quiz, $cm, $course);
/// Check login and sesskey.
require_login($quizobj->get_courseid(), false, $quizobj->get_cm());
if (!confirm_sesskey()) {
    throw new moodle_exception('confirmsesskeybad', 'error', $quizobj->view_url());
}
/// if no questions have been set up yet redirect to edit.php
if (!$quizobj->get_question_ids() && $quizobj->has_capability('mod/quiz:manage')) {
    redirect($quizobj->edit_url());
}
/// Create an object to manage all the other (non-roles) access rules.
$accessmanager = $quizobj->get_access_manager(time());
if ($quizobj->is_preview_user() && $forcenew) {
    $accessmanager->clear_password_access();
}
/// Check capabilites.
if (!$quizobj->is_preview_user()) {
    $quizobj->require_capability('mod/quiz:attempt');
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:startattempt.php

示例3: quiz_attempt_save_started

/**
 * The save started question usage and quiz attempt in db and log the started attempt.
 *
 * @param quiz                       $quizobj
 * @param question_usage_by_activity $quba
 * @param object                     $attempt
 * @return object                    attempt object with uniqueid and id set.
 */
function quiz_attempt_save_started($quizobj, $quba, $attempt)
{
    global $DB;
    // Save the attempt in the database.
    question_engine::save_questions_usage_by_activity($quba);
    $attempt->uniqueid = $quba->get_id();
    $attempt->id = $DB->insert_record('quiz_attempts', $attempt);
    // Params used by the events below.
    $params = array('objectid' => $attempt->id, 'relateduserid' => $attempt->userid, 'courseid' => $quizobj->get_courseid(), 'context' => $quizobj->get_context());
    // Decide which event we are using.
    if ($attempt->preview) {
        $params['other'] = array('quizid' => $quizobj->get_quizid());
        $event = \mod_quiz\event\attempt_preview_started::create($params);
    } else {
        $event = \mod_quiz\event\attempt_started::create($params);
    }
    // Trigger the event.
    $event->add_record_snapshot('quiz', $quizobj->get_quiz());
    $event->add_record_snapshot('quiz_attempts', $attempt);
    $event->trigger();
    return $attempt;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:30,代码来源:locallib.php


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