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

work and the reduction of the number of phases to 3 (from 4).
This commit is contained in:
rkingdon
2003-12-24 14:43:24 +00:00
parent 7667ed702c
commit f43c849f7e
10 changed files with 426 additions and 322 deletions
+29 -33
View File
@@ -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;
}
+4
View File
@@ -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;
}
+1
View File
@@ -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';
+15 -9
View File
@@ -56,19 +56,24 @@
}
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;
@@ -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 = "<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)) {
+223 -178
View File
@@ -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"<p align=\"center\"><b><a href=\"assessments.php?action=teachertable&id=$cm->id\">".
get_string("teacherassessmenttable", "exercise", $course->teacher)."</a></b></p>\n";
get_string("teacherassessmenttable", "exercise", $course->teacher)."</a></b></p>\n";
?>
<form name="weightsform" method="post" action="submissions.php">
<INPUT TYPE="hidden" NAME="id" VALUE="<?PHP echo $cm->id ?>">
<input type="hidden" name="action" value="saveweights">
<CENTER>
<?PHP
// get the final weights from the database
$teacherweight = get_field("exercise","teacherweight", "id", $exercise->id);
$gradingweight = get_field("exercise","gradingweight", "id", $exercise->id);
if (isteacheredit($course->id)) {
?>
<form name="weightsform" method="post" action="submissions.php">
<INPUT TYPE="hidden" NAME="id" VALUE="<?PHP echo $cm->id ?>">
<input type="hidden" name="action" value="saveweights">
<CENTER>
<?PHP
// now show the weights used in the grades
echo "<TABLE WIDTH=\"50%\" BORDER=\"1\">\n";
echo "<tr><td colspan=\"2\" bgcolor=\"$THEME->cellheading2\" align=\"center\"><b>".
get_string("weightsusedforoverallgrade", "exercise")."</b></td></tr>\n";
echo "<TR><TD ALIGN=\"right\">".get_string("weightforgradingofassessments", "exercise").":</TD>\n";
echo "<TD>";
exercise_choose_from_menu($EXERCISE_FWEIGHTS, "gradingweight", $gradingweight, "");
echo "</td></tr>\n";
echo "<tr><td align=\"right\">".get_string("weightforteacherassessments", "exercise",
$course->teacher).":</td>\n";
echo "<td>";
exercise_choose_from_menu($EXERCISE_FWEIGHTS, "teacherweight", $teacherweight, "");
echo "</td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\">";
echo "<INPUT TYPE=submit VALUE=\"".get_string("saveweights", "exercise")."\">\n";
echo "</td></tr>\n";
echo "</TABLE>\n";
echo "</CENTER><br />";
echo "</FORM>\n";
// get the final weights from the database
$teacherweight = get_field("exercise","teacherweight", "id", $exercise->id);
$gradingweight = get_field("exercise","gradingweight", "id", $exercise->id);
?>
<form name="leagueform" method="post" action="submissions.php">
<INPUT TYPE="hidden" NAME="id" VALUE="<?PHP echo $cm->id ?>">
<input type="hidden" name="action" value="saveleaguetable">
<CENTER>
<?PHP
// now show the weights used in the grades
echo "<TABLE WIDTH=\"50%\" BORDER=\"1\">\n";
echo "<tr><td colspan=\"2\" bgcolor=\"$THEME->cellheading2\" align=\"center\"><b>".
get_string("weightsusedforoverallgrade", "exercise")."</b></td></tr>\n";
echo "<TR><TD ALIGN=\"right\">".get_string("weightforgradingofassessments", "exercise").":</TD>\n";
echo "<TD>";
exercise_choose_from_menu($EXERCISE_FWEIGHTS, "gradingweight", $gradingweight, "");
echo "</td></tr>\n";
echo "<tr><td align=\"right\">".get_string("weightforteacherassessments", "exercise",
$course->teacher).":</td>\n";
echo "<td>";
exercise_choose_from_menu($EXERCISE_FWEIGHTS, "teacherweight", $teacherweight, "");
echo "</td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\">";
echo "<INPUT TYPE=submit VALUE=\"".get_string("saveweights", "exercise")."\">\n";
echo "</td></tr>\n";
echo "</TABLE>\n";
echo "</CENTER><br />";
echo "</FORM>\n";
echo "<TABLE WIDTH=\"50%\" BORDER=\"1\">\n";
echo "<tr><td align=\"center\" colspan=\"2\" bgcolor=\"$THEME->cellheading2\"><b>".
get_string("leaguetable", "exercise")."</b></td></tr>\n";
echo "<tr><td align=\"right\">".get_string("numberofentries", "exercise").":</td>\n";
echo "<TD>";
$numbers[22] = 'All';
$numbers[21] = 50;
for ($i=20; $i>=0; $i--) {
$numbers[$i] = $i;
?>
<form name="leagueform" method="post" action="submissions.php">
<INPUT TYPE="hidden" NAME="id" VALUE="<?PHP echo $cm->id ?>">
<input type="hidden" name="action" value="saveleaguetable">
<CENTER>
<?PHP
echo "<TABLE WIDTH=\"50%\" BORDER=\"1\">\n";
echo "<tr><td align=\"center\" colspan=\"2\" bgcolor=\"$THEME->cellheading2\"><b>".
get_string("leaguetable", "exercise")."</b></td></tr>\n";
echo "<tr><td align=\"right\">".get_string("numberofentries", "exercise").":</td>\n";
echo "<TD>";
$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 "</td></tr>\n";
echo "<tr><td align=\"right\">".get_string("hidenamesfromstudents", "exercise",
$course->students)."</td><td>\n";
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "anonymous", $exercise->anonymous, "");
echo "</td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\">";
echo "<INPUT TYPE=submit VALUE=\"".get_string("saveentries", "exercise")."\">\n";
echo "</td></tr>\n";
echo "</table>\n";
echo "</CENTER>";
echo "</FORM>\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 = "<a href=\"submissions.php?action=adminamendtitle&id=$cm->id&sid=$submission->id\">".
get_string("amendtitle", "exercise")."</a>";
$action .= " | <a href=\"submissions.php?action=adminconfirmdelete&id=$cm->id&sid=$submission->id\">".
get_string("delete", "exercise")."</a>";
$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 "</td></tr>\n";
echo "<tr><td align=\"right\">".get_string("hidenamesfromstudents", "exercise",
$course->students)."</td><td>\n";
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "anonymous", $exercise->anonymous, "");
echo "</td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\">";
echo "<INPUT TYPE=submit VALUE=\"".get_string("saveentries", "exercise")."\">\n";
echo "</td></tr>\n";
echo "</table>\n";
echo "</CENTER>";
echo "</FORM>\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 = "<a href=\"submissions.php?action=adminamendtitle&id=$cm->id&sid=$submission->id\">".
get_string("amendtitle", "exercise")."</a>";
$action .= " | <a href=\"submissions.php?action=adminconfirmdelete&id=$cm->id&sid=$submission->id\">".
get_string("delete", "exercise")."</a>";
$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 .= " | <a href=\"assessments.php?action=adminlist&id=$cm->id&sid=$submission->id\">".
get_string("view", "exercise")." ($nassessments)</a>";
}
if ($submission->late) {
$action .= " | <a href=\"submissions.php?action=adminlateflag&id=$cm->id&sid=$submission->id\">".
get_string("clearlateflag", "exercise")."</a>";
}
$action .= " | <a href=\"submissions.php?action=adminconfirmdelete&id=$cm->id&sid=$submission->id\">".
get_string("delete", "exercise")."</a>";
$title = $submission->title;
if ($submission->resubmit) {
$title .= "*";
}
$datesubmitted = userdate($submission->timecreated);
if ($submission->late) {
$datesubmitted = "<font color=\"red\">".$datesubmitted."</font>";
}
$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 "<p align=\"center\">".get_string("resubmitnote", "exercise", $course->student)."</p>\n";
}
echo "<p align=\"center\">".get_string("allgradeshaveamaximumof", "exercise", $exercise->grade)."</p></center>\n";
echo "<p align=\"center\">".get_string("allgradeshaveamaximumof", "exercise", $exercise->grade).
"</p></center>\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 "<p align=\"center\"><b>".get_string("description", "exercise").": </b>\n";
echo exercise_print_submission_title($exercise, $submission);
echo "</p>\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 = "<A HREF=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
get_string("reassess", "exercise")."</A>";
}
}
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 = "<A HREF=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
get_string("assess", "exercise")."</A>";
}
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 = "<A HREF=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
get_string("edit", "exercise")."</A>";
}
}
else {
$action = "<A HREF=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id\">"
.get_string("view", "exercise")."</A>";
}
}
}
// 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 = "<font color=\"red\">".$timegap."</font>";
}
if ($warm) {
// last chance salon
$action = "<A HREF=\"assessments.php?action=teacherassessment&id=$cm->id&aid=$studentassessment->id&sid=$submission->id\">".
get_string("edit", "exercise")."</A>";
$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 = "<A HREF=\"assessments.php?action=teacherassessment&id=$cm->id&aid=$studentassessment->id&sid=$submission->id\">".
get_string("assess", "exercise")."</A>";
$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 = "<A HREF=\"assessments.php?action=assessresubmission&id=$cm->id&sid=$submission->id\">".
get_string("edit", "exercise")."</A>";
$timegap = get_string("ago", "exercise", format_time($submission->timecreated -
$timenow));
if ($submission->late) {
$timegap = "<font color=\"red\">".$timegap."</font>";
}
$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 = "<A HREF=\"assessments.php?action=assessresubmission&id=$cm->id&sid=$submission->id\">".
get_string("assess", "exercise")."</A>";
$timegap = get_string("ago", "exercise", format_time($submission->timecreated -
$timenow));
if ($submission->late) {
$timegap = "<font color=\"red\">".$timegap."</font>";
}
$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 = "<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")) {
@@ -1995,19 +2021,35 @@ function exercise_list_user_submissions($exercise, $user) {
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>";;
$comment = get_string("assessmentmadebythe", "exercise", $course->teacher);
}
}
$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";
}
}
}
$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 = "<font color=\"red\">".$submissiondate."</font>";
}
$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 "<TR valign=top>\n";
echo " <TD align=right><P><B>". get_string("element","exercise")." $iplus1:</B></P></TD>\n";
echo "<TR valign=top>\n";
echo " <TD align=right><P><B>". get_string("element","exercise")." $iplus1:</B></P></TD>\n";
echo " <TD>".text_to_html($elements[$i]->description);
echo "</TD></TR>\n";
echo "<TR valign=top>\n";
echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";
echo "<TR valign=top>\n";
echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";
echo " <TD>\n";
if ($allowchanges) {
if ($allowchanges) {
echo " <textarea name=\"feedback[]\" rows=3 cols=75 wrap=\"virtual\">\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 " </TD>\n";
echo "</TR>\n";
echo "<TR valign=top>\n";
echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\">&nbsp;</TD>\n";
}
echo " </TD>\n";
echo "</TR>\n";
echo "<TR valign=top>\n";
echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\">&nbsp;</TD>\n";
echo "</TR>\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 "<TR valign=top>\n";
echo "<TR valign=top>\n";
echo " <TD align=right><P><B>". get_string("element","exercise")." $iplus1:</B></P></TD>\n";
echo " <TD>".text_to_html($elements[$i]->description);
echo "<P align=right><FONT size=1>Weight: "
@@ -2225,10 +2267,10 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
echo " </TD>\n";
echo "</TR>\n";
}
echo "<TR valign=top>\n";
echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";
echo "<TR valign=top>\n";
echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";
echo " <TD>\n";
if ($allowchanges) {
if ($allowchanges) {
echo " <textarea name=\"feedback[]\" rows=3 cols=75 wrap=\"virtual\">\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 " </TD>\n";
echo "</TR>\n";
echo "<TR valign=top>\n";
echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\">&nbsp;</TD>\n";
}
echo " </TD>\n";
echo "</TR>\n";
echo "<TR valign=top>\n";
echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\">&nbsp;</TD>\n";
echo "</TR>\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 "<b>".get_string("handlingofmultiplesubmissions", "exercise")."</b>:";
if ($exercise->usemaximum) {
echo get_string("usemaximum", "exercise")."<br />\n";
}
}
else {
echo get_string("usemean", "exercise")."<br />\n";
}
}
echo "<b>".get_string("detailsofassessment", "exercise")."</b>:
<a href=\"assessments.php?id=$cm->id&action=displaygradingform\">".
get_string("specimenassessmentform", "exercise")."</a><br />";
print_simple_box_end();
print_simple_box_end();
echo "<br />";
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
@@ -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");
}
+4 -4
View File
@@ -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) {
+68 -10
View File
@@ -4,8 +4,10 @@
ACTIONS handled are:
adminamendtitle
adminclearlate
adminconfirmdelete
admindelete
adminlateflag
adminlist
displayfinalgrades (teachers only)
listforassessmentstudent
@@ -78,9 +80,9 @@
<?PHP
// now get the comment
echo "<tr valign=\"top\">\n";
echo " <td align=\"right\"><P><B>". get_string("title", "exercise").":</b></p></td>\n";
echo " <td>\n";
echo "<tr valign=\"top\">\n";
echo " <td align=\"right\"><P><B>". get_string("title", "exercise").":</b></p></td>\n";
echo " <td>\n";
echo " <input type=\"text\" name=\"title\" size=\"60\" maxlength=\"100\" value=\"$submission->title\">\n";
echo " </td></tr></table>\n";
echo "<input type=submit VALUE=\"".get_string("amendtitle", "exercise")."\">\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 = "<font color=\"red\">(".$grade.")</font>";
$overallgrade = "<font color=\"red\">(".$overallgrade.")</font>";
}
echo "<tr><td>$user->firstname $user->lastname</td>\n";
echo "<td>".exercise_print_submission_title($exercise, $submission)."</td>\n";
echo "<td align=\"center\">".number_format($ownassessment->gradinggrade * $exercise->grade / COMMENTSCALE, 1)."</td>";
echo "<td align=\"center\">".number_format($assessment->grade * $exercise->grade / 100.0, 1)."</td>";
echo "<td align=\"center\">". number_format(((($assessment->grade * $EXERCISE_FWEIGHTS[$teacherweight]
/ 100.0) + ($ownassessment->gradinggrade * $EXERCISE_FWEIGHTS[$gradingweight]
/ COMMENTSCALE )) * $exercise->grade) /
($EXERCISE_FWEIGHTS[$teacherweight] + $EXERCISE_FWEIGHTS[$gradingweight]), 1).
"</td></tr>\n";
echo "<td align=\"center\">$grade</td>";
echo "<td align=\"center\">$overallgrade</td></tr>\n";
}
}
}
+5 -2
View File
@@ -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!");
}
+1 -1
View File
@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2003111400;
$module->version = 2003121000;
$module->cron = 60;
?>
+76 -85
View File
@@ -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 = "<font color=\"red\">(".$grade.")</font>";
$overallgrade = "<font color=\"red\">(".$overallgrade.")</font>";
}
echo "<TR><td>".exercise_print_submission_title($exercise, $submission)."</td>\n";
echo "<td align=\"center\">".number_format($ownassessment->gradinggrade * $exercise->grade / COMMENTSCALE, 1)."</td>";
echo "<td align=\"center\">".number_format($assessment->grade * $exercise->grade / 100.0, 1)."</td>";
echo "<td align=\"center\">". number_format(((($assessment->grade * $EXERCISE_FWEIGHTS[$teacherweight]
/ 100.0) + ($ownassessment->gradinggrade * $EXERCISE_FWEIGHTS[$gradingweight]
/ COMMENTSCALE )) * $exercise->grade) /
($EXERCISE_FWEIGHTS[$teacherweight] + $EXERCISE_FWEIGHTS[$gradingweight]), 1).
"</td></TR>\n";
echo "<td align=\"center\">$grade</td>";
echo "<td align=\"center\">$overallgrade</td></TR>\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 "<hr size=\"1\" noshade>";
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 "<hr size=\"1\" noshade>";
print_heading(get_string("pleasesubmityourwork", "exercise").":");
exercise_print_upload_form($exercise);
echo "<hr size=\"1\" noshade>";
}
}
}
}
/****************** 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 "<hr size=\"1\" noshade>";
print_heading(get_string("pleasesubmityourwork", "exercise").":");
exercise_print_upload_form($exercise);
}
echo "<hr size=\"1\" noshade>";
}
/****************** 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 "<hr size=\"1\" noshade>";
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 "<hr size=\"1\" noshade>";
print_heading(get_string("pleasesubmityourwork", "exercise").":");
exercise_print_upload_form($exercise);
echo "<hr size=\"1\" noshade>";
}
}
}
}
/****************** 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 "<p><b><a href=\"assessments.php?id=$cm->id&action=editelements\">".
get_string("amendassessmentelements", "exercise")."</a></b> \n";
helpbutton("elements", get_string("amendassessmentelements", "exercise"), "exercise");
echo "<p><b><a href=\"view.php?id=$cm->id&action=submitassignment\">".
get_string("submitexercisedescription", "exercise")."</a></b> \n";
helpbutton("submissionofdescriptions", get_string("submitexercisedescription", "exercise"), "exercise");
if (isteacheredit($course->id)) {
echo "<p><b><a href=\"assessments.php?id=$cm->id&action=editelements\">".
get_string("amendassessmentelements", "exercise")."</a></b> \n";
helpbutton("elements", get_string("amendassessmentelements", "exercise"), "exercise");
echo "<p><b><a href=\"view.php?id=$cm->id&action=submitassignment\">".
get_string("submitexercisedescription", "exercise")."</a></b> \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 "<p><b><a href=\"submissions.php?id=$cm->id&action=listforassessmentstudent\">".
get_string("studentsubmissionsforassessment", "exercise",
exercise_count_unassessed_student_submissions($exercise))."</a></b> \n";
helpbutton("grading", get_string("studentsubmissionsforassessment", "exercise"),
"exercise");
break;
case 4: // show final grades
print_heading("<A HREF=\"submissions.php?id=$cm->id&action=displayfinalgrades\">".
get_string("displayoffinalgrades", "exercise")."</A>");
}