MDL-30998: updated docblocks for advanced grading
[moodle.git] / grade / grading / renderer.php
... / ...
CommitLineData
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.
13//
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/>.
16
17/**
18 * Renderer for core_grading subsystem
19 *
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
23 */
24
25defined('MOODLE_INTERNAL') || die();
26
27/**
28 * Standard HTML output renderer for core_grading subsystem
29 *
30 * @copyright 2011 David Mudrak <david@moodle.com>
31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32 * @category grading
33 */
34class core_grading_renderer extends plugin_renderer_base {
35
36 /**
37 * Renders the active method selector at the grading method management screen
38 *
39 * @param grading_manager $manager
40 * @param moodle_url $targeturl
41 * @return string
42 */
43 public function management_method_selector(grading_manager $manager, moodle_url $targeturl) {
44
45 $method = $manager->get_active_method();
46 $methods = $manager->get_available_methods(false);
47 $methods['none'] = get_string('gradingmethodnone', 'core_grading');
48 $selector = new single_select(new moodle_url($targeturl, array('sesskey' => sesskey())),
49 'setmethod', $methods, empty($method) ? 'none' : $method, null, 'activemethodselector');
50 $selector->set_label(get_string('changeactivemethod', 'core_grading'));
51 $selector->set_help_icon('gradingmethod', 'core_grading');
52
53 return $this->output->render($selector);
54 }
55
56 /**
57 * Renders an action icon at the gradng method management screen
58 *
59 * @param moodle_url $url action URL
60 * @param string $text action text
61 * @param string $icon the name of the icon to use
62 * @return string
63 */
64 public function management_action_icon(moodle_url $url, $text, $icon) {
65
66 $img = html_writer::empty_tag('img', array('src' => $this->output->pix_url($icon), 'class' => 'action-icon'));
67 $txt = html_writer::tag('div', $text, array('class' => 'action-text'));
68 return html_writer::link($url, $img . $txt, array('class' => 'action'));
69 }
70
71 /**
72 * Renders a message for the user, typically as an action result
73 *
74 * @param string $message
75 * @return string
76 */
77 public function management_message($message) {
78 $this->page->requires->strings_for_js(array('clicktoclose'), 'core_grading');
79 $this->page->requires->yui_module('moodle-core_grading-manage', 'M.core_grading.init_manage');
80 return $this->output->box(format_string($message).html_writer::tag('span', ''), 'message', 'actionresultmessagebox');
81 }
82
83 /**
84 * Renders the template action icon
85 *
86 * @param moodle_url $url action URL
87 * @param string $text action text
88 * @param string $icon the name of the icon to use
89 * @param string $class extra class of this action
90 * @return string
91 */
92 public function pick_action_icon(moodle_url $url, $text, $icon = '', $class = '') {
93
94 $img = html_writer::empty_tag('img', array('src' => $this->output->pix_url($icon), 'class' => 'action-icon'));
95 $txt = html_writer::tag('div', $text, array('class' => 'action-text'));
96 return html_writer::link($url, $img . $txt, array('class' => 'action '.$class));
97 }
98}