Skip to content

Commit 7ce5df8

Browse files
committed
MDL-27920 gradebook: export was always excluding course totals and xml export was failing
1 parent 70e35c4 commit 7ce5df8

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

grade/export/lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function display_preview($require_user_idnumber=false) {
230230
}
231231
$user = $userdata->user;
232232
if ($require_user_idnumber and empty($user->idnumber)) {
233-
// some exports require user idnumber
233+
// some exports require user idnumber so we can match up students when importing the data
234234
continue;
235235
}
236236

grade/export/xml/grade_export_xml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function print_grades($feedback = false) {
5858
$user = $userdata->user;
5959

6060
if (empty($user->idnumber)) {
61-
//id number must exist
61+
//id number must exist otherwise we cant match up students when importing
6262
continue;
6363
}
6464

grade/export/xml/index.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
$CFG->gradepublishing = has_capability('gradeexport/xml:publish', $context);
4040
}
4141

42+
//'idnumberrequired'=>true excludes grade items that dont have an ID to use during import
4243
$mform = new grade_export_form(null, array('idnumberrequired'=>true, 'publishing'=>true, 'updategradesonly'=>true));
4344

4445
$groupmode = groups_get_course_groupmode($course); // Groups are being used
@@ -56,7 +57,11 @@
5657
// print the grades on screen for feedbacks
5758
$export->process_form($data);
5859
$export->print_continue();
59-
$export->display_preview(true);
60+
61+
$require_user_idnumber = true; //skip users without idnumber as they cannot be identified when importing
62+
$export->display_preview($require_user_idnumber);
63+
echo $OUTPUT->container(get_string('useridnumberwarning','gradeexport_xml'), 'useridnumberwarning mdl-align');
64+
6065
echo $OUTPUT->footer();
6166
exit;
6267
}

grade/export/xml/lang/en/gradeexport_xml.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@
2626
$string['pluginname'] = 'XML file';
2727
$string['xml:publish'] = 'Publish XML grade export';
2828
$string['xml:view'] = 'Use XML grade export';
29+
$string['useridnumberwarning'] = 'User\'s without an ID number are excluded from the XML export as they cannot be imported';

grade/lib.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ function next_user() {
235235
$result->user = $user;
236236
$result->grades = $grades;
237237
$result->feedbacks = $feedbacks;
238-
239238
return $result;
240239
}
241240

@@ -271,7 +270,7 @@ function _push($grade) {
271270
/**
272271
* _pop
273272
*
274-
* @return void
273+
* @return object current grade object
275274
*/
276275
function _pop() {
277276
global $DB;
@@ -280,11 +279,11 @@ function _pop() {
280279
return null; // no grades present
281280
}
282281

283-
if ($this->grades_rs->next()) {
284-
return null; // no more grades
285-
}
282+
$current = $this->grades_rs->current();
283+
284+
$this->grades_rs->next();
286285

287-
return $this->grades_rs->current();
286+
return $current;
288287
} else {
289288
return array_pop($this->gradestack);
290289
}

0 commit comments

Comments
 (0)