当前位置: 首页>>代码示例>>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;未经允许,请勿转载。