|
@@ -279,6 +279,7 @@ class iassign {
|
|
|
'viewsubmission' => '$this->view_iassign_current();',
|
|
|
'edit_status' => '$this->edit_status();',
|
|
|
'edit_grade' => '$this->edit_grade();',
|
|
|
+ 'export_csv' => '$this->export_csv();',
|
|
|
'report' => '$this->report();',
|
|
|
'print' => '$this->report();',
|
|
|
'stats' => '$this->stats();',
|
|
@@ -1332,7 +1333,9 @@ class iassign {
|
|
|
if ($this->action != 'print') {
|
|
|
$link_print = "<a href='" . $CFG->wwwroot . "/mod/iassign/view.php?id=" . $id . "&action=print&iassignid=" . $this->iassign->id . "'>" . iassign_icons::insert('print') . ' ' . get_string('print', 'iassign') . "</a>";
|
|
|
$link_stats = "<a href='" . $CFG->wwwroot . "/mod/iassign/view.php?id=" . $id . "&action=stats&iassignid=" . $this->iassign->id . "'>" . iassign_icons::insert('results') . ' ' . get_string('graphic', 'iassign') . "</a>";
|
|
|
+ $link_export = "<a href='" . $CFG->wwwroot . "/mod/iassign/view.php?id=" . $id . "&action=export_csv&iassignid=" . $this->iassign->id . "'>" . iassign_icons::insert('export_ilm') . ' ' . get_string('export_csv', 'iassign') . "</a>";
|
|
|
print '<td width=15% align="right">' . $link_stats . '</td>' . "\n";
|
|
|
+ print '<td width=15% align="right">' . $link_export . '</td>' . "\n";
|
|
|
print '<td width=15% align="right">' . $link_print . '</td>' . "\n";
|
|
|
}
|
|
|
print '</tr></table>' . "\n";
|
|
@@ -1987,6 +1990,75 @@ class iassign {
|
|
|
die();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ function export_csv () {
|
|
|
+ global $USER, $CFG, $DB, $OUTPUT;
|
|
|
+ $str = "";
|
|
|
+ $fields = "student_id, student_name";
|
|
|
+
|
|
|
+
|
|
|
+ $id = $this->cm->id;
|
|
|
+ $iassign_list = $DB->get_records_list('iassign_statement', 'iassignid', array('iassignid' => $this->iassign->id + 22), "position ASC");
|
|
|
+ $c = 1;
|
|
|
+ foreach ($iassign_list as $iassign) {
|
|
|
+ $fields .= ", activity_id_$c, activity_name_$c, total_submissions_activity_$c, grade_activity_$c"
|
|
|
+ . ", status_activity_$c, ilm_id_activity_$c, ilm_name_activity_$c";
|
|
|
+ $c ++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $params = array('shortname' => 'student');
|
|
|
+ $role = $DB->get_record_sql(
|
|
|
+ "SELECT s.id, s.shortname FROM {role} s " .
|
|
|
+ " WHERE s.shortname = :shortname", $params);
|
|
|
+ $context = context_course::instance($this->course->id);
|
|
|
+ $params = array('contextid' => $context->id, 'roleid' => $role->id);
|
|
|
+ $students = $DB->get_records_sql(
|
|
|
+ "SELECT s.userid, a.firstname, a.lastname FROM {role_assignments} s, {user} a " .
|
|
|
+ " WHERE s.contextid = :contextid AND s.userid = a.id AND s.roleid = :roleid " .
|
|
|
+ " ORDER BY a.firstname ASC,a.lastname ASC", $params);
|
|
|
+
|
|
|
+ foreach ($students as $student) {
|
|
|
+ $str .= $student->userid . ',';
|
|
|
+ $str .= '"' . $student->firstname . ' ' . $student->lastname . '"';
|
|
|
+
|
|
|
+ foreach ($iassign_list as $iassign) {
|
|
|
+ $str .= ',' . $iassign->id . ',';
|
|
|
+ $str .= '"' . $iassign->name . '",';
|
|
|
+
|
|
|
+ $student_submissions = $DB->get_record("iassign_submission", array('iassign_statementid' => $iassign->id, 'userid' => $student->userid));
|
|
|
+ $str .= $student_submissions->experiment . ',';
|
|
|
+ $str .= $student_submissions->grade . ',';
|
|
|
+ switch ($student_submissions->status) {
|
|
|
+ case 3:
|
|
|
+ $str .= '"correct",';
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ $str .= '"incorrect",';
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ $str .= '"post",';
|
|
|
+ break;
|
|
|
+ case 0:
|
|
|
+ $str .= '"not_post",';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $str .= $iassign->iassign_ilmid . ',';
|
|
|
+
|
|
|
+ $ilm_activity = $DB->get_record("iassign_ilm", array('id' => $iassign->iassign_ilmid));
|
|
|
+ $str .= '"' . $ilm_activity->name . '"';
|
|
|
+ }
|
|
|
+ $str .= "\n";
|
|
|
+ }
|
|
|
+ $str = $fields . "\n" . $str;
|
|
|
+ header("Content-disposition: attachment; filename=report.csv");
|
|
|
+ header("Pragma: no-cache");
|
|
|
+ header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
|
|
|
+ header('Content-Length: ' . strlen($str));
|
|
|
+ header('Connection: close');
|
|
|
+ echo $str;
|
|
|
+ flush();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
function report () {
|
|
@@ -2177,15 +2249,13 @@ class iassign {
|
|
|
else
|
|
|
print '<td> <a href="' . $url . '" ' . $last_solution_submission . '>' . $feedback . '</a> </td>' . "\n";
|
|
|
print '<td> </td>';
|
|
|
- print '</tr><tr>';
|
|
|
- print '<td> </td>';
|
|
|
+ print '</tr>';
|
|
|
if ($sum_comment > 0 && $sum_verify_message > 0)
|
|
|
- print '<td> <a href="' . $url . '"> ' . $comment . '</a> (' . $sum_verify_message . '/' . $sum_comment . ') </td>' . "\n";
|
|
|
+ print '<tr><td colspan="2"> <a href="' . $url . '"> ' . $comment . '</a> (' . $sum_verify_message . '/' . $sum_comment . ') </td></tr>' . "\n";
|
|
|
else if ($sum_comment > 0)
|
|
|
- print '<td> <a href="' . $url . '"> ' . $comment . '</a> (' . $sum_comment . ') </td>' . "\n";
|
|
|
- else
|
|
|
- print '<td> </td>' . "\n";
|
|
|
- print '</tr></table>' . "\n";
|
|
|
+ print '<tr><td colspan="2"> <a href="' . $url . '"> ' . $comment . '</a> (' . $sum_comment . ') </td></tr>' . "\n";
|
|
|
+
|
|
|
+ print '</table>' . "\n";
|
|
|
}
|
|
|
|
|
|
if ($this->action == 'print')
|