From f43c849f7e596018cccf881344bb1d8fb7ed3be4 Mon Sep 17 00:00:00 2001
From: rkingdon
Date: Wed, 24 Dec 2003 14:43:24 +0000
Subject: [PATCH] A new version (2003121000). Fixes to backup/restore. Addition
of "late" work and the reduction of the number of phases to 3 (from 4).
---
mod/exercise/backuplib.php | 62 +++---
mod/exercise/db/mysql.php | 4 +
mod/exercise/db/mysql.sql | 1 +
mod/exercise/index.php | 24 ++-
mod/exercise/lib.php | 401 +++++++++++++++++++----------------
mod/exercise/restorelib.php | 8 +-
mod/exercise/submissions.php | 78 ++++++-
mod/exercise/upload.php | 7 +-
mod/exercise/version.php | 2 +-
mod/exercise/view.php | 161 +++++++-------
10 files changed, 426 insertions(+), 322 deletions(-)
diff --git a/mod/exercise/backuplib.php b/mod/exercise/backuplib.php
index 0677ac92d31..78b894ddff6 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 fb4e3000907..954aab1e30c 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 943bfdc458f..916109f4d92 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 f3fe7e1bc4d..eb0757b2cbd 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 f38da93aba3..488e7847fd2 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";
+ get_string("teacherassessmenttable", "exercise", $course->teacher)."
\n";
- ?>
- \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);
+ }
}
- $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...
@@ -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 " \n";
if (isset($grades[$i]->feedback)) {
echo $grades[$i]->feedback;
@@ -2158,11 +2200,11 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
}
else {
echo text_to_html($grades[$i]->feedback);
- }
- echo " \n";
- echo " \n";
- echo "\n";
- echo " cellheading2\"> \n";
+ }
+ echo " \n";
+ echo " \n";
+ echo "\n";
+ echo " cellheading2\"> \n";
echo " \n";
}
break;
@@ -2171,7 +2213,7 @@ 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 " \n";
echo " ". get_string("element","exercise")." $iplus1:
\n";
echo " ".text_to_html($elements[$i]->description);
echo "Weight: "
@@ -2225,10 +2267,10 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
echo "
\n";
echo " \n";
}
- echo "\n";
- echo " ". get_string("feedback").":
\n";
+ echo " \n";
+ echo " ". get_string("feedback").":
\n";
echo " \n";
- if ($allowchanges) {
+ if ($allowchanges) {
echo " \n";
if (isset($grades[$i]->feedback)) {
echo $grades[$i]->feedback;
@@ -2237,11 +2279,11 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
}
else {
echo text_to_html($grades[$i]->feedback);
- }
- echo " \n";
- echo " \n";
- echo "\n";
- echo " cellheading2\"> \n";
+ }
+ echo " \n";
+ echo " \n";
+ echo "\n";
+ echo " cellheading2\"> \n";
echo " \n";
}
break;
@@ -2606,10 +2648,10 @@ 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) {
@@ -2624,17 +2666,17 @@ function exercise_print_assignment_info($exercise) {
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 " ";
- }
+}
///////////////////////////////////////////////////////////////////////////////////////////////
@@ -3609,6 +3651,9 @@ function exercise_print_league_table($exercise) {
$n = 1;
foreach ($submissions as $submission) {
if (empty($done[$submission->userid])) {
+ if ($submission->late) {
+ continue;
+ }
if (!$user = get_record("user", "id", $submission->userid)) {
error("Print league table: user not found");
}
diff --git a/mod/exercise/restorelib.php b/mod/exercise/restorelib.php
index 53654f454c5..1bbd4eb511e 100644
--- a/mod/exercise/restorelib.php
+++ b/mod/exercise/restorelib.php
@@ -199,9 +199,8 @@
$status = true;
- //Get the submissions array
+ //Get the submissions array (teacher submissions)
$submissions = $info['MOD']['#']['SUBMISSIONS']['0']['#']['SUBMISSION'];
-
//Iterate over submissions
for($i = 0; $i < sizeof($submissions); $i++) {
$sub_info = $submissions[$i];
@@ -221,9 +220,10 @@
$submission->resubmit = backup_todb($sub_info['#']['RESUBMIT']['0']['#']);
$submission->mailed = backup_todb($sub_info['#']['MAILED']['0']['#']);
$submission->isexercise = backup_todb($sub_info['#']['ISEXERCISE']['0']['#']);
+ $submission->late = backup_todb($sub_info['#']['LATE']['0']['#']);
- //test if this is from teacher or we restoring student submissions
- if ($submission->isexercise or $restore->mods['exercise']->userinfo) {
+ // always save the exercise descriptions and optionally the student submissions
+ if ($submission->isexercise or $restore->mods["exercise"]->userinfo) {
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$olduserid);
if ($user) {
diff --git a/mod/exercise/submissions.php b/mod/exercise/submissions.php
index e19ec1ade65..39c4ff0776e 100644
--- a/mod/exercise/submissions.php
+++ b/mod/exercise/submissions.php
@@ -4,8 +4,10 @@
ACTIONS handled are:
adminamendtitle
+ adminclearlate
adminconfirmdelete
admindelete
+ adminlateflag
adminlist
displayfinalgrades (teachers only)
listforassessmentstudent
@@ -78,9 +80,9 @@
\n";
- echo " ". get_string("title", "exercise").":
\n";
- echo " \n";
+ echo " \n";
+ echo " ". get_string("title", "exercise").":
\n";
+ echo " \n";
echo " title\">\n";
echo " \n";
echo " \n";
@@ -89,6 +91,29 @@
}
+ /******************* admin clear late (flag) ************************************/
+ elseif ($action == 'adminclearlate' ) {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+ if (empty($_GET['sid'])) {
+ error("Admin clear late flag: submission id missing");
+ }
+
+ if (!$submission = get_record("exercise_submissions", "id", $_GET['sid'])) {
+ error("Admin clear late flag: can not get submission record");
+ }
+ if (set_field("exercise_submissions", "late", 0, "id", $_GET['sid'])) {
+ print_heading(get_string("clearlateflag", "exercise")." ".get_string("ok"));
+ }
+
+ add_to_log($course->id, "exercise", "late flag cleared", "view.php?id=$cm->id", "submission $submission->id");
+
+ print_continue("submissions.php?id=$cm->id&action=adminlist");
+ }
+
+
/******************* admin confirm delete ************************************/
elseif ($action == 'adminconfirmdelete' ) {
@@ -98,7 +123,15 @@
if (empty($_GET['sid'])) {
error("Admin confirm delete: submission id missing");
}
-
+ if (!$submission = get_record("exercise_submissions", "id", $_GET['sid'])) {
+ error("Admin delete: can not get submission record");
+ }
+
+ if (isteacher($course->id, $submission->userid)) {
+ if (!isteacheredit($course->id)) {
+ error("Only teacher with editing permissions can delete teacher submissions.");
+ }
+ }
notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("submission", "exercise")),
"submissions.php?action=admindelete&id=$cm->id&sid=$_GET[sid]", "submissions.php?id=$cm->id&action=adminlist");
}
@@ -138,6 +171,25 @@
}
+ /******************* admin (confirm) late flag ************************************/
+ elseif ($action == 'adminlateflag' ) {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+ if (empty($_GET['sid'])) {
+ error("Admin confirm late flag: submission id missing");
+ }
+ if (!$submission = get_record("exercise_submissions", "id", $_GET['sid'])) {
+ error("Admin confirm late flag: can not get submission record");
+ }
+
+ notice_yesno(get_string("clearlateflag","exercise")."?",
+ "submissions.php?action=adminclearlate&id=$cm->id&sid=$_GET[sid]",
+ "submissions.php?id=$cm->id&action=adminlist");
+ }
+
+
/******************* list all submissions ************************************/
elseif ($action == 'adminlist' ) {
@@ -209,15 +261,21 @@
foreach ($submissions as $submission) {
if ($assessments = exercise_get_assessments($submission)) {
foreach ($assessments as $assessment) { // (normally there should only be one
+ $grade = number_format($assessment->grade * $exercise->grade / 100.0, 1);
+ $overallgrade = number_format(((($assessment->grade *
+ $EXERCISE_FWEIGHTS[$teacherweight] / 100.0) +
+ ($ownassessment->gradinggrade * $EXERCISE_FWEIGHTS[$gradingweight]/
+ COMMENTSCALE )) * $exercise->grade) / ($EXERCISE_FWEIGHTS[$teacherweight] +
+ $EXERCISE_FWEIGHTS[$gradingweight]), 1);
+ if ($submission->late) {
+ $grade = "(".$grade.") ";
+ $overallgrade = "(".$overallgrade.") ";
+ }
echo "$user->firstname $user->lastname \n";
echo "".exercise_print_submission_title($exercise, $submission)." \n";
echo "".number_format($ownassessment->gradinggrade * $exercise->grade / COMMENTSCALE, 1)." ";
- echo "".number_format($assessment->grade * $exercise->grade / 100.0, 1)." ";
- echo "". number_format(((($assessment->grade * $EXERCISE_FWEIGHTS[$teacherweight]
- / 100.0) + ($ownassessment->gradinggrade * $EXERCISE_FWEIGHTS[$gradingweight]
- / COMMENTSCALE )) * $exercise->grade) /
- ($EXERCISE_FWEIGHTS[$teacherweight] + $EXERCISE_FWEIGHTS[$gradingweight]), 1).
- " \n";
+ echo "$grade ";
+ echo "$overallgrade \n";
}
}
}
diff --git a/mod/exercise/upload.php b/mod/exercise/upload.php
index df8810aeb2f..f2782b18aa7 100644
--- a/mod/exercise/upload.php
+++ b/mod/exercise/upload.php
@@ -64,13 +64,16 @@
if (isteacher($course->id)) {
// it's an exercise submission, flag it as such
$newsubmission->userid = 0;
- $newsubmission->isexercise = 1; // it'sa description of an exercise
+ $newsubmission->isexercise = 1; // it's a description of an exercise
}
else {
- $newsubmission->userid = $USER->id;
+ $newsubmission->userid = $USER->id;
}
$newsubmission->title = $title;
$newsubmission->timecreated = $timenow;
+ if ($timenow > $exercise->deadline) {
+ $newsubmission->late = 1;
+ }
if (!$newsubmission->id = insert_record("exercise_submissions", $newsubmission)) {
error("exercise upload: Failure to create new submission record!");
}
diff --git a/mod/exercise/version.php b/mod/exercise/version.php
index dc30cd5e6b5..1163c78d889 100644
--- a/mod/exercise/version.php
+++ b/mod/exercise/version.php
@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2003111400;
+$module->version = 2003121000;
$module->cron = 60;
?>
diff --git a/mod/exercise/view.php b/mod/exercise/view.php
index 7a8640c5346..c9d4e76e494 100644
--- a/mod/exercise/view.php
+++ b/mod/exercise/view.php
@@ -3,7 +3,6 @@
/*************************************************
ACTIONS handled are:
- closeexercise( for teachers)
displayfinalgrade (for students)
makeleaguetableavailable (for teachers)
notavailable (for students)
@@ -73,8 +72,7 @@
case 0 :
case 1 : $action = 'notavailable'; break;
case 2 : $action = 'studentsview'; break;
- case 3 : $action = 'showsubmissions'; break;
- case 4 : $action = 'displayfinalgrade';
+ case 3 : $action = 'displayfinalgrade';
}
}
else { // it's a guest, oh no!
@@ -82,22 +80,8 @@
}
- /************** close exercise for student assessments and submissions (phase 3) (for teachers)**/
- if ($action == 'closeexercise') {
-
- if (!isteacher($course->id)) {
- error("Only teachers can look at this page");
- }
-
- // move to phase 3
- set_field("exercise", "phase", 3, "id", "$exercise->id");
- add_to_log($course->id, "exercise", "close", "view.php?id=$cm->id", "$exercise->id");
- redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 3));
- }
-
-
/****************** display final grade (for students) ************************************/
- elseif ($action == 'displayfinalgrade' ) {
+ if ($action == 'displayfinalgrade' ) {
// get the final weights from the database
$teacherweight = get_field("exercise","teacherweight", "id", $exercise->id);
@@ -128,14 +112,19 @@
foreach ($submissions as $submission) {
if ($assessments = exercise_get_assessments($submission)) {
foreach ($assessments as $assessment) { // (normally there should only be one
+ $grade = number_format($assessment->grade * $exercise->grade / 100.0, 1);
+ $overallgrade = number_format(((($assessment->grade *
+ $EXERCISE_FWEIGHTS[$teacherweight] / 100.0) + ($ownassessment->gradinggrade *
+ $EXERCISE_FWEIGHTS[$gradingweight] / COMMENTSCALE )) * $exercise->grade) /
+ ($EXERCISE_FWEIGHTS[$teacherweight] + $EXERCISE_FWEIGHTS[$gradingweight]), 1);
+ if ($submission->late) {
+ $grade = "(".$grade.") ";
+ $overallgrade = "(".$overallgrade.") ";
+ }
echo "".exercise_print_submission_title($exercise, $submission)." \n";
echo "".number_format($ownassessment->gradinggrade * $exercise->grade / COMMENTSCALE, 1)." ";
- echo "".number_format($assessment->grade * $exercise->grade / 100.0, 1)." ";
- echo "". number_format(((($assessment->grade * $EXERCISE_FWEIGHTS[$teacherweight]
- / 100.0) + ($ownassessment->gradinggrade * $EXERCISE_FWEIGHTS[$gradingweight]
- / COMMENTSCALE )) * $exercise->grade) /
- ($EXERCISE_FWEIGHTS[$teacherweight] + $EXERCISE_FWEIGHTS[$gradingweight]), 1).
- " \n";
+ echo "$grade ";
+ echo "$overallgrade \n";
}
}
}
@@ -151,13 +140,13 @@
/****************** make final grades available (for teachers only)**************/
elseif ($action == 'makeleaguetableavailable') {
- if (!isteacher($course->id)) {
- error("Only teachers can look at this page");
+ if (!isteacheredit($course->id)) {
+ error("Only teachers with editing permissions can do this.");
}
- set_field("exercise", "phase", 4, "id", "$exercise->id");
+ set_field("exercise", "phase", 3, "id", "$exercise->id");
add_to_log($course->id, "exercise", "display", "view.php?id=$cm->id", "$exercise->id");
- redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 4));
+ redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 3));
}
@@ -170,8 +159,8 @@
/****************** open exercise for student assessments and submissions (phase 2) (for teachers)**/
elseif ($action == 'openexercise') {
- if (!isteacher($course->id)) {
- error("Only teachers can look at this page");
+ if (!isteacheredit($course->id)) {
+ error("Only teachers with editing permissions can do this.");
}
// move to phase 2, check that teacher has made enough submissions
@@ -190,7 +179,7 @@
elseif ($action == 'setupassignment') {
if (!isteacher($course->id)) {
- error("Only teachers can look at this page");
+ error("Only teachers with editing permissions can do this.");
}
set_field("exercise", "phase", 1, "id", "$exercise->id");
@@ -199,44 +188,6 @@
}
- /****************** student's view could be in 1 of 4 stages ***********************/
- elseif ($action == 'studentsview') {
- exercise_print_assignment_info($exercise);
- // in Stage 1 - the student must make an assessment (linked to the teacher's exercise/submission
- if (!exercise_test_user_assessments($exercise, $USER)) {
- print_heading(get_string("pleaseviewtheexercise", "exercise", $course->teacher));
- exercise_list_teacher_submissions($exercise, $USER);
- }
- // in stage 2? - submit own first attempt
- else {
- // show assessment the teacher's examples, there may be feedback from teacher
- if (exercise_count_user_submissions($exercise, $USER) == 0) {
- print_heading(get_string("atthisstageyou", "exercise", $course->teacher));
- exercise_list_teacher_submissions($exercise, $USER, true); // true = allow re-assessing
- // print upload form
- print_heading(get_string("pleasesubmityourwork", "exercise").":");
- exercise_print_upload_form($exercise);
- }
- // in stage 3? - awaiting grading of assessment and assessment of work by teacher,
- // may resubmit if allowed
- else {
- print_heading(get_string("yourassessment", "exercise"));
- exercise_list_teacher_submissions($exercise, $USER);
- echo " ";
- print_heading(get_string("yoursubmission", "exercise"));
- exercise_list_user_submissions($exercise, $USER);
- if (exercise_test_for_resubmission($exercise, $USER)) {
- // if resubmission requested print upload form
- echo " ";
- print_heading(get_string("pleasesubmityourwork", "exercise").":");
- exercise_print_upload_form($exercise);
- echo " ";
- }
- }
- }
- }
-
-
/****************** showsubmissions (for students, in phase 3)***********************/
elseif ($action == 'showsubmissions') {
exercise_print_assignment_info($exercise);
@@ -274,16 +225,60 @@
print_simple_box_end();
} else {
print_heading(get_string("nosubmissions", "exercise"));
+ }
+ // always allow student to resubmit
+ if (exercise_test_for_resubmission($exercise, $USER)) {
+ // if resubmission requested print upload form
+ echo " ";
+ print_heading(get_string("pleasesubmityourwork", "exercise").":");
+ exercise_print_upload_form($exercise);
}
echo " ";
}
+ /****************** student's view could be in 1 of 4 stages ***********************/
+ elseif ($action == 'studentsview') {
+ exercise_print_assignment_info($exercise);
+ // in Stage 1 - the student must make an assessment (linked to the teacher's exercise/submission
+ if (!exercise_test_user_assessments($exercise, $USER)) {
+ print_heading(get_string("pleaseviewtheexercise", "exercise", $course->teacher));
+ exercise_list_teacher_submissions($exercise, $USER);
+ }
+ // in stage 2? - submit own first attempt
+ else {
+ // show assessment the teacher's examples, there may be feedback from teacher
+ if (exercise_count_user_submissions($exercise, $USER) == 0) {
+ print_heading(get_string("atthisstageyou", "exercise", $course->teacher));
+ exercise_list_teacher_submissions($exercise, $USER, true); // true = allow re-assessing
+ // print upload form
+ print_heading(get_string("pleasesubmityourwork", "exercise").":");
+ exercise_print_upload_form($exercise);
+ }
+ // in stage 3? - awaiting grading of assessment and assessment of work by teacher,
+ // may resubmit if allowed
+ else {
+ exercise_list_teacher_submissions($exercise, $USER);
+ echo " ";
+ print_heading(get_string("yoursubmission", "exercise"));
+ exercise_list_user_submissions($exercise, $USER);
+ if (exercise_test_for_resubmission($exercise, $USER)) {
+ // if resubmission requested print upload form
+ echo " ";
+ print_heading(get_string("pleasesubmityourwork", "exercise").":");
+ exercise_print_upload_form($exercise);
+ echo " ";
+ }
+ }
+ }
+ }
+
+
/****************** submission of assignment by teacher only***********************/
elseif ($action == 'submitassignment') {
- if (!isteacher($course->id)) {
- error("Only teachers can look at this page");
+ if (!isteacheredit($course->id)) {
+ error("Only teachers with editing permissions can do this.");
}
exercise_print_assignment_info($exercise);
@@ -311,11 +306,9 @@
exercise_print_assignment_info($exercise);
$tabs->names = array("1. ".get_string("phase1", "exercise"),
"2. ".get_string("phase2", "exercise", $course->student),
- "3. ".get_string("phase3", "exercise", $course->student),
- "4. ".get_string("phase4", "exercise"));
+ "3. ".get_string("phase3", "exercise", $course->student));
$tabs->urls = array("view.php?id=$cm->id&action=setupassignment",
"view.php?id=$cm->id&action=openexercise",
- "view.php?id=$cm->id&action=closeexercise",
"view.php?id=$cm->id&action=makeleaguetableavailable");
if ($exercise->phase) { // phase 1 or more
$tabs->highlight = $exercise->phase - 1;
@@ -328,12 +321,14 @@
switch ($exercise->phase) {
case 0:
case 1: // set up assignment
- echo "id&action=editelements\">".
- get_string("amendassessmentelements", "exercise")." \n";
- helpbutton("elements", get_string("amendassessmentelements", "exercise"), "exercise");
- echo "
id&action=submitassignment\">".
- get_string("submitexercisedescription", "exercise")." \n";
- helpbutton("submissionofdescriptions", get_string("submitexercisedescription", "exercise"), "exercise");
+ if (isteacheredit($course->id)) {
+ echo "
id&action=editelements\">".
+ get_string("amendassessmentelements", "exercise")." \n";
+ helpbutton("elements", get_string("amendassessmentelements", "exercise"), "exercise");
+ echo "
id&action=submitassignment\">".
+ get_string("submitexercisedescription", "exercise")." \n";
+ helpbutton("submissionofdescriptions", get_string("submitexercisedescription", "exercise"), "exercise");
+ }
break;
case 2: // submissions and assessments
@@ -346,16 +341,12 @@
"exercise");
break;
- case 3: // finish assessing
- // same as phase 2
+ case 3: // show final grades
echo "
id&action=listforassessmentstudent\">".
get_string("studentsubmissionsforassessment", "exercise",
exercise_count_unassessed_student_submissions($exercise))." \n";
helpbutton("grading", get_string("studentsubmissionsforassessment", "exercise"),
"exercise");
- break;
-
- case 4: // show final grades
print_heading("id&action=displayfinalgrades\">".
get_string("displayoffinalgrades", "exercise")." ");
}