本文整理汇总了PHP中print_question_icon函数的典型用法代码示例。如果您正苦于以下问题:PHP print_question_icon函数的具体用法?PHP print_question_icon怎么用?PHP print_question_icon使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_question_icon函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_content
protected function display_content($question, $rowclasses)
{
$contains = $this->qbank->offlinequiz_contains($question->id);
if ($contains) {
echo '<span class="greyed">';
}
echo print_question_icon($question);
if ($contains) {
echo '</span>';
}
}
示例2: quiz_question_tostring
/**
* Creates a textual representation of a question for display.
*
* @param object $question A question object from the database questions table
* @param bool $showicon If true, show the question's icon with the question. False by default.
* @param bool $showquestiontext If true (default), show question text after question name.
* If false, show only question name.
* @param bool $return If true (default), return the output. If false, print it.
*/
function quiz_question_tostring($question, $showicon = false,
$showquestiontext = true, $return = true) {
global $COURSE;
$result = '';
$result .= '<span class="questionname">';
if ($showicon) {
$result .= print_question_icon($question, true);
echo ' ';
}
$result .= shorten_text(format_string($question->name), 200) . '</span>';
if ($showquestiontext) {
$formatoptions = new stdClass();
$formatoptions->noclean = true;
$formatoptions->para = false;
$questiontext = strip_tags(format_text($question->questiontext,
$question->questiontextformat,
$formatoptions, $COURSE->id));
$questiontext = shorten_text($questiontext, 200);
$result .= '<span class="questiontext">';
if (!empty($questiontext)) {
$result .= $questiontext;
} else {
$result .= '<span class="error">';
$result .= get_string('questiontextisempty', 'quiz');
$result .= '</span>';
}
$result .= '</span>';
}
if ($return) {
return $result;
} else {
echo $result;
}
}
示例3: display
//.........这里部分代码省略.........
$table->column_class('rpercent', 'numcol');
$table->column_class('facility', 'numcol');
$table->column_class('qsd', 'numcol');
$table->column_class('disc_index', 'numcol');
$table->column_class('disc_coeff', 'numcol');
$table->column_suppress('id');
$table->column_suppress('qname');
$table->column_suppress('facility');
$table->column_suppress('qsd');
$table->column_suppress('disc_index');
$table->column_suppress('disc_coeff');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'itemanalysis');
$table->set_attribute('class', 'generaltable generalbox');
// Start working -- this is necessary as soon as the niceties are over
$table->setup();
$tablesort = $table->get_sql_sort();
$sorts = explode(",", trim($tablesort));
if ($tablesort and is_array($sorts)) {
$sortindex = array();
$sortorder = array();
foreach ($sorts as $sort) {
$data = explode(" ", trim($sort));
$sortindex[] = trim($data[0]);
$s = trim($data[1]);
if ($s == "ASC") {
$sortorder[] = SORT_ASC;
} else {
$sortorder[] = SORT_DESC;
}
}
if (count($sortindex) > 0) {
$sortindex[] = "id";
$sortorder[] = SORT_ASC;
foreach ($questions as $qid => $row) {
$index1[$qid] = $row[$sortindex[0]];
$index2[$qid] = $row[$sortindex[1]];
}
array_multisort($index1, $sortorder[0], $index2, $sortorder[1], $questions);
}
}
$format_options = new stdClass();
$format_options->para = false;
$format_options->noclean = true;
$format_options->newlines = false;
// Now it is time to page the data, simply slice the keys in the array
if (!isset($pagesize) || (int) $pagesize < 1) {
$pagesize = 10;
}
$table->pagesize($pagesize, count($questions));
$start = $table->get_page_start();
$pagequestions = array_slice(array_keys($questions), $start, $pagesize);
foreach ($pagequestions as $qnum) {
$q = $questions[$qnum];
$qid = $q['id'];
$question = get_record('question', 'id', $qid);
if (has_capability('moodle/question:manage', get_context_instance(CONTEXT_COURSE, $course->id))) {
$qnumber = " (" . link_to_popup_window('/question/question.php?id=' . $qid, '&cmid=' . $cm->id . 'editquestion', $qid, 450, 550, get_string('edit'), 'none', true) . ") ";
} else {
$qnumber = $qid;
}
$qname = '<div class="qname">' . format_text($question->name . " : ", $question->questiontextformat, $format_options, $quiz->course) . '</div>';
$qicon = print_question_icon($question, true);
$qreview = quiz_question_preview_button($quiz, $question);
$qtext = format_text($question->questiontext, $question->questiontextformat, $format_options, $quiz->course);
$qquestion = $qname . "\n" . $qtext . "\n";
$responses = array();
foreach ($q['responses'] as $aid => $resp) {
$response = new stdClass();
if ($q['credits'][$aid] <= 0) {
$qclass = 'uncorrect';
} elseif ($q['credits'][$aid] == 1) {
$qclass = 'correct';
} else {
$qclass = 'partialcorrect';
}
$response->credit = '<span class="' . $qclass . '">(' . format_float($q['credits'][$aid], 2) . ') </span>';
$response->text = '<span class="' . $qclass . '">' . format_text($resp, FORMAT_MOODLE, $format_options, $quiz->course) . ' </span>';
$count = $q['rcounts'][$aid] . '/' . $q['count'];
$response->rcount = $count;
$response->rpercent = '(' . format_float($q['rcounts'][$aid] / $q['count'] * 100, 0) . '%)';
$responses[] = $response;
}
$facility = format_float($q['facility'] * 100, 0) . "%";
$qsd = format_float($q['qsd'], 3);
$di = format_float($q['disc_index'], 2);
$dc = format_float($q['disc_coeff'], 2);
$response = array_shift($responses);
$table->add_data(array($qnumber . "\n<br />" . $qicon . "\n " . $qreview, $qquestion, $response->text, $response->credit, $response->rcount, $response->rpercent, $facility, $qsd, $di, $dc));
foreach ($responses as $response) {
$table->add_data(array('', '', $response->text, $response->credit, $response->rcount, $response->rpercent, '', '', '', ''));
}
}
print_heading_with_help(get_string("analysistitle", "quiz_analysis"), "itemanalysis", "quiz");
echo '<div id="tablecontainer">';
$table->print_html();
echo '</div>';
$this->print_options_form($quiz, $cm, $attemptselection, $lowmarklimit, $pagesize);
return true;
}
示例4: question_list
//.........这里部分代码省略.........
$orderselect = choose_from_menu($sortoptions, 'sortorder', $sortorder, false, 'this.form.submit();', '0', true);
$orderselect .= '<noscript><div><input type="submit" value="' . get_string("sortsubmit", "quiz") . '" /></div></noscript>';
echo "<th style=\"white-space:nowrap; text-align: left;\" class=\"header\" scope=\"col\">{$strquestionname} {$orderselect}</th>\n <th style=\"white-space:nowrap; text-align: right;\" class=\"header\" scope=\"col\">{$strtype}</th>";
echo "</tr>\n";
foreach ($questions as $question) {
$nameclass = '';
$textclass = '';
if ($question->hidden) {
$nameclass = 'dimmed_text';
$textclass = 'dimmed_text';
}
if ($showquestiontext) {
$nameclass .= ' header';
}
if ($nameclass) {
$nameclass = 'class="' . $nameclass . '"';
}
if ($textclass) {
$textclass = 'class="' . $textclass . '"';
}
echo "<tr>\n<td style=\"white-space:nowrap;\" {$nameclass}>\n";
// add to quiz
if ($editingquiz) {
echo "<a title=\"{$straddtoquiz}\" href=\"edit.php?addquestion={$question->id}&quizid={$quizid}&sesskey={$USER->sesskey}\"><img\n src=\"{$CFG->pixpath}/t/moveleft.gif\" alt=\"{$straddtoquiz}\" /></a> ";
}
// preview
link_to_popup_window('/question/preview.php?id=' . $question->id . '&quizid=' . $quizid, 'questionpreview', "<img src=\"{$CFG->pixpath}/t/preview.gif\" class=\"iconsmall\" alt=\"{$strpreview}\" />", 0, 0, $strpreview, QUESTION_PREVIEW_POPUP_OPTIONS);
// edit, hide, delete question, using question capabilities, not quiz capabilieies
if ($canedit) {
echo "<a title=\"{$stredit}\" href=\"{$CFG->wwwroot}/question/question.php?id={$question->id}\"><img\n src=\"{$CFG->pixpath}/t/edit.gif\" alt=\"{$stredit}\" /></a> ";
// hide-feature
if ($question->hidden) {
echo "<a title=\"{$strrestore}\" href=\"edit.php?courseid={$course->id}&unhide={$question->id}&sesskey={$USER->sesskey}\"><img\n src=\"{$CFG->pixpath}/t/restore.gif\" alt=\"{$strrestore}\" /></a>";
} else {
echo "<a title=\"{$strdelete}\" href=\"edit.php?courseid={$course->id}&deleteselected={$question->id}&q{$question->id}=1\"><img\n src=\"{$CFG->pixpath}/t/delete.gif\" alt=\"{$strdelete}\" /></a>";
}
}
echo " <input title=\"{$strselect}\" type=\"checkbox\" name=\"q{$question->id}\" value=\"1\" />";
echo "</td>\n";
echo "<td {$nameclass}>" . format_string($question->name) . "</td>\n";
echo "<td {$nameclass} style='text-align: right'>\n";
print_question_icon($question);
echo "</td>\n";
echo "</tr>\n";
if ($showquestiontext) {
echo '<tr><td colspan="3" ' . $textclass . '>';
$formatoptions = new stdClass();
$formatoptions->noclean = true;
$formatoptions->para = false;
echo format_text($question->questiontext, $question->questiontextformat, $formatoptions, $course->id);
echo "</td></tr>\n";
}
}
echo "</table>\n";
$paging = print_paging_bar($totalnumber, $page, $perpage, "edit.php?courseid={$course->id}&perpage={$perpage}&", 'page', false, true);
if ($totalnumber > DEFAULT_QUESTIONS_PER_PAGE) {
if ($perpage == DEFAULT_QUESTIONS_PER_PAGE) {
$showall = '<a href="edit.php?courseid=' . $course->id . '&perpage=1000">' . get_string('showall', 'moodle', $totalnumber) . '</a>';
} else {
$showall = '<a href="edit.php?courseid=' . $course->id . '&perpage=' . DEFAULT_QUESTIONS_PER_PAGE . '">' . get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE) . '</a>';
}
if ($paging) {
$paging = substr($paging, 0, strrpos($paging, '</div>'));
$paging .= "<br />{$showall}</div>";
} else {
$paging = "<div class='paging'>{$showall}</div>";
}
}
echo $paging;
echo '<table class="quiz-edit-selected"><tr><td colspan="2">';
echo '<a href="javascript:select_all_in(\'TABLE\',null,\'categoryquestions\');">' . $strselectall . '</a> /' . ' <a href="javascript:deselect_all_in(\'TABLE\',null,\'categoryquestions\');">' . $strselectnone . '</a>' . '</td><td align="right"><b> ' . get_string('withselected', 'quiz') . ':</b></td></tr><tr><td>';
if ($editingquiz) {
echo "<input type=\"submit\" name=\"add\" value=\"{$THEME->larrow} {$straddtoquiz}\" />\n";
echo '</td><td>';
}
// print delete and move selected question
if ($canedit) {
echo '<input type="submit" name="deleteselected" value="' . $strdelete . "\" /></td><td>\n";
echo '<input type="submit" name="move" value="' . get_string('moveto', 'quiz') . "\" />\n";
question_category_select_menu($course->id, false, true, $category->id);
}
echo "</td></tr></table>";
// add random question
if ($editingquiz) {
for ($i = 1; $i <= min(10, $totalnumber); $i++) {
$randomcount[$i] = $i;
}
for ($i = 20; $i <= min(100, $totalnumber); $i += 10) {
$randomcount[$i] = $i;
}
echo '<br />';
print_string('addrandom', 'quiz', choose_from_menu($randomcount, 'randomcount', '1', '', '', '', true));
echo '<input type="hidden" name="recurse" value="' . $recurse . '" />';
echo "<input type=\"hidden\" name=\"categoryid\" value=\"{$category->id}\" />";
echo ' <input type="submit" name="addrandom" value="' . get_string('add') . '" />';
helpbutton('random', get_string('random', 'quiz'), 'quiz');
}
echo '</fieldset>';
echo "</form>\n";
}
示例5: flexible_table
$table = new flexible_table('qtypeadmintable');
$table->define_baseurl($thispageurl);
$table->define_columns(array('questiontype', 'numquestions', 'version', 'requires', 'availableto', 'delete', 'settings'));
$table->define_headers(array(get_string('questiontype', 'question'), get_string('numquestions', 'question'), get_string('version'), get_string('requires', 'admin'), get_string('availableq', 'question'), get_string('delete'), get_string('settings')));
$table->set_attribute('id', 'qtypes');
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
$table->setup();
// Add a row for each question type.
$createabletypes = question_bank::get_creatable_qtypes();
foreach ($sortedqtypes as $qtypename => $localname) {
$qtype = $qtypes[$qtypename];
$row = array();
// Question icon and name.
$fakequestion = new stdClass();
$fakequestion->qtype = $qtypename;
$icon = print_question_icon($fakequestion, true);
$row[] = $icon . ' ' . $localname;
// Number of questions of this type.
if ($counts[$qtypename]->numquestions + $counts[$qtypename]->numhidden > 0) {
if ($counts[$qtypename]->numhidden > 0) {
$strcount = get_string('numquestionsandhidden', 'question', $counts[$qtypename]);
} else {
$strcount = $counts[$qtypename]->numquestions;
}
if ($canviewreports) {
$row[] = html_writer::link(new moodle_url('/report/questioninstances/index.php', array('qtype' => $qtypename)), $strcount, array('title' => get_string('showdetails', 'admin')));
} else {
$strcount;
}
} else {
$row[] = 0;
示例6: question_list
//.........这里部分代码省略.........
$textclass = '';
if ($question->hidden) {
$nameclass = 'dimmed_text';
$textclass = 'dimmed_text';
}
if ($showquestiontext) {
$nameclass .= ' header';
}
if ($question->id == $lastchangedid) {
$nameclass = 'highlight';
}
if ($nameclass) {
$nameclass = 'class="' . $nameclass . '"';
}
if ($textclass) {
$textclass = 'class="' . $textclass . '"';
}
echo "<tr>\n<td style=\"white-space:nowrap;\" {$nameclass}>\n";
$canuseq = question_has_capability_on($question, 'use', $question->category);
if (function_exists('module_specific_actions')) {
echo module_specific_actions($pageurl, $question->id, $cm->id, $canuseq);
}
// preview
if ($canuseq) {
$quizorcourseid = $quizid ? '&quizid=' . $quizid : '&courseid=' . $COURSE->id;
link_to_popup_window('/question/preview.php?id=' . $question->id . $quizorcourseid, 'questionpreview', "<img src=\"{$CFG->pixpath}/t/preview.gif\" class=\"iconsmall\" alt=\"{$strpreview}\" />", 0, 0, $strpreview, QUESTION_PREVIEW_POPUP_OPTIONS);
}
// edit, hide, delete question, using question capabilities, not quiz capabilieies
if (question_has_capability_on($question, 'edit', $question->category) || question_has_capability_on($question, 'move', $question->category)) {
echo "<a title=\"{$stredit}\" href=\"" . $questionurl->out(false, array('id' => $question->id)) . "\"><img\n src=\"{$CFG->pixpath}/t/edit.gif\" alt=\"{$stredit}\" /></a> ";
} elseif (question_has_capability_on($question, 'view', $question->category)) {
echo "<a title=\"{$strview}\" href=\"" . $questionurl->out(false, array('id' => $question->id)) . "\"><img\n src=\"{$CFG->pixpath}/i/info.gif\" alt=\"{$strview}\" /></a> ";
}
if (question_has_capability_on($question, 'move', $question->category) && question_has_capability_on($question, 'view', $question->category)) {
echo "<a title=\"{$strmove}\" href=\"" . $questionurl->out(false, array('id' => $question->id, 'movecontext' => 1)) . "\"><img\n src=\"{$CFG->pixpath}/t/move.gif\" alt=\"{$strmove}\" /></a> ";
}
if (question_has_capability_on($question, 'edit', $question->category)) {
// hide-feature
if ($question->hidden) {
echo "<a title=\"{$strrestore}\" href=\"edit.php?" . $pageurl->get_query_string() . "&unhide={$question->id}&sesskey={$USER->sesskey}\"><img\n src=\"{$CFG->pixpath}/t/restore.gif\" alt=\"{$strrestore}\" /></a>";
} else {
echo "<a title=\"{$strdelete}\" href=\"edit.php?" . $pageurl->get_query_string() . "&deleteselected={$question->id}&q{$question->id}=1\"><img\n src=\"{$CFG->pixpath}/t/delete.gif\" alt=\"{$strdelete}\" /></a>";
}
}
if ($caneditall || $canmoveall || $canuseall) {
echo " <input title=\"{$strselect}\" type=\"checkbox\" name=\"q{$question->id}\" value=\"1\" />";
}
echo "</td>\n";
echo "<td {$nameclass}>" . format_string($question->name) . "</td>\n";
echo "<td {$nameclass} style='text-align: right'>\n";
print_question_icon($question);
echo "</td>\n";
echo "</tr>\n";
if ($showquestiontext) {
echo '<tr><td colspan="3" ' . $textclass . '>';
$formatoptions = new stdClass();
$formatoptions->noclean = true;
$formatoptions->para = false;
echo format_text($question->questiontext, $question->questiontextformat, $formatoptions, $COURSE->id);
echo "</td></tr>\n";
}
}
echo "</table>\n";
$paging = print_paging_bar($totalnumber, $page, $perpage, $pageurl, 'qpage', false, true);
if ($totalnumber > DEFAULT_QUESTIONS_PER_PAGE) {
if ($perpage == DEFAULT_QUESTIONS_PER_PAGE) {
$showall = '<a href="edit.php?' . $pageurl->get_query_string(array('qperpage' => 1000)) . '">' . get_string('showall', 'moodle', $totalnumber) . '</a>';
} else {
$showall = '<a href="edit.php?' . $pageurl->get_query_string(array('qperpage' => DEFAULT_QUESTIONS_PER_PAGE)) . '">' . get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE) . '</a>';
}
if ($paging) {
$paging = substr($paging, 0, strrpos($paging, '</div>'));
$paging .= "<br />{$showall}</div>";
} else {
$paging = "<div class='paging'>{$showall}</div>";
}
}
echo $paging;
if ($caneditall || $canmoveall || $canuseall) {
echo '<a href="javascript:select_all_in(\'TABLE\',null,\'categoryquestions\');">' . $strselectall . '</a> /' . ' <a href="javascript:deselect_all_in(\'TABLE\',null,\'categoryquestions\');">' . $strselectnone . '</a>';
echo '<br />';
echo '<strong> ' . get_string('withselected', 'quiz') . ':</strong><br />';
if (function_exists('module_specific_buttons')) {
echo module_specific_buttons($cm->id);
}
// print delete and move selected question
if ($caneditall) {
echo '<input type="submit" name="deleteselected" value="' . $strdelete . "\" />\n";
}
if ($canmoveall && count($addcontexts)) {
echo '<input type="submit" name="move" value="' . get_string('moveto', 'quiz') . "\" />\n";
question_category_select_menu($addcontexts, false, 0, "{$category->id},{$category->contextid}");
}
if (function_exists('module_specific_controls') && $canuseall) {
echo module_specific_controls($totalnumber, $recurse, $category, $cm->id);
}
}
echo '</fieldset>';
echo "</form>\n";
}
示例7: col_icon
function col_icon($question){
return print_question_icon($question, true);
}
示例8: col_icon
/**
* The question type icon.
* @param object $question containst the data to display.
* @return string contents of this table cell.
*/
protected function col_icon($question)
{
if (property_exists($question, 'qtype') && $question->qtype) {
return print_question_icon($question, true);
} else {
return '';
}
}
示例9: col_icon
/**
* The question type icon.
* @param \core_question\statistics\questions\calculated $questionstat stats for the question.
* @return string contents of this table cell.
*/
protected function col_icon($questionstat)
{
return print_question_icon($questionstat->question, true);
}
示例10: display_content
protected function display_content($question, $rowclasses) {
echo print_question_icon($question);
}
示例11: display_question_block
/**
* sets up what is displayed for each question on the edit quiz question listing
*
* @param \mod_activequiz\activequiz_question $question
* @param int $qnum The question number we're currently on
* @param int $qcount The total number of questions
*
* @return string
*/
protected function display_question_block($question, $qnum, $qcount)
{
$return = '';
$dragicon = new pix_icon('i/dragdrop', 'dragdrop');
$return .= html_writer::div($this->output->render($dragicon), 'dragquestion');
$return .= html_writer::div(print_question_icon($question->getQuestion()), 'icon');
$namehtml = html_writer::start_tag('p');
$namehtml .= $question->getQuestion()->name . '<br />';
$namehtml .= get_string('points', 'activequiz') . ': ' . $question->getPoints();
$namehtml .= html_writer::end_tag('p');
$return .= html_writer::div($namehtml, 'name');
$controlHTML = '';
$spacericon = new pix_icon('spacer', 'space', null, array('class' => 'smallicon space'));
$controlHTML .= html_writer::start_tag('noscript');
if ($qnum > 1) {
// if we're on a later question than the first one add the move up control
$moveupurl = clone $this->pageurl;
$moveupurl->param('action', 'moveup');
$moveupurl->param('questionid', $question->getId());
// add the rtqqid so that the question manager handles the translation
$alt = get_string('questionmoveup', 'mod_activequiz', $qnum);
$upicon = new pix_icon('t/up', $alt);
$controlHTML .= html_writer::link($moveupurl, $this->output->render($upicon));
} else {
$controlHTML .= $this->output->render($spacericon);
}
if ($qnum < $qcount) {
// if we're not on the last question add the move down control
$movedownurl = clone $this->pageurl;
$movedownurl->param('action', 'movedown');
$movedownurl->param('questionid', $question->getId());
$alt = get_string('questionmovedown', 'mod_activequiz', $qnum);
$downicon = new pix_icon('t/down', $alt);
$controlHTML .= html_writer::link($movedownurl, $this->output->render($downicon));
} else {
$controlHTML .= $this->output->render($spacericon);
}
$controlHTML .= html_writer::end_tag('noscript');
// always add edit and delete icons
$editurl = clone $this->pageurl;
$editurl->param('action', 'editquestion');
$editurl->param('rtqquestionid', $question->getId());
$alt = get_string('questionedit', 'activequiz', $qnum);
$deleteicon = new pix_icon('t/edit', $alt);
$controlHTML .= html_writer::link($editurl, $this->output->render($deleteicon));
$deleteurl = clone $this->pageurl;
$deleteurl->param('action', 'deletequestion');
$deleteurl->param('questionid', $question->getId());
$alt = get_string('questiondelete', 'mod_activequiz', $qnum);
$deleteicon = new pix_icon('t/delete', $alt);
$controlHTML .= html_writer::link($deleteurl, $this->output->render($deleteicon));
$return .= html_writer::div($controlHTML, 'controls');
return $return;
}
示例12: quiz_question_tostring
/**
* Creates a textual representation of a question for display.
*
* @param object $question A question object from the database questions table
* @param bool $showicon If true, show the question's icon with the question. False by default.
* @param bool $showquestiontext If true (default), show question text after question name.
* If false, show only question name.
* @return string
*/
function quiz_question_tostring($question, $showicon = false, $showquestiontext = true)
{
$result = '';
$name = shorten_text(format_string($question->name), 200);
if ($showicon) {
$name .= print_question_icon($question) . ' ' . $name;
}
$result .= html_writer::span($name, 'questionname');
if ($showquestiontext) {
$questiontext = question_utils::to_plain_text($question->questiontext, $question->questiontextformat, array('noclean' => true, 'para' => false));
$questiontext = shorten_text($questiontext, 200);
if ($questiontext) {
$result .= ' ' . html_writer::span(s($questiontext), 'questiontext');
}
}
return $result;
}
示例13: quiz_question_tostring
/**
* Creates a textual representation of a question for display.
*
* @param object $question A question object from the database questions table
* @param bool $showicon If true, show the question's icon with the question. False by default.
* @param bool $showquestiontext If true (default), show question text after question name.
* If false, show only question name.
* @param bool $return If true (default), return the output. If false, print it.
*/
function quiz_question_tostring($question, $showicon = false, $showquestiontext = true, $return = true)
{
global $COURSE;
$result = '';
$result .= '<span class="questionname">';
if ($showicon) {
$result .= print_question_icon($question, true);
echo ' ';
}
$result .= shorten_text(format_string($question->name), 200) . '</span>';
if ($showquestiontext) {
$questiontext = question_utils::to_plain_text($question->questiontext, $question->questiontextformat, array('noclean' => true, 'para' => false));
$questiontext = shorten_text($questiontext, 200);
$result .= '<span class="questiontext">';
if (!empty($questiontext)) {
$result .= s($questiontext);
} else {
$result .= '<span class="error">';
$result .= get_string('questiontextisempty', 'quiz');
$result .= '</span>';
}
$result .= '</span>';
}
if ($return) {
return $result;
} else {
echo $result;
}
}
示例14: offlinequiz_question_tostring
/**
* Creates a textual representation of a question for display.
*
* @param object $question A question object from the database questions table
* @param bool $showicon If true, show the question's icon with the question. False by default.
* @param bool $showquestiontext If true (default), show question text after question name.
* If false, show only question name.
* @param bool $return If true (default), return the output. If false, print it.
*/
function offlinequiz_question_tostring($question, $showicon = false, $showquestiontext = true, $return = true, $shorttitle = false)
{
global $COURSE;
$result = '';
$formatoptions = new stdClass();
$formatoptions->noclean = true;
$formatoptions->para = false;
$questiontext = strip_tags(question_utils::to_plain_text($question->questiontext, $question->questiontextformat, array('noclean' => true, 'para' => false)));
$questiontitle = strip_tags(format_text($question->name, $question->questiontextformat, $formatoptions, $COURSE->id));
$result .= '<span class="questionname" title="' . $questiontitle . '">';
if ($shorttitle && strlen($questiontitle) > 25) {
$questiontitle = shorten_text($questiontitle, 25, false, '...');
}
if ($showicon) {
$result .= print_question_icon($question, true);
echo ' ';
}
if ($shorttitle) {
$result .= $questiontitle;
} else {
$result .= shorten_text(format_string($question->name), 200) . '</span>';
}
if ($showquestiontext) {
$result .= '<span class="questiontext" title="' . $questiontext . '">';
$questiontext = shorten_text($questiontext, 200);
if (!empty($questiontext)) {
$result .= $questiontext;
} else {
$result .= '<span class="error">';
$result .= get_string('questiontextisempty', 'offlinequiz');
$result .= '</span>';
}
$result .= '</span>';
}
if ($return) {
return $result;
} else {
echo $result;
}
}