mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-11069 grade export refactoring + removing internally calculated totals (we have already various totals in categories and calculations can be used too for that)
This commit is contained in:
parent
8a275c7242
commit
11745964a5
5 changed files with 92 additions and 139 deletions
|
@ -26,7 +26,6 @@ require_once($CFG->dirroot.'/grade/export/lib.php');
|
|||
|
||||
class grade_export_txt extends grade_export {
|
||||
|
||||
var $format = 'txt'; // export format
|
||||
var $separator = "\t"; // default separator
|
||||
|
||||
function set_separator($separator) {
|
||||
|
@ -41,17 +40,18 @@ class grade_export_txt extends grade_export {
|
|||
* To be implemented by child classes
|
||||
*/
|
||||
function print_grades($feedback = false) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$this->load_grades();
|
||||
|
||||
$retval = '';
|
||||
|
||||
/// Whether this plugin is entitled to update export time
|
||||
if ($expplugins = explode(",", $CFG->gradeexport)) {
|
||||
if (in_array($this->format, $expplugins)) {
|
||||
if (in_array('txt', $expplugins)) {
|
||||
$export = true;
|
||||
} else {
|
||||
$export = false;
|
||||
$export = false;
|
||||
}
|
||||
} else {
|
||||
$export = false;
|
||||
|
@ -79,15 +79,12 @@ class grade_export_txt extends grade_export {
|
|||
$retval .= "{$this->separator}{$column}_feedback";
|
||||
}
|
||||
}
|
||||
$retval .= "{$this->separator}".get_string("total")."\n";
|
||||
|
||||
/// Print all the lines of data.
|
||||
foreach ($this->grades as $studentid => $studentgrades) {
|
||||
|
||||
$student = $this->students[$studentid];
|
||||
if (empty($this->totals[$student->id])) {
|
||||
$this->totals[$student->id] = '';
|
||||
}
|
||||
|
||||
$retval .= "$student->firstname{$this->separator}$student->lastname{$this->separator}$student->idnumber{$this->separator}$student->institution{$this->separator}$student->department{$this->separator}$student->email";
|
||||
|
||||
foreach ($studentgrades as $gradeitemid => $grade) {
|
||||
|
@ -95,13 +92,14 @@ class grade_export_txt extends grade_export {
|
|||
$retval .= "{$this->separator}$grade";
|
||||
|
||||
if ($feedback) {
|
||||
$retval .= "{$this->separator}".array_shift($this->comments[$student->id]);
|
||||
$retval .= "{$this->separator}".$this->comments[$student->id][$gradeitemid];
|
||||
}
|
||||
|
||||
/// if export flag needs to be set
|
||||
/// construct the grade_grade object and update timestamp if CFG flag is set
|
||||
|
||||
if ($export) {
|
||||
//this should be improved with sql
|
||||
$params = new object();
|
||||
$params->itemid = $gradeitemid;
|
||||
$params->userid = $studentid;
|
||||
|
@ -112,7 +110,6 @@ class grade_export_txt extends grade_export {
|
|||
$grade_grade->update();
|
||||
}
|
||||
}
|
||||
$retval .= "{$this->separator}".$this->totals[$student->id];
|
||||
$retval .= "\n";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue