當前位置: 首頁>>代碼示例>>PHP>>正文


PHP question_bank::qtype_exists方法代碼示例

本文整理匯總了PHP中question_bank::qtype_exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP question_bank::qtype_exists方法的具體用法?PHP question_bank::qtype_exists怎麽用?PHP question_bank::qtype_exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在question_bank的用法示例。


在下文中一共展示了question_bank::qtype_exists方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: quiz_print_question_list


//.........這裏部分代碼省略.........
    }

    // The current question ordinal (no descriptions).
    $qno = 1;
    // The current question (includes questions and descriptions).
    $questioncount = 0;
    // The current page number in iteration.
    $pagecount = 0;

    $pageopen = false;

    $returnurl = $pageurl->out_as_local_url(false);
    $questiontotalcount = count($order);

    foreach ($order as $count => $qnum) {

        $reordercheckbox = '';
        $reordercheckboxlabel = '';
        $reordercheckboxlabelclose = '';

        // If the questiontype is missing change the question type.
        if ($qnum && !array_key_exists($qnum, $questions)) {
            $fakequestion = new stdClass();
            $fakequestion->id = $qnum;
            $fakequestion->category = 0;
            $fakequestion->qtype = 'missingtype';
            $fakequestion->name = get_string('missingquestion', 'quiz');
            $fakequestion->questiontext = ' ';
            $fakequestion->questiontextformat = FORMAT_HTML;
            $fakequestion->length = 1;
            $questions[$qnum] = $fakequestion;
            $quiz->grades[$qnum] = 0;

        } else if ($qnum && !question_bank::qtype_exists($questions[$qnum]->qtype)) {
            $questions[$qnum]->qtype = 'missingtype';
        }

        if ($qnum != 0 || ($qnum == 0 && !$pageopen)) {
            // This is either a question or a page break after another (no page is currently open).
            if (!$pageopen) {
                // If no page is open, start display of a page.
                $pagecount++;
                echo  '<div class="quizpage"><span class="pagetitle">' .
                        get_string('page') . '&nbsp;' . $pagecount .
                        '</span><div class="pagecontent">';
                $pageopen = true;
            }
            if ($qnum == 0  && $count < $questiontotalcount) {
                // This is the second successive page break. Tell the user the page is empty.
                echo '<div class="pagestatus">';
                print_string('noquestionsonpage', 'quiz');
                echo '</div>';
                if ($allowdelete) {
                    echo '<div class="quizpagedelete">';
                    echo $OUTPUT->action_icon($pageurl->out(true,
                            array('deleteemptypage' => $count - 1, 'sesskey'=>sesskey())),
                            new pix_icon('t/delete', $strremove),
                            new component_action('click',
                                    'M.core_scroll_manager.save_scroll_action'),
                            array('title' => $strremove));
                    echo '</div>';
                }
            }

            if ($qnum != 0) {
                $question = $questions[$qnum];
開發者ID:nigeli,項目名稱:moodle,代碼行數:67,代碼來源:editlib.php

示例2: populate_missing_questions

 /**
  * Used by populate. Make up fake data for any missing questions.
  * @param \stdClass[] $slots the data about the slots and questions in the quiz.
  * @return \stdClass[] updated $slots array.
  */
 protected function populate_missing_questions($slots)
 {
     // Address missing question types.
     foreach ($slots as $slot) {
         if ($slot->qtype === null) {
             // If the questiontype is missing change the question type.
             $slot->id = $slot->questionid;
             $slot->category = 0;
             $slot->qtype = 'missingtype';
             $slot->name = get_string('missingquestion', 'quiz');
             $slot->slot = $slot->slot;
             $slot->maxmark = 0;
             $slot->requireprevious = 0;
             $slot->questiontext = ' ';
             $slot->questiontextformat = FORMAT_HTML;
             $slot->length = 1;
         } else {
             if (!\question_bank::qtype_exists($slot->qtype)) {
                 $slot->qtype = 'missingtype';
             }
         }
     }
     return $slots;
 }
開發者ID:Hirenvaghasiya,項目名稱:moodle,代碼行數:29,代碼來源:structure.php


注:本文中的question_bank::qtype_exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。