本文整理汇总了PHP中question_bank::get_qtype_name方法的典型用法代码示例。如果您正苦于以下问题:PHP question_bank::get_qtype_name方法的具体用法?PHP question_bank::get_qtype_name怎么用?PHP question_bank::get_qtype_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_bank
的用法示例。
在下文中一共展示了question_bank::get_qtype_name方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: col_qtype
/**
* The question type name.
* @param object $question containst the data to display.
* @return string contents of this table cell.
*/
protected function col_qtype($question)
{
if (property_exists($question, 'qtype') && $question->qtype) {
return question_bank::get_qtype_name($question->qtype);
} else {
return '';
}
}
示例2: quiz_print_singlequestion
/**
* Print a given single question in quiz for the edit tab of edit.php.
* Meant to be used from quiz_print_question_list()
*
* @param object $question A question object from the database questions table
* @param object $returnurl The url to get back to this page, for example after editing.
* @param object $quiz The quiz in the context of which the question is being displayed
*/
function quiz_print_singlequestion($question, $returnurl, $quiz) {
echo '<div class="singlequestion ' . $question->qtype . '">';
echo quiz_question_edit_button($quiz->cmid, $question, $returnurl,
quiz_question_tostring($question) . ' ');
echo '<span class="questiontype">';
echo print_question_icon($question);
echo ' ' . question_bank::get_qtype_name($question->qtype) . '</span>';
echo '<span class="questionpreview">' .
quiz_question_preview_button($quiz, $question, true) . '</span>';
echo "</div>\n";
}
示例3: col_qtype
/**
* The question type name.
*
* @param \core_question\statistics\questions\calculated $questionstat stats for the question.
* @return string contents of this table cell.
*/
protected function col_qtype($questionstat)
{
return question_bank::get_qtype_name($questionstat->question->qtype);
}
示例4: validation
public function validation($data, $files) {
$errors = parent::validation($data, $files);
$questiondisplay = qtype_multianswer_extract_question($data['questiontext']);
if (isset($questiondisplay->options->questions)) {
$subquestions = fullclone($questiondisplay->options->questions);
if (count($subquestions)) {
$sub = 1;
foreach ($subquestions as $subquestion) {
$prefix = 'sub_'.$sub.'_';
$answercount = 0;
$maxgrade = false;
$maxfraction = -1;
if (isset($this->savedquestiondisplay->options->questions[$sub]->qtype) &&
$this->savedquestiondisplay->options->questions[$sub]->qtype !=
$questiondisplay->options->questions[$sub]->qtype) {
$storemess = " STORED QTYPE ".question_bank::get_qtype_name(
$this->savedquestiondisplay->options->questions[$sub]->qtype);
}
foreach ($subquestion->answer as $key => $answer) {
if (is_array($answer)) {
$answer = $answer['text'];
}
$trimmedanswer = trim($answer);
if ($trimmedanswer !== '') {
$answercount++;
if ($subquestion->qtype == 'numerical' &&
!(is_numeric($trimmedanswer) || $trimmedanswer == '*')) {
$errors[$prefix.'answer['.$key.']'] =
get_string('answermustbenumberorstar', 'qtype_numerical');
}
if ($subquestion->fraction[$key] == 1) {
$maxgrade = true;
}
if ($subquestion->fraction[$key] > $maxfraction) {
$maxfraction = $subquestion->fraction[$key];
}
}
}
if ($answercount == 0) {
if ($subquestion->qtype == 'multichoice') {
$errors[$prefix.'answer[0]'] =
get_string('notenoughanswers', 'qtype_multichoice', 2);
} else {
$errors[$prefix.'answer[0]'] =
get_string('notenoughanswers', 'question', 1);
}
}
if ($maxgrade == false) {
$errors[$prefix.'fraction[0]'] =
get_string('fractionsnomax', 'question');
}
$sub++;
}
} else {
$errors['questiontext'] = get_string('questionsmissing', 'qtype_multianswer');
}
}
if (($this->negative_diff > 0 || $this->used_in_quiz &&
($this->negative_diff > 0 || $this->negative_diff < 0 ||
$this->qtype_change))&& $this->confirm == 0) {
$errors['confirm'] =
get_string('confirmsave', 'qtype_multianswer', $this->negative_diff);
}
return $errors;
}
示例5: definition_inner
protected function definition_inner($mform)
{
$mform->addElement('hidden', 'reload', 1);
$mform->setType('reload', PARAM_INT);
// Remove meaningless defaultmark field.
$mform->removeElement('defaultmark');
$this->confirm = optional_param('confirm', false, PARAM_BOOL);
// Display the questions from questiontext.
if ($questiontext = optional_param_array('questiontext', false, PARAM_RAW)) {
$this->questiondisplay = fullclone(qtype_multianswer_extract_question($questiontext));
} else {
if (!$this->reload && !empty($this->savedquestiondisplay->id)) {
// Use database data as this is first pass
// question->id == 0 so no stored datasets.
$this->questiondisplay = fullclone($this->savedquestiondisplay);
foreach ($this->questiondisplay->options->questions as $subquestion) {
if (!empty($subquestion)) {
$subquestion->answer = array('');
foreach ($subquestion->options->answers as $ans) {
$subquestion->answer[] = $ans->answer;
}
}
}
} else {
$this->questiondisplay = "";
}
}
if (isset($this->savedquestiondisplay->options->questions) && is_array($this->savedquestiondisplay->options->questions)) {
$countsavedsubquestions = 0;
foreach ($this->savedquestiondisplay->options->questions as $subquestion) {
if (!empty($subquestion)) {
$countsavedsubquestions++;
}
}
} else {
$countsavedsubquestions = 0;
}
if ($this->reload) {
if (isset($this->questiondisplay->options->questions) && is_array($this->questiondisplay->options->questions)) {
$countsubquestions = 0;
foreach ($this->questiondisplay->options->questions as $subquestion) {
if (!empty($subquestion)) {
$countsubquestions++;
}
}
} else {
$countsubquestions = 0;
}
} else {
$countsubquestions = $countsavedsubquestions;
}
$mform->addElement('submit', 'analyzequestion', get_string('decodeverifyquestiontext', 'qtype_multianswer'));
$mform->registerNoSubmitButton('analyzequestion');
if ($this->reload) {
for ($sub = 1; $sub <= $countsubquestions; $sub++) {
if (isset($this->questiondisplay->options->questions[$sub]->qtype)) {
$this->editas[$sub] = $this->questiondisplay->options->questions[$sub]->qtype;
} else {
$this->editas[$sub] = optional_param('sub_' . $sub . '_qtype', 'unknown type', PARAM_PLUGIN);
}
$storemess = '';
if (isset($this->savedquestiondisplay->options->questions[$sub]->qtype) && $this->savedquestiondisplay->options->questions[$sub]->qtype != $this->questiondisplay->options->questions[$sub]->qtype) {
$this->qtypechange = true;
$storemess = ' ' . html_writer::tag('span', get_string('storedqtype', 'qtype_multianswer', question_bank::get_qtype_name($this->savedquestiondisplay->options->questions[$sub]->qtype)), array('class' => 'error'));
}
$mform->addElement('header', 'subhdr' . $sub, get_string('questionno', 'question', '{#' . $sub . '}') . ' ' . question_bank::get_qtype_name($this->questiondisplay->options->questions[$sub]->qtype) . $storemess);
$mform->addElement('static', 'sub_' . $sub . '_questiontext', get_string('questiondefinition', 'qtype_multianswer'));
if (isset($this->questiondisplay->options->questions[$sub]->questiontext)) {
$mform->setDefault('sub_' . $sub . '_questiontext', $this->questiondisplay->options->questions[$sub]->questiontext['text']);
}
$mform->addElement('static', 'sub_' . $sub . '_defaultmark', get_string('defaultmark', 'question'));
$mform->setDefault('sub_' . $sub . '_defaultmark', $this->questiondisplay->options->questions[$sub]->defaultmark);
if ($this->questiondisplay->options->questions[$sub]->qtype == 'shortanswer') {
$mform->addElement('static', 'sub_' . $sub . '_usecase', get_string('casesensitive', 'qtype_shortanswer'));
}
if ($this->questiondisplay->options->questions[$sub]->qtype == 'multichoice') {
$mform->addElement('static', 'sub_' . $sub . '_layout', get_string('layout', 'qtype_multianswer'));
$mform->addElement('static', 'sub_' . $sub . '_shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'));
}
foreach ($this->questiondisplay->options->questions[$sub]->answer as $key => $ans) {
$mform->addElement('static', 'sub_' . $sub . '_answer[' . $key . ']', get_string('answer', 'question'));
if ($this->questiondisplay->options->questions[$sub]->qtype == 'numerical' && $key == 0) {
$mform->addElement('static', 'sub_' . $sub . '_tolerance[' . $key . ']', get_string('acceptederror', 'qtype_numerical'));
}
$mform->addElement('static', 'sub_' . $sub . '_fraction[' . $key . ']', get_string('grade'));
$mform->addElement('static', 'sub_' . $sub . '_feedback[' . $key . ']', get_string('feedback', 'question'));
}
}
$this->negativediff = $countsavedsubquestions - $countsubquestions;
if ($this->negativediff > 0 || $this->qtypechange || $this->usedinquiz && $this->negativediff != 0) {
$mform->addElement('header', 'additemhdr', get_string('warningquestionmodified', 'qtype_multianswer'));
}
if ($this->negativediff > 0) {
$mform->addElement('static', 'alert1', "<strong>" . get_string('questiondeleted', 'qtype_multianswer') . "</strong>", get_string('questionsless', 'qtype_multianswer', $this->negativediff));
}
if ($this->qtypechange) {
$mform->addElement('static', 'alert1', "<strong>" . get_string('questiontypechanged', 'qtype_multianswer') . "</strong>", get_string('questiontypechangedcomment', 'qtype_multianswer'));
}
}
if ($this->usedinquiz) {
//.........这里部分代码省略.........
示例6: writequestion
//.........这里部分代码省略.........
$expout .= $this->write_name($question->name);
$expout .= $this->write_questiontext($question->questiontext, $question->questiontextformat);
$expout .= "{}\n";
break;
case TRUEFALSE:
$trueanswer = $question->options->answers[$question->options->trueanswer];
$falseanswer = $question->options->answers[$question->options->falseanswer];
if ($trueanswer->fraction == 1) {
$answertext = 'TRUE';
$rightfeedback = $this->write_questiontext($trueanswer->feedback, $trueanswer->feedbackformat, $question->questiontextformat);
$wrongfeedback = $this->write_questiontext($falseanswer->feedback, $falseanswer->feedbackformat, $question->questiontextformat);
} else {
$answertext = 'FALSE';
$rightfeedback = $this->write_questiontext($falseanswer->feedback, $falseanswer->feedbackformat, $question->questiontextformat);
$wrongfeedback = $this->write_questiontext($trueanswer->feedback, $trueanswer->feedbackformat, $question->questiontextformat);
}
$expout .= $this->write_name($question->name);
$expout .= $this->write_questiontext($question->questiontext, $question->questiontextformat);
$expout .= '{' . $this->repchar($answertext);
if ($wrongfeedback) {
$expout .= '#' . $wrongfeedback;
} else {
if ($rightfeedback) {
$expout .= '#';
}
}
if ($rightfeedback) {
$expout .= '#' . $rightfeedback;
}
$expout .= "}\n";
break;
case MULTICHOICE:
$expout .= $this->write_name($question->name);
$expout .= $this->write_questiontext($question->questiontext, $question->questiontextformat);
$expout .= "{\n";
foreach ($question->options->answers as $answer) {
if ($answer->fraction == 1) {
$answertext = '=';
} else {
if ($answer->fraction == 0) {
$answertext = '~';
} else {
$weight = $answer->fraction * 100;
$answertext = '~%' . $weight . '%';
}
}
$expout .= "\t" . $answertext . $this->write_questiontext($answer->answer, $answer->answerformat, $question->questiontextformat);
if ($answer->feedback != '') {
$expout .= '#' . $this->write_questiontext($answer->feedback, $answer->feedbackformat, $question->questiontextformat);
}
$expout .= "\n";
}
$expout .= "}\n";
break;
case SHORTANSWER:
$expout .= $this->write_name($question->name);
$expout .= $this->write_questiontext($question->questiontext, $question->questiontextformat);
$expout .= "{\n";
foreach ($question->options->answers as $answer) {
$weight = 100 * $answer->fraction;
$expout .= "\t=%" . $weight . '%' . $this->repchar($answer->answer) . '#' . $this->write_questiontext($answer->feedback, $answer->feedbackformat, $question->questiontextformat) . "\n";
}
$expout .= "}\n";
break;
case NUMERICAL:
$expout .= $this->write_name($question->name);
$expout .= $this->write_questiontext($question->questiontext, $question->questiontextformat);
$expout .= "{#\n";
foreach ($question->options->answers as $answer) {
if ($answer->answer != '' && $answer->answer != '*') {
$weight = 100 * $answer->fraction;
$expout .= "\t=%" . $weight . '%' . $answer->answer . ':' . (double) $answer->tolerance . '#' . $this->write_questiontext($answer->feedback, $answer->feedbackformat, $question->questiontextformat) . "\n";
} else {
$expout .= "\t~#" . $this->write_questiontext($answer->feedback, $answer->feedbackformat, $question->questiontextformat) . "\n";
}
}
$expout .= "}\n";
break;
case MATCH:
$expout .= $this->write_name($question->name);
$expout .= $this->write_questiontext($question->questiontext, $question->questiontextformat);
$expout .= "{\n";
foreach ($question->options->subquestions as $subquestion) {
$expout .= "\t=" . $this->write_questiontext($subquestion->questiontext, $subquestion->questiontextformat, $question->questiontextformat) . ' -> ' . $this->repchar($subquestion->answertext) . "\n";
}
$expout .= "}\n";
break;
default:
// Check for plugins
if ($out = $this->try_exporting_using_qtypes($question->qtype, $question)) {
$expout .= $out;
} else {
$expout .= "Question type {$question->qtype} is not supported\n";
echo $OUTPUT->notification(get_string('nohandler', 'qformat_gift', question_bank::get_qtype_name($question->qtype)));
}
}
// Add empty line to delimit questions
$expout .= "\n";
return $expout;
}
示例7: writequestion
//.........这里部分代码省略.........
$expout .= $this->write_questiontext($question->questiontext, $question->questiontextformat);
$expout .= '{' . $this->repchar($answertext);
if ($wrongfeedback) {
$expout .= '#' . $wrongfeedback;
} else if ($rightfeedback) {
$expout .= '#';
}
if ($rightfeedback) {
$expout .= '#' . $rightfeedback;
}
$expout .= $this->write_general_feedback($question, '');
$expout .= "}\n";
break;
case 'multichoice':
$expout .= $this->write_name($question->name);
$expout .= $this->write_questiontext($question->questiontext, $question->questiontextformat);
$expout .= "{\n";
foreach($question->options->answers as $answer) {
if ($answer->fraction == 1) {
$answertext = '=';
} else if ($answer->fraction == 0) {
$answertext = '~';
} else {
$weight = $answer->fraction * 100;
$answertext = '~%' . $weight . '%';
}
$expout .= "\t" . $answertext . $this->write_questiontext($answer->answer,
$answer->answerformat, $question->questiontextformat);
if ($answer->feedback != '') {
$expout .= '#' . $this->write_questiontext($answer->feedback,
$answer->feedbackformat, $question->questiontextformat);
}
$expout .= "\n";
}
$expout .= $this->write_general_feedback($question);
$expout .= "}\n";
break;
case 'shortanswer':
$expout .= $this->write_name($question->name);
$expout .= $this->write_questiontext($question->questiontext, $question->questiontextformat);
$expout .= "{\n";
foreach($question->options->answers as $answer) {
$weight = 100 * $answer->fraction;
$expout .= "\t=%" . $weight . '%' . $this->repchar($answer->answer) .
'#' . $this->write_questiontext($answer->feedback,
$answer->feedbackformat, $question->questiontextformat) . "\n";
}
$expout .= $this->write_general_feedback($question);
$expout .= "}\n";
break;
case 'numerical':
$expout .= $this->write_name($question->name);
$expout .= $this->write_questiontext($question->questiontext, $question->questiontextformat);
$expout .= "{#\n";
foreach ($question->options->answers as $answer) {
if ($answer->answer != '' && $answer->answer != '*') {
$weight = 100 * $answer->fraction;
$expout .= "\t=%" . $weight . '%' . $answer->answer . ':' .
(float)$answer->tolerance . '#' . $this->write_questiontext($answer->feedback,
$answer->feedbackformat, $question->questiontextformat) . "\n";
} else {
$expout .= "\t~#" . $this->write_questiontext($answer->feedback,
$answer->feedbackformat, $question->questiontextformat) . "\n";
}
}
$expout .= $this->write_general_feedback($question);
$expout .= "}\n";
break;
case 'match':
$expout .= $this->write_name($question->name);
$expout .= $this->write_questiontext($question->questiontext, $question->questiontextformat);
$expout .= "{\n";
foreach($question->options->subquestions as $subquestion) {
$expout .= "\t=" . $this->write_questiontext($subquestion->questiontext,
$subquestion->questiontextformat, $question->questiontextformat) .
' -> ' . $this->repchar($subquestion->answertext) . "\n";
}
$expout .= $this->write_general_feedback($question);
$expout .= "}\n";
break;
default:
// Check for plugins
if ($out = $this->try_exporting_using_qtypes($question->qtype, $question)) {
$expout .= $out;
} else {
$expout .= "Question type $question->qtype is not supported\n";
echo $OUTPUT->notification(get_string('nohandler', 'qformat_gift',
question_bank::get_qtype_name($question->qtype)));
}
}
// Add empty line to delimit questions
$expout .= "\n";
return $expout;
}