mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
added code to write back timestamp
This commit is contained in:
parent
2df712352d
commit
1b07462560
7 changed files with 206 additions and 12 deletions
|
@ -22,7 +22,38 @@
|
||||||
// http://www.gnu.org/copyleft/gpl.html //
|
// http://www.gnu.org/copyleft/gpl.html //
|
||||||
// //
|
// //
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
include_once('../../../config.php');
|
||||||
|
include_once($CFG->dirroot.'/lib/gradelib.php');
|
||||||
|
/**
|
||||||
|
* Prints all grade items for selection
|
||||||
|
* @input int id - course id
|
||||||
|
*/
|
||||||
|
function print_gradeitem_selections($id) {
|
||||||
|
|
||||||
|
// print all items for selections
|
||||||
|
// make this a standard function in lib maybe
|
||||||
|
if ($grade_items = grade_get_items($id)) {
|
||||||
|
echo '<form action="index.php" method="post">';
|
||||||
|
echo '<div>';
|
||||||
|
foreach ($grade_items as $grade_item) {
|
||||||
|
|
||||||
|
echo '<br/><input type="checkbox" name="itemids[]" value="'.$grade_item->id.'" checked="checked"/>';
|
||||||
|
|
||||||
|
if ($grade_item->itemtype == 'category') {
|
||||||
|
// grade categories should be displayed bold
|
||||||
|
echo '<b>'.$grade_item->itemname.'</b>';
|
||||||
|
} else {
|
||||||
|
echo $grade_item->itemname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '<input type="submit" value="'.get_string('submit').'" />';
|
||||||
|
echo '</div>';
|
||||||
|
echo '</form>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Base export class
|
||||||
|
*/
|
||||||
class grade_export {
|
class grade_export {
|
||||||
|
|
||||||
var $format = ''; // export format
|
var $format = ''; // export format
|
||||||
|
@ -160,7 +191,47 @@ class grade_export {
|
||||||
* To be implemented by child classes
|
* To be implemented by child classes
|
||||||
*/
|
*/
|
||||||
function print_grades() { }
|
function print_grades() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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".
|
||||||
|
get_string("email");
|
||||||
|
foreach ($this->columns as $column) {
|
||||||
|
$column = strip_tags($column);
|
||||||
|
echo "\t$column";
|
||||||
|
|
||||||
|
/// add a column_feedback column
|
||||||
|
if ($feedback) {
|
||||||
|
echo "\t{$column}_feedback";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "\t".get_string("total")."\n";
|
||||||
|
|
||||||
|
/// Print all the lines of data.
|
||||||
|
foreach ($this->grades as $studentid => $studentgrades) {
|
||||||
|
$student = $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";
|
||||||
|
foreach ($studentgrades as $grade) {
|
||||||
|
$grade = strip_tags($grade);
|
||||||
|
echo "\t$grade";
|
||||||
|
|
||||||
|
if ($feedback) {
|
||||||
|
echo "\t".array_shift($this->comments[$student->id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "\t".$this->totals[$student->id];
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -90,7 +90,27 @@ class grade_export_ods extends grade_export {
|
||||||
// writing comment if requested
|
// writing comment if requested
|
||||||
if ($feedback) {
|
if ($feedback) {
|
||||||
$myxls->write_string($i,$j++,array_shift($this->comments[$student->id]));
|
$myxls->write_string($i,$j++,array_shift($this->comments[$student->id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// if export flag needs to be set
|
||||||
|
/// construct the grade_grades_final object and update timestamp if CFG flag is set
|
||||||
|
|
||||||
|
if ($expplugins = explode(",", get_config($CFG->gradeexport))) {
|
||||||
|
if (in_array($this->format, $expplugins)) {
|
||||||
|
$params->idnumber = $this->idnumber;
|
||||||
|
// get the grade item
|
||||||
|
$gradeitem = new grade_item($params);
|
||||||
|
|
||||||
|
unset($params);
|
||||||
|
$params->itemid = $gradeitem->id;
|
||||||
|
$params->userid = $studentid;
|
||||||
|
|
||||||
|
$grade_grades_final = new grade_grades_final($params);
|
||||||
|
$grade_grades_final->exported = time();
|
||||||
|
// update the time stamp;
|
||||||
|
$grade_grades_final->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$myxls->write_number($i,$j,$this->totals[$student->id]);
|
$myxls->write_number($i,$j,$this->totals[$student->id]);
|
||||||
}
|
}
|
||||||
|
@ -103,4 +123,4 @@ class grade_export_ods extends grade_export {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
15
grade/export/txt/export.php
Executable file
15
grade/export/txt/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_txt.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_txt($id, $itemids);
|
||||||
|
$export->print_grades($feedback);
|
||||||
|
|
||||||
|
?>
|
|
@ -31,10 +31,10 @@ class grade_export_txt extends grade_export {
|
||||||
/**
|
/**
|
||||||
* To be implemented by child classes
|
* To be implemented by child classes
|
||||||
*/
|
*/
|
||||||
function print_grades($feedback = false;) {
|
function print_grades($feedback = false) {
|
||||||
|
|
||||||
/// Print header to force download
|
/// Print header to force download
|
||||||
|
global $CFG;
|
||||||
header("Content-Type: application/download\n");
|
header("Content-Type: application/download\n");
|
||||||
$downloadfilename = clean_filename("$this->course->shortname $this->strgrades");
|
$downloadfilename = clean_filename("$this->course->shortname $this->strgrades");
|
||||||
header("Content-Disposition: attachment; filename=\"$downloadfilename.txt\"");
|
header("Content-Disposition: attachment; filename=\"$downloadfilename.txt\"");
|
||||||
|
@ -71,7 +71,27 @@ class grade_export_txt extends grade_export {
|
||||||
|
|
||||||
if ($feedback) {
|
if ($feedback) {
|
||||||
echo "\t".array_shift($this->comments[$student->id]);
|
echo "\t".array_shift($this->comments[$student->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// if export flag needs to be set
|
||||||
|
/// construct the grade_grades_final object and update timestamp if CFG flag is set
|
||||||
|
|
||||||
|
if ($expplugins = explode(",", get_config($CFG->gradeexport))) {
|
||||||
|
if (in_array($this->format, $expplugins)) {
|
||||||
|
$params->idnumber = $this->idnumber;
|
||||||
|
// get the grade item
|
||||||
|
$gradeitem = new grade_item($params);
|
||||||
|
|
||||||
|
unset($params);
|
||||||
|
$params->itemid = $gradeitem->id;
|
||||||
|
$params->userid = $studentid;
|
||||||
|
|
||||||
|
$grade_grades_final = new grade_grades_final($params);
|
||||||
|
$grade_grades_final->exported = time();
|
||||||
|
// update the time stamp;
|
||||||
|
$grade_grades_final->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
echo "\t".$this->totals[$student->id];
|
echo "\t".$this->totals[$student->id];
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
@ -81,4 +101,4 @@ class grade_export_txt extends grade_export {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
46
grade/export/txt/index.php
Executable file
46
grade/export/txt/index.php
Executable file
|
@ -0,0 +1,46 @@
|
||||||
|
<?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_txt.php');
|
||||||
|
|
||||||
|
$id = required_param('id', PARAM_INT); // course id
|
||||||
|
$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);
|
||||||
|
|
||||||
|
// print the grades on screen for feedbacks
|
||||||
|
print_header();
|
||||||
|
$export = new grade_export($id, $itemids);
|
||||||
|
$export->display_grades($feedback);
|
||||||
|
print_footer();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
print_gradeitem_selections($id);
|
||||||
|
?>
|
|
@ -91,7 +91,27 @@ class grade_export_xls extends grade_export {
|
||||||
// writing comment if requested
|
// writing comment if requested
|
||||||
if ($feedback) {
|
if ($feedback) {
|
||||||
$myxls->write_string($i,$j++,array_shift($this->comments[$student->id]));
|
$myxls->write_string($i,$j++,array_shift($this->comments[$student->id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// if export flag needs to be set
|
||||||
|
/// construct the grade_grades_final object and update timestamp if CFG flag is set
|
||||||
|
|
||||||
|
if ($expplugins = explode(",", get_config($CFG->gradeexport))) {
|
||||||
|
if (in_array($this->format, $expplugins)) {
|
||||||
|
$params->idnumber = $this->idnumber;
|
||||||
|
// get the grade item
|
||||||
|
$gradeitem = new grade_item($params);
|
||||||
|
|
||||||
|
unset($params);
|
||||||
|
$params->itemid = $gradeitem->id;
|
||||||
|
$params->userid = $studentid;
|
||||||
|
|
||||||
|
$grade_grades_final = new grade_grades_final($params);
|
||||||
|
$grade_grades_final->exported = time();
|
||||||
|
// update the time stamp;
|
||||||
|
$grade_grades_final->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$myxls->write_number($i,$j,$this->totals[$student->id]);
|
$myxls->write_number($i,$j,$this->totals[$student->id]);
|
||||||
}
|
}
|
||||||
|
@ -103,4 +123,4 @@ class grade_export_xls extends grade_export {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -54,7 +54,7 @@ class grade_export_xml extends grade_export {
|
||||||
// state can be new, or regrade
|
// state can be new, or regrade
|
||||||
// require comparing of timestamps in db
|
// require comparing of timestamps in db
|
||||||
|
|
||||||
$params->idnumber = $idnumber;
|
$params->idnumber = $this->idnumber;
|
||||||
// get the grade item
|
// get the grade item
|
||||||
$gradeitem = new grade_item($params);
|
$gradeitem = new grade_item($params);
|
||||||
|
|
||||||
|
@ -91,6 +91,8 @@ class grade_export_xml extends grade_export {
|
||||||
echo '<feedback>'.$this->comments[$studentid][$index].'</feedback>';
|
echo '<feedback>'.$this->comments[$studentid][$index].'</feedback>';
|
||||||
}
|
}
|
||||||
echo '</result>';
|
echo '</result>';
|
||||||
|
|
||||||
|
// if flag is set, timestamp this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo '</results>';
|
echo '</results>';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue