function exercise_list_unassessed_student_submissions($exercise, $user) { // list the student submissions not assessed by the teacher global $CFG; $timenow = time(); if (!($course = get_record("course", "id", $exercise->course))) { error("Course is misconfigured"); } if (!($cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id))) { error("Course Module ID was incorrect"); } $table->head = array(get_string("title", "exercise"), get_string("submittedby", "exercise"), get_string("submitted", "exercise"), get_string("action", "exercise"), get_string("comment", "exercise")); $table->align = array("left", "left", "left", "left", "left"); $table->size = array("*", "*", "*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; // get all the submissions, oldest first, youngest last // exercise_get_student_submissions is group aware $groupid = get_current_group($course->id); if ($groupid) { if (!groups_group_exists($groupid)) { error("List unassessed student submissions: group not found"); } print_heading(get_string("studentsubmissionsforassessment", "exercise", $group->name)); } if ($submissions = exercise_get_student_submissions($exercise, "time", $groupid)) { foreach ($submissions as $submission) { // only consider "cold" submissions if ($submission->timecreated < $timenow - $CFG->maxeditingtime) { $comment = ""; // see if student has already submitted $submissionowner = get_record("user", "id", $submission->userid); if (exercise_count_user_submissions($exercise, $submissionowner) == 1) { // it's the student's first submission // see if there are no cold assessments for this submission if (!exercise_count_assessments($submission)) { // now see if the teacher has already assessed this submission $warm = false; if ($assessments = get_records("exercise_assessments", "submissionid", $submission->id)) { foreach ($assessments as $assessment) { if (isteacher($course->id, $assessment->userid)) { if ($assessment->timecreated > $timenow - $CFG->maxeditingtime) { $warm = true; } break; // no need to look further } } } // get their assessment if ($assessments = exercise_get_user_assessments($exercise, $submissionowner)) { foreach ($assessments as $assessment) { $studentassessment = $assessment; break; // there should only be one! } $timegap = get_string("ago", "exercise", format_time($submission->timecreated - $timenow)); if ($submission->late) { $timegap = "<font color=\"red\">" . $timegap . "</font>"; } if ($warm) { // last chance salon $action = "<a href=\"assessments.php?action=teacherassessment&id={$cm->id}&aid={$studentassessment->id}&sid={$submission->id}\">" . get_string("edit", "exercise") . "</a>"; $table->data[] = array(exercise_print_submission_title($exercise, $submission), fullname($submissionowner), $timegap, $action, $comment); } else { $action = "<a href=\"assessments.php?action=teacherassessment&id={$cm->id}&aid={$studentassessment->id}&sid={$submission->id}\">" . get_string("assess", "exercise") . "</a>"; $table->data[] = array(exercise_print_submission_title($exercise, $submission), fullname($submissionowner), $timegap, $action, $comment); } } else { // there's no student assessment, odd!! } } } else { $teacherassessed = false; $warm = false; if ($assessments = get_records("exercise_assessments", "submissionid", $submission->id)) { foreach ($assessments as $assessment) { if (isteacher($course->id, $assessment->userid)) { $teacherassessed = true; if (!($teacher = get_record("user", "id", $assessment->userid))) { error("List unassessed student submissions: teacher record not found"); } $comment = get_string("resubmissionfor", "exercise", fullname($teacher)); if ($assessment->timecreated > $timenow - $CFG->maxeditingtime) { $warm = true; } break; // no need to look further } } } if ($teacherassessed and $warm) { // last chance salon $action = "<a href=\"assessments.php?action=assessresubmission&id={$cm->id}&sid={$submission->id}\">" . get_string("edit", "exercise") . "</a>"; $timegap = get_string("ago", "exercise", format_time($submission->timecreated - $timenow)); if ($submission->late) { $timegap = "<font color=\"red\">" . $timegap . "</font>"; } $table->data[] = array(exercise_print_submission_title($exercise, $submission), fullname($submissionowner), $timegap, $action, $comment); } if (!$teacherassessed) { // no teacher's assessment // find who did the previous assessment if (!($submissions = exercise_get_user_submissions($exercise, $submissionowner))) { error("List unassessed student submissions: submission records not found"); } // get the oldest submission, exercise_get_user_submissions returns that first foreach ($submissions as $tempsubmission) { $prevsubmission = $tempsubmission; break; } // get the teacher's assessment of the student's previous submission if ($assessments = get_records("exercise_assessments", "submissionid", $prevsubmission->id)) { foreach ($assessments as $assessment) { if (isteacher($course->id, $assessment->userid)) { if (!($teacher = get_record("user", "id", $assessment->userid))) { error("List unassessed student submissions: teacher record not found"); } $comment = get_string("resubmissionfor", "exercise", fullname($teacher)); break; // no need to look further } } } $action = "<a href=\"assessments.php?action=assessresubmission&id={$cm->id}&sid={$submission->id}\">" . get_string("assess", "exercise") . "</a>"; $timegap = get_string("ago", "exercise", format_time($submission->timecreated - $timenow)); if ($submission->late) { $timegap = "<font color=\"red\">" . $timegap . "</font>"; } $table->data[] = array(exercise_print_submission_title($exercise, $submission), fullname($submissionowner), $timegap, $action, $comment); } } } } if (isset($table->data)) { print_table($table); } } }
echo "<tr align=\"center\"><td>" . get_string("enterpassword", "exercise") . " <input type=\"password\" name=\"userpassword\" /></td></tr>"; echo "<tr align=\"center\"><td>"; echo "<input type=\"button\" value=\"" . get_string("cancel") . "\" onclick=\"parent.location='../../course/view.php?id={$course->id}';\"> "; echo "<input type=\"button\" value=\"" . get_string("continue") . "\" onclick=\"document.password.submit();\" />"; echo "</td></tr></table>"; print_simple_box_end(); exit; } } // in Stage 1 - the student must make an assessment (linked to the teacher's exercise/submission if (!exercise_test_user_assessments($exercise, $USER)) { print_heading(get_string("pleaseviewtheexercise", "exercise", $course->teacher)); exercise_list_teacher_submissions($exercise, $USER); } else { // show assessment the teacher's examples, there may be feedback from teacher if (exercise_count_user_submissions($exercise, $USER) == 0) { print_heading(get_string("atthisstageyou", "exercise", $course->teacher)); exercise_list_teacher_submissions($exercise, $USER, true); // true = allow re-assessing // print upload form print_heading(get_string("pleasesubmityourwork", "exercise") . ":"); exercise_print_upload_form($exercise); } else { exercise_list_teacher_submissions($exercise, $USER); echo "<hr size=\"1\" noshade=\"noshade\" />"; print_heading(get_string("yoursubmission", "exercise")); exercise_list_user_submissions($exercise, $USER); if (exercise_test_for_resubmission($exercise, $USER)) { // if resubmission requested print upload form echo "<hr size=\"1\" noshade=\"noshade\" />"; print_heading(get_string("pleasesubmityourwork", "exercise") . ":");