/** * Creates HTML code for a question preview button. * * @param object $offlinequiz the offlinequiz 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 offlinequiz_question_preview_button($offlinequiz, $question, $label = false) { global $CFG, $OUTPUT; if (property_exists($question, 'category') && !question_has_capability_on($question, 'use', $question->category)) { return ''; } $url = offlinequiz_question_preview_url($offlinequiz, $question); // Do we want a label? $strpreviewlabel = ''; if ($label) { $strpreviewlabel = get_string('preview', 'offlinequiz'); } // Build the icon. $strpreviewquestion = get_string('previewquestion', 'offlinequiz'); $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)); }
public function preview_question_url($question) { return offlinequiz_question_preview_url($this->offlinequiz, $question); }
/** * Render the preview icon. * * @param \stdClass $offlinequiz the offlinequiz settings from the database. * @param \stdClass $question data from the question and offlinequiz_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($offlinequiz, $question, $label = null) { $url = offlinequiz_question_preview_url($offlinequiz, $question); // Do we want a label? $strpreviewlabel = ''; if ($label) { $strpreviewlabel = ' ' . get_string('preview', 'offlinequiz'); } // Build the icon. $strpreviewquestion = get_string('previewquestion', 'offlinequiz'); $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')); }