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


PHP quiz::get_context方法代码示例

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


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

示例1: start_attempt_page

 public function start_attempt_page(quiz $quizobj, mod_quiz_preflight_check_form $mform)
 {
     $output = '';
     $output .= $this->header();
     $output .= $this->heading(format_string($quizobj->get_quiz_name(), true, array("context" => $quizobj->get_context())));
     $output .= $this->quiz_intro($quizobj->get_quiz(), $quizobj->get_cm());
     ob_start();
     $mform->display();
     $output .= ob_get_clean();
     $output .= $this->footer();
     return $output;
 }
开发者ID:elnata,项目名称:moodle,代码行数:12,代码来源:renderer.php

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

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

示例4: quiz_prepare_and_start_new_attempt

/**
 * Prepare and start a new attempt deleting the previous preview attempts.
 *
 * @param  quiz $quizobj quiz object
 * @param  int $attemptnumber the attempt number
 * @param  object $lastattempt last attempt object
 * @param bool $offlineattempt whether is an offline attempt or not
 * @return object the new attempt
 * @since  Moodle 3.1
 */
function quiz_prepare_and_start_new_attempt(quiz $quizobj, $attemptnumber, $lastattempt, $offlineattempt = false)
{
    global $DB, $USER;
    // Delete any previous preview attempts belonging to this user.
    quiz_delete_previews($quizobj->get_quiz(), $USER->id);
    $quba = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj->get_context());
    $quba->set_preferred_behaviour($quizobj->get_quiz()->preferredbehaviour);
    // Create the new attempt and initialize the question sessions
    $timenow = time();
    // Update time now, in case the server is running really slowly.
    $attempt = quiz_create_attempt($quizobj, $attemptnumber, $lastattempt, $timenow, $quizobj->is_preview_user());
    if (!($quizobj->get_quiz()->attemptonlast && $lastattempt)) {
        $attempt = quiz_start_new_attempt($quizobj, $quba, $attempt, $attemptnumber, $timenow);
    } else {
        $attempt = quiz_start_attempt_built_on_last($quba, $attempt, $lastattempt);
    }
    $transaction = $DB->start_delegated_transaction();
    // Init the timemodifiedoffline for offline attempts.
    if ($offlineattempt) {
        $attempt->timemodifiedoffline = $attempt->timemodified;
    }
    $attempt = quiz_attempt_save_started($quizobj, $quba, $attempt);
    $transaction->allow_commit();
    return $attempt;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:35,代码来源:locallib.php


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