Browse files

MDL-27920 gradebook: export was always excluding course totals and xm…

…l export was failing
  • Loading branch information...
1 parent cc50a2f commit 2558ce35931e342767da8c04340cd039a1ddb1f0 @andyjdavis andyjdavis committed Jun 21, 2011
View
2 grade/export/lib.php
@@ -230,7 +230,7 @@ public function display_preview($require_user_idnumber=false) {
}
$user = $userdata->user;
if ($require_user_idnumber and empty($user->idnumber)) {
- // some exports require user idnumber
+ // some exports require user idnumber so we can match up students when importing the data
continue;
}
View
2 grade/export/xml/grade_export_xml.php
@@ -58,7 +58,7 @@ public function print_grades($feedback = false) {
$user = $userdata->user;
if (empty($user->idnumber)) {
- //id number must exist
+ //id number must exist otherwise we cant match up students when importing
continue;
}
View
7 grade/export/xml/index.php
@@ -39,6 +39,7 @@
$CFG->gradepublishing = has_capability('gradeexport/xml:publish', $context);
}
+//'idnumberrequired'=>true excludes grade items that dont have an ID to use during import
$mform = new grade_export_form(null, array('idnumberrequired'=>true, 'publishing'=>true, 'updategradesonly'=>true));
$groupmode = groups_get_course_groupmode($course); // Groups are being used
@@ -56,7 +57,11 @@
// print the grades on screen for feedbacks
$export->process_form($data);
$export->print_continue();
- $export->display_preview(true);
+
+ $require_user_idnumber = true; //skip users without idnumber as they cannot be identified when importing
+ $export->display_preview($require_user_idnumber);
+ echo $OUTPUT->container(get_string('useridnumberwarning','gradeexport_xml'), 'useridnumberwarning mdl-align');
+
echo $OUTPUT->footer();
exit;
}
View
1 grade/export/xml/lang/en/gradeexport_xml.php
@@ -26,3 +26,4 @@
$string['pluginname'] = 'XML file';
$string['xml:publish'] = 'Publish XML grade export';
$string['xml:view'] = 'Use XML grade export';
+$string['useridnumberwarning'] = 'User\'s without an ID number are excluded from the XML export as they cannot be imported';
View
11 grade/lib.php
@@ -235,7 +235,6 @@ function next_user() {
$result->user = $user;
$result->grades = $grades;
$result->feedbacks = $feedbacks;
-
return $result;
}
@@ -271,7 +270,7 @@ function _push($grade) {
/**
* _pop
*
- * @return void
+ * @return object current grade object
*/
function _pop() {
global $DB;
@@ -280,11 +279,11 @@ function _pop() {
return null; // no grades present
}
- if ($this->grades_rs->next()) {
- return null; // no more grades
- }
+ $current = $this->grades_rs->current();
+
+ $this->grades_rs->next();
- return $this->grades_rs->current();
+ return $current;
} else {
return array_pop($this->gradestack);
}

0 comments on commit 2558ce3

Please sign in to comment.