/** * Render an icon, optionally with the word 'Preview' beside it, to preview * a given question. * @param int $questionid the id of the question to be previewed. * @param context $context the context in which the preview is happening. * Must be a course or category context. * @param bool $showlabel if true, show the word 'Preview' after the icon. * If false, just show the icon. */ public function question_preview_link($questionid, context $context, $showlabel) { if ($showlabel) { $alt = ''; $label = ' ' . get_string('preview'); $attributes = array(); } else { $alt = get_string('preview'); $label = ''; $attributes = array('title' => $alt); } $image = $this->pix_icon('t/preview', $alt, '', array('class' => 'iconsmall')); $link = question_preview_url($questionid, null, null, null, null, $context); $action = new popup_action('click', $link, 'questionpreview', question_preview_popup_params()); return $this->action_link($link, $image . $label, $action, $attributes); }
protected function display_content($question, $rowclasses) { global $OUTPUT; if (question_has_capability_on($question, 'use')) { // Build the icon. $image = $OUTPUT->pix_icon('t/preview', $this->strpreview, '', array('class' => 'iconsmall')); $link = $this->qbank->preview_question_url($question); $action = new popup_action('click', $link, 'questionpreview', question_preview_popup_params()); echo $OUTPUT->action_link($link, $image, $action, array('title' => $this->strpreview)); } }
/** * @param object $quiz the quiz settings * @param object $question the question * @param bool $label if true, show the preview question label after the icon * @return the HTML for a preview question icon. */ function quiz_question_preview_button($quiz, $question, $label = false) { global $CFG, $OUTPUT; if (!question_has_capability_on($question, 'use', $question->category)) { return ''; } $url = quiz_question_preview_url($quiz, $question); // Do we want a label? $strpreviewlabel = ''; if ($label) { $strpreviewlabel = get_string('preview', 'quiz'); } // Build the icon. $strpreviewquestion = get_string('previewquestion', 'quiz'); $image = $OUTPUT->pix_icon('t/preview', $strpreviewquestion); $action = new popup_action('click', $url, 'questionpreview', question_preview_popup_params()); return $OUTPUT->action_link($url, $image, $action, array('title' => $strpreviewquestion)); }
/** * Render the preview icon. * * @param \stdClass $quiz the quiz settings from the database. * @param \stdClass $question data from the question and quiz_slots tables. * @param bool $label if true, show the preview question label after the icon * @return string HTML to output. */ public function question_preview_icon($quiz, $question, $label = null) { $url = quiz_question_preview_url($quiz, $question); // Do we want a label? $strpreviewlabel = ''; if ($label) { $strpreviewlabel = ' ' . get_string('preview', 'quiz'); } // Build the icon. $strpreviewquestion = get_string('previewquestion', 'quiz'); $image = $this->pix_icon('t/preview', $strpreviewquestion); $action = new \popup_action('click', $url, 'questionpreview', question_preview_popup_params()); return $this->action_link($url, $image . $strpreviewlabel, $action, array('title' => $strpreviewquestion, 'class' => 'preview')); }