some clean ups for gradebook import/export

This commit is contained in:
toyomoyo 2007-05-22 02:05:00 +00:00
parent 4db13f9465
commit f5f4967e7d
7 changed files with 68 additions and 27 deletions

View File

@ -201,41 +201,50 @@ class grade_export {
* Displays all the grades on screen as a feedback mechanism
*/
function display_grades($feedback=false) {
echo get_string("firstname").",".
get_string("lastname").",".
get_string("idnumber").",".
get_string("institution").",".
get_string("department").",".
get_string("email");
echo '<table>';
echo '<tr>';
echo '<th>'.get_string("firstname")."</th>".
'<th>'.get_string("lastname")."</th>".
'<th>'.get_string("idnumber")."</th>".
'<th>'.get_string("institution")."</th>".
'<th>'.get_string("department")."</th>".
'<th>'.get_string("email")."</th>";
foreach ($this->columns as $column) {
$column = strip_tags($column);
echo ",$column";
echo "<th>$column</th>";
/// add a column_feedback column
if ($feedback) {
echo ",{$column}_feedback";
echo "<th>{$column}_feedback</th>";
}
}
echo ",".get_string("total")."<br/>";
echo '<th>'.get_string("total")."</th>";
echo '</tr>';
/// Print all the lines of data.
foreach ($this->grades as $studentid => $studentgrades) {
echo '<tr>';
$student = $this->students[$studentid];
if (empty($this->totals[$student->id])) {
$this->totals[$student->id] = '';
}
echo "$student->firstname,$student->lastname,$student->idnumber,$student->institution,$student->department,$student->email";
echo "<td>$student->firstname</td><td>$student->lastname</td><td>$student->idnumber</td><td>$student->institution</td><td>$student->department</td><td>$student->email</td>";
foreach ($studentgrades as $grade) {
$grade = strip_tags($grade);
echo ",$grade";
echo "<td>$grade</td>";
if ($feedback) {
echo ",".array_shift($this->comments[$student->id]);
echo '<td>'.array_shift($this->comments[$student->id]).'</td>';
}
}
echo ",".$this->totals[$student->id];
echo "<br/>";
echo '<td>'.$this->totals[$student->id].'</td>';
echo "</tr>";
}
echo '</table>';
}
}

View File

@ -38,7 +38,10 @@ if (($data = data_submitted()) && confirm_sesskey()) {
}
// print the grades on screen for feedbacks
print_header(get_string('grade'),get_string('grade'),get_string('grade'));
$course = get_record('course', 'id', $id);
$action = 'exporttxt';
print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
$export = new grade_export($id, $data->itemids);
$export->display_grades($feedback);
@ -46,6 +49,9 @@ if (($data = data_submitted()) && confirm_sesskey()) {
redirect('export.php?id='.$id.'&amp;itemids='.$itemidsurl);
exit;
}
$course = get_record('course', 'id', $id);
$action = 'exportods';
print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
print_gradeitem_selections($id);
print_footer();
?>

View File

@ -37,8 +37,10 @@ if (($data = data_submitted()) && confirm_sesskey()) {
$itemidsurl = implode(",",$data->itemids);
}
// print the grades on screen for feedbacks
print_header(get_string('grade'),get_string('grade'),get_string('grade'));
$course = get_record('course', 'id', $id);
$action = 'exporttxt';
print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
$export = new grade_export($id, $data->itemids);
$export->display_grades($feedback);
@ -71,7 +73,7 @@ if ($grade_items = grade_get_items($id)) {
}
echo '<br/>';
echo 'tab<input type="radio" name="separator" value="tab"/>';
echo 'comma<input type="radio" name="separator" value="comma"/>';
echo 'comma<input type="radio" name="separator" value="comma" checked="checked"/>';
echo '<input type="hidden" name="id" value="'.$id.'"/>';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'"/>';
echo '<br/>';

View File

@ -38,7 +38,10 @@ if (($data = data_submitted()) && confirm_sesskey()) {
}
// print the grades on screen for feedbacks
print_header(get_string('grade'),get_string('grade'),get_string('grade'));
$course = get_record('course', 'id', $id);
$action = 'exporttxt';
print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
$export = new grade_export($id, $data->itemids);
$export->display_grades($feedback);
@ -46,6 +49,9 @@ if (($data = data_submitted()) && confirm_sesskey()) {
redirect('export.php?id='.$id.'&amp;itemids='.$itemidsurl);
exit;
}
$course = get_record('course', 'id', $id);
$action = 'exportxls';
print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
print_gradeitem_selections($id);
print_footer();
?>

View File

@ -38,7 +38,10 @@ if (($data = data_submitted()) && confirm_sesskey()) {
}
// print the grades on screen for feedbacks
print_header(get_string('grade'),get_string('grade'),get_string('grade'));
$course = get_record('course', 'id', $id);
$action = 'exporttxt';
print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
$export = new grade_export($id, $data->itemids);
$export->display_grades($feedback);
@ -46,6 +49,9 @@ if (($data = data_submitted()) && confirm_sesskey()) {
redirect('export.php?id='.$id.'&amp;itemids='.$itemidsurl);
exit;
}
$course = get_record('course', 'id', $id);
$action = 'exportxml';
print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
print_gradeitem_selections($id);
print_footer();
?>

View File

@ -29,7 +29,11 @@ if (isset($CFG->CSV_DELIMITER)) {
require_once('../grade_import_form.php');
print_header("test","test","test");
require_once($CFG->dirroot.'/grade/lib.php');
$course = get_record('course', 'id', $id);
$action = 'importcsv';
print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
$mform = new grade_import_form();

View File

@ -1157,6 +1157,14 @@ function grade_nav($course, $action='grades') {
case 'excepts':
$strcurpage = get_string('gradeexceptions', 'grades');
break;
case 'exporttxt':
case 'exportxml':
case 'exportods':
case 'exportxls':
case 'importcsv':
case 'importxml':
$strcurpage = get_string($action);
break;
default:
unset($strcurpage);
break;