MDL-30998: updated docblocks for backup of advanced grading
[moodle.git] / grade / grading / renderer.php
CommitLineData
6832a102
DM
1<?php
2
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.
14//
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/>.
17
18/**
19 * Renderer for core_grading subsystem
20 *
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
25 */
26
27defined('MOODLE_INTERNAL') || die();
28
29/**
30 * Standard HTML output renderer for core_grading subsystem
31 */
32class core_grading_renderer extends plugin_renderer_base {
33
34 /**
35 * Renders the active method selector at the grading method management screen
36 *
37 * @param grading_manager $gradingman
38 * @param moodle_url $targeturl
39 * @return string
40 */
41 public function management_method_selector(grading_manager $manager, moodle_url $targeturl) {
42
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())),
71bd9d20 47 'setmethod', $methods, empty($method) ? 'none' : $method, null, 'activemethodselector');
6832a102
DM
48 $selector->set_label(get_string('changeactivemethod', 'core_grading'));
49 $selector->set_help_icon('gradingmethod', 'core_grading');
50
51 return $this->output->render($selector);
52 }
53
54 /**
55 * Renders an action icon at the gradng method management screen
56 *
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
61 */
62 public function management_action_icon(moodle_url $url, $text, $icon) {
63
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'));
67 }
68
fde33804
DM
69 /**
70 * Renders a message for the user, typically as an action result
71 *
72 * @param string $message
73 * @return string
74 */
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');
79 }
80
6832a102 81 /**
20836db9 82 * Renders the template action icon
6832a102 83 *
20836db9
DM
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
6832a102
DM
88 * @return string
89 */
20836db9 90 public function pick_action_icon(moodle_url $url, $text, $icon = '', $class = '') {
6832a102 91
20836db9
DM
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));
6832a102
DM
95 }
96}