"MDL-16597, show a hand cursor file menu"
[moodle.git] / grade / edit / letter / index.php
CommitLineData
e060e33d 1<?php
284abb09 2
e060e33d 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/>.
8ad36f4c 17
1c1f64a2 18/**
19 * List of grade letters.
20 *
21 * @package moodlecore
22 * @copyright 2008 Nicolas Connault
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
284abb09 26require_once '../../../config.php';
27require_once $CFG->dirroot.'/grade/lib.php';
28require_once $CFG->libdir.'/gradelib.php';
29
30$courseid = optional_param('id', SITEID, PARAM_INT);
31$action = optional_param('action', '', PARAM_ALPHA);
32
a6855934 33$PAGE->set_url('/grade/edit/letter/index.php', array('id' => $courseid));
1c1f64a2 34
d24832f9 35if (!$course = $DB->get_record('course', array('id' => $courseid))) {
284abb09 36 print_error('nocourseid');
37}
1c1f64a2 38
76780d88 39require_login($course);
9376f5a6 40
76780d88 41$context = get_context_instance(CONTEXT_COURSE, $course->id);
9376f5a6 42if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:manageletters', $context)) {
c7a4be5e 43 print_error('nopermissiontoviewletergrade');
9376f5a6 44}
284abb09 45
46$gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'letter', 'courseid'=>$courseid));
47
48$strgrades = get_string('grades');
49$pagename = get_string('letters', 'grades');
50
dc482cfa 51print_grade_page_head($courseid, 'letter', 'view', get_string('gradeletters', 'grades'));
284abb09 52
53$letters = grade_get_letters($context);
54
55$data = array();
56
57$max = 100;
58foreach($letters as $boundary=>$letter) {
59 $line = array();
60 $line[] = format_float($max,2).' %';
61 $line[] = format_float($boundary,2).' %';
62 $line[] = format_string($letter);
63 $data[] = $line;
64 $max = $boundary - 0.01;
65}
66
03fcc729 67$table = new html_table();
284abb09 68$table->head = array(get_string('max', 'grades'), get_string('min', 'grades'), get_string('letter', 'grades'));
69$table->size = array('30%', '30%', '40%');
70$table->align = array('left', 'left', 'left');
71$table->width = '30%';
72$table->data = $data;
1c1f64a2 73$table->tablealign = 'center';
16be8974 74echo html_writer::table($table);
284abb09 75
6c3ef410 76echo $OUTPUT->footer();