Additional information exercises page (index.php).

This commit is contained in:
rkingdon 2003-10-12 17:19:19 +00:00
parent 3ca5e8bee8
commit b896875293
3 changed files with 164 additions and 91 deletions

View file

@ -22,6 +22,8 @@
$strtopic = get_string("topic"); $strtopic = get_string("topic");
$strname = get_string("name"); $strname = get_string("name");
$strtitle = get_string("title", "exercise"); $strtitle = get_string("title", "exercise");
$strphase = get_string("phase", "exercise");
$strgrade = get_string("grade");
$strdeadline = get_string("deadline", "exercise"); $strdeadline = get_string("deadline", "exercise");
$strsubmitted = get_string("submitted", "assignment"); $strsubmitted = get_string("submitted", "assignment");
@ -35,11 +37,19 @@
$timenow = time(); $timenow = time();
if ($course->format == "weeks") { if ($course->format == "weeks") {
$table->head = array ($strweek, $strname, $strtitle, $strsubmitted, $strdeadline); if (isteacher($course->id)) {
$table->align = array ("CENTER", "LEFT", "LEFT","LEFT", "LEFT"); $table->head = array ($strweek, $strname, $strtitle, $strphase, $strsubmitted, $strdeadline);
} else {
$table->head = array ($strweek, $strname, $strtitle, $strgrade, $strsubmitted, $strdeadline);
}
$table->align = array ("CENTER", "LEFT", "LEFT","center","LEFT", "LEFT");
} else if ($course->format == "topics") { } else if ($course->format == "topics") {
$table->head = array ($strtopic, $strname, $strtitle, $strsubmitted, $strdeadline); if (isteacher($course->id)) {
$table->align = array ("CENTER", "LEFT", "LEFT", "LEFT", "LEFT"); $table->head = array ($strtopic, $strname, $strtitle, $strphase, $strsubmitted, $strdeadline);
} else {
$table->head = array ($strtopic, $strname, $strtitle, $strgrade, $strsubmitted, $strdeadline);
}
$table->align = array ("CENTER", "LEFT", "LEFT", "center", "LEFT", "LEFT");
} else { } else {
$table->head = array ($strname, $strsubmitted, $strdeadline); $table->head = array ($strname, $strsubmitted, $strdeadline);
$table->align = array ("LEFT", "LEFT", "LEFT"); $table->align = array ("LEFT", "LEFT", "LEFT");
@ -47,7 +57,7 @@
foreach ($exercises as $exercise) { foreach ($exercises as $exercise) {
if ($submissions = exercise_get_user_submissions($exercise, $USER)) { if ($submissions = exercise_get_user_submissions($exercise, $USER)) {
foreach ($submissions as $submission) { foreach ($submissions as $submission) {
if ($submission->timecreated <= $exercise->deadline) { if ($submission->timecreated <= $exercise->deadline) {
$submitted = userdate($submission->timecreated); $submitted = userdate($submission->timecreated);
} }
@ -58,26 +68,63 @@
$link = "<A HREF=\"view.php?id=$exercise->coursemodule\">$exercise->name</A>"; $link = "<A HREF=\"view.php?id=$exercise->coursemodule\">$exercise->name</A>";
$title = $submission->title; $title = $submission->title;
if ($course->format == "weeks" or $course->format == "topics") { if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ($exercise->section, $link, $title, $submitted, $due); if (isteacher($course->id)) {
switch ($exercise->phase) {
case 1: $phase = get_string("phase1short", "exercise");
break;
case 2: $phase = get_string("phase2short", "exercise");
break;
case 3: $phase = get_string("phase3short", "exercise");
break;
case 4: $phase = get_string("phase4short", "exercise");
break;
}
$table->data[] = array ($exercise->section, $link, $title, $phase,
$submitted, $due);
} else {
if ($exercise->usemaximum) {
$maximum = exercise_get_best_grade($submission);
$grade = $maximum->grade;
}else { // use mean value
$mean = exercise_get_mean_grade($submission);
$grade = $mean->grade;
}
// now get the user's grading grade
if (!$assessments = exercise_get_user_assessments($exercise, $USER)) {
error("Index: assessment record not found");
}
foreach ($assessments as $assessment) {
// just use the first one (should only be one)
$gradinggrade = $assessment->gradinggrade;
break;
}
$overallgrade = (($gradinggrade * $EXERCISE_FWEIGHTS[$exercise->gradingweight] * $exercise->grade / COMMENTSCALE ) + ($grade * $EXERCISE_FWEIGHTS[$exercise->teacherweight] * $exercise->grade / 100.0)) / ($EXERCISE_FWEIGHTS[$exercise->gradingweight] + $EXERCISE_FWEIGHTS[$exercise->teacherweight]);
$table->data[] = array ($exercise->section, $link, $title,
number_format($overallgrade, 1), $submitted, $due);
} }
}
else { else {
$table->data[] = array ($link, $submitted, $due); $table->data[] = array ($link, $submitted, $due);
}
} }
} }
}
else { else {
$submitted = get_string("no"); $submitted = get_string("no");
$title = ''; $title = '';
$due = userdate($exercise->deadline); $due = userdate($exercise->deadline);
$link = "<A HREF=\"view.php?id=$exercise->coursemodule\">$exercise->name</A>"; $link = "<A HREF=\"view.php?id=$exercise->coursemodule\">$exercise->name</A>";
if ($course->format == "weeks" or $course->format == "topics") { if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ($exercise->section, $link, $title, $submitted, $due); if (isteacher($course->id)) {
$table->data[] = array ($exercise->section, $link, $title, $exercise->phase,
$submitted, $due);
} else {
$table->data[] = array ($exercise->section, $link, $title, "0", $submitted, $due);
} }
else { } else {
$table->data[] = array ($link, $submitted, $due); $table->data[] = array ($link, $submitted, $due);
}
} }
} }
}
echo "<BR>"; echo "<BR>";
print_table($table); print_table($table);

View file

@ -130,6 +130,18 @@ function exercise_cron () {
echo "Could not find submission $assessment->submissionid\n"; echo "Could not find submission $assessment->submissionid\n";
continue; continue;
} }
if (! $exercise = get_record("exercise", "id", $submission->exerciseid)) {
echo "Could not find exercise record for id $submission->exerciseid\n";
continue;
}
if (! $course = get_record("course", "id", "$exercise->course")) {
echo "Could not find course $exercise->course\n";
continue;
}
if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
error("Course Module ID was incorrect");
continue;
}
if (! $submissionowner = get_record("user", "id", "$submission->userid")) { if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
echo "Could not find user $submission->userid\n"; echo "Could not find user $submission->userid\n";
continue; continue;
@ -138,20 +150,12 @@ function exercise_cron () {
echo "Could not find user $assessment->userid\n"; echo "Could not find user $assessment->userid\n";
continue; continue;
} }
if (! $course = get_record("course", "id", "$assessment->course")) {
echo "Could not find course $assessment->course\n";
continue;
}
if (! isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) { if (! isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) {
continue; // Not an active participant continue; // Not an active participant
} }
if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) { if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) {
continue; // Not an active participant continue; // Not an active participant
} }
if (! $exercise = get_coursemodule_from_instance("exercise", $assessment->exerciseid, $course->id)) {
echo "Could not find course module for exercise id $submission->exercise\n";
continue;
}
$strexercises = get_string("modulenameplural", "exercise"); $strexercises = get_string("modulenameplural", "exercise");
$strexercise = get_string("modulename", "exercise"); $strexercise = get_string("modulename", "exercise");
@ -170,17 +174,17 @@ function exercise_cron () {
$posttext .= $msg; $posttext .= $msg;
// "You can see it in your exercise assignment" // "You can see it in your exercise assignment"
$posttext .= get_string("mail3", "exercise").":\n"; $posttext .= get_string("mail3", "exercise").":\n";
$posttext .= " $CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\n"; $posttext .= " $CFG->wwwroot/mod/exercise/view.php?id=$cm->id\n";
$posttext .= "---------------------------------------------------------------------\n"; $posttext .= "---------------------------------------------------------------------\n";
if ($sendto->mailformat == 1) { // HTML if ($sendto->mailformat == 1) { // HTML
$posthtml = "<P><FONT FACE=sans-serif>". $posthtml = "<P><FONT FACE=sans-serif>".
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->". "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->".
"<A HREF=\"$CFG->wwwroot/mod/exercise/index.php?id=$course->id\">$strexercises</A> ->". "<A HREF=\"$CFG->wwwroot/mod/exercise/index.php?id=$course->id\">$strexercises</A> ->".
"<A HREF=\"$CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\">$exercise->name</A></FONT></P>"; "<A HREF=\"$CFG->wwwroot/mod/exercise/view.php?id=$cm->id\">$exercise->name</A></FONT></P>";
$posthtml .= "<HR><FONT FACE=sans-serif>"; $posthtml .= "<HR><FONT FACE=sans-serif>";
$posthtml .= "<P>$msg</P>"; $posthtml .= "<P>$msg</P>";
$posthtml .= "<P>".get_string("mail3", "exercise"). $posthtml .= "<P>".get_string("mail3", "exercise").
" <A HREF=\"$CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\">$exercise->name</A>.</P></FONT><HR>"; " <A HREF=\"$CFG->wwwroot/mod/exercise/view.php?id=$cm->id\">$exercise->name</A>.</P></FONT><HR>";
} else { } else {
$posthtml = ""; $posthtml = "";
} }
@ -210,9 +214,16 @@ function exercise_cron () {
echo "Could not find submission $assessment->submissionid\n"; echo "Could not find submission $assessment->submissionid\n";
continue; continue;
} }
if (! $exercise = get_record("exercise", "id", $submission->exerciseid)) {
if (! $submissionowner = get_record("user", "id", "$submission->userid")) { echo "Could not find exercise record for id $submission->exerciseid\n";
echo "Could not find user $submission->userid\n"; continue;
}
if (! $course = get_record("course", "id", "$exercise->course")) {
echo "Could not find course $exercise->course\n";
continue;
}
if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
error("Course Module ID was incorrect");
continue; continue;
} }
@ -221,24 +232,10 @@ function exercise_cron () {
continue; continue;
} }
if (! $course = get_record("course", "id", "$assessment->course")) {
echo "Could not find course $assessment->course\n";
continue;
}
if (! isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) {
continue; // Not an active participant
}
if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) { if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) {
continue; // Not an active participant continue; // Not an active participant
} }
if (! $exercise = get_coursemodule_from_instance("exercise", $assessment->exerciseid, $course->id)) {
echo "Could not find course module for exercise id $submission->exercise\n";
continue;
}
$strexercises = get_string("modulenameplural", "exercise"); $strexercises = get_string("modulenameplural", "exercise");
$strexercise = get_string("modulename", "exercise"); $strexercise = get_string("modulename", "exercise");
@ -256,17 +253,17 @@ function exercise_cron () {
$posttext .= $msg; $posttext .= $msg;
// "You can see it in your exercise assignment" // "You can see it in your exercise assignment"
$posttext .= get_string("mail3", "exercise").":\n"; $posttext .= get_string("mail3", "exercise").":\n";
$posttext .= " $CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\n"; $posttext .= " $CFG->wwwroot/mod/exercise/view.php?id=$cm->id\n";
$posttext .= "---------------------------------------------------------------------\n"; $posttext .= "---------------------------------------------------------------------\n";
if ($sendto->mailformat == 1) { // HTML if ($sendto->mailformat == 1) { // HTML
$posthtml = "<P><FONT FACE=sans-serif>". $posthtml = "<P><FONT FACE=sans-serif>".
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->". "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->".
"<A HREF=\"$CFG->wwwroot/mod/exercise/index.php?id=$course->id\">$strexercises</A> ->". "<A HREF=\"$CFG->wwwroot/mod/exercise/index.php?id=$cm->id\">$strexercises</A> ->".
"<A HREF=\"$CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\">$exercise->name</A></FONT></P>"; "<A HREF=\"$CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\">$exercise->name</A></FONT></P>";
$posthtml .= "<HR><FONT FACE=sans-serif>"; $posthtml .= "<HR><FONT FACE=sans-serif>";
$posthtml .= "<P>$msg</P>"; $posthtml .= "<P>$msg</P>";
$posthtml .= "<P>".get_string("mail3", "exercise"). $posthtml .= "<P>".get_string("mail3", "exercise").
" <A HREF=\"$CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\">$exercise->name</A>.</P></FONT><HR>"; " <A HREF=\"$CFG->wwwroot/mod/exercise/view.php?id=$cm->id\">$exercise->name</A>.</P></FONT><HR>";
} else { } else {
$posthtml = ""; $posthtml = "";
} }
@ -335,10 +332,10 @@ global $EXERCISE_FWEIGHTS;
if (!$exercise = get_record("exercise", "id", $exerciseid)) { if (!$exercise = get_record("exercise", "id", $exerciseid)) {
error("Exercise record not found"); error("Exercise record not found");
} }
if (! $course = get_record("course", "id", $exercise->course)) { if (! $course = get_record("course", "id", $exercise->course)) {
error("Course is misconfigured"); error("Course is misconfigured");
} }
// calculate scaling factor // calculate scaling factor
$scaling = $exercise->grade / (100.0 * ($EXERCISE_FWEIGHTS[$exercise->gradingweight] + $scaling = $exercise->grade / (100.0 * ($EXERCISE_FWEIGHTS[$exercise->gradingweight] +
@ -350,17 +347,17 @@ global $EXERCISE_FWEIGHTS;
foreach ($bestgrades as $bestgrade) { foreach ($bestgrades as $bestgrade) {
$return->grades[$bestgrade->userid] = $bestgrade->grade * $return->grades[$bestgrade->userid] = $bestgrade->grade *
$EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling; $EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling;
}
} }
} }
}
else { // use mean values else { // use mean values
if ($meangrades = exercise_get_mean_submission_grades($exercise)) { if ($meangrades = exercise_get_mean_submission_grades($exercise)) {
foreach ($meangrades as $meangrade) { foreach ($meangrades as $meangrade) {
$return->grades[$meangrade->userid] = $meangrade->grade * $return->grades[$meangrade->userid] = $meangrade->grade *
$EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling; $EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling;
}
} }
} }
}
// now get the users grading grades // now get the users grading grades
if ($assessments = exercise_get_teacher_submission_assessments($exercise)) { if ($assessments = exercise_get_teacher_submission_assessments($exercise)) {
foreach ($assessments as $assessment) { foreach ($assessments as $assessment) {
@ -368,9 +365,9 @@ global $EXERCISE_FWEIGHTS;
if (isset($return->grades[$assessment->userid])) { if (isset($return->grades[$assessment->userid])) {
$return->grades[$assessment->userid] += $assessment->gradinggrade * $return->grades[$assessment->userid] += $assessment->gradinggrade *
$EXERCISE_FWEIGHTS[$exercise->gradingweight] * $scaling * 100.0 / COMMENTSCALE; $EXERCISE_FWEIGHTS[$exercise->gradingweight] * $scaling * 100.0 / COMMENTSCALE;
}
} }
} }
}
$return->maxgrade = get_field("exercise", "grade", "id", "$exerciseid"); $return->maxgrade = get_field("exercise", "grade", "id", "$exerciseid");
return $return; return $return;
} }
@ -981,12 +978,25 @@ function exercise_get_assessments($submission) {
} }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_best_grade($submission) {
// Returns the best grade of students' submission (there may, occassionally be more than one assessment)
global $CFG;
return get_record_sql("SELECT MAX(a.grade) grade FROM
{$CFG->prefix}exercise_assessments a
WHERE a.submissionid = $submission->id
GROUP BY a.submissionid");
}
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_best_submission_grades($exercise) { function exercise_get_best_submission_grades($exercise) {
// Returns the grades of students' best submissions // Returns the grades of students' best submissions
global $CFG; global $CFG;
return get_records_sql("SELECT DISTINCT MAX(a.grade) grade, u.userid FROM {$CFG->prefix}exercise_submissions s, return get_records_sql("SELECT DISTINCT MAX(a.grade) grade, u.userid FROM
{$CFG->prefix}exercise_submissions s,
{$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u {$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u
WHERE u.course = $exercise->course WHERE u.course = $exercise->course
AND s.userid = u.userid AND s.userid = u.userid
@ -1015,12 +1025,25 @@ function exercise_get_grade_logs($course, $timestart) {
} }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_mean_grade($submission) {
// Returns the mean grade of students' submission (may, very occassionally, be more than one assessment)
global $CFG;
return get_record_sql("SELECT AVG(a.grade) grade FROM
{$CFG->prefix}exercise_assessments a
WHERE a.submissionid = $submission->id
GROUP BY a.submissionid");
}
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_mean_submission_grades($exercise) { function exercise_get_mean_submission_grades($exercise) {
// Returns the mean grades of students' submissions // Returns the mean grades of students' submissions
global $CFG; global $CFG;
return get_records_sql("SELECT DISTINCT AVG(a.grade) grade, u.userid FROM {$CFG->prefix}exercise_submissions s, return get_records_sql("SELECT DISTINCT AVG(a.grade) grade, u.userid FROM
{$CFG->prefix}exercise_submissions s,
{$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u {$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u
WHERE u.course = $exercise->course WHERE u.course = $exercise->course
AND s.userid = u.userid AND s.userid = u.userid

View file

@ -58,43 +58,44 @@
// has the assignment any elements // has the assignment any elements
if (count_records("exercise_elements", "exerciseid", $exercise->id)) { if (count_records("exercise_elements", "exerciseid", $exercise->id)) {
$action = "teachersview"; $action = "teachersview";
} }
else { else {
redirect("assessments.php?action=editelements&id=$cm->id"); redirect("assessments.php?action=editelements&id=$cm->id");
}
} }
} }
}
elseif (!isguest()) { // it's a student then elseif (!isguest()) { // it's a student then
if (!$cm->visible) { if (!$cm->visible) {
notice(get_string("activityiscurrentlyhidden")); notice(get_string("activityiscurrentlyhidden"));
} }
switch ($exercise->phase) { switch ($exercise->phase) {
case 0 : case 0 :
case 1 : $action = 'notavailable'; break; case 1 : $action = 'notavailable'; break;
case 2 : $action = 'studentsview'; break; case 2 : $action = 'studentsview'; break;
case 3 : $action = 'notavailable'; break; case 3 : $action = 'notavailable'; break;
case 4 : $action = 'displayfinalgrade'; case 4 : $action = 'displayfinalgrade';
}
} }
}
else { // it's a guest, oh no! else { // it's a guest, oh no!
$action = 'notavailable'; $action = 'notavailable';
} }
/*********************** close exercise for student assessments and submissions (move to phase 3) (for teachers)**/ /************** close exercise for student assessments and submissions (phase 3) (for teachers)**/
if ($action == 'closeexercise') { if ($action == 'closeexercise') {
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
}
// move tp phase 3
set_field("exercise", "phase", 3, "id", "$exercise->id");
redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 3));
} }
// 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) ************************************/ /****************** display final grade (for students) ************************************/
elseif ($action == 'displayfinalgrade' ) { elseif ($action == 'displayfinalgrade' ) {
// get the final weights from the database // get the final weights from the database
@ -118,11 +119,11 @@
if ($ownassessments = exercise_get_user_assessments($exercise, $USER)) { if ($ownassessments = exercise_get_user_assessments($exercise, $USER)) {
foreach ($ownassessments as $ownassessment) { foreach ($ownassessments as $ownassessment) {
break; // there should only be one break; // there should only be one
}
} }
}
else { else {
$ownassessment->gradinggrade = 0; $ownassessment->gradinggrade = 0;
} }
foreach ($submissions as $submission) { foreach ($submissions as $submission) {
if ($assessments = exercise_get_assessments($submission)) { if ($assessments = exercise_get_assessments($submission)) {
foreach ($assessments as $assessment) { // (normally there should only be one foreach ($assessments as $assessment) { // (normally there should only be one
@ -134,40 +135,40 @@
/ COMMENTSCALE )) * $exercise->grade) / / COMMENTSCALE )) * $exercise->grade) /
($EXERCISE_FWEIGHTS[$teacherweight] + $EXERCISE_FWEIGHTS[$gradingweight]), 1). ($EXERCISE_FWEIGHTS[$teacherweight] + $EXERCISE_FWEIGHTS[$gradingweight]), 1).
"</td></TR>\n"; "</td></TR>\n";
}
} }
} }
} }
}
echo "</TABLE><BR CLEAR=ALL>\n"; echo "</TABLE><BR CLEAR=ALL>\n";
exercise_print_league_table($exercise); exercise_print_league_table($exercise);
} }
/*********************** make final grades available (for teachers only)**************/ /****************** make final grades available (for teachers only)**************/
elseif ($action == 'makeleaguetableavailable') { elseif ($action == 'makeleaguetableavailable') {
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
} }
set_field("exercise", "phase", 4, "id", "$exercise->id"); set_field("exercise", "phase", 4, "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", 4));
add_to_log($course->id, "exercise", "display grades", "view.php?a=$exercise->id", "$exercise->id"); }
}
/*********************** assignment not available (for students)***********************/ /*********************** assignment not available (for students)***********************/
elseif ($action == 'notavailable') { elseif ($action == 'notavailable') {
print_heading(get_string("notavailable", "exercise")); print_heading(get_string("notavailable", "exercise"));
} }
/*********************** open exercise for student assessments and submissions (move to phase 2) (for teachers)**/ /****************** open exercise for student assessments and submissions (phase 2) (for teachers)**/
elseif ($action == 'openexercise') { elseif ($action == 'openexercise') {
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
} }
// move to phase 2, check that teacher has made enough submissions // move to phase 2, check that teacher has made enough submissions
if (exercise_count_teacher_submissions($exercise) == 0) { if (exercise_count_teacher_submissions($exercise) == 0) {
@ -175,32 +176,33 @@
} }
else { else {
set_field("exercise", "phase", 2, "id", "$exercise->id"); set_field("exercise", "phase", 2, "id", "$exercise->id");
redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 2));
add_to_log($course->id, "exercise", "open", "view.php?id=$cm->id", "$exercise->id"); add_to_log($course->id, "exercise", "open", "view.php?id=$cm->id", "$exercise->id");
} redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 2));
} }
}
/*********************** set up assignment (move back to phase 1) (for teachers)***********************/ /****************** set up assignment (move back to phase 1) (for teachers)***********************/
elseif ($action == 'setupassignment') { elseif ($action == 'setupassignment') {
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
} }
set_field("exercise", "phase", 1, "id", "$exercise->id"); set_field("exercise", "phase", 1, "id", "$exercise->id");
add_to_log($course->id, "exercise", "set up", "view.php?id=$cm->id", "$exercise->id");
redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 1)); redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 1));
} }
/*********************** student's view could be in 1 of 4 stages ***********************/ /****************** student's view could be in 1 of 4 stages ***********************/
elseif ($action == 'studentsview') { elseif ($action == 'studentsview') {
exercise_print_assignment_info($exercise); exercise_print_assignment_info($exercise);
// in Stage 1 - the student must make an assessment (linked to the teacher's exercise/submission // in Stage 1 - the student must make an assessment (linked to the teacher's exercise/submission
if (!exercise_test_user_assessments($exercise, $USER)) { if (!exercise_test_user_assessments($exercise, $USER)) {
print_heading(get_string("pleaseviewtheexercise", "exercise", $course->teacher)); print_heading(get_string("pleaseviewtheexercise", "exercise", $course->teacher));
exercise_list_teacher_submissions($exercise, $USER); exercise_list_teacher_submissions($exercise, $USER);
} }
// in stage 2? - submit own first attempt // in stage 2? - submit own first attempt
else { else {
// show assessment the teacher's examples, there may be feedback from teacher // show assessment the teacher's examples, there may be feedback from teacher
@ -210,8 +212,9 @@
// print upload form // print upload form
print_heading(get_string("pleasesubmityourwork", "exercise").":"); print_heading(get_string("pleasesubmityourwork", "exercise").":");
exercise_print_upload_form($exercise); exercise_print_upload_form($exercise);
} }
// in stage 3? - awaiting grading of assessment and assessment of work by teacher, may resubmit if allowed // in stage 3? - awaiting grading of assessment and assessment of work by teacher,
// may resubmit if allowed
else { else {
print_heading(get_string("yourassessment", "exercise")); print_heading(get_string("yourassessment", "exercise"));
exercise_list_teacher_submissions($exercise, $USER); exercise_list_teacher_submissions($exercise, $USER);
@ -224,18 +227,18 @@
print_heading(get_string("pleasesubmityourwork", "exercise").":"); print_heading(get_string("pleasesubmityourwork", "exercise").":");
exercise_print_upload_form($exercise); exercise_print_upload_form($exercise);
echo "<hr size=\"1\" noshade>"; echo "<hr size=\"1\" noshade>";
}
} }
} }
} }
}
/*********************** submission of assignment by teacher only***********************/ /****************** submission of assignment by teacher only***********************/
elseif ($action == 'submitassignment') { elseif ($action == 'submitassignment') {
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
} }
exercise_print_assignment_info($exercise); exercise_print_assignment_info($exercise);
@ -247,7 +250,7 @@
// print upload form // print upload form
print_heading(get_string("submitexercisedescription", "exercise").":"); print_heading(get_string("submitexercisedescription", "exercise").":");
exercise_print_upload_form($exercise); exercise_print_upload_form($exercise);
} }
/****************** teacher's view - display admin page (current phase options) ************/ /****************** teacher's view - display admin page (current phase options) ************/
@ -255,7 +258,7 @@
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
} }
print_heading_with_help(get_string("managingassignment", "exercise"), "managing", "exercise"); print_heading_with_help(get_string("managingassignment", "exercise"), "managing", "exercise");
@ -307,16 +310,16 @@
case 4: // show final grades case 4: // show final grades
print_heading("<A HREF=\"submissions.php?id=$cm->id&action=displayfinalgrades\">". print_heading("<A HREF=\"submissions.php?id=$cm->id&action=displayfinalgrades\">".
get_string("displayoffinalgrades", "exercise")."</A>"); get_string("displayoffinalgrades", "exercise")."</A>");
} }
print_heading("<A HREF=\"submissions.php?id=$cm->id&action=adminlist\">". print_heading("<A HREF=\"submissions.php?id=$cm->id&action=adminlist\">".
get_string("administration")."</A>"); get_string("administration")."</A>");
} }
/*************** no man's land **************************************/ /*************** no man's land **************************************/
else { else {
error("Fatal Error: Unknown Action: ".$action."\n"); error("Fatal Error: Unknown Action: ".$action."\n");
} }
print_footer($course); print_footer($course);