Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'MDL-30069_21' of git://github.com/timhunt/moodle into M…

…OODLE_21_STABLE
  • Loading branch information...
commit 1e7732cec6654056a06764077d7ef4fa77326c27 2 parents 372d9df + 195a8b7
@stronk7 stronk7 authored
View
12 lib/questionlib.php
@@ -825,16 +825,8 @@ function get_question_options(&$questions, $loadtags = false) {
* @return string the HTML for the img tag.
*/
function print_question_icon($question) {
- global $OUTPUT;
-
- $qtype = question_bank::get_qtype($question->qtype, false);
- $namestr = $qtype->menu_name();
-
- // TODO convert to return a moodle_icon object, or whatever the class is.
- $html = '<img src="' . $OUTPUT->pix_url('icon', $qtype->plugin_name()) . '" alt="' .
- $namestr . '" title="' . $namestr . '" />';
-
- return $html;
+ global $PAGE;
+ return $PAGE->get_renderer('question', 'bank')->qtype_icon($question->qtype);
}
/**
View
8 mod/quiz/editlib.php
@@ -781,7 +781,7 @@ function quiz_print_singlequestion($question, $returnurl, $quiz) {
echo quiz_question_edit_button($quiz->cmid, $question, $returnurl,
quiz_question_tostring($question) . ' ');
echo '<span class="questiontype">';
- print_question_icon($question);
+ 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>';
@@ -807,7 +807,7 @@ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktoo
}
echo '<div class="randomquestionfromcategory">';
- print_question_icon($question);
+ echo print_question_icon($question);
print_random_option_icon($question);
echo ' ' . get_string('randomfromcategory', 'quiz') . '</div>';
@@ -886,7 +886,7 @@ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktoo
function quiz_print_singlequestion_reordertool($question, $returnurl, $quiz) {
echo '<div class="singlequestion">';
echo '<label for="s' . $question->id . '">';
- print_question_icon($question);
+ echo print_question_icon($question);
echo ' ' . quiz_question_tostring($question);
echo '</label>';
echo '<span class="questionpreview">' .
@@ -920,7 +920,7 @@ function quiz_print_randomquestion_reordertool(&$question, &$pageurl, &$quiz) {
echo '<div class="quiz_randomquestion">';
echo '<div class="randomquestionfromcategory">';
echo $reordercheckboxlabel;
- print_question_icon($question);
+ echo print_question_icon($question);
print_random_option_icon($question);
if ($questioncount == 0) {
View
2  question/editlib.php
@@ -1787,7 +1787,7 @@ function print_qtype_to_add_option($qtype) {
echo '<span class="qtypename">';
$fakequestion = new stdClass();
$fakequestion->qtype = $qtype->name();
- print_question_icon($fakequestion);
+ echo print_question_icon($fakequestion);
echo $qtype->menu_name() . '</span><span class="qtypesummary">' .
get_string($qtype->name() . 'summary', 'qtype_' . $qtype->name());
echo "</span></label>\n";
View
49 question/renderer.php
@@ -0,0 +1,49 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Renderers for outputting parts of the question bank.
+ *
+ * @package moodlecore
+ * @subpackage questionbank
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+
+/**
+ * This renderer outputs parts of the question bank.
+ *
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class core_question_bank_renderer extends plugin_renderer_base {
+
+ /**
+ * Output the icon for a question type
+ * @param string $qtype the question type.
+ * @return string HTML fragment.
+ */
+ public function qtype_icon($qtype) {
+ $qtype = question_bank::get_qtype($qtype, false);
+ $namestr = $qtype->local_name();
+
+ return $this->pix_icon('icon', $namestr, $qtype->plugin_name(), array('title' => $namestr));
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.