Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'brokencalc_23' of git://github.com/andyjdavis/moodle in…

…to MOODLE_23_STABLE
  • Loading branch information...
commit 6d28ff14f09d927bc74c51852f0f9b611661adf7 2 parents 70d7e35 + abd110f
@danpoltawski danpoltawski authored
View
10 grade/export/lib.php
@@ -406,3 +406,13 @@ public function close() {
}
}
+/**
+ * Verify that there is a valid set of grades to export.
+ * @param $courseid int The course being exported
+ */
+function export_verify_grades($courseid) {
+ $regraderesult = grade_regrade_final_grades($courseid);
+ if (is_array($regraderesult)) {
+ throw new moodle_exception('gradecantregrade', 'error', '', implode(',', $regraderesult));
+ }
+}
View
1  grade/export/ods/index.php
@@ -34,6 +34,7 @@
require_capability('gradeexport/ods:view', $context);
print_grade_page_head($COURSE->id, 'export', 'ods', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_ods'));
+export_verify_grades($COURSE->id);
if (!empty($CFG->gradepublishing)) {
$CFG->gradepublishing = has_capability('gradeexport/ods:publish', $context);
View
1  grade/export/txt/index.php
@@ -34,6 +34,7 @@
require_capability('gradeexport/txt:view', $context);
print_grade_page_head($COURSE->id, 'export', 'txt', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_txt'));
+export_verify_grades($COURSE->id);
if (!empty($CFG->gradepublishing)) {
$CFG->gradepublishing = has_capability('gradeexport/txt:publish', $context);
View
1  grade/export/xls/index.php
@@ -34,6 +34,7 @@
require_capability('gradeexport/xls:view', $context);
print_grade_page_head($COURSE->id, 'export', 'xls', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_xls'));
+export_verify_grades($COURSE->id);
if (!empty($CFG->gradepublishing)) {
$CFG->gradepublishing = has_capability('gradeexport/xls:publish', $context);
View
1  grade/export/xml/index.php
@@ -34,6 +34,7 @@
require_capability('gradeexport/xml:view', $context);
print_grade_page_head($COURSE->id, 'export', 'xml', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_xml'));
+export_verify_grades($COURSE->id);
if (!empty($CFG->gradepublishing)) {
$CFG->gradepublishing = has_capability('gradeexport/xml:publish', $context);
View
5 grade/lib.php
@@ -123,7 +123,10 @@ public function init() {
$this->close();
- grade_regrade_final_grades($this->course->id);
+ $regraderesult = grade_regrade_final_grades($this->course->id);
+ if (is_array($regraderesult)) {
+ throw new moodle_exception('gradecantregrade', 'error', '', implode(',', $regraderesult));
+ }
$course_item = grade_item::fetch_course_item($this->course->id);
if ($course_item->needsupdate) {
// can not calculate all final grades - sorry
View
1  lang/en/error.php
@@ -238,6 +238,7 @@
$string['forumblockingtoomanyposts'] = 'You have exceeded the posting threshold set for this forum';
$string['generalexceptionmessage'] = 'Exception - {$a}';
$string['gradepubdisable'] = 'Grade publishing disabled';
+$string['gradecantregrade'] = 'An error occurred during grade calculation: {$a}';
$string['groupalready'] = 'User already belongs to group {$a}';
$string['groupexistforcourse'] = 'Group "{$a}" already exists for this course';
$string['groupexistforcoursewithidnumber'] = '{$a->problemgroup}: Group "{$a->name}" with an idnumber of "{$a->idnumber}" already exists for this course';
View
1  lang/en/grades.php
@@ -172,6 +172,7 @@
$string['encoding'] = 'Encoding';
$string['errorcalculationnoequal'] = 'Formula must start with equal sign (=1+2)';
$string['errorcalculationunknown'] = 'Invalid formula';
+$string['errorcalculationbroken'] = 'Probably circular reference or broken calculation formula';
$string['errorgradevaluenonnumeric'] = 'Received non-numeric for low or high grade for';
$string['errornocalculationallowed'] = 'Calculations are not allowed for this item';
$string['errornocategorisedid'] = 'Could not get an uncategorised id!';
View
4 lib/gradelib.php
@@ -1097,9 +1097,9 @@ function grade_regrade_final_grades($courseid, $userid=null, $updated_item=null)
continue; // this one is ok
}
$grade_items[$gid]->force_regrading();
- $errors[$grade_items[$gid]->id] = 'Probably circular reference or broken calculation formula'; // TODO: localize
+ $errors[$grade_items[$gid]->id] = get_string('errorcalculationbroken', 'grades');
}
- break; // oki, found error
+ break; // Found error.
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.