protected function display_content($question, $rowclasses) { echo '<div>'; $labelfor = $this->label_for($question); if ($labelfor) { echo '<label for="' . $labelfor . '">'; } echo quiz_question_tostring($question); if ($labelfor) { echo '</label>'; } echo '</div>'; }
public function test_quiz_question_tostring() { $question = new stdClass(); $question->qtype = 'multichoice'; $question->name = 'The question name'; $question->questiontext = '<p>What sort of <b>inequality</b> is x < y<img alt="?" src="..."></p>'; $question->questiontextformat = FORMAT_HTML; $summary = quiz_question_tostring($question); $this->assertEquals('<span class="questionname">The question name</span> ' . '<span class="questiontext">What sort of INEQUALITY is x < y[?]' . "\n" . '</span>', $summary); }
/** * Renders html to display a random question the link to edit the configuration * and also to see that category in the question bank. * * @param structure $structure object containing the structure of the quiz. * @param \stdClass $question data from the question and quiz_slots tables. * @param \moodle_url $pageurl the canonical URL of this page. * @return string HTML to output. */ public function random_question(structure $structure, $question, $pageurl) { $editurl = new \moodle_url('/question/question.php', array('returnurl' => $pageurl->out_as_local_url(), 'cmid' => $structure->get_cmid(), 'id' => $question->id)); $temp = clone $question; $temp->questiontext = ''; $instancename = quiz_question_tostring($temp); $configuretitle = get_string('configurerandomquestion', 'quiz'); $qtype = \question_bank::get_qtype($question->qtype, false); $namestr = $qtype->local_name(); $icon = $this->pix_icon('icon', $namestr, $qtype->plugin_name(), array('title' => $namestr, 'class' => 'icon activityicon', 'alt' => ' ', 'role' => 'presentation')); $editicon = $this->pix_icon('t/edit', $configuretitle, 'moodle', array('title' => '')); // If this is a random question, display a link to show the questions // selected from in the question bank. $qbankurl = new \moodle_url('/question/edit.php', array('cmid' => $structure->get_cmid(), 'cat' => $question->category . ',' . $question->contextid, 'recurse' => !empty($question->questiontext))); $qbanklink = ' ' . \html_writer::link($qbankurl, get_string('seequestions', 'quiz'), array('class' => 'mod_quiz_random_qbank_link')); return html_writer::link($editurl, $icon . $editicon, array('title' => $configuretitle)) . ' ' . $instancename . ' ' . $qbanklink; }