mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
new grade book export plugins development
This commit is contained in:
parent
b6b354e36e
commit
985d1ee11b
@ -143,18 +143,19 @@ class grade_export {
|
||||
|
||||
foreach ($gradeitems as $gradeitem) {
|
||||
|
||||
$this->columns[] = "$gradeitem->itemmodule: ".format_string($gradeitem->itemname,true)." - $gradeitem->grademax";
|
||||
$this->columnidnumbers[] = $gradeitem->idnumber; // this might be needed for some export plugins
|
||||
|
||||
if (!empty($gradeitem->maxgrade)) {
|
||||
$maxgrade = "$strmax: $gradeitem->maxgrade";
|
||||
} else {
|
||||
$maxgrade = "";
|
||||
}
|
||||
|
||||
// load as an array of grade_final objects
|
||||
if ($itemgrades = $gradeitem -> load_final()) {
|
||||
|
||||
$this->columns[$itemgrades->id] = "$gradeitem->itemmodule: ".format_string($gradeitem->itemname,true)." - $gradeitem->grademax";
|
||||
|
||||
$this->columnidnumbers[$itemgrades->id] = $gradeitem->idnumber; // this might be needed for some export plugins
|
||||
|
||||
if (!empty($gradeitem->grademax)) {
|
||||
$maxgrade = "$strmax: $gradeitem->grademax";
|
||||
} else {
|
||||
$maxgrade = "";
|
||||
}
|
||||
|
||||
if (!empty($this->students)) {
|
||||
foreach ($this->students as $student) {
|
||||
|
||||
@ -164,7 +165,7 @@ class grade_export {
|
||||
if (!empty($studentgrade->gradevalue)) {
|
||||
$this->grades[$student->id][$itemgrades->id] = $currentstudentgrade = $studentgrade->gradevalue;
|
||||
} else {
|
||||
$this->grades[$student->id][] = $currentstudentgrade = "";
|
||||
$this->grades[$student->id][$itemgrades->id] = $currentstudentgrade = "";
|
||||
$this->gradeshtml[$student->id][$itemgrades->id] = "";
|
||||
}
|
||||
if (!empty($maxgrade)) {
|
||||
@ -198,41 +199,41 @@ class grade_export {
|
||||
/**
|
||||
* Displays all the grades on screen as a feedback mechanism
|
||||
*/
|
||||
function display_grades() {
|
||||
echo get_string("firstname")."\t".
|
||||
get_string("lastname")."\t".
|
||||
get_string("idnumber")."\t".
|
||||
get_string("institution")."\t".
|
||||
get_string("department")."\t".
|
||||
function display_grades($feedback=false) {
|
||||
echo get_string("firstname").",".
|
||||
get_string("lastname").",".
|
||||
get_string("idnumber").",".
|
||||
get_string("institution").",".
|
||||
get_string("department").",".
|
||||
get_string("email");
|
||||
foreach ($this->columns as $column) {
|
||||
$column = strip_tags($column);
|
||||
echo "\t$column";
|
||||
echo ",$column";
|
||||
|
||||
/// add a column_feedback column
|
||||
if ($feedback) {
|
||||
echo "\t{$column}_feedback";
|
||||
echo ",{$column}_feedback";
|
||||
}
|
||||
}
|
||||
echo "\t".get_string("total")."\n";
|
||||
echo ",".get_string("total")."<br/>";
|
||||
|
||||
/// Print all the lines of data.
|
||||
foreach ($this->grades as $studentid => $studentgrades) {
|
||||
$student = $students[$studentid];
|
||||
$student = $this->students[$studentid];
|
||||
if (empty($this->totals[$student->id])) {
|
||||
$this->totals[$student->id] = '';
|
||||
}
|
||||
echo "$student->firstname\t$student->lastname\t$student->idnumber\t$student->institution\t$student->department\t$student->email";
|
||||
echo "$student->firstname,$student->lastname,$student->idnumber,$student->institution,$student->department,$student->email";
|
||||
foreach ($studentgrades as $grade) {
|
||||
$grade = strip_tags($grade);
|
||||
echo "\t$grade";
|
||||
echo ",$grade";
|
||||
|
||||
if ($feedback) {
|
||||
echo "\t".array_shift($this->comments[$student->id]);
|
||||
echo ",".array_shift($this->comments[$student->id]);
|
||||
}
|
||||
}
|
||||
echo "\t".$this->totals[$student->id];
|
||||
echo "\n";
|
||||
echo ",".$this->totals[$student->id];
|
||||
echo "<br/>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
15
grade/export/ods/export.php
Executable file
15
grade/export/ods/export.php
Executable file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
require_once("../../../config.php");
|
||||
require_once($CFG->dirroot.'/grade/export/lib.php');
|
||||
require_once('grade_export_ods.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
$itemids = required_param('itemids', PARAM_NOTAGS);
|
||||
$feedback = optional_param('feedback', '', PARAM_ALPHA);
|
||||
|
||||
// print all the exported data here
|
||||
$export = new grade_export_ods($id, $itemids);
|
||||
$export->print_grades($feedback);
|
||||
|
||||
?>
|
@ -41,9 +41,13 @@ class grade_export_ods extends grade_export {
|
||||
if ($expplugins = explode(",", $CFG->gradeexport)) {
|
||||
if (in_array($this->format, $expplugins)) {
|
||||
$export = true;
|
||||
}
|
||||
} else {
|
||||
$export = false;
|
||||
}
|
||||
} else {
|
||||
$export = false;
|
||||
}
|
||||
|
||||
|
||||
/// Calculate file name
|
||||
$downloadfilename = clean_filename("{$this->course->shortname} $this->strgrades.ods");
|
||||
/// Creating a workbook
|
||||
@ -88,7 +92,7 @@ class grade_export_ods extends grade_export {
|
||||
$myxls->write_string($i,4,$student->department);
|
||||
$myxls->write_string($i,5,$student->email);
|
||||
$j=6;
|
||||
foreach ($studentgrades as $grade) {
|
||||
foreach ($studentgrades as $gradeitemid => $grade) {
|
||||
if (is_numeric($grade)) {
|
||||
$myxls->write_number($i,$j++,strip_tags($grade));
|
||||
}
|
||||
|
51
grade/export/ods/index.php
Executable file
51
grade/export/ods/index.php
Executable file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 2001-2003 Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
require_once("../../../config.php");
|
||||
require_once($CFG->dirroot.'/grade/export/lib.php');
|
||||
require_once('grade_export_ods.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
$feedback = optional_param('feedback', '', PARAM_ALPHA);
|
||||
|
||||
// process post information
|
||||
if ($data = data_submitted() && confirm_sesskey()) {
|
||||
|
||||
if (!is_array($data->itemids)) {
|
||||
$itemidsurl = $data->itemids;
|
||||
} else {
|
||||
$itemidsurl = implode(",",$data->itemids);
|
||||
}
|
||||
|
||||
// print the grades on screen for feedbacks
|
||||
print_header(get_string('grade'),get_string('grade'),get_string('grade'));
|
||||
$export = new grade_export($id, $data->itemids);
|
||||
$export->display_grades($feedback);
|
||||
print_footer();
|
||||
// this redirect should trigger a download prompt
|
||||
redirect('export.php?id='.$id.'&itemids='.$itemidsurl);
|
||||
exit;
|
||||
}
|
||||
|
||||
print_gradeitem_selections($id);
|
||||
?>
|
@ -39,7 +39,11 @@ class grade_export_txt extends grade_export {
|
||||
if ($expplugins = explode(",", $CFG->gradeexport)) {
|
||||
if (in_array($this->format, $expplugins)) {
|
||||
$export = true;
|
||||
}
|
||||
} else {
|
||||
$export = false;
|
||||
}
|
||||
} else {
|
||||
$export = false;
|
||||
}
|
||||
|
||||
/// Print header to force download
|
||||
|
@ -30,15 +30,21 @@ $feedback = optional_param('feedback', '', PARAM_ALPHA);
|
||||
|
||||
// process post information
|
||||
if ($data = data_submitted() && confirm_sesskey()) {
|
||||
$itemids = implode(",", $data->itemids);
|
||||
// this redirect should trigger a download prompt
|
||||
redirect('export.php?id='.$id.'&itemids='.$itemids);
|
||||
|
||||
|
||||
if (!is_array($data->itemids)) {
|
||||
$itemidsurl = $data->itemids;
|
||||
} else {
|
||||
$itemidsurl = implode(",",$data->itemids);
|
||||
}
|
||||
|
||||
// print the grades on screen for feedbacks
|
||||
print_header();
|
||||
$export = new grade_export($id, $itemids);
|
||||
print_header(get_string('grade'),get_string('grade'),get_string('grade'));
|
||||
$export = new grade_export($id, $data->itemids);
|
||||
$export->display_grades($feedback);
|
||||
print_footer();
|
||||
|
||||
// this redirect should trigger a download prompt
|
||||
redirect('export.php?id='.$id.'&itemids='.$itemidsurl);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
15
grade/export/xls/export.php
Executable file
15
grade/export/xls/export.php
Executable file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
require_once("../../../config.php");
|
||||
require_once($CFG->dirroot.'/grade/export/lib.php');
|
||||
require_once('grade_export_xls.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
$itemids = required_param('itemids', PARAM_NOTAGS);
|
||||
$feedback = optional_param('feedback', '', PARAM_ALPHA);
|
||||
|
||||
// print all the exported data here
|
||||
$export = new grade_export_xls($id, $itemids);
|
||||
$export->print_grades($feedback);
|
||||
|
||||
?>
|
@ -39,7 +39,11 @@ class grade_export_xls extends grade_export {
|
||||
if ($expplugins = explode(",", $CFG->gradeexport)) {
|
||||
if (in_array($this->format, $expplugins)) {
|
||||
$export = true;
|
||||
}
|
||||
} else {
|
||||
$export = false;
|
||||
}
|
||||
} else {
|
||||
$export = false;
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/lib/excellib.class.php');
|
||||
@ -87,7 +91,7 @@ class grade_export_xls extends grade_export {
|
||||
$myxls->write_string($i,4,$student->department);
|
||||
$myxls->write_string($i,5,$student->email);
|
||||
$j=6;
|
||||
foreach ($studentgrades as $grade) {
|
||||
foreach ($studentgrades as $gradeitemid => $grade) {
|
||||
if (is_numeric($grade)) {
|
||||
$myxls->write_number($i,$j++,strip_tags($grade));
|
||||
}
|
||||
|
52
grade/export/xls/index.php
Executable file
52
grade/export/xls/index.php
Executable file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 2001-2003 Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
require_once("../../../config.php");
|
||||
require_once($CFG->dirroot.'/grade/export/lib.php');
|
||||
require_once('grade_export_xls.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
$feedback = optional_param('feedback', '', PARAM_ALPHA);
|
||||
|
||||
// process post information
|
||||
if ($data = data_submitted() && confirm_sesskey()) {
|
||||
|
||||
if (!is_array($data->itemids)) {
|
||||
$itemidsurl = $data->itemids;
|
||||
} else {
|
||||
$itemidsurl = implode(",",$data->itemids);
|
||||
}
|
||||
|
||||
// print the grades on screen for feedbacks
|
||||
print_header(get_string('grade'),get_string('grade'),get_string('grade'));
|
||||
$export = new grade_export($id, $data->itemids);
|
||||
$export->display_grades($feedback);
|
||||
print_footer();
|
||||
|
||||
// this redirect should trigger a download prompt
|
||||
redirect('export.php?id='.$id.'&itemids='.$itemidsurl);
|
||||
exit;
|
||||
}
|
||||
|
||||
print_gradeitem_selections($id);
|
||||
?>
|
@ -39,7 +39,11 @@ class grade_export_xml extends grade_export {
|
||||
if ($expplugins = explode(",", $CFG->gradeexport)) {
|
||||
if (in_array($this->format, $expplugins)) {
|
||||
$export = true;
|
||||
}
|
||||
} else {
|
||||
$export = false;
|
||||
}
|
||||
} else {
|
||||
$export = false;
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/lib/excellib.class.php');
|
||||
@ -68,18 +72,17 @@ class grade_export_xml extends grade_export {
|
||||
|
||||
// we are trying to figure out if this is a new grade, or a regraded grade
|
||||
// only relevant if this grade for this user is already exported
|
||||
if (!empty($gradeitem->exported)) {
|
||||
|
||||
// get the grade_grades_final for this user
|
||||
unset($params);
|
||||
$params->itemid = $gradeitem->id;
|
||||
$params->userid = $studentid;
|
||||
// get the grade_grades_final for this user
|
||||
unset($params);
|
||||
$params->itemid = $gradeitem->id;
|
||||
$params->userid = $studentid;
|
||||
|
||||
$grade_grades_final = new grade_grades_final($params);
|
||||
$grade_grades_final = new grade_grades_final($params);
|
||||
|
||||
// if exported, check grade_history, if modified after export, set state to regrade
|
||||
|
||||
if (record_exists_select('grade_hitory', 'itemid = '.$gradeitem->id.' AND userid = '.$studentid.' AND timemodified > '.$grade_grades_final->exported)) {
|
||||
// if exported, check grade_history, if modified after export, set state to regrade
|
||||
if (!empty($grade_grades_final->exported)) {
|
||||
if (record_exists_select('grade_history', 'itemid = '.$gradeitem->id.' AND userid = '.$studentid.' AND timemodified > '.$grade_grades_final->exported)) {
|
||||
$status = 'regrade';
|
||||
} else {
|
||||
$status = 'new';
|
||||
|
@ -30,15 +30,21 @@ $feedback = optional_param('feedback', '', PARAM_ALPHA);
|
||||
|
||||
// process post information
|
||||
if ($data = data_submitted() && confirm_sesskey()) {
|
||||
$itemids = implode(",", $data->itemids);
|
||||
// this redirect should trigger a download prompt
|
||||
redirect('export.php?id='.$id.'&itemids='.$itemids);
|
||||
|
||||
|
||||
if (!is_array($data->itemids)) {
|
||||
$itemidsurl = $data->itemids;
|
||||
} else {
|
||||
$itemidsurl = implode(",",$data->itemids);
|
||||
}
|
||||
|
||||
// print the grades on screen for feedbacks
|
||||
print_header();
|
||||
$export = new grade_export($id, $itemids);
|
||||
print_header(get_string('grade'),get_string('grade'),get_string('grade'));
|
||||
$export = new grade_export($id, $data->itemids);
|
||||
$export->display_grades($feedback);
|
||||
print_footer();
|
||||
|
||||
// this redirect should trigger a download prompt
|
||||
redirect('export.php?id='.$id.'&itemids='.$itemidsurl);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user