MDL-19404 Getting default values for grade_item object when creating a new grade_cate...
[moodle.git] / grade / edit / letter / index.php
CommitLineData
284abb09 1<?php // $Id$
2
8ad36f4c 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///////////////////////////////////////////////////////////////////////////
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
d24832f9 33if (!$course = $DB->get_record('course', array('id' => $courseid))) {
284abb09 34 print_error('nocourseid');
35}
36require_login($course);
37$context = get_context_instance(CONTEXT_COURSE, $course->id);
9376f5a6 38
39if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:manageletters', $context)) {
c7a4be5e 40 print_error('nopermissiontoviewletergrade');
9376f5a6 41}
284abb09 42
43$gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'letter', 'courseid'=>$courseid));
44
45$strgrades = get_string('grades');
46$pagename = get_string('letters', 'grades');
47
dc482cfa 48print_grade_page_head($courseid, 'letter', 'view', get_string('gradeletters', 'grades'));
284abb09 49
50$letters = grade_get_letters($context);
51
52$data = array();
53
54$max = 100;
55foreach($letters as $boundary=>$letter) {
56 $line = array();
57 $line[] = format_float($max,2).' %';
58 $line[] = format_float($boundary,2).' %';
59 $line[] = format_string($letter);
60 $data[] = $line;
61 $max = $boundary - 0.01;
62}
63
64$table = new object();
65$table->head = array(get_string('max', 'grades'), get_string('min', 'grades'), get_string('letter', 'grades'));
66$table->size = array('30%', '30%', '40%');
67$table->align = array('left', 'left', 'left');
68$table->width = '30%';
69$table->data = $data;
70print_table($table);
71
72print_footer($course);
73
74?>