dirroot/files/mimetypes.php"); /*** Constants **********************************/ $EXERCISE_TYPE = array (0 => get_string("notgraded", "exercise"), 1 => get_string("accumulative", "exercise"), 2 => get_string("errorbanded", "exercise"), 3 => get_string("criterion", "exercise"), 4 => get_string("rubric", "exercise") ); $EXERCISE_SCALES = array( 0 => array( 'name' => get_string("scaleyes", "exercise"), 'type' => 'radio', 'size' => 2, 'start' => get_string("yes"), 'end' => get_string("no")), 1 => array( 'name' => get_string("scalepresent", "exercise"), 'type' => 'radio', 'size' => 2, 'start' => get_string("present", "exercise"), 'end' => get_string("absent", "exercise")), 2 => array( 'name' => get_string("scalecorrect", "exercise"), 'type' => 'radio', 'size' => 2, 'start' => get_string("correct", "exercise"), 'end' => get_string("incorrect", "exercise")), 3 => array( 'name' => get_string("scalegood3", "exercise"), 'type' => 'radio', 'size' => 3, 'start' => get_string("good", "exercise"), 'end' => get_string("poor", "exercise")), 4 => array( 'name' => get_string("scaleexcellent4", "exercise"), 'type' => 'radio', 'size' => 4, 'start' => get_string("excellent", "exercise"), 'end' => get_string("verypoor", "exercise")), 5 => array( 'name' => get_string("scaleexcellent5", "exercise"), 'type' => 'radio', 'size' => 5, 'start' => get_string("excellent", "exercise"), 'end' => get_string("verypoor", "exercise")), 6 => array( 'name' => get_string("scaleexcellent7", "exercise"), 'type' => 'radio', 'size' => 7, 'start' => get_string("excellent", "exercise"), 'end' => get_string("verypoor", "exercise")), 7 => array( 'name' => get_string("scale10", "exercise"), 'type' => 'selection', 'size' => 10), 8 => array( 'name' => get_string("scale20", "exercise"), 'type' => 'selection', 'size' => 20), 9 => array( 'name' => get_string("scale100", "exercise"), 'type' => 'selection', 'size' => 100)); $EXERCISE_EWEIGHTS = array( 0 => -4.0, 1 => -2.0, 2 => -1.5, 3 => -1.0, 4 => -0.75, 5 => -0.5, 6 => -0.25, 7 => 0.0, 8 => 0.25, 9 => 0.5, 10 => 0.75, 11=> 1.0, 12 => 1.5, 13=> 2.0, 14 => 4.0); $EXERCISE_FWEIGHTS = array( 0 => 0, 1 => 0.1, 2 => 0.25, 3 => 0.5, 4 => 0.75, 5 => 1.0, 6 => 1.5, 7 => 2.0, 8 => 3.0, 9 => 5.0, 10 => 7.5, 11=> 10.0); if (!defined("COMMENTSCALE")) { define("COMMENTSCALE", 20); } /*** Standard Moodle functions ****************** function exercise_add_instance($exercise) function exercise_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) { function exercise_cron () function exercise_delete_instance($id) function exercise_grades($exerciseid) function exercise_print_recent_activity(&$logs, $isteacher=false) function exercise_update_instance($exercise) function exercise_user_outline($course, $user, $mod, $exercise) function exercise_user_complete($course, $user, $mod, $exercise) **********************************************/ /*******************************************************************/ function exercise_add_instance($exercise) { // Given an object containing all the necessary data, // (defined by the form in mod.html) this function // will create a new instance and return the id number // of the new instance. $exercise->timemodified = time(); $exercise->deadline = make_timestamp($exercise->deadlineyear, $exercise->deadlinemonth, $exercise->deadlineday, $exercise->deadlinehour, $exercise->deadlineminute); return insert_record("exercise", $exercise); } /*******************************************************************/ function exercise_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) { /// Given an array of value, creates a popup menu to be part of a form /// $options["value"]["label"] if ($nothing == "choose") { $nothing = get_string("choose")."..."; } if ($script) { $javascript = "onChange=\"$script\""; } else { $javascript = ""; } $output = "
id); $gradingweight = get_field("exercise","gradingweight", "id", $exercise->id); // now show the weights used in the grades echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
cellheading2\" align=\"center\">". get_string("weightsusedforoverallgrade", "exercise")."
".get_string("weightforgradingofassessments", "exercise").":"; exercise_choose_from_menu($EXERCISE_FWEIGHTS, "gradingweight", $gradingweight, ""); echo "
".get_string("weightforteacherassessments", "exercise", $course->teacher).":"; exercise_choose_from_menu($EXERCISE_FWEIGHTS, "teacherweight", $teacherweight, ""); echo "
"; echo "\n"; echo "
\n"; echo "

"; echo "\n"; ?>
\n"; echo "cellheading2\">". get_string("leaguetable", "exercise")."\n"; echo "".get_string("numberofentries", "exercise").":\n"; echo ""; $numbers[22] = 'All'; $numbers[21] = 50; for ($i=20; $i>=0; $i--) { $numbers[$i] = $i; } $nentries = $exercise->showleaguetable; if ($nentries == 99) { $nentries = 'All'; } choose_from_menu($numbers, "nentries", "$nentries", ""); echo "\n"; echo "".get_string("hidenamesfromstudents", "exercise", $course->students)."\n"; $options[0] = get_string("no"); $options[1] = get_string("yes"); choose_from_menu($options, "anonymous", $exercise->anonymous, ""); echo "\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "
"; echo "
\n"; // list any teacher submissions $table->head = array (get_string("title", "exercise"), get_string("submitted", "exercise"), get_string("action", "exercise")); $table->align = array ("left", "left", "left"); $table->size = array ("*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; if ($submissions = exercise_get_teacher_submissions($exercise)) { foreach ($submissions as $submission) { $action = "id&sid=$submission->id\">". get_string("amendtitle", "exercise").""; $action .= " | id&sid=$submission->id\">". get_string("delete", "exercise").""; $table->data[] = array(exercise_print_submission_title($exercise, $submission), userdate($submission->timecreated), $action); } print_heading(get_string("studentsubmissions", "exercise", $course->teacher), "center"); print_table($table); } // list student assessments // Get all the students... if ($users = get_course_students($course->id, "u.firstname, u.lastname")) { $timenow = time(); unset($table); $table->head = array(get_string("name"), get_string("title", "exercise"), get_string("assessed", "exercise"), get_string("action", "exercise")); $table->align = array ("left", "left", "left", "left"); $table->size = array ("*", "*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; $nassessments = 0; foreach ($users as $user) { if ($assessments = exercise_get_user_assessments($exercise, $user)) { $title =''; foreach ($assessments as $assessment) { if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) { error("exercise_list_submissions_for_admin: Submission record not found!"); } $title .= $submission->title; // test for allocated assesments which have not been done if ($assessment->timecreated < $timenow) { // show only warm or cold assessments $title .= " {".number_format($assessment->grade * $exercise->grade / 100.0, 0); if ($assessment->timegraded) { $title .= "/".number_format($assessment->gradinggrade * $exercise->grade / COMMENTSCALE, 0); } $title .= "} "; if ($realassessments = exercise_count_user_assessments_done($exercise, $user)) { $action = "id&userid=$user->id\">". get_string("view", "exercise").""; } else { $action =""; } $nassessments++; $table->data[] = array("$user->firstname $user->lastname", $title, userdate($assessment->timecreated), $action); } } } } if (isset($table->data)) { print_heading(get_string("studentassessments", "exercise", $course->student)." [$nassessments]"); print_table($table); echo "

".get_string("noteonstudentassessments", "exercise")."

\n"; } } // now the sudent submissions unset($table); if ($users) { $table->head = array (get_string("submittedby", "exercise"), get_string("title", "exercise"), get_string("submitted", "exercise"), get_string("action", "exercise")); $table->align = array ("left", "left", "left", "left"); $table->size = array ("*", "*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; $nsubmissions = 0; foreach ($users as $user) { if ($submissions = exercise_get_user_submissions($exercise, $user)) { foreach ($submissions as $submission) { $action = "id&sid=$submission->id\">". get_string("amendtitle", "exercise").""; // has teacher already assessed this submission if ($assessment = get_record_select("exercise_assessments", "submissionid = $submission->id AND userid = $USER->id")) { $curtime = time(); if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) { $action .= " | id&sid=$submission->id\">". get_string("reassess", "exercise").""; } else { // there's still time left to edit... $action .= " | id&sid=$submission->id\">". get_string("edit", "exercise").""; } } else { // user has not assessed this submission $action .= " | id&sid=$submission->id\">". get_string("assess", "exercise").""; } if ($nassessments = exercise_count_assessments($submission)) { $action .= " | id&sid=$submission->id\">". get_string("view", "exercise")." ($nassessments)"; } $action .= " | id&sid=$submission->id\">". get_string("delete", "exercise").""; $title = $submission->title; if ($submission->resubmit) { $title .= "*"; } $table->data[] = array("$user->firstname $user->lastname", $title. " ".exercise_print_submission_assessments($exercise, $submission), userdate($submission->timecreated), $action); $nsubmissions++; } } } print_heading(get_string("studentsubmissions", "exercise", $course->student)." [$nsubmissions]", "center"); print_table($table); echo "

".get_string("resubmitnote", "exercise", $course->student)."

\n"; echo "

".get_string("allgradeshaveamaximumof", "exercise", $exercise->grade)."

\n"; } } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_list_teacher_assessments($exercise, $user) { global $CFG; if (! $course = get_record("course", "id", $exercise->course)) { error("Course is misconfigured"); } $table->head = array (get_string("title", "exercise"), get_string("action", "exercise"), get_string("comment", "exercise")); $table->align = array ("LEFT", "LEFT", "LEFT"); $table->size = array ("*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; // get user's submissions if ($submissions = exercise_get_user_submissions($exercise, $user)) { foreach ($submissions as $submission) { // get the assessments if ($assessments = exercise_get_assessments($submission)) { foreach ($assessments as $assessment) { if (isteacher($exercise->course, $assessment->userid)) { // assessments by teachers only $action = "id&aid=$assessment->id\">". get_string("view", "exercise").""; // has teacher commented on teacher's assessment? shouldn't happen but leave test in if ($assessment->timegraded and ($timenow - $assessment->timegraded > $CFG->maxeditingtime)) { $comment = get_string("gradedbyteacher", "exercise", $course->teacher); } else { $comment = userdate($assessment->timecreated); } $table->data[] = array(exercise_print_submission_title($exercise, $submission), $action, $comment); } } } } } if (isset($table->data)) { print_table($table); } else { echo "
".get_string("noassessmentsdone", "exercise")."
\n"; } } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_list_teacher_submissions($exercise, $user, $reassess = false) { // always allow user to reassess if that flag is true global $CFG; 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"); } $strexercises = get_string("modulenameplural", "exercise"); $strexercise = get_string("modulename", "exercise"); $nexercises = 1; // set as a variable (possible future extension) if ($nexercises ==1 ) { $table->head = array ($strexercise, get_string("action", "exercise"), get_string("assessed", "exercise"), get_string("comment", "exercise")); } else { //use plural $table->head = array ($strexercises, get_string("action", "exercise"), get_string("assessed", "exercise"), get_string("comment", "exercise")); } $table->align = array ("LEFT", "LEFT", "LEFT", "LEFT"); $table->size = array ("*", "*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; // get the number of assessments this user has done (could include placeholder one) $nassessed = count_records_select("exercise_assessments", "exerciseid = $exercise->id AND userid = $user->id"); if ($nassessed < $nexercises) { // if user has not assessed enough, set up "future" assessment records for this user for the teacher submissions... // ... first count the number of assessments for each teacher submission... if ($submissions = exercise_get_teacher_submissions($exercise)) { srand ((float)microtime()*1000000); // initialise random number generator foreach ($submissions as $submission) { $n = count_records("exercise_assessments", "submissionid", $submission->id); // ...OK to have zero, we add a small random number to randomise things... $nassessments[$submission->id] = $n + rand(0, 99) / 100; } // ...put the submissions with the lowest number of assessments first... asort($nassessments); reset($nassessments); foreach ($nassessments as $submissionid => $n) { // break out of loop when we allocated enough assessments... $submission = get_record("exercise_submissions", "id", $submissionid); // ... provided the user has NOT already assessed that submission... 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 $assessment->exerciseid = $exercise->id; $assessment->submissionid = $submission->id; $assessment->userid = $user->id; $assessment->grade = -1; // set impossible grade $assessment->timecreated = $yearfromnow; if (!$assessment->id = insert_record("exercise_assessments", $assessment)) { error("Could not insert exercise assessment!"); } $nassessed++; if ($nassessed >= $nexercises) { break; } } } } } // now list user's assessments (but only list those which come from teacher submissions) if ($assessments = exercise_get_user_assessments($exercise, $user)) { $timenow = time(); foreach ($assessments as $assessment) { if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) { error ("exercise_list_teacher_submissions: unable to get submission"); } // submission from a teacher, i.e an exercise submission? if ($submission->isexercise) { $comment = ''; if ($reassess) { //just show re-assess $action = "id&sid=$submission->id\">". get_string("reassess", "exercise").""; } else { // reassess is false - assessment is a "normal state" // user assessment has three states: record created but not assessed (date created in the future); // just assessed but still editable; and "static" (may or may not have been graded by teacher, that // is shown in the comment) if ($assessment->timecreated > $timenow) { // user needs to assess this submission $action = "id&sid=$submission->id\">". get_string("assess", "exercise").""; } elseif ($assessment->timecreated > ($timenow - $CFG->maxeditingtime)) { // there's still time left to edit... $action = "id&sid=$submission->id\">". get_string("edit", "exercise").""; } else { $action = "id&aid=$assessment->id\">" .get_string("view", "exercise").""; } } // show the date if in the past (otherwise the user hasn't done the assessment yet $assessmentdate = ''; if ($assessment->timecreated < $timenow) { $assessmentdate = userdate($assessment->timecreated); // if user has submitted work, see if teacher has graded assessment if (exercise_count_user_submissions($exercise, $user) > 0) { if ($assessment->timegraded and (($timenow - $assessment->timegraded) > $CFG->maxeditingtime)) { $comment .= get_string("thereisfeedbackfromthe", "exercise", $course->teacher); } else { $comment .= get_string("awaitingfeedbackfromthe", "exercise", $course->teacher); } } } $table->data[] = array(exercise_print_submission_title($exercise, $submission), $action, $assessmentdate, $comment); } } } print_table($table); } /////////////////////////////////////////////////////////////////////////////////////////////// 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 if ($submissions = exercise_get_student_submissions($exercise)) { 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! } if ($warm) { // last chance salon $action = "id&aid=$studentassessment->id&sid=$submission->id\">". get_string("edit", "exercise").""; $table->data[] = array(exercise_print_submission_title($exercise, $submission), $submissionowner->firstname." ".$submissionowner->lastname, get_string("ago", "exercise", format_time($submission->timecreated - $timenow)), $action, $comment); } else { $action = "id&aid=$studentassessment->id&sid=$submission->id\">". get_string("assess", "exercise").""; $table->data[] = array(exercise_print_submission_title($exercise, $submission), $submissionowner->firstname." ".$submissionowner->lastname, get_string("ago", "exercise", format_time($submission->timecreated - $timenow)), $action, $comment); } } else { // there's no student assessment, odd!! } } } // this is student's second... submission 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", "$teacher->firstname $teacher->lastname"); if ($assessment->timecreated > $timenow - $CFG->maxeditingtime) { $warm = true; } break; // no need to look further } } } if ($teacherassessed and $warm) { // last chance salon $action = "id&sid=$submission->id\">". get_string("edit", "exercise").""; $table->data[] = array(exercise_print_submission_title($exercise, $submission), $submissionowner->firstname." ".$submissionowner->lastname, format_time($submission->timecreated - $timenow), $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", "$teacher->firstname $teacher->lastname"); break; // no need to look further } } } $action = "id&sid=$submission->id\">". get_string("assess", "exercise").""; $table->data[] = array(exercise_print_submission_title($exercise, $submission), $submissionowner->firstname." ".$submissionowner->lastname, get_string("ago", "exercise", format_time($submission->timecreated - $timenow)), $action, $comment); } } } } if (isset($table->data)) { print_table($table); } } } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_list_unassessed_teacher_submissions($exercise, $user) { // list the teacher submissions not assessed by this user global $CFG; $table->head = array (get_string("title", "exercise"), get_string("action", "exercise"), get_string("comment", "exercise")); $table->align = array ("LEFT", "LEFT", "LEFT"); $table->size = array ("*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; if ($submissions = exercise_get_teacher_submissions($exercise)) { foreach ($submissions as $submission) { $comment = ""; // see if user already graded this assessment if ($assessment = get_record_select("exercise_assessments", "submissionid = $submission->id AND userid = $user->id")) { $timenow = time(); if (($timenow - $assessment->timecreated < $CFG->maxeditingtime)) { // last chance salon $action = "id&sid=$submission->id\">". get_string("edit", "exercise").""; $table->data[] = array(exercise_print_submission_title($exercise, $submission), $action, $comment); } } else { // no assessment $action = "id&sid=$submission->id\">". get_string("assess", "exercise").""; $table->data[] = array(exercise_print_submission_title($exercise, $submission), $action, $comment); } } if (isset($table->data)) { print_table($table); } } } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_list_ungraded_assessments($exercise, $stype) { global $CFG; 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"); } // lists all the assessments of student submissions for grading by teacher $table->head = array (get_string("title", "exercise"), get_string("submittedby", "exercise"), get_string("assessor", "exercise"), get_string("timeassessed", "exercise"), get_string("action", "exercise")); $table->align = array ("LEFT", "LEFT", "LEFT", "LEFT"); $table->size = array ("*", "*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; $timenow = time(); switch ($stype) { case "student" : $assessments = exercise_get_ungraded_assessments_student($exercise); break; case "teacher" : $assessments = exercise_get_ungraded_assessments_teacher($exercise); break; } if ($assessments) { foreach ($assessments as $assessment) { if (!isteacher($exercise->course, $assessment->userid)) { // don't let teacher grade their own assessments if (($timenow - $assessment->timegraded) < $CFG->maxeditingtime) { $action = "id&stype=$stype&aid=$assessment->id\">". get_string("edit", "exercise").""; } else { $action = "id&stype=$stype&aid=$assessment->id\">". get_string("grade", "exercise").""; } $submission = get_record("exercise_submissions", "id", $assessment->submissionid); $submissionowner = get_record("user", "id", $submission->userid); $assessor = get_record("user", "id", $assessment->userid); $table->data[] = array(exercise_print_submission_title($exercise, $submission), $submissionowner->firstname." ".$submissionowner->lastname, $assessor->firstname." ".$assessor->lastname, userdate($assessment->timecreated), $action); } } if (isset($table->data)) { print_table($table); } } } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_list_user_submissions($exercise, $user) { global $CFG; 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(); $table->head = array (get_string("title", "exercise"), get_string("action", "exercise"), get_string("submitted", "assignment"), get_string("comment", "exercise")); $table->align = array ("LEFT", "LEFT", "LEFT", "LEFT"); $table->size = array ("*", "*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; if ($submissions = exercise_get_user_submissions($exercise, $user)) { foreach ($submissions as $submission) { $action = ''; $comment = ''; if (isstudent($course->id, $user->id)) { $comment = get_string("awaitingassessmentbythe", "exercise", $course->teacher); } // allow user to delete submission if it's warm if ($submission->timecreated > $timenow - $CFG->maxeditingtime) { $action = "id&sid=$submission->id\">". get_string("delete", "exercise").""; } // get the teacher assessments (could be more than one, if unlikely, when multiple teachers) if ($assessments = get_records_select("exercise_assessments", "exerciseid = $exercise->id AND submissionid = $submission->id")) { foreach ($assessments as $assessment) { // make sure it's real if ($assessment->timecreated < $timenow - $CFG->maxeditingtime) { // it's cold if ($action) { $action .= " | "; } $action .= "id&aid=$assessment->id\">". get_string("viewassessment", "exercise")."";; $comment = get_string("assessmentmadebythe", "exercise", $course->teacher); } } } $table->data[] = array(exercise_print_submission_title($exercise, $submission), $action, userdate($submission->timecreated), $comment); } print_table($table); } } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_assessment_form($exercise, $assessment = false, $allowchanges = false, $returnto = '') { // prints several variants of the assessment form global $CFG, $THEME, $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 ($assessment) { if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) { error ("exercise_print_assessment_form: Submission record not found"); } // test if this assessment is from a teacher or student. // Teacher's assessments are more complicated as we need to go back a couple of steps // to find the exercise. Student's assessments are directly associated with an exercise. if (isteacher($course->id, $assessment->userid)) { // A teacher's assessment, requires getting the student's assessment(s) // and finding which of those assessments which comes from a teacher submission, // that is the exercise $exercisefound = false; if (!$submissionowner = get_record("user", "id", $submission->userid)) { error ("exercise_print_assessment_form: User record not found"); } if ($initialassessments = exercise_get_user_assessments($exercise, $submissionowner)) { // should only be one but we'll loop anyway foreach($initialassessments as $initialassessment) { if (!$teachersubmission = get_record("exercise_submissions", "id", $initialassessment->submissionid)) { error ("exercise_print_assessment_form: Teacher Submission record not found"); } if ($teachersubmission->isexercise) { $exercisefound = true; break; } } } if ($exercisefound) { print_heading(get_string("theexerciseandthesubmissionby", "exercise", "$submissionowner->firstname $submissionowner->lastname")); echo "
cellcontent\">\n"; echo exercise_print_submission_title($exercise, $teachersubmission); echo "

\n"; } } else { // it's a student assessment, print instructions if it's their own assessment if ($assessment->userid == $USER->id) { print_heading_with_help(get_string("pleaseusethisform", "exercise"), "grading", "exercise"); } } echo "
cellcontent\">\n"; echo exercise_print_submission_title($exercise, $submission); echo "

\n"; // only show the grade if grading strategy > 0 and the grade is positive if ($exercise->gradingstrategy and $assessment->grade >= 0) { echo "
".get_string("thegradeis", "exercise").": ". number_format($assessment->grade * $exercise->grade / 100.0, 2)." (". get_string("maximumgrade")." ".number_format($exercise->grade, 0).")

\n"; } } // now print the grading form with the teacher's comments if any // FORM is needed for Mozilla browsers, else radio bttons are not checked ?>
userid)) { error("Exercise_print_assessment_form: could not find user record"); } if ($assessmentowner->id == $USER->id) { $formtitle = get_string("yourassessment", "exercise"); } else { $formtitle = get_string("assessmentby", "exercise", "$assessmentowner->firstname $assessmentowner->lastname"); } } else { $formtitle = get_string("assessmentform", "exercise"); } echo "
\n"; echo "\n"; echo " \n"; echo "\n"; // get the assignment elements... if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) { print_string("noteonassignmentelements", "exercise"); } else { foreach ($elementsraw as $element) { $elements[] = $element; // to renumber index 0,1,2... } } if ($assessment) { // 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... } } } else { // setup dummy grades array for($i = 0; $i < count($elementsraw); $i++) { // gives a suitable sized loop $grades[$i]->feedback = get_string("yourfeedbackgoeshere", "exercise"); $grades[$i]->grade = 0; } } // 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 "\n"; echo " \n"; echo " \n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; } break; case 1: // accumulative grading // now print the form for ($i=0; $i < count($elements); $i++) { $iplus1 = $i+1; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; } echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\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 "\n"; echo " \n"; echo " \n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; if (empty($grades[$i]->grade)) { $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; } } // print the number of negative elements // echo "\n"; // echo "\n"; // echo " \n"; echo "
cellheading2\">
$formtitle

". get_string("element","exercise")." $iplus1:

".text_to_html($elements[$i]->description); echo "

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo text_to_html($grades[$i]->feedback); } echo "
cellheading2\"> 

". get_string("element","exercise")." $iplus1:

".text_to_html($elements[$i]->description); echo "

Weight: " .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."\n"; echo "

". get_string("grade"). ":

\n"; // get the appropriate scale $scalenumber=$elements[$i]->scale; $SCALE = (object)$EXERCISE_SCALES[$scalenumber]; switch ($SCALE->type) { case 'radio' : // show selections highest first echo "
$SCALE->start   "; 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 "    \n"; } else { echo "    \n"; } } echo "   $SCALE->end
\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 "

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo text_to_html($grades[$i]->feedback); } echo "
cellheading2\"> 

". get_string("element","exercise")." $iplus1:

".text_to_html($elements[$i]->description); echo "

Weight: " .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."\n"; echo "

". get_string("grade"). ":

\n"; // get the appropriate scale - yes/no scale (0) $SCALE = (object) $EXERCISE_SCALES[0]; switch ($SCALE->type) { case 'radio' : // show selections highest first echo "
$SCALE->start   "; 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 "    \n"; } else { echo "    \n"; } } echo "   $SCALE->end
\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 "

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { if (isset($grades[$i]->feedback)) { echo text_to_html($grades[$i]->feedback); } } echo " 
cellheading2\"> 
".get_string("numberofnegativeitems", "exercise")."$negativecount
cellheading2\"> 
\n"; // now print the grade table echo "

".get_string("gradetable","exercise")."
\n"; echo "
\n"; for ($i=0; $i<=$exercise->nelements; $i++) { if ($i == intval($error + 0.5)) { echo "\n"; } else { echo "\n"; } } echo "
". get_string("numberofnegativeresponses", "exercise"); echo "". get_string("suggestedgrade", "exercise")."
$i{$elements[$i]->maxscore}
$i{$elements[$i]->maxscore}
\n"; echo "

\n"; break; case 3: // criteria grading echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \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 "\n"; echo " \n"; if ($selection == $i) { echo " \n"; } else { echo " \n"; } echo "\n"; } echo "
". get_string("optionaladjustment", "exercise").":\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 "
cellheading2\"> cellheading2\">". get_string("criterion","exercise")."cellheading2\">".get_string("select", "exercise")."cellheading2\">".get_string("suggestedgrade", "exercise")."
$iplus1".text_to_html($elements[$i]->description)."{$elements[$i]->maxscore}
\n"; echo "

\n"; break; case 4: // rubric grading // now run through the elements... for ($i=0; $i < count($elements); $i++) { $iplus1 = $i+1; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \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 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 "\n"; if ($selection == $j) { echo " \n"; }else { echo " \n"; } echo "\n"; } echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; } } break; } // end of outer switch // now get the general comment (present in all types) echo "\n"; switch ($exercise->gradingstrategy) { case 0: case 1: case 4 : // no grading, accumulative and rubic echo " \n"; break; default : echo " \n"; } echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; $timenow = time(); // the teacher's comment on the assessment // always allow the teacher to change their comment and grade if it's not their assessment! if (isteacher($course->id) and ($assessment->userid != $USER->id)) { echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; } elseif ($assessment->timegraded and ($assessment->timegraded < ($timenow - $CFG->maxeditingtime))) { // now show the teacher's comment (but not the grade) to the student if available... echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } // ...and close the table, show buttons if needed... echo "
". get_string("optionaladjustment", "exercise")."\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 "
".get_string("element", "exercise")." $iplus1:".text_to_html($elements[$i]->description). "

Weight: " .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."

cellheading2\" align=\"center\">".get_string("select", "exercise")."cellheading2\">". get_string("criterion","exercise")."
".text_to_html($rubrics[$j]->description)."

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo text_to_html($grades[$i]->feedback); } echo "
cellheading2\"> 

". get_string("generalcomment", "exercise").":

". get_string("reasonforadjustment", "exercise").":

\n"; if ($allowchanges) { echo " \n"; } else { if ($assessment) { if (isset($assessment->generalcomment)) { echo text_to_html($assessment->generalcomment); } } else { print_string("yourfeedbackgoeshere", "exercise"); } } echo " 
cellheading2\"> 
".get_string("gradeforstudentsassessment", "exercise", $course->student). "\n"; // set up coment scale for ($i=COMMENTSCALE; $i>=0; $i--) { $num[$i] = $i; } choose_from_menu($num, "gradinggrade", $assessment->gradinggrade, ""); echo "

". get_string("teacherscomment", "exercise").":

\n"; echo "\n"; echo "

". get_string("teacherscomment", "exercise").":

\n"; echo text_to_html($assessment->teachercomment); echo " 
cellheading2\"> 

\n"; if ($assessment and $allowchanges) { if (isteacher($course->id)) { // ...show two buttons...to resubmit or not to resubmit echo "student)."\" onclick=\"document.assessmentform.submit();\">\n"; echo "student)."\" onclick=\"document.assessmentform.resubmit.value='1';document.assessmentform.submit();\">\n"; } else { // ... show save button echo "\n"; } } echo "
\n"; } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_assessments_by_user_for_admin($exercise, $user) { 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"); } if ($assessments =exercise_get_user_assessments($exercise, $user)) { foreach ($assessments as $assessment) { echo "

".get_string("assessmentby", "exercise", $user->firstname." ".$user->lastname)."

\n"; exercise_print_assessment_form($exercise, $assessment); echo "

id&aid=$assessment->id\">". get_string("delete", "exercise")."


\n"; } } } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_assessments_for_admin($exercise, $submission) { 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"); } if ($assessments =exercise_get_assessments($submission)) { foreach ($assessments as $assessment) { if (!$user = get_record("user", "id", $assessment->userid)) { error (" exercise_print_assessments_for_admin: unable to get user record"); } echo "

".get_string("assessmentby", "exercise", $user->firstname." ".$user->lastname)."

\n"; exercise_print_assessment_form($exercise, $assessment); echo "

id&aid=$assessment->id\">". get_string("delete", "exercise")."


\n"; } } } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_assignment_info($exercise) { 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"); } // print standard assignment heading $strdifference = format_time($exercise->deadline - time()); if (($exercise->deadline - time()) < 0) { $strdifference = "$strdifference"; } $strduedate = userdate($exercise->deadline)." ($strdifference)"; print_simple_box_start("center"); print_heading($exercise->name, "center"); print_simple_box_start("center"); echo "".get_string("duedate", "exercise").": $strduedate
"; echo "".get_string("maximumgrade").": $exercise->grade
"; echo "".get_string("handlingofmultiplesubmissions", "exercise").":"; if ($exercise->usemaximum) { echo get_string("usemaximum", "exercise")."
\n"; } else { echo get_string("usemean", "exercise")."
\n"; } echo "".get_string("detailsofassessment", "exercise").": id&action=displaygradingform\">". get_string("specimenassessmentform", "exercise")."
"; print_simple_box_end(); print_simple_box_end(); echo "
"; } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_difference($time) { if ($time < 0) { $timetext = get_string("late", "assignment", format_time($time)); return " ($timetext)"; } else { $timetext = get_string("early", "assignment", format_time($time)); return " ($timetext)"; } } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_dual_assessment_form($exercise, $assessment, $submission, $returnto = '') { // prints the user's assessment and a blank form for the user's submission (for teachers only) global $CFG, $THEME, $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 dual assessment form: User record not found"); } echo "
cellcontent\">\n"; if (!$teachersubmission = get_record("exercise_submissions", "id", $assessment->submissionid)) { error ("exercise_print_assessment_form: Submission record not found"); } echo exercise_print_submission_title($exercise, $teachersubmission); echo "

\n"; print_heading_with_help(get_string("pleasegradetheassessment", "exercise", "$submissionowner->firstname $submissionowner->lastname"), "gradinggrade", "exercise"); echo "
cellcontent\">\n"; echo exercise_print_submission_title($exercise, $submission); echo "

\n"; // only show the grade if grading strategy > 0 and the grade is positive if ($exercise->gradingstrategy and $assessment->grade >= 0) { echo "
".get_string("thegradeis", "exercise").": ". number_format($assessment->grade * $exercise->grade / 100.0, 2)." (". get_string("maximumgrade")." ".number_format($exercise->grade, 0).")

\n"; } // now print the student's assessment form with the teacher's comments if any // in this (first) form only allow teachers to change their comment and the grading grade // the other "active" elements in thie form are suffixed with "_0" to stop conflicts with the teacher's // assessment form $allowchanges = false; // FORM is needed for Mozilla browsers, else radio bttons are not checked ?>
userid)) { error("Exercise_print_dual_assessment_form: could not find user record"); } echo "
\n"; echo "\n"; echo " \n"; echo "\n"; // get the assignment elements... if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) { print_string("noteonassignmentelements", "exercise"); } else { foreach ($elementsraw as $element) { $elements[] = $element; // to renumber index 0,1,2... } } // 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 "\n"; echo " \n"; echo " \n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; } break; case 1: // accumulative grading // now print the form for ($i=0; $i < count($elements); $i++) { $iplus1 = $i+1; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; } echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\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 "\n"; echo " \n"; echo " \n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; if (empty($grades[$i]->grade)) { $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; } } // print the number of negative elements // echo "\n"; // echo "\n"; // echo " \n"; echo "
cellheading2\">
".get_string("assessmentby", "exercise", "$assessmentowner->firstname $assessmentowner->lastname")."

". get_string("element","exercise")." $iplus1:

".text_to_html($elements[$i]->description); echo "

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo text_to_html($grades[$i]->feedback); } echo "
cellheading2\"> 

". get_string("element","exercise")." $iplus1:

".text_to_html($elements[$i]->description); echo "

Weight: " .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."\n"; echo "

". get_string("grade"). ":

\n"; // get the appropriate scale $scalenumber=$elements[$i]->scale; $SCALE = (object)$EXERCISE_SCALES[$scalenumber]; switch ($SCALE->type) { case 'radio' : // show selections highest first echo "
$SCALE->start   "; 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 "    \n"; } else { echo "    \n"; } } echo "   $SCALE->end
\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, "grade2_0[$i]", $grades[$i]->grade, ""); } else { choose_from_menu($numbers, "grade2_0[$i]", 0, ""); } break; echo "

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo text_to_html($grades[$i]->feedback); } echo "
cellheading2\"> 

". get_string("element","exercise")." $iplus1:

".text_to_html($elements[$i]->description); echo "

Weight: " .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."\n"; echo "

". get_string("grade"). ":

\n"; // get the appropriate scale - yes/no scale (0) $SCALE = (object) $EXERCISE_SCALES[0]; switch ($SCALE->type) { case 'radio' : // show selections highest first echo "
$SCALE->start   "; 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 "    \n"; } else { echo "    \n"; } } echo "   $SCALE->end
\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_0[$i]", $grades[$i]->grade, ""); } else { choose_from_menu($numbers, "grade_0[$i]", 0, ""); } break; } echo "

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { if (isset($grades[$i]->feedback)) { echo text_to_html($grades[$i]->feedback); } } echo " 
cellheading2\"> 
".get_string("numberofnegativeitems", "exercise")."$negativecount
cellheading2\"> 
\n"; // now print the grade table echo "

".get_string("gradetable","exercise")."
\n"; echo "
\n"; for ($i=0; $i<=$exercise->nelements; $i++) { if ($i == intval($error + 0.5)) { echo "\n"; } else { echo "\n"; } } echo "
". get_string("numberofnegativeresponses", "exercise"); echo "". get_string("suggestedgrade", "exercise")."
$i{$elements[$i]->maxscore}
$i{$elements[$i]->maxscore}
\n"; echo "

\n"; break; case 3: // criteria grading echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \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 "\n"; echo " \n"; if ($selection == $i) { echo " \n"; } else { echo " \n"; } echo "\n"; } echo "
". get_string("optionaladjustment", "exercise")."\n"; unset($numbers); for ($j = 20; $j >= -20; $j--) { $numbers[$j] = $j; } if (isset($grades[$exercise->nelements]->grade)) { choose_from_menu($numbers, "grade_0[$exercise->nelements]", $grades[$exercise->nelements]->grade, ""); } else { choose_from_menu($numbers, "grade_0[$exercise->nelements]", 0, ""); } echo "
cellheading2\"> cellheading2\">". get_string("criterion","exercise")."cellheading2\">".get_string("select", "exercise")."cellheading2\">".get_string("suggestedgrade", "exercise")."
$iplus1".text_to_html($elements[$i]->description)."{$elements[$i]->maxscore}
\n"; echo "

\n"; break; case 4: // rubric grading // now run through the elements... for ($i=0; $i < count($elements); $i++) { $iplus1 = $i+1; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \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 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 "\n"; if ($selection == $j) { echo " \n"; }else { echo " \n"; } echo "\n"; } echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; } } break; } // end of outer switch // now get the general comment (present in all types) echo "\n"; switch ($exercise->gradingstrategy) { case 0: case 1: case 4 : // no grading, accumulative and rubic echo " \n"; break; default : echo " \n"; } echo " \n"; echo "\n"; // the teacher's comment on the assessment // always allow the teacher to change/add their comment and grade if it's not their assessment! if (isteacher($course->id) and ($assessment->userid != $USER->id)) { echo "\n"; echo " \n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; } elseif ($assessment->timegraded and (($timenow - $assessment->timegraded) > $CFG->maxeditingtime)) { // now show the teacher's comment (but not the grade) to the student if available... echo "\n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } // ...and close the table echo "
". get_string("optionaladjustment", "exercise")."\n"; unset($numbers); for ($j = 20; $j >= -20; $j--) { $numbers[$j] = $j; } if (isset($grades[1]->grade)) { choose_from_menu($numbers, "grade_0[1]", $grades[1]->grade, ""); } else { choose_from_menu($numbers, "grade[1]", 0, ""); } echo "
".get_string("element", "exercise")." $iplus1:".text_to_html($elements[$i]->description). "

Weight: " .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."

cellheading2\" align=\"center\">".get_string("select", "exercise")."cellheading2\">". get_string("criterion","exercise")."
".text_to_html($rubrics[$j]->description)."

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo text_to_html($grades[$i]->feedback); } echo "
cellheading2\"> 

". get_string("generalcomment", "exercise").":

". get_string("reasonforadjustment", "exercise").":

\n"; if ($allowchanges) { echo " \n"; } else { if ($assessment) { if (isset($assessment->generalcomment)) { echo text_to_html($assessment->generalcomment); } } else { print_string("yourfeedbackgoeshere", "exercise"); } } echo " 
cellheading2\" align=\"center\">". get_string("pleasegradetheassessment", "exercise", "$submissionowner->firstname $submissionowner->lastname"). "
".get_string("gradeforstudentsassessment", "exercise", $course->student). "\n"; // set up coment scale for ($i=COMMENTSCALE; $i>=0; $i--) { $num[$i] = $i; } choose_from_menu($num, "gradinggrade", $assessment->gradinggrade, ""); echo "

". get_string("teacherscomment", "exercise").":

\n"; echo "\n"; echo "
cellheading2\"> 

". get_string("teacherscomment", "exercise", $course->teacher).":

\n"; echo text_to_html($assessment->teachercomment); echo " 
cellheading2\"> 


\n"; // ****************************second form****************************************** // now print a normal assessment form based on the student's assessment for this submission // and allow the teacher to grade and add comments $studentassessment = $assessment; $allowchanges = true; print_heading_with_help(get_string("nowpleasemakeyourownassessment", "exercise", "$submissionowner->firstname $submissionowner->lastname"), "grading", "exercise"); // is there an existing assessment for the submission if (!$assessment = exercise_get_submission_assessment($submission, $USER)) { // copy student's assessment without the comments for the student's submission $assessment = exercise_copy_assessment($studentassessment, $submission); } // only show the grade if grading strategy > 0 and the grade is positive if ($exercise->gradingstrategy and $assessment->grade >= 0) { echo "
".get_string("thegradeis", "exercise").": ". number_format($assessment->grade * $exercise->grade / 100.0, 2)." (". get_string("maximumgrade")." ".number_format($exercise->grade, 0).")

\n"; } echo "
\n"; echo "\n"; echo " \n"; echo "\n"; unset($grades); // 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 "\n"; echo " \n"; echo " \n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; } break; case 1: // accumulative grading // now print the form for ($i=0; $i < count($elements); $i++) { $iplus1 = $i+1; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; } echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\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 "\n"; echo " \n"; echo " \n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; if (empty($grades[$i]->grade)) { $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; } } // print the number of negative elements // echo "\n"; // echo "\n"; // echo " \n"; echo "
cellheading2\">
".get_string("yourassessment", "exercise"). "

". get_string("element","exercise")." $iplus1:

".text_to_html($elements[$i]->description); echo "

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo text_to_html($grades[$i]->feedback); } echo "
cellheading2\"> 

". get_string("element","exercise")." $iplus1:

".text_to_html($elements[$i]->description); echo "

Weight: " .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."\n"; echo "

". get_string("grade"). ":

\n"; // get the appropriate scale $scalenumber=$elements[$i]->scale; $SCALE = (object)$EXERCISE_SCALES[$scalenumber]; switch ($SCALE->type) { case 'radio' : // show selections highest first echo "
$SCALE->start   "; 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 "    \n"; } else { echo "    \n"; } } echo "   $SCALE->end
\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 "

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo text_to_html($grades[$i]->feedback); } echo "
cellheading2\"> 

". get_string("element","exercise")." $iplus1:

".text_to_html($elements[$i]->description); echo "

Weight: " .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."\n"; echo "

". get_string("grade"). ":

\n"; // get the appropriate scale - yes/no scale (0) $SCALE = (object) $EXERCISE_SCALES[0]; switch ($SCALE->type) { case 'radio' : // show selections highest first echo "
$SCALE->start   "; 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 "    \n"; } else { echo "    \n"; } } echo "   $SCALE->end
\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 "

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { if (isset($grades[$i]->feedback)) { echo text_to_html($grades[$i]->feedback); } } echo " 
cellheading2\"> 
".get_string("numberofnegativeitems", "exercise")."$negativecount
cellheading2\"> 
\n"; // now print the grade table echo "

".get_string("gradetable","exercise")."
\n"; echo "
\n"; for ($i=0; $i<=$exercise->nelements; $i++) { if ($i == intval($error + 0.5)) { echo "\n"; } else { echo "\n"; } } echo "
". get_string("numberofnegativeresponses", "exercise"); echo "". get_string("suggestedgrade", "exercise")."
$i{$elements[$i]->maxscore}
$i{$elements[$i]->maxscore}
\n"; echo "

\n"; break; case 3: // criteria grading echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \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 "\n"; echo " \n"; if ($selection == $i) { echo " \n"; } else { echo " \n"; } echo "\n"; } echo "
". get_string("optionaladjustment", "exercise")."\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 "
cellheading2\"> cellheading2\">". get_string("criterion","exercise")."cellheading2\">".get_string("select", "exercise")."cellheading2\">".get_string("suggestedgrade", "exercise")."
$iplus1".text_to_html($elements[$i]->description)."{$elements[$i]->maxscore}
\n"; echo "

\n"; break; case 4: // rubric grading // now run through the elements... for ($i=0; $i < count($elements); $i++) { $iplus1 = $i+1; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \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 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 "\n"; if ($selection == $j) { echo " \n"; }else { echo " \n"; } echo "\n"; } echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; } } break; } // end of outer switch // now get the general comment (present in all types) echo "\n"; switch ($exercise->gradingstrategy) { case 0: case 1: case 4 : // no grading, accumulative and rubic echo " \n"; break; default : echo " \n"; } echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; // ...and close the table and show two buttons...to resubmit or not to resubmit echo "
". get_string("optionaladjustment", "exercise")."\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 "
".get_string("element", "exercise")." $iplus1:".text_to_html($elements[$i]->description). "

Weight: " .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."

cellheading2\" align=\"center\">".get_string("select", "exercise")."cellheading2\">". get_string("criterion","exercise")."
".text_to_html($rubrics[$j]->description)."

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo text_to_html($grades[$i]->feedback); } echo "
cellheading2\"> 

". get_string("generalcomment", "exercise").":

". get_string("reasonforadjustment", "exercise").":

\n"; if ($allowchanges) { echo " \n"; } else { if ($assessment) { if (isset($assessment->generalcomment)) { echo text_to_html($assessment->generalcomment); } } else { print_string("yourfeedbackgoeshere", "exercise"); } } echo " 
cellheading2\"> 
\n"; echo "
student)."\" onclick=\"document.assessmentform.submit();\">\n"; echo "student)."\" onclick=\"document.assessmentform.resubmit.value='1';document.assessmentform.submit();\">\n"; echo "
\n"; } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_feedback($course, $submission) { global $CFG, $THEME, $RATING; if (! $teacher = get_record("user", "id", $submission->teacher)) { error("Weird exercise error"); } echo "\n
"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "\n
body\" WIDTH=35 VALIGN=TOP>"; print_user_picture($teacher->id, $course->id, $teacher->picture); echo "cellheading\">$teacher->firstname $teacher->lastname"; echo "  ".userdate($submission->timemarked).""; echo "
cellcontent\">"; echo "

"; if ($submission->grade) { echo get_string("grade").": $submission->grade"; } else { echo get_string("nograde"); } echo "

"; echo text_to_html($submission->assessorcomment); echo "
"; echo "
"; } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_league_table($exercise) { // print an order table of (student) submissions in grade order, only print the student's best submission when // there are multiple submissions if (! $course = get_record("course", "id", $exercise->course)) { error("Print league table: Course is misconfigured"); } $nentries = $exercise->showleaguetable; if ($nentries == 99) { $nentries = 999999; // a large number } if ($exercise->anonymous and isstudent($course->id)) { $table->head = array (get_string("title", "exercise"), get_string("grade")); $table->align = array ("left", "center"); $table->size = array ("*", "*"); } else { // show names $table->head = array (get_string("title", "exercise"), get_string("name"), get_string("grade")); $table->align = array ("left", "left", "center"); $table->size = array ("*", "*", "*"); } $table->cellpadding = 2; $table->cellspacing = 0; if ($submissions = exercise_get_student_submissions($exercise, "grade")) { $n = 1; foreach ($submissions as $submission) { if (empty($done[$submission->userid])) { if (!$user = get_record("user", "id", $submission->userid)) { error("Print league table: user not found"); } if ($exercise->anonymous and isstudent($course->id)) { $table->data[] = array(exercise_print_submission_title($exercise, $submission), number_format($submission->grade * $exercise->grade / 100.0, 1)); } else { $table->data[] = array(exercise_print_submission_title($exercise, $submission), $user->firstname." ".$user->lastname, number_format($submission->grade * $exercise->grade / 100.0, 1)); } $n++; if ($n > $nentries) { break; } $done[$submission->userid] = 'ok'; } } print_heading(get_string("leaguetable", "exercise")); print_table($table); } } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_submission_assessments($exercise, $submission) { // Returns a list of grades for this submission 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"); } $str = ''; if ($assessments = exercise_get_assessments($submission)) { foreach ($assessments as $assessment) { if (isteacher($exercise->course, $assessment->userid)) { $str .= "[".number_format($assessment->grade * $exercise->grade / 100.0, 0)."] "; } else { // assessment by student - shouldn't happen! $str .= "{".number_format($assessment->grade * $exercise->grade / 100.0, 0)."} "; } } } if (!$str) { $str = " "; // be kind to Mozilla browsers! } return $str; } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_submission_title($exercise, $submission) { global $CFG; if (!$submission->timecreated) { // a "no submission" return $submission->title; } $filearea = exercise_file_area_name($exercise, $submission); if ($basedir = exercise_file_area($exercise, $submission)) { if (list($file) = get_directory_list($basedir)) { $icon = mimeinfo("icon", $file); if ($CFG->slasharguments) { $ffurl = "file.php/$filearea/$file"; } else { $ffurl = "file.php?file=/$filearea/$file"; } return "wwwroot/files/pix/$icon\" HEIGHT=16 WIDTH=16 BORDER=0 ALT=\"File\">". " wwwroot/$ffurl\">$submission->title"; } } } ////////////////////////////////////////////////////////////////////////////////////// function exercise_print_tabbed_heading($tabs) { // Prints a tabbed heading where one of the tabs highlighted. // $tabs is an object with several properties. // $tabs->names is an array of tab names // $tabs->urls is an array of links // $tabs->align is an array of column alignments (defaults to "center") // $tabs->size is an array of column sizes // $tabs->wrap is an array of "nowrap"s or nothing // $tabs->highlight is an index (zero based) of "active" heading . // $tabs->width is an percentage of the page (defualts to 80%) // $tabs->cellpadding padding on each cell (defaults to 5) global $CFG, $THEME; if (isset($tabs->names)) { foreach ($tabs->names as $key => $name) { if (!empty($tabs->urls[$key])) { $url =$tabs->urls[$key]; if ($tabs->highlight == $key) { $tabcontents[$key] = "$name"; } else { $tabcontents[$key] = "$name"; } } else { $tabcontents[$key] = "$name"; } } } if (empty($tabs->width)) { $tabs->width = "80%"; } if (empty($tabs->cellpadding)) { $tabs->cellpadding = "5"; } // print_simple_box_start("center", "$table->width", "#ffffff", 0); echo "cellpadding\" cellspacing=\"0\" class=\"generaltable\">\n"; if (!empty($tabs->names)) { echo ""; echo "\n"; foreach ($tabcontents as $key => $tab) { if (isset($align[$key])) { $alignment = "align=\"$align[$key]\""; } else { $alignment = "align=\"center\""; } if (isset($size[$key])) { $width = "width=\"$size[$key]\""; } else { $width = ""; } if (isset($wrap[$key])) { $wrapping = "no wrap"; } else { $wrapping = ""; } if ($key == $tabs->highlight) { echo "\n"; } else { echo "\n"; } echo "\n"; } echo "\n"; } else { echo "\n"; } // bottom stripe $ncells = count($tabs->names)*2 +1; $height = 2; echo "\n"; echo "
". "wwwroot/pix/spacer.gif\" alt=\"\">cellheading2\">$tabcellheading\">$tab". "wwwroot/pix/spacer.gif\" alt=\"\">
No names specified
cellheading2\">". "wwwroot/pix/spacer.gif\" alt=\"\">
\n"; // print_simple_box_end(); return true; } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_time_to_deadline($time) { if ($time < 0) { $timetext = get_string("afterdeadline", "exercise", format_time($time)); return " ($timetext)"; } else { $timetext = get_string("beforedeadline", "exercise", format_time($time)); return " ($timetext)"; } } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_teacher_table($course) { // print how many assessments each teacher has done in each exercise if (! $exercises = get_all_instances_in_course("exercise", $course)) { notice("There are no exercises", "../../course/view.php?id=$course->id"); die; } $timenow = time(); $table->head[] = ''; $table->align[] = 'left'; $table->size[] = '*'; $table->head[] = get_string("total"); $table->align[] = "center"; $table->size[] = "*"; foreach ($exercises as $exercise) { $table->head[] = $exercise->name; $table->align[] = "center"; $table->size[] = "*"; } $table->cellpadding = 2; $table->cellspacing = 0; if (!$teachers = get_course_teachers($course->id, "u.firstname, u.lastname")) { error("No teachers on this course!"); } for ($j = 0; $j < count($exercises); $j++) { $grand[$j] = 0; } $grandtotal = 0; foreach ($teachers as $teacher) { unset($n); $total = 0; $j = 0; foreach ($exercises as $exercise) { $i = exercise_count_assessments_by_teacher($exercise, $teacher); $n[] = $i; $total += $i; $grand[$j] += $i; $j++; } $grandtotal += $total; $table->data[] = array_merge(array("$teacher->firstname $teacher->lastname"), array($total), $n); } $table->data[] = array_merge(array(get_string("total")), array($grandtotal), $grand); print_heading(get_string("teacherassessmenttable", "exercise", $course->teacher)); print_table($table); } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_upload_form($exercise) { 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"); } echo "
"; echo "
"; echo " maxbytes\">"; echo " id\">"; echo "".get_string("title", "exercise").":

\n"; echo " "; echo " "; echo "
"; echo "
"; } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_user_assessments($exercise, $user) { // Returns the number of assessments and a hyperlinked list of grading grades for the assessments made by this user if ($assessments = exercise_get_user_assessments($exercise, $user)) { $n = count($assessments); $str = "$n ("; foreach ($assessments as $assessment) { if ($assessment->timegraded) { $gradingscaled = intval($assessment->gradinggrade * $exercise->grade / COMMENTSCALE); $str .= "id&aid=$assessment->id\">"; $str .= "$gradingscaled "; } else { $str .= "id&aid=$assessment->id\">"; $str .= "- "; } } $str .= ")"; } else { $str ="0"; } return $str; } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_test_for_resubmission($exercise, $user) { // see if any of the user's submissions have the resubmit flag set $result = false; if ($submissions = exercise_get_user_submissions($exercise, $user)) { foreach ($submissions as $submission) { if ($submission->resubmit) { $result =true; break; } } } return $result; } /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_test_user_assessments($exercise, $user) { // see if user has assessed one of teacher's exercises/submissions... global $CFG; $result = false; $timenow =time(); if ($submissions = exercise_get_teacher_submissions($exercise)) { foreach ($submissions as $submission) { if ($assessment = exercise_get_submission_assessment($submission, $user)) { // ...the date stamp on the assessment should be in the past if ($assessment->timecreated < $timenow) { $result = true; break; } } } } return $result; } ?>