if (!($assessment = exercise_get_submission_assessment($submission, $USER))) { if (!($submissions = exercise_get_user_submissions($exercise, $submissionowner))) { error("Assess resubmission: submission records not found"); } $lastone = ''; // just the last but one submission foreach ($submissions as $submission) { $prevsubmission = $lastone; $lastone = $submission; } // get the teacher's assessment of the student's previous submission if (!($prevassessment = exercise_get_submission_assessment($prevsubmission, $USER))) { error("Assess resubmission: Previous assessment record not found"); } // copy this assessment with comments... $assessment = exercise_copy_assessment($prevassessment, $submission, true); } print_heading(get_string("thisisaresubmission", "exercise", fullname($submissionowner))); // show assessment and allow changes exercise_print_assessment_form($exercise, $assessment, true, $_SERVER["HTTP_REFERER"]); } elseif ($action == 'assesssubmission') { if (empty($sid)) { error("exercise asssessments: assesssubmission called with no sid"); } if (!($submission = get_record("exercise_submissions", "id", $sid))) { error("Assess submission is misconfigured - no submission record!"); } // there can be an assessment record (for teacher submissions), if there isn't... if (!($assessment = exercise_get_submission_assessment($submission, $USER))) { $yearfromnow = time() + 365 * 86400; // ...create one and set timecreated way in the future, this is reset when record is updated
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"; }