function exercise_user_complete($course, $user, $mod, $exercise) { if ($submissions = exercise_get_user_submissions($exercise, $user)) { print_simple_box_start(); $table->head = array(get_string("submission", "exercise"), get_string("submitted", "exercise"), get_string("assessed", "exercise"), get_string("grade")); $table->width = "100%"; $table->align = array("left", "left", "left", "center"); $table->size = array("*", "*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; foreach ($submissions as $submission) { if ($assessments = exercise_get_assessments($submission)) { // should only be one but we'll loop anyway foreach ($assessments as $assessment) { $table->data[] = array(exercise_print_submission_title($exercise, $submission), userdate($submission->timecreated), userdate($assessment->timecreated), $assessment->grade * $exercise->grade / 100.0); } } else { // submission not yet assessed (by teacher) $table->data[] = array(exercise_print_submission_title($exercise, $submission), userdate($submission->timecreated), get_string("notassessedyet", "exercise"), 0); } } print_table($table); print_simple_box_end(); } else { print_string("nosubmissions", "exercise"); } }
function exercise_print_teacher_assessment_form($exercise, $assessment, $submission, $returnto = '') { // prints an assessment form based on the student's assessment // if the teacher is re-assessing a submission they would use exercise_print_assessment_form() // (for teachers only) global $CFG, $USER, $EXERCISE_SCALES, $EXERCISE_EWEIGHTS; 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"); } $timenow = time(); if (!($submissionowner = get_record("user", "id", $submission->userid))) { error("Print teacher assessment form: User record not found"); } echo "<center><table border=\"1\" width=\"30%\"><tr>\n <td align=\"center\">\n"; if (!($teachersubmission = get_record("exercise_submissions", "id", $assessment->submissionid))) { error("Print teacher assessment form: Submission record not found"); } echo exercise_print_submission_title($exercise, $teachersubmission); echo "</td></tr></table><br clear=\"all\" />\n"; echo "<center><table border=\"1\" width=\"30%\"><tr>\n <td align=\"center\">\n"; echo exercise_print_submission_title($exercise, $submission); echo "</td></tr></table></center><br clear=\"all\" />\n"; ?> <form id="assessmentform" method="post" action="assessments.php"> <input type="hidden" name="id" value="<?php echo $cm->id; ?> " /> <input type="hidden" name="said" value="<?php echo $assessment->id; ?> " /> <input type="hidden" name="sid" value="<?php echo $submission->id; ?> " /> <input type="hidden" name="action" value="updateteacherassessment" /> <input type="hidden" name="resubmit" value="0" /> <input type="hidden" name="returnto" value="<?php echo $returnto; ?> " /> <?php // now print a normal assessment form based on the student's assessment for this submission // and allow the teacher to grade and add additional comments $studentassessment = $assessment; $allowchanges = true; print_heading_with_help(get_string("pleasemakeyourownassessment", "exercise", fullname($submissionowner)), "grading", "exercise"); // is there an existing assessment for the submission if (!($assessment = exercise_get_submission_assessment($submission, $USER))) { // copy student's assessment with their comments for the teacher's assessment $assessment = exercise_copy_assessment($studentassessment, $submission, true); } // only show the grade if grading strategy > 0 and the grade is positive if ($exercise->gradingstrategy and $assessment->grade >= 0) { echo "<center><b>" . get_string("thegradeis", "exercise") . ": " . number_format($assessment->grade * $exercise->grade / 100.0, 2) . " (" . get_string("maximumgrade") . " " . number_format($exercise->grade, 0) . ")</b></center><br clear=\"all\" />\n"; } echo "<center><table cellpadding=\"2\" border=\"1\">\n"; echo "<tr valign=\"top\">\n"; echo " <td colspan=\"2\"><center><b>" . get_string("yourassessment", "exercise") . "</b></center></td>\n"; echo "</tr>\n"; // get the assignment elements... if (!($elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC"))) { error("Teacher assessment form: Elements not found"); } foreach ($elementsraw as $element) { $elements[] = $element; // to renumber index 0,1,2... } // ...and get any previous grades... if ($gradesraw = get_records_select("exercise_grades", "assessmentid = {$assessment->id}", "elementno")) { foreach ($gradesraw as $grade) { $grades[] = $grade; // to renumber index 0,1,2... } } // determine what sort of grading switch ($exercise->gradingstrategy) { case 0: // no grading // now print the form for ($i = 0; $i < count($elements); $i++) { $iplus1 = $i + 1; echo "<tr valign=\"top\">\n"; echo " <td align=\"right\"><p><b>" . get_string("element", "exercise") . " {$iplus1}:</b></p></td>\n"; echo " <td>" . text_to_html($elements[$i]->description); echo "</td></tr>\n"; echo "<tr valign=\"top\">\n"; echo " <td align=\"right\"><p><b>" . get_string("feedback") . ":</b></p></td>\n"; echo " <td>\n"; if ($allowchanges) { echo " <textarea name=\"feedback[]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n"; if (isset($grades[$i]->feedback)) { echo $grades[$i]->feedback; } echo "</textarea>\n"; } else { echo text_to_html($grades[$i]->feedback); } echo " </td>\n"; echo "</tr>\n"; echo "<tr valign=\"top\">\n"; echo " <td colspan=\"2\"> </td>\n"; echo "</tr>\n"; } break; case 1: // accumulative grading // now print the form for ($i = 0; $i < count($elements); $i++) { $iplus1 = $i + 1; echo "<tr valign=\"top\">\n"; echo " <td align=\"right\"><p><b>" . get_string("element", "exercise") . " {$iplus1}:</b></p></td>\n"; echo " <td>" . text_to_html($elements[$i]->description); echo "<p align=\"right\"><font size=\"1\">Weight: " . number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2) . "</font>\n"; echo "</td></tr>\n"; echo "<tr valign=\"top\">\n"; echo " <td align=\"right\"><p><b>" . get_string("grade") . ":</b></p></td>\n"; echo " <td valign=\"top\">\n"; // get the appropriate scale $scalenumber = $elements[$i]->scale; $SCALE = (object) $EXERCISE_SCALES[$scalenumber]; switch ($SCALE->type) { case 'radio': // show selections highest first echo "<center><b>{$SCALE->start}</b> "; for ($j = $SCALE->size - 1; $j >= 0; $j--) { $checked = false; if (isset($grades[$i]->grade)) { if ($j == $grades[$i]->grade) { $checked = true; } } else { // there's no previous grade so check the lowest option if ($j == 0) { $checked = true; } } if ($checked) { echo " <input type=\"RADIO\" name=\"grade[{$i}]\" value=\"{$j}\" checked=\"checked\" /> \n"; } else { echo " <input type=\"RADIO\" name=\"grade[{$i}]\" value=\"{$j}\" /> \n"; } } echo " <b>{$SCALE->end}</b></center>\n"; break; case 'selection': unset($numbers); for ($j = $SCALE->size; $j >= 0; $j--) { $numbers[$j] = $j; } if (isset($grades[$i]->grade)) { choose_from_menu($numbers, "grade[{$i}]", $grades[$i]->grade, ""); } else { choose_from_menu($numbers, "grade[{$i}]", 0, ""); } break; echo " </td>\n"; echo "</tr>\n"; } echo "<tr valign=\"top\">\n"; echo " <td align=\"right\"><p><b>" . get_string("feedback") . ":</b></p></td>\n"; echo " <td>\n"; if ($allowchanges) { echo " <textarea name=\"feedback[]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n"; if (isset($grades[$i]->feedback)) { echo $grades[$i]->feedback; } echo "</textarea>\n"; } else { echo text_to_html($grades[$i]->feedback); } echo " </td>\n"; echo "</tr>\n"; echo "<tr valign=\"top\">\n"; echo " <td colspan=\"2\"> </td>\n"; echo "</tr>\n"; } break; case 2: // error banded grading // now run through the elements $error = 0; for ($i = 0; $i < count($elements) - 1; $i++) { $iplus1 = $i + 1; echo "<tr valign=\"top\">\n"; echo " <td align=\"right\"><p><b>" . get_string("element", "exercise") . " {$iplus1}:</b></p></td>\n"; echo " <td>" . text_to_html($elements[$i]->description); echo "<p align=\"right\"><font size=\"1\">Weight: " . number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2) . "</font>\n"; echo "</td></tr>\n"; echo "<tr valign=\"top\">\n"; echo " <td align=\"right\"><p><b>" . get_string("grade") . ":</b></p></td>\n"; echo " <td valign=\"top\">\n"; // get the appropriate scale - yes/no scale (0) $SCALE = (object) $EXERCISE_SCALES[0]; switch ($SCALE->type) { case 'radio': // show selections highest first echo "<center><b>{$SCALE->start}</b> "; for ($j = $SCALE->size - 1; $j >= 0; $j--) { $checked = false; if (isset($grades[$i]->grade)) { if ($j == $grades[$i]->grade) { $checked = true; } } else { // there's no previous grade so check the lowest option if ($j == 0) { $checked = true; } } if ($checked) { echo " <input type=\"RADIO\" name=\"grade[{$i}]\" value=\"{$j}\" checked=\"checked\" /> \n"; } else { echo " <input type=\"RADIO\" name=\"grade[{$i}]\" value=\"{$j}\" /> \n"; } } echo " <b>{$SCALE->end}</b></center>\n"; break; case 'selection': unset($numbers); for ($j = $SCALE->size; $j >= 0; $j--) { $numbers[$j] = $j; } if (isset($grades[$i]->grade)) { choose_from_menu($numbers, "grade[{$i}]", $grades[$i]->grade, ""); } else { choose_from_menu($numbers, "grade[{$i}]", 0, ""); } break; } echo " </td>\n"; echo "</tr>\n"; echo "<tr valign=\"top\">\n"; echo " <td align=\"right\"><p><b>" . get_string("feedback") . ":</b></p></td>\n"; echo " <td>\n"; if ($allowchanges) { echo " <textarea name=\"feedback[{$i}]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n"; if (isset($grades[$i]->feedback)) { echo $grades[$i]->feedback; } echo "</textarea>\n"; } else { if (isset($grades[$i]->feedback)) { echo text_to_html($grades[$i]->feedback); } } echo " </td>\n"; echo "</tr>\n"; echo "<tr valign=\"top\">\n"; echo " <td colspan=\"2\"> </td>\n"; echo "</tr>\n"; if (empty($grades[$i]->grade)) { $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; } } // print the number of negative elements // echo "<tr><td>".get_string("numberofnegativeitems", "exercise")."</td><td>$negativecount</td></tr>\n"; // echo "<tr valign=\"top\">\n"; // echo " <td colspan=\"2\"> </td>\n"; echo "</table></center>\n"; // now print the grade table echo "<p><center><b>" . get_string("gradetable", "exercise") . "</b></center>\n"; echo "<center><table cellpadding=\"5\" border=\"1\"><tr><td align=\"CENTER\">" . get_string("numberofnegativeresponses", "exercise"); echo "</td><td>" . get_string("suggestedgrade", "exercise") . "</td></tr>\n"; for ($i = 0; $i <= $exercise->nelements; $i++) { if ($i == intval($error + 0.5)) { echo "<tr><td align=\"CENTER\"><img src=\"{$CFG->pixpath}/t/right.gif\" alt=\"\" /> {$i}</td><td align=\"CENTER\">{$elements[$i]->maxscore}</td></tr>\n"; } else { echo "<tr><td align=\"CENTER\">{$i}</td><td align=\"CENTER\">{$elements[$i]->maxscore}</td></tr>\n"; } } echo "</table></center>\n"; echo "<p><center><table cellpadding=\"5\" border=\"1\"><tr><td align=\"right\"><b>" . get_string("optionaladjustment", "exercise") . "</b></td><td>\n"; unset($numbers); for ($j = 20; $j >= -20; $j--) { $numbers[$j] = $j; } if (isset($grades[$exercise->nelements]->grade)) { choose_from_menu($numbers, "grade[{$exercise->nelements}]", $grades[$exercise->nelements]->grade, ""); } else { choose_from_menu($numbers, "grade[{$exercise->nelements}]", 0, ""); } echo "</td></tr>\n"; break; case 3: // criteria grading echo "<tr valign=\"top\">\n"; echo " <td> </td>\n"; echo " <td><b>" . get_string("criterion", "exercise") . "</b></td>\n"; echo " <td><b>" . get_string("select") . "</b></td>\n"; echo " <td><b>" . get_string("suggestedgrade", "exercise") . "</b></td>\n"; // find which criteria has been selected (saved in the zero element), if any if (isset($grades[0]->grade)) { $selection = $grades[0]->grade; } else { $selection = 0; } // now run through the elements for ($i = 0; $i < count($elements); $i++) { $iplus1 = $i + 1; echo "<tr valign=\"top\">\n"; echo " <td>{$iplus1}</td><td>" . text_to_html($elements[$i]->description) . "</td>\n"; if ($selection == $i) { echo " <td align=\"center\"><input type=\"RADIO\" name=\"grade[0]\" value=\"{$i}\" checked=\"checked\" /></td>\n"; } else { echo " <td align=\"center\"><input type=\"RADIO\" name=\"grade[0]\" value=\"{$i}\" /></td>\n"; } echo "<td align=\"center\">{$elements[$i]->maxscore}</td></tr>\n"; } echo "</table></center>\n"; echo "<p><center><table cellpadding=\"5\" border=\"1\"><tr><td align=\"right\"><b>" . get_string("optionaladjustment", "exercise") . "</b></td><td>\n"; unset($numbers); for ($j = 20; $j >= -20; $j--) { $numbers[$j] = $j; } if (isset($grades[1]->grade)) { choose_from_menu($numbers, "grade[1]", $grades[1]->grade, ""); } else { choose_from_menu($numbers, "grade[1]", 0, ""); } echo "</td></tr>\n"; break; case 4: // rubric grading // now run through the elements... for ($i = 0; $i < count($elements); $i++) { $iplus1 = $i + 1; echo "<tr valign=\"top\">\n"; echo "<td align=\"right\"><b>" . get_string("element", "exercise") . " {$iplus1}:</b></td>\n"; echo "<td>" . text_to_html($elements[$i]->description) . "<p align=\"right\"><font size=\"1\">Weight: " . number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2) . "</font></td></tr>\n"; echo "<tr valign=\"top\">\n"; echo " <td align=\"center\"><b>" . get_string("select") . "</b></td>\n"; echo " <td><b>" . get_string("criterion", "exercise") . "</b></td></tr>\n"; if (isset($grades[$i])) { $selection = $grades[$i]->grade; } else { $selection = 0; } // ...and the rubrics if ($rubricsraw = get_records_select("exercise_rubrics", "exerciseid = {$exercise->id} AND \n elementno = {$i}", "rubricno ASC")) { unset($rubrics); foreach ($rubricsraw as $rubic) { $rubrics[] = $rubic; // to renumber index 0,1,2... } for ($j = 0; $j < 5; $j++) { if (empty($rubrics[$j]->description)) { break; // out of inner for loop } echo "<tr valign=\"top\">\n"; if ($selection == $j) { echo " <td align=\"center\"><input type=\"RADIO\" name=\"grade[{$i}]\" value=\"{$j}\" checked=\"checked\" /></td>\n"; } else { echo " <td align=\"center\"><input type=\"RADIO\" name=\"grade[{$i}]\" value=\"{$j}\" /></td>\n"; } echo "<td>" . text_to_html($rubrics[$j]->description) . "</td>\n"; } echo "<tr valign=\"top\">\n"; echo " <td align=\"right\"><p><b>" . get_string("feedback") . ":</b></p></td>\n"; echo " <td>\n"; if ($allowchanges) { echo " <textarea name=\"feedback[]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n"; if (isset($grades[$i]->feedback)) { echo $grades[$i]->feedback; } echo "</textarea>\n"; } else { echo text_to_html($grades[$i]->feedback); } echo " </td>\n"; echo "</tr>\n"; echo "<tr valign=\"top\">\n"; echo " <td colspan=\"2\"> </td>\n"; echo "</tr>\n"; } } break; } // end of outer switch // now get the general comment (present in all types) echo "<tr valign=\"top\">\n"; switch ($exercise->gradingstrategy) { case 0: case 1: case 4: // no grading, accumulative and rubic echo " <td align=\"right\"><p><b>" . get_string("generalcomment", "exercise") . ":</b></p></td>\n"; break; default: echo " <td align=\"right\"><p><b>" . get_string("reasonforadjustment", "exercise") . ":</b></p></td>\n"; } echo " <td>\n"; if ($allowchanges) { echo " <textarea name=\"generalcomment\" rows=\"5\" cols=\"75\" wrap=\"virtual\">\n"; if (isset($assessment->generalcomment)) { echo $assessment->generalcomment; } echo "</textarea>\n"; } else { if ($assessment) { if (isset($assessment->generalcomment)) { echo text_to_html($assessment->generalcomment); } } else { print_string("yourfeedbackgoeshere", "exercise"); } } echo " </td>\n"; echo "</tr>\n"; echo "<tr valign=\"top\">\n"; echo " <td colspan=\"2\"> </td>\n"; echo "</tr>\n"; // ...and close the table and show two buttons...to resubmit or not to resubmit echo "</table>\n"; echo "<br /><input type=\"button\" value=\"" . get_string("studentnotallowed", "exercise", $course->student) . "\" \n onclick=\"getElementById('assessmentform').submit();\" />\n"; echo "<input type=\"button\" value=\"" . get_string("studentallowedtoresubmit", "exercise", $course->student) . "\" \n onclick=\"getElementById('assessmentform').resubmit.value='1';getElementById('assessmentform').submit();\" />\n"; echo "</center></form>\n"; }
$ownassessment->gradinggrade = 0; } if ($submissions = exercise_get_user_submissions($exercise, $user)) { foreach ($submissions as $submission) { if ($assessments = exercise_get_assessments($submission)) { foreach ($assessments as $assessment) { // (normally there should only be one $gradinggrade = number_format($ownassessment->gradinggrade * $exercise->gradinggrade / 100.0, 1); $grade = number_format($assessment->grade * $exercise->grade / 100.0, 1); $overallgrade = number_format($assessment->grade * $exercise->grade / 100.0 + $ownassessment->gradinggrade * $exercise->gradinggrade / 100.0, 1); if ($submission->late) { $grade = "<font color=\"red\">(" . $grade . ")</font>"; $overallgrade = "<font color=\"red\">(" . $overallgrade . ")</font>"; } echo "<tr><td>" . fullname($user) . "</td>\n"; echo "<td>" . exercise_print_submission_title($exercise, $submission) . "</td>\n"; echo "<td align=\"center\">{$gradinggrade}</td>"; echo "<td align=\"center\">{$grade}</td>"; echo "<td align=\"center\">{$overallgrade}</td></tr>\n"; } } } } } echo "</table><br clear=\"all\" />\n"; if ($exercise->showleaguetable) { exercise_print_league_table($exercise); echo "<br />\n"; } echo get_string("maximumgrade") . ": {$exercise->grade}\n"; print_continue("view.php?id={$cm->id}");
print_simple_box_start("center"); $table->head = array(get_string("submission", "exercise"), get_string("submitted", "exercise"), get_string("assessed", "exercise"), get_string("grade")); $table->width = "100%"; $table->align = array("left", "left", "left", "center"); $table->size = array("*", "*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; foreach ($submissions as $submission) { if ($assessments = exercise_get_assessments($submission)) { // should only be one but we'll loop anyway foreach ($assessments as $assessment) { $table->data[] = array(exercise_print_submission_title($exercise, $submission), userdate($submission->timecreated), userdate($assessment->timecreated), "<a href=\"assessments.php?action=viewassessment&id={$cm->id}&aid={$assessment->id}\">" . $assessment->grade * $exercise->grade / 100.0 . "</a>"); } } else { // submission not yet assessed (by teacher) $table->data[] = array(exercise_print_submission_title($exercise, $submission), userdate($submission->timecreated), get_string("notassessedyet", "exercise"), 0); } } print_table($table); print_simple_box_end(); } else { print_heading(get_string("nosubmissions", "exercise")); } // always allow student to resubmit 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") . ":"); exercise_print_upload_form($exercise); } echo "<hr size=\"1\" noshade=\"noshade\" />";