From: rkingdon Date: Wed, 24 Dec 2003 14:43:24 +0000 (+0000) Subject: A new version (2003121000). Fixes to backup/restore. Addition of "late" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f43c849f7e596018cccf881344bb1d8fb7ed3be4;p=moodle.git A new version (2003121000). Fixes to backup/restore. Addition of "late" work and the reduction of the number of phases to 3 (from 4). --- diff --git a/mod/exercise/backuplib.php b/mod/exercise/backuplib.php index 0677ac92d3..78b894ddff 100644 --- a/mod/exercise/backuplib.php +++ b/mod/exercise/backuplib.php @@ -68,11 +68,7 @@ //Now we backup exercise elements $status = backup_exercise_elements($bf,$preferences,$exercise->id); //Now we backup any teacher submissions (these are an integral part of the exercise) - $status = backup_exercise_teacher_submissions($bf, $preferences, $exercise->id); - //if we've selected to backup users info, then execute backup_exercise_submisions - if ($preferences->mods["exercise"]->userinfo) { - $status = backup_exercise_student_submissions($bf,$preferences,$exercise->id); - } + $status = backup_exercise_submissions($bf, $preferences, $exercise->id); //End mod $status =fwrite ($bf,end_tag("MOD",3,true)); //we need to backup the teacher files (the exercise descriptions) @@ -152,8 +148,8 @@ return $status; } - //Backup exercise_teacher_submissions contents (executed from exercise_backup_mods) - function backup_exercise_teacher_submissions ($bf,$preferences,$exerciseid) { + //Backup exercise_submissions contents (executed from exercise_backup_mods) + function backup_exercise_submissions ($bf,$preferences,$exerciseid) { global $CFG; @@ -184,6 +180,32 @@ //End submission $status =fwrite ($bf,end_tag("SUBMISSION",5,true)); } + //if we've selected to backup users info, then backup the student submisions + if ($preferences->mods["exercise"]->userinfo) { + $exercise_submissions = get_records_select("exercise_submissions","exerciseid = $exerciseid + AND isexercise = 0"); + //If there is submissions + if ($exercise_submissions) { + //Iterate over each submission + foreach ($exercise_submissions as $submission) { + //Start submission + $status =fwrite ($bf,start_tag("SUBMISSION",5,true)); + //Print submission contents + fwrite ($bf,full_tag("ID",6,false,$submission->id)); + fwrite ($bf,full_tag("USERID",6,false,$submission->userid)); + fwrite ($bf,full_tag("TITLE",6,false,$submission->title)); + fwrite ($bf,full_tag("TIMECREATED",6,false,$submission->timecreated)); + fwrite ($bf,full_tag("RESUBMIT",6,false,$submission->resubmit)); + fwrite ($bf,full_tag("MAILED",6,false,$submission->mailed)); + fwrite ($bf,full_tag("ISEXERCISE",6,false,$submission->isexercise)); + fwrite ($bf,full_tag("LATE",6,false,$submission->late)); + //Now we backup any exercise assessments + $status = backup_exercise_assessments($bf,$preferences,$exerciseid,$submission->id); + //End submission + $status =fwrite ($bf,end_tag("SUBMISSION",5,true)); + } + } + } //Write end tag $status =fwrite ($bf,end_tag("SUBMISSIONS",4,true)); } @@ -197,32 +219,6 @@ $status = true; - $exercise_submissions = get_records_select("exercise_submissions","exerciseid = $exerciseid - AND isexercise = 0"); - //If there is submissions - if ($exercise_submissions) { - //Write start tag - $status =fwrite ($bf,start_tag("SUBMISSIONS",4,true)); - //Iterate over each submission - foreach ($exercise_submissions as $submission) { - //Start submission - $status =fwrite ($bf,start_tag("SUBMISSION",5,true)); - //Print submission contents - fwrite ($bf,full_tag("ID",6,false,$submission->id)); - fwrite ($bf,full_tag("USERID",6,false,$submission->userid)); - fwrite ($bf,full_tag("TITLE",6,false,$submission->title)); - fwrite ($bf,full_tag("TIMECREATED",6,false,$submission->timecreated)); - fwrite ($bf,full_tag("RESUBMIT",6,false,$submission->resubmit)); - fwrite ($bf,full_tag("MAILED",6,false,$submission->mailed)); - fwrite ($bf,full_tag("ISEXERCISE",6,false,$submission->isexercise)); - //Now we backup any exercise assessments - $status = backup_exercise_assessments($bf,$preferences,$exerciseid,$submission->id); - //End submission - $status =fwrite ($bf,end_tag("SUBMISSION",5,true)); - } - //Write end tag - $status =fwrite ($bf,end_tag("SUBMISSIONS",4,true)); - } return $status; } diff --git a/mod/exercise/db/mysql.php b/mod/exercise/db/mysql.php index fb4e300090..954aab1e30 100644 --- a/mod/exercise/db/mysql.php +++ b/mod/exercise/db/mysql.php @@ -13,6 +13,10 @@ function exercise_upgrade($oldversion) { execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_assessments` ADD INDEX (`userid`)"); execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_grades` ADD INDEX (`assessmentid`)"); } + + if ($oldversion < 2003121000) { + execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_submissions` ADD `late` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0'"); + } return true; } diff --git a/mod/exercise/db/mysql.sql b/mod/exercise/db/mysql.sql index 943bfdc458..916109f4d9 100644 --- a/mod/exercise/db/mysql.sql +++ b/mod/exercise/db/mysql.sql @@ -35,6 +35,7 @@ CREATE TABLE `prefix_exercise_submissions` ( `resubmit` tinyint(3) unsigned NOT NULL default '0', `mailed` tinyint(3) unsigned NOT NULL default '0', `isexercise` tinyint(3) unsigned NOT NULL default '0', + `late` tinyint(3) unsigned NOT NULL default '0', PRIMARY KEY (`id`), INDEX `userid` (`userid`) ) COMMENT='Info about submitted work from teacher and students'; diff --git a/mod/exercise/index.php b/mod/exercise/index.php index f3fe7e1bc4..eb0757b2cb 100644 --- a/mod/exercise/index.php +++ b/mod/exercise/index.php @@ -56,19 +56,24 @@ } foreach ($exercises as $exercise) { + if ($exercise->deadline > $timenow) { + $due = userdate($exercise->deadline); + } else { + $due = "".userdate($exercise->deadline).""; + } if ($submissions = exercise_get_user_submissions($exercise, $USER)) { foreach ($submissions as $submission) { - if ($submission->timecreated <= $exercise->deadline) { - $submitted = userdate($submission->timecreated); + if ($submission->late) { + $submitted = "".userdate($submission->timecreated).""; } else { - $submitted = "".userdate($submission->timecreated).""; + $submitted = userdate($submission->timecreated); } - $due = userdate($exercise->deadline); $link = "coursemodule\">$exercise->name"; $title = $submission->title; if ($course->format == "weeks" or $course->format == "topics") { if (isteacher($course->id)) { + $phase = ''; switch ($exercise->phase) { case 1: $phase = get_string("phase1short", "exercise"); break; @@ -76,8 +81,6 @@ break; case 3: $phase = get_string("phase3short", "exercise"); break; - case 4: $phase = get_string("phase4short", "exercise"); - break; } $table->data[] = array ($exercise->section, $link, $title, $phase, $submitted, $due); @@ -97,9 +100,13 @@ } } if ($assessed) { - $actualgrade = $grade * $exercise->grade / 100.0; + $actualgrade = number_format($grade * $exercise->grade / 100.0, 1); + if ($submission->late) { + $actualgrade = "(".$actualgrade.")"; + } else { + } $table->data[] = array ($exercise->section, $link, $title, - number_format($actualgrade, 1), $submitted, $due); + $actualgrade, $submitted, $due); } else { $table->data[] = array ($exercise->section, $link, $title, "-", $submitted, $due); @@ -114,7 +121,6 @@ else { $submitted = get_string("no"); $title = ''; - $due = userdate($exercise->deadline); $link = "coursemodule\">$exercise->name"; if ($course->format == "weeks" or $course->format == "topics") { if (isteacher($course->id)) { diff --git a/mod/exercise/lib.php b/mod/exercise/lib.php index f38da93aba..488e7847fd 100644 --- a/mod/exercise/lib.php +++ b/mod/exercise/lib.php @@ -650,7 +650,7 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission function exercise_print_feedback($course, $submission) { function exercise_print_league_table($exercise) { function exercise_print_submission_assessments($exercise, $submission, $type) { -function exercise_print_submission_title($exercise, $user) { +function exercise_print_submission_title($exercise, $submission) { function exercise_print_tabbed_table($table) { function exercise_print_teacher_table($course) { function exercise_print_time_to_deadline($time) { @@ -1055,6 +1055,7 @@ function exercise_get_best_submission_grades($exercise) { WHERE u.course = $exercise->course AND s.userid = u.userid AND s.exerciseid = $exercise->id + AND s.late = 0 AND a.submissionid = s.id GROUP BY u.userid"); } @@ -1104,6 +1105,7 @@ function exercise_get_mean_submission_grades($exercise) { WHERE u.course = $exercise->course AND s.userid = u.userid AND s.exerciseid = $exercise->id + AND s.late = 0 AND a.submissionid = s.id AND a.timecreated < $timenow GROUP BY u.userid"); @@ -1351,97 +1353,99 @@ function exercise_list_submissions_for_admin($exercise) { } exercise_print_assignment_info($exercise); - - print_heading_with_help(get_string("administration"), "administration", "exercise"); + print_heading_with_help(get_string("administration"), "administration", "exercise"); echo"

id\">". - get_string("teacherassessmenttable", "exercise", $course->teacher)."

\n"; - - ?> -
- - -
- 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"; - - ?> -
- - -
- teacher)."

\n"; + + + if (isteacheredit($course->id)) { + ?> + + + +
+ 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; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
cellheading2\">". - get_string("leaguetable", "exercise")."
".get_string("numberofentries", "exercise").":"; - $numbers[22] = 'All'; - $numbers[21] = 50; - for ($i=20; $i>=0; $i--) { - $numbers[$i] = $i; - } - $nentries = $exercise->showleaguetable; - if ($nentries == 99) { - $nentries = 'All'; + 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); + } } - choose_from_menu($numbers, "nentries", "$nentries", ""); - 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 "
"; - 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... @@ -1530,15 +1534,23 @@ function exercise_list_submissions_for_admin($exercise) { $action .= " | id&sid=$submission->id\">". get_string("view", "exercise")." ($nassessments)"; } + if ($submission->late) { + $action .= " | id&sid=$submission->id\">". + get_string("clearlateflag", "exercise").""; + } $action .= " | id&sid=$submission->id\">". get_string("delete", "exercise").""; $title = $submission->title; if ($submission->resubmit) { $title .= "*"; } + $datesubmitted = userdate($submission->timecreated); + if ($submission->late) { + $datesubmitted = "".$datesubmitted.""; + } $table->data[] = array("$user->firstname $user->lastname", $title. " ".exercise_print_submission_assessments($exercise, $submission), - userdate($submission->timecreated), $action); + $datesubmitted, $action); $nsubmissions++; } } @@ -1549,7 +1561,8 @@ function exercise_list_submissions_for_admin($exercise) { print_table($table); echo "

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

\n"; } - echo "

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

\n"; + echo "

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

\n"; } } @@ -1606,7 +1619,7 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false) 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"); } @@ -1614,42 +1627,27 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false) $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... + // get any assessment this user has done (could include hot one) + if (!$assessment = get_record_select("exercise_assessments", "exerciseid = $exercise->id + AND userid = $user->id")) { + // the user has not yet assessed this exercise, set up a hot assessment record for this user for one + // of 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 + mt_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; - } + $nassessments[$submission->id] = $n + mt_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... + foreach ($nassessments as $submissionid => $n) { // break out of loop after the first element $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 + // ...create one and set timecreated way in the future, reset when record is updated $assessment->exerciseid = $exercise->id; $assessment->submissionid = $submission->id; $assessment->userid = $user->id; @@ -1657,46 +1655,66 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false) $assessment->timecreated = $yearfromnow; if (!$assessment->id = insert_record("exercise_assessments", $assessment)) { error("Could not insert exercise assessment!"); - } - $nassessed++; - if ($nassessed >= $nexercises) { - break; - } } + break; } } } + } else { + // get hold of the teacher submission + if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) { + error("List teacher submissions: submission record not found"); + } + } + print_simple_box_start("center"); + print_heading_with_help(get_string("theexercise", "exercise"), "junk", "exercise"); + print_simple_box_start("center"); + echo "

".get_string("description", "exercise").": \n"; + echo exercise_print_submission_title($exercise, $submission); + echo "

\n"; + print_simple_box_end(); + print_simple_box_end(); + + $table->head = array (get_string("action", "exercise"), get_string("assessed", "exercise"), + get_string("comment", "exercise")); + $table->align = array ("LEFT", "LEFT", "LEFT"); + $table->size = array ("*", "*", "*"); + $table->cellpadding = 2; + $table->cellspacing = 0; + // now list user's assessments (but only list those which come from teacher submissions) + print_heading(get_string("yourassessment", "exercise")); 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 + 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) + // 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... + } + 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) { @@ -1705,19 +1723,18 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false) 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); } + $table->data[] = array($action, $assessmentdate, $comment); } } - print_table($table); - } + print_table($table); + } +} /////////////////////////////////////////////////////////////////////////////////////////////// @@ -1772,21 +1789,24 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { $studentassessment = $assessment; break; // there should only be one! } + $timegap = get_string("ago", "exercise", format_time($submission->timecreated - + $timenow)); + if ($submission->late) { + $timegap = "".$timegap.""; + } 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); + $timegap, $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); + $timegap, $action, $comment); } } else { // there's no student assessment, odd!! @@ -1817,9 +1837,14 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { // last chance salon $action = "id&sid=$submission->id\">". get_string("edit", "exercise").""; + $timegap = get_string("ago", "exercise", format_time($submission->timecreated - + $timenow)); + if ($submission->late) { + $timegap = "".$timegap.""; + } $table->data[] = array(exercise_print_submission_title($exercise, $submission), $submissionowner->firstname." ".$submissionowner->lastname, - format_time($submission->timecreated - $timenow), $action, $comment); + $timegap, $action, $comment); } if (!$teacherassessed) { // no teacher's assessment @@ -1849,10 +1874,14 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { } $action = "id&sid=$submission->id\">". get_string("assess", "exercise").""; + $timegap = get_string("ago", "exercise", format_time($submission->timecreated - + $timenow)); + if ($submission->late) { + $timegap = "".$timegap.""; + } $table->data[] = array(exercise_print_submission_title($exercise, $submission), $submissionowner->firstname." ".$submissionowner->lastname, - get_string("ago", "exercise", format_time($submission->timecreated - $timenow)), - $action, $comment); + $timegap, $action, $comment); } } } @@ -1969,7 +1998,7 @@ function exercise_list_user_submissions($exercise, $user) { $timenow = time(); $table->head = array (get_string("title", "exercise"), get_string("action", "exercise"), - get_string("submitted", "assignment"), get_string("comment", "exercise")); + get_string("submitted", "exercise"), get_string("assessment", "exercise")); $table->align = array ("LEFT", "LEFT", "LEFT", "LEFT"); $table->size = array ("*", "*", "*", "*"); $table->cellpadding = 2; @@ -1979,14 +2008,11 @@ function exercise_list_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")) { @@ -1995,19 +2021,35 @@ function exercise_list_user_submissions($exercise, $user) { 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); } - } + $action .= "id&aid=$assessment->id\">". + get_string("viewassessment", "exercise").""; + if ($comment) { + $action .= " | "; + } + $grade = number_format($assessment->grade * $exercise->grade / 100.0, 1); + if ($submission->late) { + $comment .= get_string("grade"). + ": ($grade)"; + } else { + $comment .= get_string("grade").": $grade"; + } + } } - $table->data[] = array(exercise_print_submission_title($exercise, $submission), $action, - userdate($submission->timecreated), $comment); } - print_table($table); + if (!$comment and isstudent($course->id, $user->id)) { + $comment = get_string("awaitingassessmentbythe", "exercise", $course->teacher); + } + $submissiondate = userdate($submission->timecreated); + if ($submission->late) { + $submissiondate = "".$submissiondate.""; + } + $table->data[] = array(exercise_print_submission_title($exercise, $submission), $action, + $submissiondate, $comment); } + print_table($table); } +} /////////////////////////////////////////////////////////////////////////////////////////////// @@ -2142,14 +2184,14 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch // now print the form for ($i=0; $i < count($elements); $i++) { $iplus1 = $i+1; - echo "\n"; - echo "

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

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

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

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

". get_string("feedback").":

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

". get_string("feedback").":

\n"; echo " \n"; - if ($allowchanges) { + if ($allowchanges) { echo "