Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / grade / edit / letter / index.php
blob410471b5b95e55842a48fb5bd7f7d47005229b5f
1 <?php // $Id$
3 ///////////////////////////////////////////////////////////////////////////
4 // //
5 // NOTICE OF COPYRIGHT //
6 // //
7 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
8 // http://moodle.com //
9 // //
10 // Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
11 // //
12 // This program is free software; you can redistribute it and/or modify //
13 // it under the terms of the GNU General Public License as published by //
14 // the Free Software Foundation; either version 2 of the License, or //
15 // (at your option) any later version. //
16 // //
17 // This program is distributed in the hope that it will be useful, //
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20 // GNU General Public License for more details: //
21 // //
22 // http://www.gnu.org/copyleft/gpl.html //
23 // //
24 ///////////////////////////////////////////////////////////////////////////
26 require_once '../../../config.php';
27 require_once $CFG->dirroot.'/grade/lib.php';
28 require_once $CFG->libdir.'/gradelib.php';
30 $courseid = optional_param('id', SITEID, PARAM_INT);
31 $action = optional_param('action', '', PARAM_ALPHA);
33 if (!$course = get_record('course', 'id', $courseid)) {
34 print_error('nocourseid');
36 require_login($course);
37 $context = get_context_instance(CONTEXT_COURSE, $course->id);
39 if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:manageletters', $context)) {
40 error('Missing permission to view letter grades');
43 $gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'letter', 'courseid'=>$courseid));
45 $strgrades = get_string('grades');
46 $pagename = get_string('letters', 'grades');
48 $navigation = grade_build_nav(__FILE__, $pagename, $courseid);
50 /// Print header
51 print_header_simple($strgrades.': '.$pagename, ': '.$strgrades, $navigation, '', '', true, '', navmenu($course));
52 /// Print the plugin selector at the top
53 print_grade_plugin_selector($courseid, 'edit', 'letter');
55 $currenttab = 'lettersview';
56 require('tabs.php');
58 $letters = grade_get_letters($context);
60 $data = array();
62 $max = 100;
63 foreach($letters as $boundary=>$letter) {
64 $line = array();
65 $line[] = format_float($max,2).' %';
66 $line[] = format_float($boundary,2).' %';
67 $line[] = format_string($letter);
68 $data[] = $line;
69 $max = $boundary - 0.01;
72 $table = new object();
73 $table->head = array(get_string('max', 'grades'), get_string('min', 'grades'), get_string('letter', 'grades'));
74 $table->size = array('30%', '30%', '40%');
75 $table->align = array('left', 'left', 'left');
76 $table->width = '30%';
77 $table->data = $data;
78 print_table($table);
80 print_footer($course);