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


PHP quiz_access_manager::is_preflight_check_required方法代码示例

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


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

示例1: get_attempt_access_information

 /**
  * Return access information for a given attempt in a quiz.
  *
  * @param int $quizid quiz instance id
  * @param int $attemptid attempt id, 0 for the user last attempt if exists
  * @return array of warnings and the access information
  * @since Moodle 3.1
  * @throws  moodle_quiz_exception
  */
 public static function get_attempt_access_information($quizid, $attemptid = 0)
 {
     global $DB, $USER;
     $warnings = array();
     $params = array('quizid' => $quizid, 'attemptid' => $attemptid);
     $params = self::validate_parameters(self::get_attempt_access_information_parameters(), $params);
     list($quiz, $course, $cm, $context) = self::validate_quiz($params['quizid']);
     $attempttocheck = 0;
     if (!empty($params['attemptid'])) {
         $attemptobj = quiz_attempt::create($params['attemptid']);
         if ($attemptobj->get_userid() != $USER->id) {
             throw new moodle_quiz_exception($attemptobj->get_quizobj(), 'notyourattempt');
         }
         $attempttocheck = $attemptobj->get_attempt();
     }
     // Access manager now.
     $quizobj = quiz::create($cm->instance, $USER->id);
     $ignoretimelimits = has_capability('mod/quiz:ignoretimelimits', $context, null, false);
     $timenow = time();
     $accessmanager = new quiz_access_manager($quizobj, $timenow, $ignoretimelimits);
     $attempts = quiz_get_user_attempts($quiz->id, $USER->id, 'finished', true);
     $lastfinishedattempt = end($attempts);
     if ($unfinishedattempt = quiz_get_user_attempt_unfinished($quiz->id, $USER->id)) {
         $attempts[] = $unfinishedattempt;
         // Check if the attempt is now overdue. In that case the state will change.
         $quizobj->create_attempt_object($unfinishedattempt)->handle_if_time_expired(time(), false);
         if ($unfinishedattempt->state != quiz_attempt::IN_PROGRESS and $unfinishedattempt->state != quiz_attempt::OVERDUE) {
             $lastfinishedattempt = $unfinishedattempt;
         }
     }
     $numattempts = count($attempts);
     if (!$attempttocheck) {
         $attempttocheck = $unfinishedattempt ? $unfinishedattempt : $lastfinishedattempt;
     }
     $result = array();
     $result['isfinished'] = $accessmanager->is_finished($numattempts, $lastfinishedattempt);
     $result['preventnewattemptreasons'] = $accessmanager->prevent_new_attempt($numattempts, $lastfinishedattempt);
     if ($attempttocheck) {
         $endtime = $accessmanager->get_end_time($attempttocheck);
         $result['endtime'] = $endtime === false ? 0 : $endtime;
         $attemptid = $unfinishedattempt ? $unfinishedattempt->id : null;
         $result['ispreflightcheckrequired'] = $accessmanager->is_preflight_check_required($attemptid);
     }
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:55,代码来源:external.php

示例2: array

    $viewobj->markcolumn = $viewobj->gradecolumn && $quiz->grade != $quiz->sumgrades;
    $viewobj->overallstats = $lastfinishedattempt && $alloptions->marks >= question_display_options::MARK_AND_MAX;
    $viewobj->feedbackcolumn = quiz_has_feedback($quiz) && $alloptions->overallfeedback;
}
$viewobj->timenow = $timenow;
$viewobj->numattempts = $numattempts;
$viewobj->mygrade = $mygrade;
$viewobj->moreattempts = $unfinished || !$accessmanager->is_finished($numattempts, $lastfinishedattempt);
$viewobj->mygradeoverridden = $mygradeoverridden;
$viewobj->gradebookfeedback = $gradebookfeedback;
$viewobj->lastfinishedattempt = $lastfinishedattempt;
$viewobj->canedit = has_capability('mod/quiz:manage', $context);
$viewobj->editurl = new moodle_url('/mod/quiz/edit.php', array('cmid' => $cm->id));
$viewobj->backtocourseurl = new moodle_url('/course/view.php', array('id' => $course->id));
$viewobj->startattempturl = $quizobj->start_attempt_url();
if ($accessmanager->is_preflight_check_required($unfinishedattemptid)) {
    $viewobj->preflightcheckform = $accessmanager->get_preflight_check_form($viewobj->startattempturl, $unfinishedattemptid);
}
$viewobj->popuprequired = $accessmanager->attempt_must_be_in_popup();
$viewobj->popupoptions = $accessmanager->get_popup_options();
// Display information about this quiz.
$viewobj->infomessages = $viewobj->accessmanager->describe_rules();
if ($quiz->attempts != 1) {
    $viewobj->infomessages[] = get_string('gradingmethod', 'quiz', quiz_get_grading_option_name($quiz->grademethod));
}
// Determine wheter a start attempt button should be displayed.
$viewobj->quizhasquestions = $quizobj->has_questions();
$viewobj->preventmessages = array();
if (!$viewobj->quizhasquestions) {
    $viewobj->buttontext = '';
} else {
开发者ID:sirromas,项目名称:lms,代码行数:31,代码来源:view.php


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