Permalink
Browse files

A new version (2003121000). Fixes to backup/restore. Addition of "late"

work and the reduction of the number of phases to 3 (from 4).
  • Loading branch information...
1 parent 7667ed7 commit f43c849f7e596018cccf881344bb1d8fb7ed3be4 rkingdon committed Dec 24, 2003
@@ -68,11 +68,7 @@ function exercise_backup_mods($bf,$preferences) {
//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 @@ function backup_exercise_rubrics ($bf,$preferences,$exercise,$elementno) {
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 @@ function backup_exercise_teacher_submissions ($bf,$preferences,$exerciseid) {
//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 @@ function backup_exercise_student_submissions ($bf,$preferences,$exerciseid) {
$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;
}
@@ -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;
}
@@ -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';
@@ -56,28 +56,31 @@
}
foreach ($exercises as $exercise) {
+ if ($exercise->deadline > $timenow) {
+ $due = userdate($exercise->deadline);
+ } else {
+ $due = "<FONT COLOR=\"red\">".userdate($exercise->deadline)."</FONT>";
+ }
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 = "<FONT COLOR=\"red\">".userdate($submission->timecreated)."</FONT>";
}
else {
- $submitted = "<FONT COLOR=red>".userdate($submission->timecreated)."</FONT>";
+ $submitted = userdate($submission->timecreated);
}
- $due = userdate($exercise->deadline);
$link = "<A HREF=\"view.php?id=$exercise->coursemodule\">$exercise->name</A>";
$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;
case 2: $phase = get_string("phase2short", "exercise");
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 = "<font color=\"red\">(".$actualgrade.")<font color=\"red\">";
+ } 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 = "<A HREF=\"view.php?id=$exercise->coursemodule\">$exercise->name</A>";
if ($course->format == "weeks" or $course->format == "topics") {
if (isteacher($course->id)) {
Oops, something went wrong.

0 comments on commit f43c849

Please sign in to comment.