weekly release 4.5dev
[moodle.git] / grade / grading / renderer.php
blob55227660357159d8ab961108a5d442de569a759a
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Renderer for core_grading subsystem
20 * @package core_grading
21 * @copyright 2011 David Mudrak <david@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
27 /**
28 * Standard HTML output renderer for core_grading subsystem
30 * @package core_grading
31 * @copyright 2011 David Mudrak <david@moodle.com>
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33 * @category grading
35 class core_grading_renderer extends plugin_renderer_base {
37 /**
38 * Renders the active method selector at the grading method management screen
40 * @param grading_manager $manager
41 * @param moodle_url $targeturl
42 * @return string
44 public function management_method_selector(grading_manager $manager, moodle_url $targeturl) {
46 $method = $manager->get_active_method();
47 $methods = $manager->get_available_methods(false);
48 $methods['none'] = get_string('gradingmethodnone', 'core_grading');
49 $selector = new single_select(new moodle_url($targeturl, array('sesskey' => sesskey())),
50 'setmethod', $methods, empty($method) ? 'none' : $method, null, 'activemethodselector');
51 $selector->set_label(get_string('changeactivemethod', 'core_grading'));
52 $selector->set_help_icon('gradingmethod', 'core_grading');
54 return $this->output->render($selector);
57 /**
58 * Renders an action icon at the gradng method management screen
60 * @param moodle_url $url action URL
61 * @param string $text action text
62 * @param string $icon the name of the icon to use
63 * @return string
65 public function management_action_icon(moodle_url $url, $text, $icon) {
67 $img = $this->output->pix_icon($icon, '');
68 $txt = html_writer::tag('div', $text, array('class' => 'action-text'));
69 return html_writer::link($url, $img . $txt, array('class' => 'action btn btn-lg'));
72 /**
73 * Renders a message for the user, typically as an action result
75 * @param string $message
76 * @return string
78 public function management_message($message) {
79 $this->page->requires->strings_for_js(array('clicktoclose'), 'core_grading');
80 $this->page->requires->yui_module('moodle-core_grading-manage', 'M.core_grading.init_manage');
81 return $this->output->box(format_string($message) . ' - ' . html_writer::tag('span', ''), 'message',
82 'actionresultmessagebox');
85 /**
86 * Renders the template action icon
88 * @param moodle_url $url action URL
89 * @param string $text action text
90 * @param string $icon the name of the icon to use
91 * @param string $class extra class of this action
92 * @return string
94 public function pick_action_icon(moodle_url $url, $text, $icon = '', $class = '') {
96 $img = $this->output->pix_icon($icon, '');
97 $txt = html_writer::tag('div', $text, array('class' => 'action-text'));
98 return html_writer::link($url, $img . $txt, array('class' => 'action '.$class));