Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes to Backup and upload (now allows teachers multiple uploads in a

short period)
  • Loading branch information...
commit 2e855d5f052084ef1469374d5557dfb4e33a2a64 1 parent c0ae5fc
rkingdon authored
View
1  mod/exercise/backuplib.php
@@ -173,6 +173,7 @@ function backup_exercise_submissions ($bf,$preferences,$exerciseid) {
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 (if student data required)
if ($preferences->mods["exercise"]->userinfo) {
$status = backup_exercise_assessments($bf,$preferences,$exerciseid,$submission->id);
View
53 mod/exercise/lib.php
@@ -1297,10 +1297,10 @@ function exercise_get_user_submissions($exercise, $user) {
error("Course is misconfigured");
}
if (isteacher($course->id, $user->id)) {
- return get_records_select("exercise_submissions ",
+ return get_records_select("exercise_submissions",
"exerciseid = $exercise->id AND isexercise = 1", "timecreated" );
}
- return get_records_select("exercise_submissions ",
+ return get_records_select("exercise_submissions",
"exerciseid = $exercise->id AND userid = $user->id", "timecreated" );
}
@@ -2005,7 +2005,7 @@ function exercise_list_user_submissions($exercise, $user) {
$table->cellspacing = 0;
if ($submissions = exercise_get_user_submissions($exercise, $user)) {
- foreach ($submissions as $submission) {
+ foreach ($submissions as $submission) {
$action = '';
$comment = '';
// allow user to delete submission if it's warm
@@ -2013,30 +2013,33 @@ function exercise_list_user_submissions($exercise, $user) {
$action = "<a href=\"submissions.php?action=userconfirmdelete&id=$cm->id&sid=$submission->id\">".
get_string("delete", "exercise")."</a>";
}
- // 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 .= "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id\">".
- get_string("viewassessment", "exercise")."</a>";
- if ($comment) {
- $action .= " | ";
- }
- $grade = number_format($assessment->grade * $exercise->grade / 100.0, 1);
- if ($submission->late) {
- $comment .= get_string("grade").
- ": <font color=\"red\">($grade)</font>";
- } else {
- $comment .= get_string("grade").": $grade";
+ // if this is a teacher's submission (an exercise descrription) ignore any assessments
+ if (!$submission->isexercise) {
+ // 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 .= "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id\">".
+ get_string("viewassessment", "exercise")."</a>";
+ if ($comment) {
+ $action .= " | ";
+ }
+ $grade = number_format($assessment->grade * $exercise->grade / 100.0, 1);
+ if ($submission->late) {
+ $comment .= get_string("grade").
+ ": <font color=\"red\">($grade)</font>";
+ } else {
+ $comment .= get_string("grade").": $grade";
+ }
}
}
- }
- }
+ }
+ }
if (!$comment and isstudent($course->id, $user->id)) {
$comment = get_string("awaitingassessmentbythe", "exercise", $course->teacher);
}
View
19 mod/exercise/upload.php
@@ -36,14 +36,17 @@
"", "", true);
// check that this is not a "rapid" second submission, caused by using the back button
- if ($submissions = exercise_get_user_submissions($exercise, $USER)) {
- // returns all submissions, newest on first
- foreach ($submissions as $submission) {
- if ($submission->timecreated > $timenow - $CFG->maxeditingtime) {
- // ignore this submission
- redirect("view.php?id=$cm->id");
- print_footer($course);
- exit();
+ // only check if a student, teachers may want to submit a set of exercise variants
+ if (isstudent($course->id)) {
+ if ($submissions = exercise_get_user_submissions($exercise, $USER)) {
+ // returns all submissions, newest on first
+ foreach ($submissions as $submission) {
+ if ($submission->timecreated > $timenow - $CFG->maxeditingtime) {
+ // ignore this submission
+ redirect("view.php?id=$cm->id");
+ print_footer($course);
+ exit();
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.