本文整理汇总了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') . ' ' . $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];
示例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;
}