Skip to content

Commit

Permalink
MDL-27920 gradebook: export was always excluding course totals and xm…
Browse files Browse the repository at this point in the history
…l export was failing
  • Loading branch information
andyjdavis committed Jun 21, 2011
1 parent 70e35c4 commit 7ce5df8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion grade/export/lib.php
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion grade/export/xml/grade_export_xml.php
Expand Up @@ -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;
}

Expand Down
7 changes: 6 additions & 1 deletion grade/export/xml/index.php
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions grade/export/xml/lang/en/gradeexport_xml.php
Expand Up @@ -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';
11 changes: 5 additions & 6 deletions grade/lib.php
Expand Up @@ -235,7 +235,6 @@ function next_user() {
$result->user = $user;
$result->grades = $grades;
$result->feedbacks = $feedbacks;

return $result;
}

Expand Down Expand Up @@ -271,7 +270,7 @@ function _push($grade) {
/**
* _pop
*
* @return void
* @return object current grade object
*/
function _pop() {
global $DB;
Expand All @@ -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);
}
Expand Down

0 comments on commit 7ce5df8

Please sign in to comment.