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) {
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");
}
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");
}
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";
-
- ?>
- <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);
-
- // 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";
-
- ?>
- <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
+ get_string("teacherassessmenttable", "exercise", $course->teacher)."</a></b></p>\n";
+
+
+ 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
+
+ // get the final weights from the database
+ $teacherweight = get_field("exercise","teacherweight", "id", $exercise->id);
+ $gradingweight = get_field("exercise","gradingweight", "id", $exercise->id);
+
+ // 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";
+
+ ?>
+ <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;
- 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';
+ 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);
+ }
}
- 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...
$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++;
}
}
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";
}
}
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");
}
$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;
$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) {
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);
+ }
+}
///////////////////////////////////////////////////////////////////////////////////////////////
$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!!
// 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
}
$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);
}
}
}
$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;
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")) {
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);
}
+}
///////////////////////////////////////////////////////////////////////////////////////////////
// now print the form
for ($i=0; $i < count($elements); $i++) {
$iplus1 = $i+1;
- echo "<TR valign=top>\n";\r
- echo " <TD align=right><P><B>". get_string("element","exercise")." $iplus1:</B></P></TD>\n";\r
+ 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";\r
- echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";\r
+ echo "<TR valign=top>\n";
+ echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";
echo " <TD>\n";
- if ($allowchanges) {\r
+ if ($allowchanges) {
echo " <textarea name=\"feedback[]\" rows=3 cols=75 wrap=\"virtual\">\n";
if (isset($grades[$i]->feedback)) {
echo $grades[$i]->feedback;
}
else {
echo text_to_html($grades[$i]->feedback);
- }\r
- echo " </TD>\n";\r
- echo "</TR>\n";\r
- echo "<TR valign=top>\n";\r
- echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ }
+ echo " </TD>\n";
+ echo "</TR>\n";
+ echo "<TR valign=top>\n";
+ echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";
echo "</TR>\n";
}
break;
// now print the form
for ($i=0; $i < count($elements); $i++) {
$iplus1 = $i+1;
- echo "<TR valign=top>\n";\r
+ echo "<TR valign=top>\n";
echo " <TD align=right><P><B>". get_string("element","exercise")." $iplus1:</B></P></TD>\n";\r
echo " <TD>".text_to_html($elements[$i]->description);
echo "<P align=right><FONT size=1>Weight: "
echo " </TD>\n";
echo "</TR>\n";
}
- echo "<TR valign=top>\n";\r
- echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";\r
+ echo "<TR valign=top>\n";
+ echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";
echo " <TD>\n";
- if ($allowchanges) {\r
+ if ($allowchanges) {
echo " <textarea name=\"feedback[]\" rows=3 cols=75 wrap=\"virtual\">\n";
if (isset($grades[$i]->feedback)) {
echo $grades[$i]->feedback;
}
else {
echo text_to_html($grades[$i]->feedback);
- }\r
- echo " </TD>\n";\r
- echo "</TR>\n";\r
- echo "<TR valign=top>\n";\r
- echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ }
+ echo " </TD>\n";
+ echo "</TR>\n";
+ echo "<TR valign=top>\n";
+ echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";
echo "</TR>\n";
}
break;
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) {
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 />";
- }
+}
///////////////////////////////////////////////////////////////////////////////////////////////
$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");
}
/*************************************************
ACTIONS handled are:
- closeexercise( for teachers)
displayfinalgrade (for students)
makeleaguetableavailable (for teachers)
notavailable (for students)
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!
}
- /************** 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);
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";
}
}
}
/****************** 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));
}
/****************** 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
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");
}
- /****************** 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);
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);
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;
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
"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>");
}