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

short period)
This commit is contained in:
rkingdon 2004-01-23 17:02:47 +00:00
parent c0ae5fc15b
commit 2e855d5f05
3 changed files with 40 additions and 33 deletions

View File

@ -173,6 +173,7 @@
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 File

@ -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 File

@ -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();
}
}
}
}