adding support for specific item ids and text feedbacks

This commit is contained in:
toyomoyo 2007-05-09 08:45:25 +00:00
parent b6903c43eb
commit f67e327e37

View File

@ -27,8 +27,10 @@ class grade_export {
var $format = ''; // export format
var $id; // course id
var $itemids; // comma separated grade_item ids;
var $grades = array(); // Collect all grades in this array
var $gradeshtml= array(); // Collect all grades html formatted in this array
var $comments = array(); // Collect all comments for each grade
var $totals = array(); // Collect all totals in this array
var $columns = array(); // Accumulate column names in this array.
var $columnhtml = array(); // Accumulate column html in this array.
@ -40,11 +42,14 @@ class grade_export {
/**
* Constructor should set up all the private variables ready to be pulled
* @input int id - course id
* @input string itemids - comma separated value of itemids to process for this export
*/
function grade_export($id) {
function grade_export($id, $itemids = '') {
$this->strgrades = get_string("grades");
$this->strgrade = get_string("grade");
$this->itemids = $itemids;
$strmax = get_string("maximumshort");
@ -83,10 +88,23 @@ class grade_export {
$this->grades[$student->id] = array(); // Collect all grades in this array
$this->gradeshtml[$student->id] = array(); // Collect all grades html formatted in this array
$this->totals[$student->id] = array(); // Collect all totals in this array
$this->comments[$student->id] = array(); // Collect all comments in tihs array
}
}
if ($gradeitems = grade_get_items($this->id)) {
// if grade_item ids are specified
if ($iids = explode(",", $itemids)) {
foreach ($iids as $iid) {
$params->id = $iid;
$gradeitems[] = new grade_item($params);
}
} else {
// else we get all items for this course
$gradeitems = grade_get_items($this->id);
}
if ($gradeitems) {
foreach ($gradeitems as $gradeitem) {
@ -105,27 +123,32 @@ class grade_export {
foreach ($students as $student) {
// add support for comment here MDL-9634
if (!empty($itemgrades[$student->id]->gradevalue)) {
$this->grades[$student->id][] = $currentstudentgrade = $itemgrades[$student->id]->gradevalue;
$studentgrade = $itemgrades[$student->id];
if (!empty($studentgrade->gradevalue)) {
$this->grades[$student->id][] = $currentstudentgrade = $studentgrade->gradevalue;
} else {
$this->grades[$student->id][] = $currentstudentgrade = "";
$this->gradeshtml[$student->id][] = "";
}
if (!empty($modgrades->maxgrade)) {
if (!empty($maxgrade)) {
$this->totals[$student->id] = (float)($totals[$student->id]) + (float)($currentstudentgrade);
} else {
$this->totals[$student->id] = (float)($totals[$student->id]) + 0;
}
}
// load comments here
$studentgrade->load_text();
// get the actual comment
$comment = $studentgrade->grade_grades_text->feedback;
if (!empty($comment)) {
$this->comments[$student->id][] = $comment;
} else {
$this->comments[$student->id][] = '';
}
}
}
/* we might be able to loop by gradeitems instead of students
foreach ($itemgrades as $itemgrade) {
$grades[$itemgrade->userid][] = $itemgrade->gradevalue;
$totals[$itemgrade->userid] = (float)($totals[$itemgrade->userid]) +
(float)($itemgrade->gradevalue);
}
*/
}
}
}