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


PHP quiz::get_quiz方法代码示例

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


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

示例1: make

 public static function make(quiz $quizobj, $timenow, $canignoretimelimits)
 {
     if (empty($quizobj->get_quiz()->offlinemode_enabled) || !self::is_compatible_behaviour($quizobj->get_quiz()->preferredbehaviour)) {
         return null;
     }
     return new self($quizobj, $timenow);
 }
开发者ID:gurujiathome,项目名称:moodle-quizaccess_offlinemode,代码行数:7,代码来源:rule.php

示例2: edit_page

    /**
     * Render the edit page
     *
     * @param \quiz $quizobj object containing all the quiz settings information.
     * @param structure $structure object containing the structure of the quiz.
     * @param \question_edit_contexts $contexts the relevant question bank contexts.
     * @param \moodle_url $pageurl the canonical URL of this page.
     * @param array $pagevars the variables from {@link question_edit_setup()}.
     * @return string HTML to output.
     */
    public function edit_page(\quiz $quizobj, structure $structure,
            \question_edit_contexts $contexts, \moodle_url $pageurl, array $pagevars) {
        $output = '';

        // Page title.
        $output .= $this->heading_with_help(get_string('editingquizx', 'quiz',
                format_string($quizobj->get_quiz_name())), 'editingquiz', 'quiz', '',
                get_string('basicideasofquiz', 'quiz'), 2);

        // Information at the top.
        $output .= $this->quiz_state_warnings($structure);
        $output .= $this->quiz_information($structure);
        $output .= $this->maximum_grade_input($quizobj->get_quiz(), $this->page->url);
        $output .= $this->repaginate_button($structure, $pageurl);
        $output .= $this->total_marks($quizobj->get_quiz());

        // Show the questions organised into sections and pages.
        $output .= $this->start_section_list();

        $sections = $structure->get_quiz_sections();
        $lastsection = end($sections);
        foreach ($sections as $section) {
            $output .= $this->start_section($section);
            $output .= $this->questions_in_section($structure, $section, $contexts, $pagevars, $pageurl);
            if ($section === $lastsection) {
                $output .= \html_writer::start_div('last-add-menu');
                $output .= html_writer::tag('span', $this->add_menu_actions($structure, 0,
                        $pageurl, $contexts, $pagevars), array('class' => 'add-menu-outer'));
                $output .= \html_writer::end_div();
            }
            $output .= $this->end_section();
        }

        $output .= $this->end_section_list();

        // Inialise the JavaScript.
        $this->initialise_editing_javascript($quizobj->get_course(), $quizobj->get_quiz());

        // Include the contents of any other popups required.
        if ($structure->can_be_edited()) {
            $popups = '';

            $popups .= $this->question_bank_loading();
            $this->page->requires->yui_module('moodle-mod_quiz-quizquestionbank',
                    'M.mod_quiz.quizquestionbank.init',
                    array('class' => 'questionbank', 'cmid' => $structure->get_cmid()));

            $popups .= $this->random_question_form($pageurl, $contexts, $pagevars);
            $this->page->requires->yui_module('moodle-mod_quiz-randomquestion',
                    'M.mod_quiz.randomquestion.init');

            $output .= html_writer::div($popups, 'mod_quiz_edit_forms');

            // Include the question chooser.
            $output .= $this->question_chooser();
            $this->page->requires->yui_module('moodle-mod_quiz-questionchooser', 'M.mod_quiz.init_questionchooser');
        }

        return $output;
    }
开发者ID:jtibbetts,项目名称:moodle,代码行数:70,代码来源:edit_renderer.php

示例3: make

 public static function make(quiz $quizobj, $timenow, $canignoretimelimits)
 {
     if (empty($quizobj->get_quiz()->honestycheckrequired)) {
         return null;
     }
     return new self($quizobj, $timenow);
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:7,代码来源:rule.php

示例4: create_for_quiz

 /**
  * Create an instance of this class representing the structure of a given quiz.
  * @param \quiz $quizobj the quiz.
  * @return structure
  */
 public static function create_for_quiz($quizobj)
 {
     $structure = self::create();
     $structure->quizobj = $quizobj;
     $structure->populate_structure($quizobj->get_quiz());
     return $structure;
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:12,代码来源:structure.php

示例5: make

 public static function make(quiz $quizobj, $timenow, $canignoretimelimits)
 {
     if ($quizobj->get_quiz()->browsersecurity !== 'safebrowser') {
         return null;
     }
     return new self($quizobj, $timenow);
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:7,代码来源:rule.php

示例6: make

 public static function make(quiz $quizobj, $timenow, $canignoretimelimits)
 {
     if (empty($quizobj->get_quiz()->reattemptchecker)) {
         return null;
     }
     return new self($quizobj, $timenow);
 }
开发者ID:jmvedrine,项目名称:moodle-quizaccess_reattemptchecker,代码行数:7,代码来源:rule.php

示例7: make

 public static function make(quiz $quizobj, $timenow, $canignoretimelimits)
 {
     global $THEME;
     if (empty($quizobj->get_quiz()->gradebycategory)) {
         return null;
     }
     return new self($quizobj, $timenow);
 }
开发者ID:advancingdesign,项目名称:moodle-mod_quiz_accessrule_gradebycategory,代码行数:8,代码来源:rule.php

示例8: make

 public static function make(quiz $quizobj, $timenow, $canignoretimelimits)
 {
     global $CFG;
     // If mobile services are off, the user won't be able to use any external app.
     if (empty($CFG->enablemobilewebservice) or empty($quizobj->get_quiz()->allowofflineattempts)) {
         return null;
     }
     return new self($quizobj, $timenow);
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:9,代码来源:rule.php

示例9: quiz_create_attempt

/**
 * Creates an object to represent a new attempt at a quiz
 *
 * Creates an attempt object to represent an attempt at the quiz by the current
 * user starting at the current time. The ->id field is not set. The object is
 * NOT written to the database.
 *
 * @param object $quizobj the quiz object to create an attempt for.
 * @param int $attemptnumber the sequence number for the attempt.
 * @param object $lastattempt the previous attempt by this user, if any. Only needed
 *         if $attemptnumber > 1 and $quiz->attemptonlast is true.
 * @param int $timenow the time the attempt was started at.
 * @param bool $ispreview whether this new attempt is a preview.
 *
 * @return object the newly created attempt object.
 */
function quiz_create_attempt(quiz $quizobj, $attemptnumber, $lastattempt, $timenow, $ispreview = false) {
    global $USER;

    $quiz = $quizobj->get_quiz();
    if ($quiz->sumgrades < 0.000005 && $quiz->grade > 0.000005) {
        throw new moodle_exception('cannotstartgradesmismatch', 'quiz',
                new moodle_url('/mod/quiz/view.php', array('q' => $quiz->id)),
                    array('grade' => quiz_format_grade($quiz, $quiz->grade)));
    }

    if ($attemptnumber == 1 || !$quiz->attemptonlast) {
        // We are not building on last attempt so create a new attempt.
        $attempt = new stdClass();
        $attempt->quiz = $quiz->id;
        $attempt->userid = $USER->id;
        $attempt->preview = 0;
        $attempt->layout = quiz_clean_layout($quiz->questions, true);
        if ($quiz->shufflequestions) {
            $attempt->layout = quiz_repaginate($attempt->layout, $quiz->questionsperpage, true);
        }
    } else {
        // Build on last attempt.
        if (empty($lastattempt)) {
            print_error('cannotfindprevattempt', 'quiz');
        }
        $attempt = $lastattempt;
    }

    $attempt->attempt = $attemptnumber;
    $attempt->timestart = $timenow;
    $attempt->timefinish = 0;
    $attempt->timemodified = $timenow;
    $attempt->state = quiz_attempt::IN_PROGRESS;

    // If this is a preview, mark it as such.
    if ($ispreview) {
        $attempt->preview = 1;
    }

    $timeclose = $quizobj->get_access_manager($timenow)->get_end_time($attempt);
    if ($timeclose === false || $ispreview) {
        $attempt->timecheckstate = null;
    } else {
        $attempt->timecheckstate = $timeclose;
    }

    return $attempt;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:64,代码来源:locallib.php

示例10: start_attempt_page

 public function start_attempt_page(quiz $quizobj, mod_quiz_preflight_check_form $mform) {
     $output = '';
     $output .= $this->header();
     $output .= $this->quiz_intro($quizobj->get_quiz(), $quizobj->get_cm());
     ob_start();
     $mform->display();
     $output .= ob_get_clean();
     $output .= $this->footer();
     return $output;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:10,代码来源:renderer.php

示例11: __construct

 /**
  * Create an instance of this rule for a particular quiz.
  * @param quiz $quizobj information about the quiz in question.
  * @param int $timenow the time that should be considered as 'now'.
  */
 public function __construct($quizobj, $timenow)
 {
     $this->quizobj = $quizobj;
     $this->quiz = $quizobj->get_quiz();
     $this->timenow = $timenow;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:11,代码来源:accessrulebase.php

示例12: time

if (!$quizobj->is_preview_user() && $messages) {
    print_error('attempterror', 'quiz', $quizobj->view_url(), $accessmanager->print_messages($messages, true));
}
$accessmanager->do_password_check($quizobj->is_preview_user());
/// Delete any previous preview attempts belonging to this user.
quiz_delete_previews($quiz, $USER->id);
/// Create the new attempt and initialize the question sessions
$attempt = quiz_create_attempt($quiz, $attemptnumber, $lastattempt, time(), $quizobj->is_preview_user());
/// Save the attempt in the database.
if (!($attempt->id = $DB->insert_record('quiz_attempts', $attempt))) {
    quiz_error($quiz, 'newattemptfail');
}
/// Log the new attempt.
if ($attempt->preview) {
    add_to_log($course->id, 'quiz', 'preview', 'view.php?id=' . $quizobj->get_cmid(), $quizobj->get_quizid(), $quizobj->get_cmid());
} else {
    add_to_log($course->id, 'quiz', 'attempt', 'review.php?attempt=' . $attempt->id, $quizobj->get_quizid(), $quizobj->get_cmid());
}
/// Fully load all the questions in this quiz.
$quizobj->preload_questions();
$quizobj->load_questions();
/// Create initial states for all questions in this quiz.
if (!($states = get_question_states($quizobj->get_questions(), $quizobj->get_quiz(), $attempt, $lastattemptid))) {
    print_error('cannotrestore', 'quiz');
}
/// Save all the newly created states.
foreach ($quizobj->get_questions() as $i => $question) {
    save_question_session($question, $states[$i]);
}
/// Redirect to the attempt page.
redirect($quizobj->attempt_url($attempt->id));
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:startattempt.php

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

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

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


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