mirror of
https://github.com/moodle/moodle.git
synced 2025-08-10 11:26:41 +02:00
regular whitespace cleanup in grade code
This commit is contained in:
parent
e1d2692a73
commit
ba74762bda
21 changed files with 297 additions and 297 deletions
|
@ -3,14 +3,14 @@
|
|||
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 = explode(",", required_param('itemids', PARAM_RAW));
|
||||
$feedback = optional_param('feedback', '', PARAM_ALPHA);
|
||||
|
||||
$feedback = optional_param('feedback', '', PARAM_ALPHA);
|
||||
|
||||
// print all the exported data here
|
||||
$export = new grade_export_txt($id, $itemids);
|
||||
$export->set_separator(optional_param('separator'));
|
||||
$export->print_grades($feedback);
|
||||
|
||||
|
||||
?>
|
|
@ -25,22 +25,22 @@
|
|||
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) {
|
||||
if ($separator == 'comma') {
|
||||
$this->separator = ",";
|
||||
} else if ($separator == 'tab') {
|
||||
$this->separator = "\t";
|
||||
}
|
||||
$this->separator = "\t";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To be implemented by child classes
|
||||
*/
|
||||
function print_grades($feedback = false) {
|
||||
function print_grades($feedback = false) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
|
@ -49,14 +49,14 @@ class grade_export_txt extends grade_export {
|
|||
if (in_array($this->format, $expplugins)) {
|
||||
$export = true;
|
||||
} else {
|
||||
$export = false;
|
||||
$export = false;
|
||||
}
|
||||
} else {
|
||||
$export = false;
|
||||
$export = false;
|
||||
}
|
||||
|
||||
/// Print header to force download
|
||||
header("Content-Type: application/download\n");
|
||||
|
||||
/// Print header to force download
|
||||
header("Content-Type: application/download\n");
|
||||
$downloadfilename = clean_filename("{$this->course->shortname} $this->strgrades");
|
||||
header("Content-Disposition: attachment; filename=\"$downloadfilename.txt\"");
|
||||
|
||||
|
@ -71,17 +71,17 @@ class grade_export_txt extends grade_export {
|
|||
foreach ($this->columns as $column) {
|
||||
$column = strip_tags($column);
|
||||
echo "{$this->separator}$column";
|
||||
|
||||
/// add a column_feedback column
|
||||
|
||||
/// add a column_feedback column
|
||||
if ($feedback) {
|
||||
echo "{$this->separator}{$column}_feedback";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "{$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] = '';
|
||||
|
@ -90,12 +90,12 @@ class grade_export_txt extends grade_export {
|
|||
|
||||
foreach ($studentgrades as $gradeitemid => $grade) {
|
||||
$grade = strip_tags($grade);
|
||||
echo "{$this->separator}$grade";
|
||||
|
||||
echo "{$this->separator}$grade";
|
||||
|
||||
if ($feedback) {
|
||||
echo "{$this->separator}".array_shift($this->comments[$student->id]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// if export flag needs to be set
|
||||
/// construct the grade_grades object and update timestamp if CFG flag is set
|
||||
|
||||
|
@ -103,7 +103,7 @@ class grade_export_txt extends grade_export {
|
|||
$params = new object();
|
||||
$params->itemid = $gradeitemid;
|
||||
$params->userid = $studentid;
|
||||
|
||||
|
||||
$grade_grades = new grade_grades($params);
|
||||
$grade_grades->exported = time();
|
||||
// update the time stamp;
|
||||
|
@ -113,7 +113,7 @@ class grade_export_txt extends grade_export {
|
|||
echo "{$this->separator}".$this->totals[$student->id];
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,15 +16,15 @@ class grade_export_txt_form extends moodleform {
|
|||
$mform->addElement($element);
|
||||
}
|
||||
}
|
||||
|
||||
include_once($CFG->libdir.'/pear/HTML/QuickForm/radio.php');
|
||||
|
||||
include_once($CFG->libdir.'/pear/HTML/QuickForm/radio.php');
|
||||
$radio = array();
|
||||
$radio[] = &MoodleQuickForm::createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab');
|
||||
$radio[] = &MoodleQuickForm::createElement('radio', 'separator', null, get_string('sepcomma', 'grades'), 'comma');
|
||||
$mform->addGroup($radio, 'separator', get_string('separator', 'grades'), ' ', false);
|
||||
$mform->setDefault('separator', 'comma');
|
||||
$mform->setDefault('separator', 'comma');
|
||||
|
||||
$this->add_action_buttons(false, get_string('submit'));
|
||||
$this->add_action_buttons(false, get_string('submit'));
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -48,13 +48,13 @@ if (($data = data_submitted()) && confirm_sesskey()) {
|
|||
} else {
|
||||
$itemidsurl = implode(",",$data->itemids);
|
||||
}
|
||||
|
||||
|
||||
$export = new grade_export($id, $data->itemids);
|
||||
$export->display_grades($feedback);
|
||||
|
||||
|
||||
// this redirect should trigger a download prompt
|
||||
redirect('export.php?id='.$id.'&itemids='.$itemidsurl.'&separator='.$data->separator);
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
|
||||
// print the form to choose what grade_items to export
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue