Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Revert "MDL-32076 core_grade: fixed ajax handling of unlimited grades…

… and added some unit tests"

This reverts commit 88df34a.
  • Loading branch information...
commit efd779c2c6fed7cda4d6e634b6a0b2407e3e24ae 1 parent 5389bd9
Dan Poltawski danpoltawski authored
11 grade/report/grader/ajax_callbacks.php
@@ -81,13 +81,10 @@
81 81 // Warn if the grade is out of bounds.
82 82 if (is_null($finalgrade)) {
83 83 // ok
84   - } else {
85   - $bounded = $grade_item->bounded_grade($finalgrade);
86   - if ($bounded > $finalgrade) {
87   - $errorstr = 'lessthanmin';
88   - } else if ($bounded < $finalgrade) {
89   - $errorstr = 'morethanmax';
90   - }
  84 + } else if ($finalgrade < $grade_item->grademin) {
  85 + $errorstr = 'lessthanmin';
  86 + } else if ($finalgrade > $grade_item->grademax) {
  87 + $errorstr = 'morethanmax';
91 88 }
92 89
93 90 if ($errorstr) {
2  grade/report/grader/lib.php
@@ -256,7 +256,7 @@ public function process_data($data) {
256 256 } else {
257 257 $bounded = $gradeitem->bounded_grade($finalgrade);
258 258 if ($bounded > $finalgrade) {
259   - $errorstr = 'lessthanmin';
  259 + $errorstr = 'lessthanmin';
260 260 } else if ($bounded < $finalgrade) {
261 261 $errorstr = 'morethanmax';
262 262 }
115 grade/tests/reportgrader_test.php
... ... @@ -1,115 +0,0 @@
1   -<?php
2   -// This file is part of Moodle - http://moodle.org/
3   -//
4   -// Moodle is free software: you can redistribute it and/or modify
5   -// it under the terms of the GNU General Public License as published by
6   -// the Free Software Foundation, either version 3 of the License, or
7   -// (at your option) any later version.
8   -//
9   -// Moodle is distributed in the hope that it will be useful,
10   -// but WITHOUT ANY WARRANTY; without even the implied warranty of
11   -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   -// GNU General Public License for more details.
13   -//
14   -// You should have received a copy of the GNU General Public License
15   -// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16   -
17   -/**
18   - * Unit tests for grade/report/user/lib.php.
19   - *
20   - * @package core_grade
21   - * @category phpunit
22   - * @copyright 2012 Andrew Davis
23   - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
24   - */
25   -
26   -defined('MOODLE_INTERNAL') || die();
27   -
28   -global $CFG;
29   -require_once($CFG->dirroot.'/grade/lib.php');
30   -require_once($CFG->dirroot.'/grade/report/grader/lib.php');
31   -
32   -/**
33   - * Tests grade_report_grader (the grader report)
34   - */
35   -class grade_report_graderlib_testcase extends advanced_testcase {
36   -
37   - /**
38   - * Tests grade_report_grader::process_data()
39   - *
40   - * process_data() processes submitted grade and feedback data
41   - */
42   - public function test_process_data() {
43   - global $DB, $CFG;
44   -
45   - $this->resetAfterTest(true);
46   -
47   - $course = $this->getDataGenerator()->create_course();
48   - $coursecontext = context_course::instance($course->id);
49   -
50   - // Create and enrol a student.
51   - $student = $this->getDataGenerator()->create_user(array('username' => 'Student Sam'));
52   - $role = $DB->get_record('role', array('shortname' => 'student'), '*', MUST_EXIST);
53   - $this->getDataGenerator()->enrol_user($student->id, $course->id, $role->id);
54   -
55   - // Test with limited grades.
56   - $CFG->unlimitedgrades = 0;
57   -
58   - $forummax = 80;
59   - $forum1 = $this->getDataGenerator()->create_module('forum', array('assessed' => 1, 'scale' => $forummax, 'course' => $course->id));
60   - // Switch the stdClass instance for a grade item instance.
61   - $forum1 = grade_item::fetch(array('itemtype' => 'mod', 'itemmodule' => 'forum', 'iteminstance' => $forum1->id, 'courseid' => $course->id));
62   -
63   - $report = $this->create_report($course, $coursecontext);
64   - $testgrade = 60.00;
65   -
66   - $data = new stdClass();
67   - $data->id = $course->id;
68   - $data->report = 'grader';
69   -
70   - $fieldname = 'grade_'.$student->id.'_'.$forum1->id;
71   - $data->$fieldname = $testgrade;
72   -
73   - $warnings = $report->process_data($data);
74   - $this->assertEquals(count($warnings), 0);
75   -
76   - $studentgrade = grade_grade::fetch(array('itemid' => $forum1->id, '' => $student->id));
77   - $this->assertEquals($studentgrade->finalgrade, $testgrade);
78   -
79   - // Grade above max. Should be pulled down to max.
80   - $toobig = 200.00;
81   - $data->$fieldname = $toobig;
82   - $warnings = $report->process_data($data);
83   - $this->assertEquals(count($warnings), 1);
84   -
85   - $studentgrade = grade_grade::fetch(array('itemid' => $forum1->id, '' => $student->id));
86   - $this->assertEquals($studentgrade->finalgrade, $forummax);
87   -
88   - // Grade below min. Should be pulled up to min.
89   - $toosmall = -10.00;
90   - $data->$fieldname = $toosmall;
91   - $warnings = $report->process_data($data);
92   - $this->assertEquals(count($warnings), 1);
93   -
94   - $studentgrade = grade_grade::fetch(array('itemid' => $forum1->id, '' => $student->id));
95   - $this->assertEquals($studentgrade->finalgrade, 0);
96   -
97   - // Test unlimited grades so we can give a student a grade about max.
98   - $CFG->unlimitedgrades = 1;
99   -
100   - $data->$fieldname = $toobig;
101   - $warnings = $report->process_data($data);
102   - $this->assertEquals(count($warnings), 0);
103   -
104   - $studentgrade = grade_grade::fetch(array('itemid' => $forum1->id, '' => $student->id));
105   - $this->assertEquals($studentgrade->finalgrade, $toobig);
106   - }
107   -
108   - private function create_report($course, $coursecontext) {
109   -
110   - $gpr = new grade_plugin_return(array('type' => 'report', 'plugin'=>'grader', 'courseid' => $course->id));
111   - $report = new grade_report_grader($course->id, $gpr, $coursecontext);
112   -
113   - return $report;
114   - }
115   -}

0 comments on commit efd779c

Please sign in to comment.
Something went wrong with that request. Please try again.