Initial support for the grading management screen
[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())),
47 'activemethod', $methods, empty($method) ? 'none' : $method, null, 'activemethodselector');
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
69 /**
70 * Renders the common information about the form definition
71 *
72 * @param gradingform_controller $controller
73 * @return string
74 */
75 public function preview_definition_header(gradingform_controller $controller) {
76
77 $definition = $controller->get_definition();
78 // todo make this nicer, append the information about the time created/modified etc
79 return $this->output->heading(format_text($definition->name));
80 }
81}