Merge branch 'MDL-33122-master' of git://github.com/ankitagarwal/moodle
[moodle.git] / grade / grading / renderer.php
blob1ab295599d5331115cd0393d2daf64fb7752129c
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * Renderer for core_grading subsystem
21 * @package core
22 * @subpackage grading
23 * @copyright 2011 David Mudrak <david@moodle.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 defined('MOODLE_INTERNAL') || die();
29 /**
30 * Standard HTML output renderer for core_grading subsystem
32 class core_grading_renderer extends plugin_renderer_base {
34 /**
35 * Renders the active method selector at the grading method management screen
37 * @param grading_manager $gradingman
38 * @param moodle_url $targeturl
39 * @return string
41 public function management_method_selector(grading_manager $manager, moodle_url $targeturl) {
43 $method = $manager->get_active_method();
44 $methods = $manager->get_available_methods(false);
45 $methods['none'] = get_string('gradingmethodnone', 'core_grading');
46 $selector = new single_select(new moodle_url($targeturl, array('sesskey' => sesskey())),
47 'setmethod', $methods, empty($method) ? 'none' : $method, null, 'activemethodselector');
48 $selector->set_label(get_string('changeactivemethod', 'core_grading'));
49 $selector->set_help_icon('gradingmethod', 'core_grading');
51 return $this->output->render($selector);
54 /**
55 * Renders an action icon at the gradng method management screen
57 * @param moodle_url $url action URL
58 * @param string $text action text
59 * @param string $icon the name of the icon to use
60 * @return string
62 public function management_action_icon(moodle_url $url, $text, $icon) {
64 $img = html_writer::empty_tag('img', array('src' => $this->output->pix_url($icon), 'class' => 'action-icon'));
65 $txt = html_writer::tag('div', $text, array('class' => 'action-text'));
66 return html_writer::link($url, $img . $txt, array('class' => 'action'));
69 /**
70 * Renders a message for the user, typically as an action result
72 * @param string $message
73 * @return string
75 public function management_message($message) {
76 $this->page->requires->strings_for_js(array('clicktoclose'), 'core_grading');
77 $this->page->requires->yui_module('moodle-core_grading-manage', 'M.core_grading.init_manage');
78 return $this->output->box(format_string($message).html_writer::tag('span', ''), 'message', 'actionresultmessagebox');
81 /**
82 * Renders the template action icon
84 * @param moodle_url $url action URL
85 * @param string $text action text
86 * @param string $icon the name of the icon to use
87 * @param string $class extra class of this action
88 * @return string
90 public function pick_action_icon(moodle_url $url, $text, $icon = '', $class = '') {
92 $img = html_writer::empty_tag('img', array('src' => $this->output->pix_url($icon), 'class' => 'action-icon'));
93 $txt = html_writer::tag('div', $text, array('class' => 'action-text'));
94 return html_writer::link($url, $img . $txt, array('class' => 'action '.$class));