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


PHP quiz_update_effective_access函数代码示例

本文整理汇总了PHP中quiz_update_effective_access函数的典型用法代码示例。如果您正苦于以下问题:PHP quiz_update_effective_access函数的具体用法?PHP quiz_update_effective_access怎么用?PHP quiz_update_effective_access使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: create_helper

 /**
  * Used by {create()} and {create_from_usage_id()}.
  * @param array $conditions passed to $DB->get_record('quiz_attempts', $conditions).
  */
 protected static function create_helper($conditions)
 {
     global $DB;
     $attempt = $DB->get_record('quiz_attempts', $conditions, '*', MUST_EXIST);
     $quiz = quiz_access_manager::load_quiz_and_settings($attempt->quiz);
     $course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
     $cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id, false, MUST_EXIST);
     // Update quiz with override information.
     $quiz = quiz_update_effective_access($quiz, $attempt->userid);
     return new quiz_attempt($attempt, $quiz, $cm, $course);
 }
开发者ID:elie89,项目名称:moodle,代码行数:15,代码来源:attemptlib.php

示例2: get_string

    }
}
/// Guests can't do a quiz, so offer them a choice of logging in or going back.
if (isguestuser()) {
    echo $OUTPUT->confirm('<p>' . get_string('guestsno', 'quiz') . "</p>\n\n<p>" . get_string('liketologin') . "</p>\n", get_login_url(), get_referer(false));
    echo $OUTPUT->footer();
    exit;
}
/// If they are not enrolled in this course in a good enough role, tell them to enrol.
if (!($canattempt || $canpreview || $canreviewmine)) {
    echo $OUTPUT->box('<p>' . get_string('youneedtoenrol', 'quiz') . "</p>\n\n<p>" . $OUTPUT->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id) . "</p>\n", 'generalbox', 'notice');
    echo $OUTPUT->footer();
    exit;
}
/// Update the quiz with overrides for the current user
$quiz = quiz_update_effective_access($quiz, $USER->id);
/// Get this user's attempts.
$attempts = quiz_get_user_attempts($quiz->id, $USER->id);
$lastfinishedattempt = end($attempts);
$unfinished = false;
if ($unfinishedattempt = quiz_get_user_attempt_unfinished($quiz->id, $USER->id)) {
    $attempts[] = $unfinishedattempt;
    $unfinished = true;
}
$numattempts = count($attempts);
/// Work out the final grade, checking whether it was overridden in the gradebook.
$mygrade = quiz_get_best_grade($quiz, $USER->id);
$mygradeoverridden = false;
$gradebookfeedback = '';
$grading_info = grade_get_grades($course->id, 'mod', 'quiz', $quiz->id, $USER->id);
if (!empty($grading_info->items)) {
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:31,代码来源:view.php

示例3: get_quizzes_by_courses

 /**
  * Returns a list of quizzes in a provided list of courses,
  * if no list is provided all quizzes that the user can view will be returned.
  *
  * @param array $courseids Array of course ids
  * @return array of quizzes details
  * @since Moodle 3.1
  */
 public static function get_quizzes_by_courses($courseids = array())
 {
     global $USER;
     $warnings = array();
     $returnedquizzes = array();
     $params = array('courseids' => $courseids);
     $params = self::validate_parameters(self::get_quizzes_by_courses_parameters(), $params);
     $mycourses = array();
     if (empty($params['courseids'])) {
         $mycourses = enrol_get_my_courses();
         $params['courseids'] = array_keys($mycourses);
     }
     // Ensure there are courseids to loop through.
     if (!empty($params['courseids'])) {
         list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);
         // Get the quizzes in this course, this function checks users visibility permissions.
         // We can avoid then additional validate_context calls.
         $quizzes = get_all_instances_in_courses("quiz", $courses);
         foreach ($quizzes as $quiz) {
             $context = context_module::instance($quiz->coursemodule);
             // Update quiz with override information.
             $quiz = quiz_update_effective_access($quiz, $USER->id);
             // Entry to return.
             $quizdetails = array();
             // First, we return information that any user can see in the web interface.
             $quizdetails['id'] = $quiz->id;
             $quizdetails['coursemodule'] = $quiz->coursemodule;
             $quizdetails['course'] = $quiz->course;
             $quizdetails['name'] = external_format_string($quiz->name, $context->id);
             if (has_capability('mod/quiz:view', $context)) {
                 // Format intro.
                 list($quizdetails['intro'], $quizdetails['introformat']) = external_format_text($quiz->intro, $quiz->introformat, $context->id, 'mod_quiz', 'intro', null);
                 $viewablefields = array('timeopen', 'timeclose', 'grademethod', 'section', 'visible', 'groupmode', 'groupingid');
                 $timenow = time();
                 $quizobj = quiz::create($quiz->id, $USER->id);
                 $accessmanager = new quiz_access_manager($quizobj, $timenow, has_capability('mod/quiz:ignoretimelimits', $context, null, false));
                 // Fields the user could see if have access to the quiz.
                 if (!$accessmanager->prevent_access()) {
                     // Some times this function returns just empty.
                     $hasfeedback = quiz_has_feedback($quiz);
                     $quizdetails['hasfeedback'] = !empty($hasfeedback) ? 1 : 0;
                     $quizdetails['hasquestions'] = (int) $quizobj->has_questions();
                     $quizdetails['autosaveperiod'] = get_config('quiz', 'autosaveperiod');
                     $additionalfields = array('timelimit', 'attempts', 'attemptonlast', 'grademethod', 'decimalpoints', 'questiondecimalpoints', 'reviewattempt', 'reviewcorrectness', 'reviewmarks', 'reviewspecificfeedback', 'reviewgeneralfeedback', 'reviewrightanswer', 'reviewoverallfeedback', 'questionsperpage', 'navmethod', 'sumgrades', 'grade', 'browsersecurity', 'delay1', 'delay2', 'showuserpicture', 'showblocks', 'completionattemptsexhausted', 'completionpass', 'overduehandling', 'graceperiod', 'preferredbehaviour', 'canredoquestions');
                     $viewablefields = array_merge($viewablefields, $additionalfields);
                 }
                 // Fields only for managers.
                 if (has_capability('moodle/course:manageactivities', $context)) {
                     $additionalfields = array('shuffleanswers', 'timecreated', 'timemodified', 'password', 'subnet');
                     $viewablefields = array_merge($viewablefields, $additionalfields);
                 }
                 foreach ($viewablefields as $field) {
                     $quizdetails[$field] = $quiz->{$field};
                 }
             }
             $returnedquizzes[] = $quizdetails;
         }
     }
     $result = array();
     $result['quizzes'] = $returnedquizzes;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:71,代码来源:external.php

示例4: create

 /**
  * Static function to create a new quiz_attempt object given an attemptid.
  *
  * @param integer $attemptid the attempt id.
  * @return quiz_attempt the new quiz_attempt object
  */
 public static function create($attemptid)
 {
     global $DB;
     if (!($attempt = quiz_load_attempt($attemptid))) {
         throw new moodle_exception('invalidattemptid', 'quiz');
     }
     if (!($quiz = $DB->get_record('quiz', array('id' => $attempt->quiz)))) {
         throw new moodle_exception('invalidquizid', 'quiz');
     }
     if (!($course = $DB->get_record('course', array('id' => $quiz->course)))) {
         throw new moodle_exception('invalidcoursemodule');
     }
     if (!($cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id))) {
         throw new moodle_exception('invalidcoursemodule');
     }
     // Update quiz with override information
     $quiz = quiz_update_effective_access($quiz, $attempt->userid);
     return new quiz_attempt($attempt, $quiz, $cm, $course);
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:25,代码来源:attemptlib.php


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