From 067675c006d863682e5eef38f9bafc9a8e80b2e3 Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Fri, 20 Aug 2004 20:12:48 +0000 Subject: [PATCH] introduced the fullname() function in a lot of places. Still not complete though, especially in sorting. --- mod/chat/view.php | 2 +- mod/dialogue/lib.php | 10 +- mod/dialogue/locallib.php | 668 +++++------ mod/exercise/assessments.php | 2048 +++++++++++++++++----------------- mod/exercise/lib.php | 8 +- mod/exercise/locallib.php | 54 +- mod/exercise/submissions.php | 2 +- mod/forum/lib.php | 4 +- mod/forum/report.php | 6 +- mod/glossary/report.php | 6 +- mod/workshop/assessments.php | 1973 ++++++++++++++++---------------- mod/workshop/submissions.php | 1986 +++++++++++++++++---------------- 12 files changed, 3400 insertions(+), 3367 deletions(-) diff --git a/mod/chat/view.php b/mod/chat/view.php index a53f6306be..a314457f14 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -141,7 +141,7 @@ print_user_picture($chatuser->id, 0, $chatuser->picture, false, false, false); echo ""; echo "

"; - echo "$chatuser->firstname $chatuser->lastname
"; + echo fullname($chatuser).'
'; echo "$stridle: ".format_time($lastping, $str).""; echo "

"; echo ""; diff --git a/mod/dialogue/lib.php b/mod/dialogue/lib.php index 3074eec536..fc36fbfab1 100644 --- a/mod/dialogue/lib.php +++ b/mod/dialogue/lib.php @@ -77,7 +77,7 @@ function dialogue_cron () { $strdialogue = get_string("modulename", "dialogue"); unset($dialogueinfo); - $dialogueinfo->userfrom = "$userfrom->firstname $userfrom->lastname"; + $dialogueinfo->userfrom = fullname($userfrom); $dialogueinfo->dialogue = "$dialogue->name"; $dialogueinfo->url = "$CFG->wwwroot/mod/dialogue/view.php?id=$cm->id"; @@ -170,7 +170,7 @@ function dialogue_print_recent_activity($course, $isteacher, $timestart) { //Obtain the visible property from the instance if (instance_is_visible("dialogue",$tempmod)) { $date = userdate($log->time, $strftimerecent); - echo "

$date - $log->firstname $log->lastname
"; + echo '

'.$date.' - '.fullname($log).'
'; echo "\"wwwroot/mod/dialogue/$log->url\">"; echo "$log->name"; echo "\"

"; @@ -204,7 +204,7 @@ function dialogue_print_recent_activity($course, $isteacher, $timestart) { //Obtain the visible property from the instance if (instance_is_visible("dialogue",$tempmod)) { $date = userdate($log->time, $strftimerecent); - echo "

$date - $log->firstname $log->lastname
"; + echo '

'.$date.' - '.fullname($log).'
'; echo "\"wwwroot/mod/dialogue/$log->url\">"; echo "$log->name"; echo "\"

"; @@ -239,7 +239,7 @@ function dialogue_print_recent_activity($course, $isteacher, $timestart) { if (instance_is_visible("dialogue",$tempmod)) { $date = userdate($log->time, $strftimerecent); echo "

$date - ".get_string("namehascloseddialogue", "dialogue", - "$log->firstname $log->lastname")."
"; + fullname($log))."
"; echo "\"wwwroot/mod/dialogue/$log->url\">"; echo "$log->name"; echo "\"

"; @@ -297,7 +297,7 @@ function dialogue_user_complete($course, $user, $mod, $dialogue) { } else { $status = get_string("open", "dialogue"); } - $table->data[] = array("$with->firstname $with->lastname", $byuser." ". + $table->data[] = array(fullname($with), $byuser." ". get_string("of", "dialogue")." ".$total, userdate($conversation->timemodified), $status); } print_table($table); diff --git a/mod/dialogue/locallib.php b/mod/dialogue/locallib.php index 33b9b7e50b..c563fa06fe 100644 --- a/mod/dialogue/locallib.php +++ b/mod/dialogue/locallib.php @@ -10,36 +10,36 @@ function dialogue_count_all_needing_replies_self($user = '') { // function requested by Williams Castillo 17 Oct 2003 global $USER; - if ($user) { - return count_records_select("dialogue_conversations", "(userid = $user->id OR + if ($user) { + return count_records_select("dialogue_conversations", "(userid = $user->id OR recipientid = $user->id) AND lastid != $user->id AND closed = 0"); } else { - return count_records_select("dialogue_conversations", "(userid = $USER->id OR + return count_records_select("dialogue_conversations", "(userid = $USER->id OR recipientid = $USER->id) AND lastid != $USER->id AND closed = 0"); - } + } } ////////////////////////////////////////////////////////////////////////////////////// function dialogue_count_closed($dialogue, $user) { - - return count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND + + return count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND (userid = $user->id OR recipientid = $user->id) AND closed = 1"); - } + } ////////////////////////////////////////////////////////////////////////////////////// function dialogue_count_open($dialogue, $user) { - - return count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND + + return count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND (userid = $user->id OR recipientid = $user->id) AND closed = 0"); } ////////////////////////////////////////////////////////////////////////////////////// function dialogue_count_needing_replies_other($dialogue, $user) { -// count [conversations] needing replies [from] other [person] - return count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND +// count [conversations] needing replies [from] other [person] + return count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND (userid = $user->id OR recipientid = $user->id) AND lastid = $user->id AND closed = 0"); } @@ -47,8 +47,8 @@ function dialogue_count_needing_replies_other($dialogue, $user) { ////////////////////////////////////////////////////////////////////////////////////// function dialogue_count_needing_replies_self($dialogue, $user) { // count [conversations] needing replies [from] self - - return count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND + + return count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND (userid = $user->id OR recipientid = $user->id) AND lastid != $user->id AND closed = 0"); } @@ -129,14 +129,14 @@ function dialogue_get_available_users($dialogue) { ////////////////////////////////////////////////////////////////////////////////////// function dialogue_get_available_students($dialogue) { global $USER; - + if (! $course = get_record("course", "id", $dialogue->course)) { error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { error("Course Module ID was incorrect"); } - + $groupid = get_current_group($course->id); // add current group before list of students if it's the teacher if (isteacher($course->id) and groupmode($course)) { @@ -152,10 +152,10 @@ global $USER; $gnames["spacer"] = "------------"; } // get the students on this course (default sort order)... - if ($users = get_course_students($course->id)) { - foreach ($users as $otheruser) { - // ...exclude self and... - if ($USER->id != $otheruser->id) { + if ($users = get_course_students($course->id)) { + foreach ($users as $otheruser) { + // ...exclude self and... + if ($USER->id != $otheruser->id) { // ...if teacher and groups then exclude students not in the current group if (isteacher($course->id) and groupmode($course) and $groupid) { if (!ismember($groupid, $otheruser->id)) { @@ -168,16 +168,16 @@ global $USER; continue; } } - // ... and any already in any open conversations unless multiple conversations allowed - if ($dialogue->multipleconversations or count_records_select("dialogue_conversations", + // ... and any already in any open conversations unless multiple conversations allowed + if ($dialogue->multipleconversations or count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND ((userid = $USER->id AND recipientid = $otheruser->id) OR (userid = $otheruser->id AND recipientid = $USER->id)) AND closed = 0") == 0) { - $names[$otheruser->id] = fullname($otheruser); - } - } - } - } + $names[$otheruser->id] = fullname($otheruser); + } + } + } + } if (isset($gnames)) { $list = $gnames; } @@ -200,31 +200,31 @@ global $USER; ////////////////////////////////////////////////////////////////////////////////////// function dialogue_get_available_teachers($dialogue) { global $USER; - + if (! $course = get_record("course", "id", $dialogue->course)) { error("Course is misconfigured"); } // get the teachers on this course (default sort order)... - if ($users = get_course_teachers($course->id)) { - // $names[0] = "-----------------------"; - foreach ($users as $otheruser) { + if ($users = get_course_teachers($course->id)) { + // $names[0] = "-----------------------"; + foreach ($users as $otheruser) { // ...exclude self and ... - if ($USER->id != $otheruser->id) { + if ($USER->id != $otheruser->id) { // ...any already in open conversations unless multiple conversations allowed - if ($dialogue->multipleconversations or count_records_select("dialogue_conversations", + if ($dialogue->multipleconversations or count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND ((userid = $USER->id AND recipientid = $otheruser->id) OR (userid = $otheruser->id AND recipientid = $USER->id)) AND closed = 0") == 0) { - $names[$otheruser->id] = fullname($otheruser); - } - } - } - } - if (isset($names)) { + $names[$otheruser->id] = fullname($otheruser); + } + } + } + } + if (isset($names)) { natcasesort($names); - return $names; - } - return; + return $names; + } + return; } @@ -251,59 +251,59 @@ function dialogue_get_users_done($dialogue) { function dialogue_list_conversations_closed($dialogue) { // list the closed for the current user global $USER; - - if (! $course = get_record("course", "id", $dialogue->course)) { + + if (! $course = get_record("course", "id", $dialogue->course)) { error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { error("Course Module ID was incorrect"); } - + if ($conversations = dialogue_get_conversations($dialogue, $USER, "closed = 1")) { // reorder the conversations by (other) name foreach ($conversations as $conversation) { - if ($USER->id != $conversation->userid) { - if (!$with = get_record("user", "id", $conversation->userid)) { - error("User's record not found"); - } - } - else { - if (!$with = get_record("user", "id", $conversation->recipientid)) { - error("User's record not found"); - } - } + if ($USER->id != $conversation->userid) { + if (!$with = get_record("user", "id", $conversation->userid)) { + error("User's record not found"); + } + } + else { + if (!$with = get_record("user", "id", $conversation->recipientid)) { + error("User's record not found"); + } + } $names[$conversation->id] = fullname($with); } natcasesort($names); - print_simple_box_start(); - $table->head = array (get_string("dialoguewith", "dialogue"), get_string("subject", "dialogue"), + print_simple_box_start(); + $table->head = array (get_string("dialoguewith", "dialogue"), get_string("subject", "dialogue"), get_string("numberofentries", "dialogue"), get_string("lastentry", "dialogue"), get_string("status", "dialogue")); - $table->width = "100%"; - $table->align = array ("left", "left", "center", "left", "left"); - $table->size = array ("*", "*", "*", "*", "*"); - $table->cellpadding = 2; - $table->cellspacing = 0; + $table->width = "100%"; + $table->align = array ("left", "left", "center", "left", "left"); + $table->size = array ("*", "*", "*", "*", "*"); + $table->cellpadding = 2; + $table->cellspacing = 0; - foreach ($names as $cid=>$name) { + foreach ($names as $cid=>$name) { if (!$conversation = get_record("dialogue_conversations", "id", $cid)) { error("Closed conversations: could not find conversation record"); } - $total = dialogue_count_entries($dialogue, $conversation); - $byuser = dialogue_count_entries($dialogue, $conversation, $USER); - if ($conversation->closed) { - $status = get_string("closed", "dialogue"); - } else { - $status = get_string("open", "dialogue"); - } - $table->data[] = array("id&action=showdialogues&cid=$conversation->id\">". - "$name", $conversation->subject, $byuser." ".get_string("of", "dialogue")." ".$total, - userdate($conversation->timemodified), $status); - } - print_table($table); - print_simple_box_end(); - } + $total = dialogue_count_entries($dialogue, $conversation); + $byuser = dialogue_count_entries($dialogue, $conversation, $USER); + if ($conversation->closed) { + $status = get_string("closed", "dialogue"); + } else { + $status = get_string("open", "dialogue"); + } + $table->data[] = array("id&action=showdialogues&cid=$conversation->id\">". + "$name", $conversation->subject, $byuser." ".get_string("of", "dialogue")." ".$total, + userdate($conversation->timemodified), $status); + } + print_table($table); + print_simple_box_end(); + } } @@ -311,60 +311,60 @@ function dialogue_list_conversations_closed($dialogue) { function dialogue_list_conversations_other($dialogue) { // list the conversations of the current user awaiting response from the other person global $THEME, $USER; - - if (!$course = get_record("course", "id", $dialogue->course)) { + + if (!$course = get_record("course", "id", $dialogue->course)) { error("Course is misconfigured"); } if (!$cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { error("Course Module ID was incorrect"); } - + $timenow = time(); if ($conversations = dialogue_get_conversations($dialogue, $USER, "lastid = $USER->id AND closed = 0")) { // reorder the conversations by (other) name foreach ($conversations as $conversation) { - if ($USER->id != $conversation->userid) { - if (!$with = get_record("user", "id", $conversation->userid)) { - error("User's record not found"); - } - } - else { - if (!$with = get_record("user", "id", $conversation->recipientid)) { - error("User's record not found"); - } - } + if ($USER->id != $conversation->userid) { + if (!$with = get_record("user", "id", $conversation->userid)) { + error("User's record not found"); + } + } + else { + if (!$with = get_record("user", "id", $conversation->recipientid)) { + error("User's record not found"); + } + } $names[$conversation->id] = fullname($with); } natcasesort($names); - print_simple_box_start(); - $table->head = array (get_string("dialoguewith", "dialogue"), get_string("subject", "dialogue"), + print_simple_box_start(); + $table->head = array (get_string("dialoguewith", "dialogue"), get_string("subject", "dialogue"), get_string("numberofentries", "dialogue"), get_string("lastentry", "dialogue"), get_string("status", "dialogue")); - $table->width = "100%"; - $table->align = array ("left", "left", "center", "left", "left"); - $table->size = array ("*", "*", "*", "*", "*"); - $table->cellpadding = 2; - $table->cellspacing = 0; + $table->width = "100%"; + $table->align = array ("left", "left", "center", "left", "left"); + $table->size = array ("*", "*", "*", "*", "*"); + $table->cellpadding = 2; + $table->cellspacing = 0; - foreach ($names as $cid=>$name) { + foreach ($names as $cid=>$name) { if (!$conversation = get_record("dialogue_conversations", "id", $cid)) { error("Closed conversations: could not find conversation record"); } - $total = dialogue_count_entries($dialogue, $conversation); - $byuser = dialogue_count_entries($dialogue, $conversation, $USER); - if ($conversation->seenon) { - $status = get_string("seen", "dialogue", format_time($timenow - $conversation->seenon)); - } else { - $status = get_string("notyetseen", "dialogue"); - } - $table->data[] = array("id&action=printdialogue&cid=$conversation->id\">". - "$name", $conversation->subject, $byuser." ".get_string("of", "dialogue")." ".$total, - userdate($conversation->timemodified), $status); - } - print_table($table); - print_simple_box_end(); - } + $total = dialogue_count_entries($dialogue, $conversation); + $byuser = dialogue_count_entries($dialogue, $conversation, $USER); + if ($conversation->seenon) { + $status = get_string("seen", "dialogue", format_time($timenow - $conversation->seenon)); + } else { + $status = get_string("notyetseen", "dialogue"); + } + $table->data[] = array("id&action=printdialogue&cid=$conversation->id\">". + "$name", $conversation->subject, $byuser." ".get_string("of", "dialogue")." ".$total, + userdate($conversation->timemodified), $status); + } + print_table($table); + print_simple_box_end(); + } } @@ -372,8 +372,8 @@ function dialogue_list_conversations_other($dialogue) { function dialogue_list_conversations_self($dialogue) { // list open conversations of the current user awaiting their reply global $THEME, $USER; - - if (! $course = get_record("course", "id", $dialogue->course)) { + + if (! $course = get_record("course", "id", $dialogue->course)) { error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { @@ -383,104 +383,104 @@ function dialogue_list_conversations_self($dialogue) { // set up some general variables $usehtmleditor = can_use_html_editor(); - $timenow = time(); - $showbutton = false; - - echo "
\n"; - echo "\n"; - echo "id\">\n"; - echo "\n"; - - // list the conversations requiring a resonse from this user in full - if ($conversations = dialogue_get_conversations($dialogue, $USER, "lastid != $USER->id AND closed = 0")) { - $showbutton = true; - print_simple_box_start("center"); - foreach ($conversations as $conversation) { + $timenow = time(); + $showbutton = false; + + echo "\n"; + echo "\n"; + echo "id\">\n"; + echo "\n"; + + // list the conversations requiring a resonse from this user in full + if ($conversations = dialogue_get_conversations($dialogue, $USER, "lastid != $USER->id AND closed = 0")) { + $showbutton = true; + print_simple_box_start("center"); + foreach ($conversations as $conversation) { // set seenon if required if (!$conversation->seenon) { if (!set_field("dialogue_conversations", "seenon", $timenow, "id", $conversation->id)) { error("List conversations self: could not set seenon"); } } - echo "
\n"; - echo ""; - echo ""; - - if ($entries = get_records_select("dialogue_entries", "conversationid = $conversation->id", + if (dialogue_count_entries($dialogue, $conversation)) { + echo "id&cid=$conversation->id&pane=1\">". + get_string("close", "dialogue")."\n"; + helpbutton("closedialogue", get_string("close", "dialogue"), "dialogue"); + } + else { + echo " "; + } + echo "
"; + + if ($entries = get_records_select("dialogue_entries", "conversationid = $conversation->id", "id")) { - foreach ($entries as $entry) { - if ($entry->userid == $USER->id) { - echo "
\n"; - } - else { - echo "\n"; + } + else { + echo "\n"; - } - } - } - - echo "\n"; - echo "\n"; + } + } + } + + echo "\n"; + echo ""; - echo "
cellheading2\" valign=\"top\">\n"; - if ($conversation->userid == $USER->id) { - if (!$otheruser = get_record("user", "id", $conversation->recipientid)) { - error("User not found"); - } - } - else { - if (!$otheruser = get_record("user", "id", $conversation->userid)) { - error("User not found"); - } - } - // print_user_picture($user->id, $course->id, $user->picture); - echo "".get_string("dialoguewith", "dialogue", "$otheruser->firstname $otheruser->lastname"). + echo "
cellheading2\" valign=\"top\">\n"; + if ($conversation->userid == $USER->id) { + if (!$otheruser = get_record("user", "id", $conversation->recipientid)) { + error("User not found"); + } + } + else { + if (!$otheruser = get_record("user", "id", $conversation->userid)) { + error("User not found"); + } + } + // print_user_picture($user->id, $course->id, $user->picture); + echo "".get_string("dialoguewith", "dialogue", fullname($otheruser)). "cellheading2\">$conversation->subject 
\n"; + echo "
cellheading2\">$conversation->subject 
\n"; echo "
\n"; - if (!$conversation->subject) { + if (!$conversation->subject) { // conversation does not have a subject, show add subject link echo "id&cid=$conversation->id&pane=2\">". - get_string("addsubject", "dialogue")."\n"; - helpbutton("addsubject", get_string("addsubject", "dialogue"), "dialogue"); + get_string("addsubject", "dialogue")."\n"; + helpbutton("addsubject", get_string("addsubject", "dialogue"), "dialogue"); echo "  | "; } - if (dialogue_count_entries($dialogue, $conversation)) { - echo "id&cid=$conversation->id&pane=1\">". - get_string("close", "dialogue")."\n"; - helpbutton("closedialogue", get_string("close", "dialogue"), "dialogue"); - } - else { - echo " "; - } - echo "
\n"; - echo text_to_html("".get_string("onyouwrote", "dialogue", + foreach ($entries as $entry) { + if ($entry->userid == $USER->id) { + echo "
\n"; + echo text_to_html("".get_string("onyouwrote", "dialogue", userdate($entry->timecreated)).":
".$entry->text); - echo "
body\">\n"; - echo text_to_html("".get_string("onwrote", "dialogue", + echo "
body\">\n"; + echo text_to_html("".get_string("onwrote", "dialogue", userdate($entry->timecreated)." ".$otheruser->firstname). ":
".$entry->text); - echo "
\n"; - if ($entries) { - echo "".get_string("typereply", "dialogue")."\n"; - } - else { - echo "".get_string("typefirstentry", "dialogue")."\n"; - } - echo "
\n"; - helpbutton("writing", get_string("helpwriting"), "moodle", true, true); - echo "
"; - echo "
\n"; - // use a cumbersome name on the textarea is just historical :-) + echo "
\n"; + if ($entries) { + echo "".get_string("typereply", "dialogue")."\n"; + } + else { + echo "".get_string("typefirstentry", "dialogue")."\n"; + } + echo "
\n"; + helpbutton("writing", get_string("helpwriting"), "moodle", true, true); + echo "
"; + echo "
\n"; + // use a cumbersome name on the textarea is just historical :-) print_textarea($usehtmleditor, 20, 75, 630, 300, "reply$conversation->id"); - echo "

\n"; - } - print_simple_box_end(); + echo ""; + echo "
\n"; + } + print_simple_box_end(); use_html_editor(); - if ($showbutton) { - echo "
\n"; - echo "
\n"; - } - echo "
\n"; - } + if ($showbutton) { + echo "
\n"; + echo "
\n"; + } + echo "\n"; + } } @@ -488,21 +488,21 @@ function dialogue_list_conversations_self($dialogue) { function dialogue_print_conversation($dialogue, $conversation) { // print a conversation and allow a new entry global $THEME, $USER; - - if (! $course = get_record("course", "id", $dialogue->course)) { + + if (! $course = get_record("course", "id", $dialogue->course)) { error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { error("Course Module ID was incorrect"); } - - $timenow = time(); - $showbutton = false; - - echo "
\n"; - echo "\n"; - echo "id\">\n"; - echo "\n"; + + $timenow = time(); + $showbutton = false; + + echo "\n"; + echo "\n"; + echo "id\">\n"; + echo "\n"; $showbutton = true; print_simple_box_start("center", "", $THEME->cellcontent2); @@ -520,7 +520,7 @@ function dialogue_print_conversation($dialogue, $conversation) { } } // print_user_picture($user->id, $course->id, $user->picture); - echo "".get_string("dialoguewith", "dialogue", "$otheruser->firstname $otheruser->lastname"). + echo "".get_string("dialoguewith", "dialogue", fullname($otheruser)). ""; echo "cellheading2\">$conversation->subject 
\n"; echo "
\n"; @@ -564,12 +564,12 @@ function dialogue_print_conversation($dialogue, $conversation) { use_html_editor(); echo ""; echo "
\n"; - print_simple_box_end(); - if ($showbutton) { - echo "
\n"; - echo "
\n"; - } - echo "\n"; + print_simple_box_end(); + if ($showbutton) { + echo "
\n"; + echo "
\n"; + } + echo "\n"; } @@ -577,26 +577,26 @@ function dialogue_print_conversation($dialogue, $conversation) { function dialogue_print_tabbed_heading($tabs) { // Prints a tabbed heading where one of the tabs highlighted. // $tabs is an object with several properties. -// $tabs->names is an array of tab names -// $tabs->urls is an array of links -// $tabs->align is an array of column alignments (defaults to "center") -// $tabs->size is an array of column sizes -// $tabs->wrap is an array of "nowrap"s or nothing -// $tabs->highlight is an index (zero based) of "active" heading . -// $tabs->width is an percentage of the page (defualts to 80%) -// $tabs->cellpadding padding on each cell (defaults to 5) - - global $CFG, $THEME; - +// $tabs->names is an array of tab names +// $tabs->urls is an array of links +// $tabs->align is an array of column alignments (defaults to "center") +// $tabs->size is an array of column sizes +// $tabs->wrap is an array of "nowrap"s or nothing +// $tabs->highlight is an index (zero based) of "active" heading . +// $tabs->width is an percentage of the page (defualts to 80%) +// $tabs->cellpadding padding on each cell (defaults to 5) + + global $CFG, $THEME; + if (isset($tabs->names)) { foreach ($tabs->names as $key => $name) { if (!empty($tabs->urls[$key])) { - $url =$tabs->urls[$key]; - if ($tabs->highlight == $key) { - $tabcontents[$key] = "$name"; - } else { - $tabcontents[$key] = "$name"; - } + $url =$tabs->urls[$key]; + if ($tabs->highlight == $key) { + $tabcontents[$key] = "$name"; + } else { + $tabcontents[$key] = "$name"; + } } else { $tabcontents[$key] = "$name"; } @@ -617,43 +617,43 @@ function dialogue_print_tabbed_heading($tabs) { if (!empty($tabs->names)) { echo ""; - echo "". - "wwwroot/pix/spacer.gif\" alt=\"\">\n"; + echo "". + "wwwroot/pix/spacer.gif\" alt=\"\">\n"; foreach ($tabcontents as $key => $tab) { if (isset($align[$key])) { - $alignment = "align=\"$align[$key]\""; - } else { + $alignment = "align=\"$align[$key]\""; + } else { $alignment = "align=\"center\""; } if (isset($size[$key])) { $width = "width=\"$size[$key]\""; } else { - $width = ""; - } + $width = ""; + } if (isset($wrap[$key])) { - $wrapping = "no wrap"; - } else { + $wrapping = "no wrap"; + } else { $wrapping = ""; } - if ($key == $tabs->highlight) { - echo "cellheading2\">$tab\n"; - } else { - echo "cellheading\">$tab\n"; - } - echo "". - "wwwroot/pix/spacer.gif\" alt=\"\">\n"; + if ($key == $tabs->highlight) { + echo "cellheading2\">$tab\n"; + } else { + echo "cellheading\">$tab\n"; + } + echo "". + "wwwroot/pix/spacer.gif\" alt=\"\">\n"; } echo "\n"; } else { - echo "No names specified\n"; - } - // bottom stripe - $ncells = count($tabs->names)*2 +1; - $height = 2; - echo "cellheading2\">". - "wwwroot/pix/spacer.gif\" alt=\"\">\n"; + echo "No names specified\n"; + } + // bottom stripe + $ncells = count($tabs->names)*2 +1; + $height = 2; + echo "cellheading2\">". + "wwwroot/pix/spacer.gif\" alt=\"\">\n"; echo "\n"; - // print_simple_box_end(); + // print_simple_box_end(); return true; } @@ -663,55 +663,55 @@ function dialogue_print_tabbed_heading($tabs) { ////////////////////////////////////////////////////////////////////////////////////// function dialogue_show_conversation($dialogue, $conversation) { global $THEME, $USER; - - if (! $course = get_record("course", "id", $dialogue->course)) { + + if (! $course = get_record("course", "id", $dialogue->course)) { error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { error("Course Module ID was incorrect"); } - - $timenow = time(); - print_simple_box_start("center"); - echo "
\n"; - - echo ""; - echo "\n"; + } + } + } + echo "
cellheading2\" valign=\"top\">\n"; - if ($conversation->userid == $USER->id) { - if (!$otheruser = get_record("user", "id", $conversation->recipientid)) { - error("User not found"); - } - } - else { - if (!$otheruser = get_record("user", "id", $conversation->userid)) { - error("User not found"); - } - } - // print_user_picture($user->id, $course->id, $user->picture); - echo "".get_string("dialoguewith", "dialogue", "$otheruser->firstname $otheruser->lastname"). + + $timenow = time(); + print_simple_box_start("center"); + echo "
\n"; + + echo ""; + echo ""; - echo ""; + echo ""; - if ($entries = get_records_select("dialogue_entries", "conversationid = $conversation->id", "id")) { - foreach ($entries as $entry) { - if ($entry->userid == $USER->id) { - echo "\n"; - } - else { - echo "\n"; + } + else { + echo "\n"; - } - } - } - echo "
cellheading2\" valign=\"top\">\n"; + if ($conversation->userid == $USER->id) { + if (!$otheruser = get_record("user", "id", $conversation->recipientid)) { + error("User not found"); + } + } + else { + if (!$otheruser = get_record("user", "id", $conversation->userid)) { + error("User not found"); + } + } + // print_user_picture($user->id, $course->id, $user->picture); + echo "".get_string("dialoguewith", "dialogue", fullname($otheruser)). "cellheading2\" valign=\"top\">$conversation->subject 
cellheading2\" valign=\"top\">$conversation->subject 
\n"; - echo text_to_html("".get_string("onyouwrote", "dialogue", + if ($entries = get_records_select("dialogue_entries", "conversationid = $conversation->id", "id")) { + foreach ($entries as $entry) { + if ($entry->userid == $USER->id) { + echo "
\n"; + echo text_to_html("".get_string("onyouwrote", "dialogue", userdate($entry->timecreated)). - ":
".$entry->text); - echo "
body\">\n"; - echo text_to_html("".get_string("onwrote", "dialogue", + ":
".$entry->text); + echo "
body\">\n"; + echo text_to_html("".get_string("onwrote", "dialogue", userdate($entry->timecreated)." ".$otheruser->firstname).":
".$entry->text); - echo "

\n"; - print_simple_box_end(); - print_continue("view.php?id=$cm->id&pane=3"); + echo "

\n"; + print_simple_box_end(); + print_continue("view.php?id=$cm->id&pane=3"); } @@ -719,29 +719,29 @@ function dialogue_show_conversation($dialogue, $conversation) { function dialogue_show_other_conversations($dialogue, $conversation) { // prints the other CLOSED conversations for this pair of users global $THEME; - - if (! $course = get_record("course", "id", $dialogue->course)) { + + if (! $course = get_record("course", "id", $dialogue->course)) { error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { error("Course Module ID was incorrect"); } - - if (!$user = get_record("user", "id", $conversation->userid)) { - error("User not found"); - } - if (!$otheruser = get_record("user", "id", $conversation->recipientid)) { - error("User not found"); - } - - if ($conversations = get_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND - ((userid = $user->id AND recipientid = $otheruser->id) OR (userid = $otheruser->id AND + + if (!$user = get_record("user", "id", $conversation->userid)) { + error("User not found"); + } + if (!$otheruser = get_record("user", "id", $conversation->recipientid)) { + error("User not found"); + } + + if ($conversations = get_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND + ((userid = $user->id AND recipientid = $otheruser->id) OR (userid = $otheruser->id AND recipientid = $user->id)) AND closed = 1", "timemodified DESC")) { - if (count($conversations) > 1) { - $timenow = time(); - foreach ($conversations as $otherconversation) { - if ($conversation->id != $otherconversation->id) { - // for this conversation work out which is the other user + if (count($conversations) > 1) { + $timenow = time(); + foreach ($conversations as $otherconversation) { + if ($conversation->id != $otherconversation->id) { + // for this conversation work out which is the other user if ($otherconversation->userid == $user->id) { if (!$otheruser = get_record("user", "id", $otherconversation->recipientid)) { error("Show other conversations: could not get user record"); @@ -753,40 +753,40 @@ function dialogue_show_other_conversations($dialogue, $conversation) { } } print_simple_box_start("center"); - echo "
\n"; - - echo ""; - echo ""; + echo "
cellheading2\" VALIGN=TOP>\n"; - // print_user_picture($otheruser->id, $course->id, $otheruser->picture); - echo "".get_string("dialoguewith", "dialogue", - "$otheruser->firstname $otheruser->lastname")."
\n"; + + echo ""; + echo ""; echo ""; - if ($entries = get_records_select("dialogue_entries", + if ($entries = get_records_select("dialogue_entries", "conversationid = $otherconversation->id", "id")) { - foreach ($entries as $entry) { - if ($entry->userid == $user->id) { - echo "\n"; - } - else { - echo "\n"; + } + else { + echo "\n"; - } - } - } - - echo "
cellheading2\" VALIGN=TOP>\n"; + // print_user_picture($otheruser->id, $course->id, $otheruser->picture); + echo "".get_string("dialoguewith", "dialogue", + fullname($otheruser))."cellheading2\" valign=\"top\">$otherconversation->subject 
\n"; - echo text_to_html("".get_string("onyouwrote", "dialogue", + foreach ($entries as $entry) { + if ($entry->userid == $user->id) { + echo "
\n"; + echo text_to_html("".get_string("onyouwrote", "dialogue", userdate($entry->timecreated)).":
".$entry->text); - echo "
body\">\n"; - echo text_to_html("".get_string("onwrote", "dialogue", + echo "
body\">\n"; + echo text_to_html("".get_string("onwrote", "dialogue", userdate($entry->timecreated)." ".$otheruser->firstname). ":
".$entry->text); - echo "

\n"; - print_simple_box_end(); - } - } - print_continue("view.php?id=$cm->id&pane=3"); + echo "\n"; + } + } + } + + echo "
\n"; + print_simple_box_end(); + } + } + print_continue("view.php?id=$cm->id&pane=3"); } - } + } } diff --git a/mod/exercise/assessments.php b/mod/exercise/assessments.php index c42d4a11bc..de7d499ab0 100644 --- a/mod/exercise/assessments.php +++ b/mod/exercise/assessments.php @@ -1,56 +1,56 @@ course)) { - error("Course is misconfigured"); - } + if (! $course = get_record("course", "id", $cm->course)) { + error("Course is misconfigured"); + } - if (! $exercise = get_record("exercise", "id", $cm->instance)) { - error("Course module is incorrect"); - } + if (! $exercise = get_record("exercise", "id", $cm->instance)) { + error("Course module is incorrect"); + } exercise_add_custom_scales($exercise); require_login($course->id); - + $navigation = ""; if ($course->category) { $navigation = "id\">$course->shortname ->"; @@ -59,29 +59,29 @@ $strexercises = get_string("modulenameplural", "exercise"); $strexercise = get_string("modulename", "exercise"); $strassessments = get_string("assessments", "exercise"); - - // ... print the header and... + + // ... print the header and... print_header("$course->shortname: $exercise->name", "$course->fullname", "$navigation id>$strexercises -> id\">$exercise->name -> $strassessments", "", "", true); - //...get the action - require_variable($action); - - - /******************* admin amend Grading Grade ************************************/ - if ($action == 'adminamendgradinggrade' ) { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - if (empty($_GET['aid'])) { - error("Admin Amend Grading grade: assessment id missing"); - } - - if (!$assessment = get_record("exercise_assessments", "id", $_GET['aid'])) { - error("Amin Amend Grading grade: assessment not found"); + //...get the action + require_variable($action); + + + /******************* admin amend Grading Grade ************************************/ + if ($action == 'adminamendgradinggrade' ) { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_GET['aid'])) { + error("Admin Amend Grading grade: assessment id missing"); + } + + if (!$assessment = get_record("exercise_assessments", "id", $_GET['aid'])) { + error("Amin Amend Grading grade: assessment not found"); } print_heading(get_string("amend", "exercise")." ".get_string("gradeforstudentsassessment", "exercise", $course->student)); @@ -90,15 +90,15 @@ echo "\n"; echo "id\">\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; @@ -106,502 +106,506 @@ echo ""; echo "\n"; } - + - /******************* admin confirm delete ************************************/ + /******************* admin confirm delete ************************************/ elseif ($action == 'adminconfirmdelete' ) { - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - if (empty($_GET['aid'])) { - error("Admin confirm delete: assessment id missing"); - } - - notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("assessment", "exercise")), - "assessments.php?action=admindelete&id=$cm->id&aid=$_GET[aid]", + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_GET['aid'])) { + error("Admin confirm delete: assessment id missing"); + } + + notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("assessment", "exercise")), + "assessments.php?action=admindelete&id=$cm->id&aid=$_GET[aid]", "submissions.php?action=adminlist&id=$cm->id"); - } - - - /******************* admin delete ************************************/ - elseif ($action == 'admindelete' ) { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - if (empty($_GET['aid'])) { - error("Admin delete: submission id missing"); - } - - print_string("deleting", "exercise"); - // first delete all the associated records... - delete_records("exercise_grades", "assessmentid", $_GET['aid']); - // ...now delete the assessment... - delete_records("exercise_assessments", "id", $_GET['aid']); - - print_continue("submissions.php?id=$cm->id&action=adminlist"); - } - - - /*********************** admin list of asssessments (of a submission) (by teachers)**************/ - elseif ($action == 'adminlist') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - if (empty($_GET['sid'])) { - error ("exercise asssessments: adminlist called with no sid"); - } - $submission = get_record("exercise_submissions", "id", $_GET['sid']); - exercise_print_assessments_for_admin($exercise, $submission); - print_continue("submissions.php?action=adminlist&id=$cm->id"); - } - - - /****************** admin list of asssessments by a student (used by teachers only )******************/ - elseif ($action == 'adminlistbystudent') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - if (empty($_GET['userid'])) { - error ("exercise asssessments: adminlistbystudent called with no userid"); - } - $user = get_record("user", "id", $_GET['userid']); - exercise_print_assessments_by_user_for_admin($exercise, $user); - print_continue("submissions.php?action=adminlist&id=$cm->id"); - } - - - /****************** Assess resubmission (by teacher) ***************************/ - elseif ($action == 'assessresubmission') { - - require_variable($sid); - - if (! $submission = get_record("exercise_submissions", "id", $sid)) { - error("Assess submission is misconfigured - no submission record!"); - } - if (!$submissionowner = get_record("user", "id", $submission->userid)) { - error("Assess resubmission: user record not found"); - } - - // there can be an assessment record, if there isn't... - if (!$assessment = exercise_get_submission_assessment($submission, $USER)) { - if (!$submissions = exercise_get_user_submissions($exercise, $submissionowner)) { - error("Assess resubmission: submission records not found"); - } - $lastone= ''; + } + + + /******************* admin delete ************************************/ + elseif ($action == 'admindelete' ) { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_GET['aid'])) { + error("Admin delete: submission id missing"); + } + + print_string("deleting", "exercise"); + // first delete all the associated records... + delete_records("exercise_grades", "assessmentid", $_GET['aid']); + // ...now delete the assessment... + delete_records("exercise_assessments", "id", $_GET['aid']); + + print_continue("submissions.php?id=$cm->id&action=adminlist"); + } + + + /*********************** admin list of asssessments (of a submission) (by teachers)**************/ + elseif ($action == 'adminlist') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + if (empty($_GET['sid'])) { + error ("exercise asssessments: adminlist called with no sid"); + } + $submission = get_record("exercise_submissions", "id", $_GET['sid']); + exercise_print_assessments_for_admin($exercise, $submission); + print_continue("submissions.php?action=adminlist&id=$cm->id"); + } + + + /****************** admin list of asssessments by a student (used by teachers only )******************/ + elseif ($action == 'adminlistbystudent') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + if (empty($_GET['userid'])) { + error ("exercise asssessments: adminlistbystudent called with no userid"); + } + $user = get_record("user", "id", $_GET['userid']); + exercise_print_assessments_by_user_for_admin($exercise, $user); + print_continue("submissions.php?action=adminlist&id=$cm->id"); + } + + + /****************** Assess resubmission (by teacher) ***************************/ + elseif ($action == 'assessresubmission') { + + require_variable($sid); + + if (! $submission = get_record("exercise_submissions", "id", $sid)) { + error("Assess submission is misconfigured - no submission record!"); + } + if (!$submissionowner = get_record("user", "id", $submission->userid)) { + error("Assess resubmission: user record not found"); + } + + // there can be an assessment record, if there isn't... + if (!$assessment = exercise_get_submission_assessment($submission, $USER)) { + if (!$submissions = exercise_get_user_submissions($exercise, $submissionowner)) { + error("Assess resubmission: submission records not found"); + } + $lastone= ''; // just the last but one submission - foreach ($submissions as $submission) { - $prevsubmission = $lastone; + foreach ($submissions as $submission) { + $prevsubmission = $lastone; $lastone = $submission; } - // get the teacher's assessment of the student's previous submission - if (!$prevassessment = exercise_get_submission_assessment($prevsubmission, $USER)) { - error("Assess resubmission: Previous assessment record not found"); - } - // copy this assessment with comments... - $assessment = exercise_copy_assessment($prevassessment, $submission, true); - } - - print_heading(get_string("thisisaresubmission", "exercise", - "$submissionowner->firstname $submissionowner->lastname")); - // show assessment and allow changes - exercise_print_assessment_form($exercise, $assessment, true, $_SERVER["HTTP_REFERER"]); - } - - - /****************** Assess submission (by teacher or student) ***************************/ - elseif ($action == 'assesssubmission') { - - require_variable($sid); - - if (! $submission = get_record("exercise_submissions", "id", $sid)) { - error("Assess submission is misconfigured - no submission record!"); - } - - // there can be an assessment record (for teacher submissions), if there isn't... - 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 - $assessment->exerciseid = $exercise->id; - $assessment->submissionid = $submission->id; - $assessment->userid = $USER->id; - $assessment->grade = -1; // set impossible grade - $assessment->timecreated = $yearfromnow; - $assessment->timegraded = 0; - if (!$assessment->id = insert_record("exercise_assessments", $assessment)) { - error("Could not insert exercise assessment!"); - } - } - - // show assessment and allow changes - exercise_print_assessment_form($exercise, $assessment, true, $_SERVER["HTTP_REFERER"]); - } - - - /****************** display grading form (viewed by student) *********************************/ - elseif ($action == 'displaygradingform') { - - print_heading_with_help(get_string("specimenassessmentform", "exercise"), "specimen", "exercise"); - - exercise_print_assessment_form($exercise); // called with no assessment - print_continue("view.php?id=$cm->id"); - } - - - /****************** edit assessment elements (for teachers) ***********************/ - elseif ($action == 'editelements') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - $count = count_records("exercise_grades", "exerciseid", $exercise->id); - if ($exercise->phase > 1 and $count) { - notify(get_string("warningonamendingelements", "exercise")); - } - // set up heading, form and table - print_heading_with_help(get_string("editingassessmentelements", "exercise"), "elements", "exercise"); - ?> - - - -
".get_string("gradeforstudentsassessment", "exercise", + echo "
".get_string("gradeforstudentsassessment", "exercise", $course->student)." :\n"; - // set up coment scale - for ($i=$exercise->gradinggrade; $i>=0; $i--) { - $num[$i] = $i; - } - choose_from_menu($num, "gradinggrade", + // set up coment scale + for ($i=$exercise->gradinggrade; $i>=0; $i--) { + $num[$i] = $i; + } + choose_from_menu($num, "gradinggrade", number_format($exercise->gradinggrade * $assessment->gradinggrade / 100, 0), ""); - echo "
"; echo "\n"; echo "
- id, "elementno ASC" )) { - foreach ($elementsraw as $element) { - $elements[] = $element; // to renumber index 0,1,2... - } - } - // check for missing elements (this happens either the first time round or when the number + // get the teacher's assessment of the student's previous submission + if (!$prevassessment = exercise_get_submission_assessment($prevsubmission, $USER)) { + error("Assess resubmission: Previous assessment record not found"); + } + // copy this assessment with comments... + $assessment = exercise_copy_assessment($prevassessment, $submission, true); + } + + print_heading(get_string("thisisaresubmission", "exercise", + fullname($submissionowner))); + // show assessment and allow changes + exercise_print_assessment_form($exercise, $assessment, true, $_SERVER["HTTP_REFERER"]); + } + + + /****************** Assess submission (by teacher or student) ***************************/ + elseif ($action == 'assesssubmission') { + + require_variable($sid); + + if (! $submission = get_record("exercise_submissions", "id", $sid)) { + error("Assess submission is misconfigured - no submission record!"); + } + + // there can be an assessment record (for teacher submissions), if there isn't... + 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 + $assessment->exerciseid = $exercise->id; + $assessment->submissionid = $submission->id; + $assessment->userid = $USER->id; + $assessment->grade = -1; // set impossible grade + $assessment->timecreated = $yearfromnow; + $assessment->timegraded = 0; + if (!$assessment->id = insert_record("exercise_assessments", $assessment)) { + error("Could not insert exercise assessment!"); + } + } + + // show assessment and allow changes + exercise_print_assessment_form($exercise, $assessment, true, $_SERVER["HTTP_REFERER"]); + } + + + /****************** display grading form (viewed by student) *********************************/ + elseif ($action == 'displaygradingform') { + + print_heading_with_help(get_string("specimenassessmentform", "exercise"), "specimen", "exercise"); + + exercise_print_assessment_form($exercise); // called with no assessment + print_continue("view.php?id=$cm->id"); + } + + + /****************** edit assessment elements (for teachers) ***********************/ + elseif ($action == 'editelements') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + $count = count_records("exercise_grades", "exerciseid", $exercise->id); + if ($exercise->phase > 1 and $count) { + notify(get_string("warningonamendingelements", "exercise")); + } + // set up heading, form and table + print_heading_with_help(get_string("editingassessmentelements", "exercise"), "elements", "exercise"); + ?> + + + +
+ id, "elementno ASC" )) { + foreach ($elementsraw as $element) { + $elements[] = $element; // to renumber index 0,1,2... + } + } + // check for missing elements (this happens either the first time round or when the number // of elements is icreased) - for ($i=0; $i<$exercise->nelements; $i++) { - if (!isset($elements[$i])) { - $elements[$i]->description = ''; - $elements[$i]->scale =0; - $elements[$i]->maxscore = 0; - $elements[$i]->weight = 11; - } - } - switch ($exercise->gradingstrategy) { - case 0: // no grading - for ($i=0; $i<$exercise->nelements; $i++) { - $iplus1 = $i+1; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - } - break; - - case 1: // accumulative grading - // set up scales name - foreach ($EXERCISE_SCALES as $KEY => $SCALE) { - $SCALES[] = $SCALE['name']; - } + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + } + break; + + case 1: // accumulative grading + // set up scales name + foreach ($EXERCISE_SCALES as $KEY => $SCALE) { + $SCALES[] = $SCALE['name']; + } - for ($i=0; $i<$exercise->nelements; $i++) { - $iplus1 = $i+1; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - } - break; - - case 2: // error banded grading - for ($i=0; $i<$exercise->nelements; $i++) { - $iplus1 = $i+1; - echo "\n"; - echo " \n"; - echo "\n"; - if ($elements[$i]->weight == '') { // not set - $elements[$i]->weight = 11; // unity - } - echo "\n"; - echo "\n"; + if ($elements[$i]->weight == '') { // not set + $elements[$i]->weight = 11; // unity + } + echo "\n"; + echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - } - echo "

". get_string("element","exercise")." $iplus1:

\n"; - echo "
cellheading2\"> 
cellheading2\"> 

". get_string("element","exercise")." $iplus1:

\n"; - echo "

". get_string("typeofscale", "exercise"). ":

\n"; - choose_from_menu($SCALES, "scale[]", $elements[$i]->scale, ""); - if ($elements[$i]->weight == '') { // not set - $elements[$i]->weight = 11; // unity - } - echo "
".get_string("elementweight", "exercise"). + echo "

". get_string("typeofscale", "exercise"). ":

\n"; + choose_from_menu($SCALES, "scale[]", $elements[$i]->scale, ""); + if ($elements[$i]->weight == '') { // not set + $elements[$i]->weight = 11; // unity + } + echo "
".get_string("elementweight", "exercise"). ":\n"; - exercise_choose_from_menu($EXERCISE_EWEIGHTS, "weight[]", $elements[$i]->weight, ""); - echo "
cellheading2\"> 

". get_string("element","exercise")." $iplus1:

\n"; - echo "
".get_string("elementweight", "exercise"). + echo "
".get_string("elementweight", "exercise"). ":\n"; - exercise_choose_from_menu($EXERCISE_EWEIGHTS, "weight[]", $elements[$i]->weight, ""); - echo "
cellheading2\"> 

\n"; - echo "

".get_string("gradetable","exercise")."
\n"; - echo "
\n"; - for ($j = $exercise->grade; $j >= 0; $j--) { - $numbers[$j] = $j; - } - for ($i=0; $i<=$exercise->nelements; $i++) { - echo "\n"; - } - break; - - case 3: // criterion grading - for ($j = $exercise->grade; $j >= 0; $j--) { - $numbers[$j] = $j; - } - for ($i=0; $i<$exercise->nelements; $i++) { - $iplus1 = $i+1; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - } - break; - - case 4: // rubric - for ($j = 100; $j >= 0; $j--) { - $numbers[$j] = $j; - } - if ($rubricsraw = get_records("exercise_rubrics", "exerciseid", $exercise->id)) { - foreach ($rubricsraw as $rubric) { - $rubrics[$rubric->elementno][$rubric->rubricno] = $rubric->description; // reindex 0,1,2... - } - } - for ($i=0; $i<$exercise->nelements; $i++) { - $iplus1 = $i+1; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; + echo "\n"; - echo "\n"; - - for ($j=0; $j<5; $j++) { - $jplus1 = $j+1; - if (empty($rubrics[$i][$j])) { - $rubrics[$i][$j] = ""; - } - echo "\n"; - echo " \n"; - echo "\n"; - } - echo "\n"; - echo " \n"; - echo "\n"; - } - break; - } - // close table and form - ?> -
". - get_string("numberofnegativeresponses", "exercise"); - echo "". get_string("suggestedgrade", "exercise")."
$i"; - if (!isset($elements[$i])) { // the "last one" will be! - $elements[$i]->description = ""; - $elements[$i]->maxscore = 0; - } - choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, ""); - echo "

". get_string("criterion","exercise")." $iplus1:

\n"; - echo "
". get_string("suggestedgrade", "exercise").":\n"; - choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, ""); - echo "
cellheading2\"> 

". get_string("element","exercise")." $iplus1:

\n"; - echo "
".get_string("elementweight", "exercise"). + echo "
".get_string("elementweight", "exercise"). ":\n"; - exercise_choose_from_menu($EXERCISE_EWEIGHTS, "weight[]", $elements[$i]->weight, ""); - echo "

". get_string("grade")." $j:

\n"; - echo "
cellheading2\"> 

- "> - "> -
- - id)) { - error("Only teachers can look at this page"); - } - - $form = (object)$HTTP_POST_VARS; - - // let's not fool around here, dump the junk! - delete_records("exercise_elements", "exerciseid", $exercise->id); + echo " \n"; + } + echo "\n"; + echo " cellheading2\"> \n"; + echo "\n"; + } + break; + } + // close table and form + + ?> +
+ "> + "> + + + + id)) { + error("Only teachers can look at this page"); + } + + $form = (object)$HTTP_POST_VARS; + + // let's not fool around here, dump the junk! + delete_records("exercise_elements", "exerciseid", $exercise->id); - // determine wich type of grading - switch ($exercise->gradingstrategy) { - case 0: // no grading - // Insert all the elements that contain something - foreach ($form->description as $key => $description) { - if ($description) { - unset($element); - $element->description = $description; - $element->exerciseid = $exercise->id; - $element->elementno = $key; - if (!$element->id = insert_record("exercise_elements", $element)) { - error("Could not insert exercise element!"); - } - } - } - break; - - case 1: // accumulative grading - // Insert all the elements that contain something - foreach ($form->description as $key => $description) { - if ($description) { - unset($element); - $element->description = $description; - $element->exerciseid = $exercise->id; - $element->elementno = $key; - if (isset($form->scale[$key])) { - $element->scale = $form->scale[$key]; - switch ($EXERCISE_SCALES[$form->scale[$key]]['type']) { - case 'radio' : $element->maxscore = $EXERCISE_SCALES[$form->scale[$key]]['size'] - 1; - break; - case 'selection' : $element->maxscore = $EXERCISE_SCALES[$form->scale[$key]]['size']; - break; - } - } - if (isset($form->weight[$key])) { - $element->weight = $form->weight[$key]; - } - if (!$element->id = insert_record("exercise_elements", $element)) { - error("Could not insert exercise element!"); - } - } - } - break; - - case 2: // error banded grading... - case 3: // ...and criterion grading - // Insert all the elements that contain something, the number of descriptions is + // determine wich type of grading + switch ($exercise->gradingstrategy) { + case 0: // no grading + // Insert all the elements that contain something + foreach ($form->description as $key => $description) { + if ($description) { + unset($element); + $element->description = $description; + $element->exerciseid = $exercise->id; + $element->elementno = $key; + if (!$element->id = insert_record("exercise_elements", $element)) { + error("Could not insert exercise element!"); + } + } + } + break; + + case 1: // accumulative grading + // Insert all the elements that contain something + foreach ($form->description as $key => $description) { + if ($description) { + unset($element); + $element->description = $description; + $element->exerciseid = $exercise->id; + $element->elementno = $key; + if (isset($form->scale[$key])) { + $element->scale = $form->scale[$key]; + switch ($EXERCISE_SCALES[$form->scale[$key]]['type']) { + case 'radio' : $element->maxscore = $EXERCISE_SCALES[$form->scale[$key]]['size'] - 1; + break; + case 'selection' : $element->maxscore = $EXERCISE_SCALES[$form->scale[$key]]['size']; + break; + } + } + if (isset($form->weight[$key])) { + $element->weight = $form->weight[$key]; + } + if (!$element->id = insert_record("exercise_elements", $element)) { + error("Could not insert exercise element!"); + } + } + } + break; + + case 2: // error banded grading... + case 3: // ...and criterion grading + // Insert all the elements that contain something, the number of descriptions is // one less than the number of grades - foreach ($form->maxscore as $key => $themaxscore) { - unset($element); - $element->exerciseid = $exercise->id; - $element->elementno = $key; - $element->maxscore = $themaxscore; - if (isset($form->description[$key])) { - $element->description = $form->description[$key]; - } - if (isset($form->weight[$key])) { - $element->weight = $form->weight[$key]; - } - if (!$element->id = insert_record("exercise_elements", $element)) { - error("Could not insert exercise element!"); - } - } - break; - - case 4: // ...and criteria grading - // Insert all the elements that contain something - foreach ($form->description as $key => $description) { - unset($element); - $element->exerciseid = $exercise->id; - $element->elementno = $key; - $element->description = $description; - $element->weight = $form->weight[$key]; - for ($j=0;$j<5;$j++) { - if (empty($form->rubric[$key][$j])) - break; - } - $element->maxscore = $j - 1; - if (!$element->id = insert_record("exercise_elements", $element)) { - error("Could not insert exercise element!"); - } - } - // let's not fool around here, dump the junk! - delete_records("exercise_rubrics", "exerciseid", $exercise->id); - for ($i=0;$i<$exercise->nelements;$i++) { - for ($j=0;$j<5;$j++) { - unset($element); - if (empty($form->rubric[$i][$j])) { // OK to have an element with fewer than 5 items - break; - } - $element->exerciseid = $exercise->id; - $element->elementno = $i; - $element->rubricno = $j; - $element->description = $form->rubric[$i][$j]; - if (!$element->id = insert_record("exercise_rubrics", $element)) { - error("Could not insert exercise element!"); - } - } - } - break; - } // end of switch - redirect("view.php?id=$cm->id", get_string("savedok", "exercise")); - } - - - /****************** list assessments for grading (Student submissions)(by teachers)*********************/ - elseif ($action == 'listungradedstudentsubmissions') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - exercise_list_ungraded_assessments($exercise, "student"); - print_continue("view.php?id=$cm->id"); - } - - - /***************** list assessments for grading student assessments ( linked to the + foreach ($form->maxscore as $key => $themaxscore) { + unset($element); + $element->exerciseid = $exercise->id; + $element->elementno = $key; + $element->maxscore = $themaxscore; + if (isset($form->description[$key])) { + $element->description = $form->description[$key]; + } + if (isset($form->weight[$key])) { + $element->weight = $form->weight[$key]; + } + if (!$element->id = insert_record("exercise_elements", $element)) { + error("Could not insert exercise element!"); + } + } + break; + + case 4: // ...and criteria grading + // Insert all the elements that contain something + foreach ($form->description as $key => $description) { + unset($element); + $element->exerciseid = $exercise->id; + $element->elementno = $key; + $element->description = $description; + $element->weight = $form->weight[$key]; + for ($j=0;$j<5;$j++) { + if (empty($form->rubric[$key][$j])) + break; + } + $element->maxscore = $j - 1; + if (!$element->id = insert_record("exercise_elements", $element)) { + error("Could not insert exercise element!"); + } + } + // let's not fool around here, dump the junk! + delete_records("exercise_rubrics", "exerciseid", $exercise->id); + for ($i=0;$i<$exercise->nelements;$i++) { + for ($j=0;$j<5;$j++) { + unset($element); + if (empty($form->rubric[$i][$j])) { // OK to have an element with fewer than 5 items + break; + } + $element->exerciseid = $exercise->id; + $element->elementno = $i; + $element->rubricno = $j; + $element->description = $form->rubric[$i][$j]; + if (!$element->id = insert_record("exercise_rubrics", $element)) { + error("Could not insert exercise element!"); + } + } + } + break; + } // end of switch + redirect("view.php?id=$cm->id", get_string("savedok", "exercise")); + } + + + /****************** list assessments for grading (Student submissions)(by teachers)*********************/ + elseif ($action == 'listungradedstudentsubmissions') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + exercise_list_ungraded_assessments($exercise, "student"); + print_continue("view.php?id=$cm->id"); + } + + + /***************** list assessments for grading student assessments ( linked to the ******************Teacher's submissions) (by teachers)****/ - elseif ($action == 'listungradedstudentassessments') { + elseif ($action == 'listungradedstudentassessments') { - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - exercise_list_ungraded_assessments($exercise, "teacher"); - print_continue("view.php?id=$cm->id"); - } + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + exercise_list_ungraded_assessments($exercise, "teacher"); + print_continue("view.php?id=$cm->id"); + } - /****************** list teacher submissions ***********************/ - elseif ($action == 'listteachersubmissions') { + /****************** list teacher submissions ***********************/ + elseif ($action == 'listteachersubmissions') { - exercise_list_teacher_submissions($exercise, $USER); - print_continue("view.php?id=$cm->id"); - } + exercise_list_teacher_submissions($exercise, $USER); + print_continue("view.php?id=$cm->id"); + } - /******************* regrade student assessments ************************************/ + /******************* regrade student assessments ************************************/ elseif ($action == 'regradestudentassessments' ) { - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); } // get all the student assessments - if ($assessments = exercise_get_teacher_submission_assessments($exercise)) { + if ($assessments = exercise_get_teacher_submission_assessments($exercise)) { foreach ($assessments as $studentassessment) { if ($studentassessment->timegraded > 0) { if (!$submissions = get_records_select("exercise_submissions", @@ -623,535 +627,535 @@ } } } - redirect("submissions.php?id=$cm->id&action=adminlist"); - } - - - /****************** teacher assessment : grading of assessment and submission (from student) ************/ - elseif ($action == 'teacherassessment') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - require_variable($aid); - require_variable($sid); - if (!$assessment = get_record("exercise_assessments", "id", $aid)) { - error("Teacher assessment: User's assessment record not found"); - } - if (!$submission = get_record("exercise_submissions", "id", $sid)) { - error("Teacher assessment: User's submission record not found"); - } - exercise_print_teacher_assessment_form($exercise, $assessment, $submission, $_SERVER["HTTP_REFERER"]); - } - - - /****************** teacher table : show assessments by exercise and teacher ************/ - elseif ($action == 'teachertable') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - exercise_print_teacher_table($course); + redirect("submissions.php?id=$cm->id&action=adminlist"); + } + + + /****************** teacher assessment : grading of assessment and submission (from student) ************/ + elseif ($action == 'teacherassessment') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + require_variable($aid); + require_variable($sid); + if (!$assessment = get_record("exercise_assessments", "id", $aid)) { + error("Teacher assessment: User's assessment record not found"); + } + if (!$submission = get_record("exercise_submissions", "id", $sid)) { + error("Teacher assessment: User's submission record not found"); + } + exercise_print_teacher_assessment_form($exercise, $assessment, $submission, $_SERVER["HTTP_REFERER"]); + } + + + /****************** teacher table : show assessments by exercise and teacher ************/ + elseif ($action == 'teachertable') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + exercise_print_teacher_table($course); print_continue("index.php?id=$course->id"); - } + } - /****************** update assessment (by teacher or student) ***************************/ - elseif ($action == 'updateassessment') { + /****************** update assessment (by teacher or student) ***************************/ + elseif ($action == 'updateassessment') { - $timenow = time(); - $form = (object)$HTTP_POST_VARS; + $timenow = time(); + $form = (object)$HTTP_POST_VARS; - require_variable($aid); - if (! $assessment = get_record("exercise_assessments", "id", $aid)) { - error("exercise assessment is misconfigured"); - } + require_variable($aid); + if (! $assessment = get_record("exercise_assessments", "id", $aid)) { + error("exercise assessment is misconfigured"); + } - // first get the assignment elements for maxscores and weights... - if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) { - print_string("noteonassignmentelements", "exercise"); - } - else { - foreach ($elementsraw as $element) { - $elements[] = $element; // to renumber index 0,1,2... - } - } + // first get the assignment elements for maxscores and weights... + if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) { + print_string("noteonassignmentelements", "exercise"); + } + else { + foreach ($elementsraw as $element) { + $elements[] = $element; // to renumber index 0,1,2... + } + } // don't fiddle about, delete all the old and then add the new! - delete_records("exercise_grades", "assessmentid", $assessment->id); - - //determine what kind of grading we have - switch ($exercise->gradingstrategy) { - case 0: // no grading - // Insert all the elements that contain something - foreach ($form->feedback as $key => $thefeedback) { - unset($element); - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = $key; - $element->feedback = $thefeedback; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - } - $grade = 0; // set to satisfy save to db - break; - - case 1: // accumulative grading - // Insert all the elements that contain something - foreach ($form->grade as $key => $thegrade) { - unset($element); - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = $key; - $element->feedback = $form->feedback[$key]; - $element->grade = $thegrade; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - } - // now work out the grade... - $rawgrade=0; - $totalweight=0; - foreach ($form->grade as $key => $grade) { - $maxscore = $elements[$key]->maxscore; - $weight = $EXERCISE_EWEIGHTS[$elements[$key]->weight]; - if ($weight > 0) { - $totalweight += $weight; - } - $rawgrade += ($grade / $maxscore) * $weight; - // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade
"; - } - $grade = 100.0 * ($rawgrade / $totalweight); - break; - - case 2: // error banded graded - // Insert all the elements that contain something - $error = 0.0; - for ($i =0; $i < $exercise->nelements; $i++) { - unset($element); - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = $i; - $element->feedback = $form->feedback[$i]; - $element->grade = $form->grade[$i]; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - if (empty($form->grade[$i])){ - $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; - } - } - // now save the adjustment - unset($element); - $i = $exercise->nelements; - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = $i; - $element->grade = $form->grade[$i]; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) + delete_records("exercise_grades", "assessmentid", $assessment->id); + + //determine what kind of grading we have + switch ($exercise->gradingstrategy) { + case 0: // no grading + // Insert all the elements that contain something + foreach ($form->feedback as $key => $thefeedback) { + unset($element); + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = $key; + $element->feedback = $thefeedback; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + } + $grade = 0; // set to satisfy save to db + break; + + case 1: // accumulative grading + // Insert all the elements that contain something + foreach ($form->grade as $key => $thegrade) { + unset($element); + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = $key; + $element->feedback = $form->feedback[$key]; + $element->grade = $thegrade; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + } + // now work out the grade... + $rawgrade=0; + $totalweight=0; + foreach ($form->grade as $key => $grade) { + $maxscore = $elements[$key]->maxscore; + $weight = $EXERCISE_EWEIGHTS[$elements[$key]->weight]; + if ($weight > 0) { + $totalweight += $weight; + } + $rawgrade += ($grade / $maxscore) * $weight; + // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade
"; + } + $grade = 100.0 * ($rawgrade / $totalweight); + break; + + case 2: // error banded graded + // Insert all the elements that contain something + $error = 0.0; + for ($i =0; $i < $exercise->nelements; $i++) { + unset($element); + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = $i; + $element->feedback = $form->feedback[$i]; + $element->grade = $form->grade[$i]; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + if (empty($form->grade[$i])){ + $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; + } + } + // now save the adjustment + unset($element); + $i = $exercise->nelements; + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = $i; + $element->grade = $form->grade[$i]; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100.0 / $exercise->grade; - // echo "

".get_string("weightederrorcount", "exercise", intval($error + 0.5)). - // " ".get_string("adjustment", "exercise").": ".$form->grade[$i]."\n"; - // check the grade for sanity! - if ($grade > 100.0) { - $grade = 100.0; - } - if ($grade < 0.0) { - $grade = 0.0; - } - break; - - case 3: // criteria grading - // save in the selected criteria value in element zero, - unset($element); - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = 0; - $element->grade = $form->grade[0]; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - // now save the adjustment in element one - unset($element); - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = 1; - $element->grade = $form->grade[1]; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * 100 / $exercise->grade; - // check the grade for sanity! - if ($grade >100.0) { - $grade = 100.0; - } - if ($grade < 0.0) { - $grade = 0.0; - } - break; - - case 4: // rubric grading (identical to accumulative grading) - // Insert all the elements that contain something - foreach ($form->grade as $key => $thegrade) { - unset($element); - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = $key; - $element->feedback = $form->feedback[$key]; - $element->grade = $thegrade; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - } - // now work out the grade... - $rawgrade=0; - $totalweight=0; - foreach ($form->grade as $key => $grade) { - $maxscore = $elements[$key]->maxscore; - $weight = $EXERCISE_EWEIGHTS[$elements[$key]->weight]; - if ($weight > 0) { - $totalweight += $weight; - } - $rawgrade += ($grade / $maxscore) * $weight; - } - $grade = 100.0 * ($rawgrade / $totalweight); - break; - - } // end of switch - - // update the time of the assessment record (may be re-edited)... - set_field("exercise_assessments", "timecreated", $timenow, "id", $assessment->id); - set_field("exercise_assessments", "grade", $grade, "id", $assessment->id); - // ...and clear any grading of this assessment (these assessments are never graded but...) - set_field("exercise_assessments", "timegraded", 0, "id", $assessment->id); - set_field("exercise_assessments", "gradinggrade", 0, "id", $assessment->id); - - // any comment? - if (!empty($form->generalcomment)) { - set_field("exercise_assessments", "generalcomment", $form->generalcomment, "id", $assessment->id); - } - - // is user allowed to resubmit? - if (isteacher($course->id)) { - if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) { - error ("Updateassessment: submission record not found"); - } - if ($form->resubmit == 1) { - set_field("exercise_submissions", "resubmit", 1, "id", $submission->id); - } - else { - // clear resubmit flag - set_field("exercise_submissions", "resubmit", 0, "id", $submission->id); - } - } - - add_to_log($course->id, "exercise", "assess", "view.php?id=$cm->id", "$assessment->id"); - - // set up return address - if (!$returnto = $form->returnto) { - $returnto = "view.php?id=$cm->id"; - } - - // show grade if grading strategy is not zero - if ($exercise->gradingstrategy) { - redirect($returnto, "

".get_string("thegradeis", "exercise").": ". + // echo "

".get_string("weightederrorcount", "exercise", intval($error + 0.5)). + // " ".get_string("adjustment", "exercise").": ".$form->grade[$i]."\n"; + // check the grade for sanity! + if ($grade > 100.0) { + $grade = 100.0; + } + if ($grade < 0.0) { + $grade = 0.0; + } + break; + + case 3: // criteria grading + // save in the selected criteria value in element zero, + unset($element); + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = 0; + $element->grade = $form->grade[0]; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + // now save the adjustment in element one + unset($element); + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = 1; + $element->grade = $form->grade[1]; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * 100 / $exercise->grade; + // check the grade for sanity! + if ($grade >100.0) { + $grade = 100.0; + } + if ($grade < 0.0) { + $grade = 0.0; + } + break; + + case 4: // rubric grading (identical to accumulative grading) + // Insert all the elements that contain something + foreach ($form->grade as $key => $thegrade) { + unset($element); + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = $key; + $element->feedback = $form->feedback[$key]; + $element->grade = $thegrade; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + } + // now work out the grade... + $rawgrade=0; + $totalweight=0; + foreach ($form->grade as $key => $grade) { + $maxscore = $elements[$key]->maxscore; + $weight = $EXERCISE_EWEIGHTS[$elements[$key]->weight]; + if ($weight > 0) { + $totalweight += $weight; + } + $rawgrade += ($grade / $maxscore) * $weight; + } + $grade = 100.0 * ($rawgrade / $totalweight); + break; + + } // end of switch + + // update the time of the assessment record (may be re-edited)... + set_field("exercise_assessments", "timecreated", $timenow, "id", $assessment->id); + set_field("exercise_assessments", "grade", $grade, "id", $assessment->id); + // ...and clear any grading of this assessment (these assessments are never graded but...) + set_field("exercise_assessments", "timegraded", 0, "id", $assessment->id); + set_field("exercise_assessments", "gradinggrade", 0, "id", $assessment->id); + + // any comment? + if (!empty($form->generalcomment)) { + set_field("exercise_assessments", "generalcomment", $form->generalcomment, "id", $assessment->id); + } + + // is user allowed to resubmit? + if (isteacher($course->id)) { + if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) { + error ("Updateassessment: submission record not found"); + } + if ($form->resubmit == 1) { + set_field("exercise_submissions", "resubmit", 1, "id", $submission->id); + } + else { + // clear resubmit flag + set_field("exercise_submissions", "resubmit", 0, "id", $submission->id); + } + } + + add_to_log($course->id, "exercise", "assess", "view.php?id=$cm->id", "$assessment->id"); + + // set up return address + if (!$returnto = $form->returnto) { + $returnto = "view.php?id=$cm->id"; + } + + // show grade if grading strategy is not zero + if ($exercise->gradingstrategy) { + redirect($returnto, "

".get_string("thegradeis", "exercise").": ". number_format($grade * $exercise->grade / 100.0, 1)." (".get_string("maximumgrade"). - " ".number_format($exercise->grade).")

", 1); - } - else { - redirect($returnto); - } - } - - - /****************** update teacher assessment (by teacher only) ***************************/ - elseif ($action == 'updateteacherassessment') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - $timenow = time(); - $form = (object)$HTTP_POST_VARS; - - - // first do the (teacher's) assessment of the student's submission - if (! $submission = get_record("exercise_submissions", "id", $form->sid)) { - error("Update teacher assessment: student's submission record not found"); - } - if (!$assessment = exercise_get_submission_assessment($submission, $USER)) { - error("Update teacher assessment: teacher's assessment record not found"); - } - - // first get the assignment elements for maxscores and weights... - if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) { - print_string("noteonassignmentelements", "exercise"); - } - else { - foreach ($elementsraw as $element) { - $elements[] = $element; // to renumber index 0,1,2... - } - } + " ".number_format($exercise->grade).")

", 1); + } + else { + redirect($returnto); + } + } + + + /****************** update teacher assessment (by teacher only) ***************************/ + elseif ($action == 'updateteacherassessment') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + $timenow = time(); + $form = (object)$HTTP_POST_VARS; + + + // first do the (teacher's) assessment of the student's submission + if (! $submission = get_record("exercise_submissions", "id", $form->sid)) { + error("Update teacher assessment: student's submission record not found"); + } + if (!$assessment = exercise_get_submission_assessment($submission, $USER)) { + error("Update teacher assessment: teacher's assessment record not found"); + } + + // first get the assignment elements for maxscores and weights... + if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) { + print_string("noteonassignmentelements", "exercise"); + } + else { + foreach ($elementsraw as $element) { + $elements[] = $element; // to renumber index 0,1,2... + } + } // don't fiddle about, delete all the old and then add the new! - delete_records("exercise_grades", "assessmentid", $assessment->id); - - //determine what kind of grading we have - switch ($exercise->gradingstrategy) { - case 0: // no grading - // Insert all the elements that contain something - foreach ($form->feedback as $key => $thefeedback) { - unset($element); - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = $key; - $element->feedback = $thefeedback; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - } - $grade = 0; // set to satisfy save to db - break; - - case 1: // accumulative grading - // Insert all the elements that contain something - foreach ($form->grade as $key => $thegrade) { - unset($element); - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = $key; - $element->feedback = $form->feedback[$key]; - $element->grade = $thegrade; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - } - // now work out the grade... - $rawgrade=0; - $totalweight=0; - foreach ($form->grade as $key => $grade) { - $maxscore = $elements[$key]->maxscore; - $weight = $EXERCISE_EWEIGHTS[$elements[$key]->weight]; - if ($weight > 0) { - $totalweight += $weight; - } - $rawgrade += ($grade / $maxscore) * $weight; - // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade
"; - } - $grade = 100.0 * ($rawgrade / $totalweight); - break; - - case 2: // error banded graded - // Insert all the elements that contain something - $error = 0.0; - for ($i =0; $i < $exercise->nelements; $i++) { - unset($element); - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = $i; - $element->feedback = $form->feedback[$i]; - $element->grade = $form->grade[$i]; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - if (empty($form->grade[$i])){ - $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; - } - } - // now save the adjustment - unset($element); - $i = $exercise->nelements; - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = $i; - $element->grade = $form->grade[$i]; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $exercise->grade; - echo "

".get_string("weightederrorcount", "exercise", intval($error + 0.5))."\n"; - break; - - case 3: // criteria grading - // save in the selected criteria value in element zero, - unset($element); - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = 0; - $element->grade = $form->grade[0]; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - // now save the adjustment in element one - unset($element); - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = 1; - $element->grade = $form->grade[1]; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * 100 / $exercise->grade; - break; - - case 4: // rubric grading (identical to accumulative grading) - // Insert all the elements that contain something - foreach ($form->grade as $key => $thegrade) { - unset($element); - $element->exerciseid = $exercise->id; - $element->assessmentid = $assessment->id; - $element->elementno = $key; - $element->feedback = $form->feedback[$key]; - $element->grade = $thegrade; - if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); - } - } - // now work out the grade... - $rawgrade=0; - $totalweight=0; - foreach ($form->grade as $key => $grade) { - $maxscore = $elements[$key]->maxscore; - $weight = $EXERCISE_EWEIGHTS[$elements[$key]->weight]; - if ($weight > 0) { - $totalweight += $weight; - } - $rawgrade += ($grade / $maxscore) * $weight; - } - $grade = 100.0 * ($rawgrade / $totalweight); - break; - - } // end of switch - - // update the time of the assessment record (may be re-edited)... - set_field("exercise_assessments", "timecreated", $timenow, "id", $assessment->id); - set_field("exercise_assessments", "grade", $grade, "id", $assessment->id); - // ...and clear any grading of this assessment (never needed but...) - set_field("exercise_assessments", "timegraded", 0, "id", $assessment->id); - set_field("exercise_assessments", "gradinggrade", 0, "id", $assessment->id); - - // any comment? - if (!empty($form->generalcomment)) { - set_field("exercise_assessments", "generalcomment", $form->generalcomment, "id", $assessment->id); - } - - // now calculate the (grading) grade of the student's assessment... - if (!$stassessment = get_record("exercise_assessments", "id", $form->said)) { - error("Update teacher assessment: student's assessment record not found"); - } + delete_records("exercise_grades", "assessmentid", $assessment->id); + + //determine what kind of grading we have + switch ($exercise->gradingstrategy) { + case 0: // no grading + // Insert all the elements that contain something + foreach ($form->feedback as $key => $thefeedback) { + unset($element); + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = $key; + $element->feedback = $thefeedback; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + } + $grade = 0; // set to satisfy save to db + break; + + case 1: // accumulative grading + // Insert all the elements that contain something + foreach ($form->grade as $key => $thegrade) { + unset($element); + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = $key; + $element->feedback = $form->feedback[$key]; + $element->grade = $thegrade; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + } + // now work out the grade... + $rawgrade=0; + $totalweight=0; + foreach ($form->grade as $key => $grade) { + $maxscore = $elements[$key]->maxscore; + $weight = $EXERCISE_EWEIGHTS[$elements[$key]->weight]; + if ($weight > 0) { + $totalweight += $weight; + } + $rawgrade += ($grade / $maxscore) * $weight; + // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade
"; + } + $grade = 100.0 * ($rawgrade / $totalweight); + break; + + case 2: // error banded graded + // Insert all the elements that contain something + $error = 0.0; + for ($i =0; $i < $exercise->nelements; $i++) { + unset($element); + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = $i; + $element->feedback = $form->feedback[$i]; + $element->grade = $form->grade[$i]; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + if (empty($form->grade[$i])){ + $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; + } + } + // now save the adjustment + unset($element); + $i = $exercise->nelements; + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = $i; + $element->grade = $form->grade[$i]; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $exercise->grade; + echo "

".get_string("weightederrorcount", "exercise", intval($error + 0.5))."\n"; + break; + + case 3: // criteria grading + // save in the selected criteria value in element zero, + unset($element); + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = 0; + $element->grade = $form->grade[0]; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + // now save the adjustment in element one + unset($element); + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = 1; + $element->grade = $form->grade[1]; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * 100 / $exercise->grade; + break; + + case 4: // rubric grading (identical to accumulative grading) + // Insert all the elements that contain something + foreach ($form->grade as $key => $thegrade) { + unset($element); + $element->exerciseid = $exercise->id; + $element->assessmentid = $assessment->id; + $element->elementno = $key; + $element->feedback = $form->feedback[$key]; + $element->grade = $thegrade; + if (!$element->id = insert_record("exercise_grades", $element)) { + error("Could not insert exercise element!"); + } + } + // now work out the grade... + $rawgrade=0; + $totalweight=0; + foreach ($form->grade as $key => $grade) { + $maxscore = $elements[$key]->maxscore; + $weight = $EXERCISE_EWEIGHTS[$elements[$key]->weight]; + if ($weight > 0) { + $totalweight += $weight; + } + $rawgrade += ($grade / $maxscore) * $weight; + } + $grade = 100.0 * ($rawgrade / $totalweight); + break; + + } // end of switch + + // update the time of the assessment record (may be re-edited)... + set_field("exercise_assessments", "timecreated", $timenow, "id", $assessment->id); + set_field("exercise_assessments", "grade", $grade, "id", $assessment->id); + // ...and clear any grading of this assessment (never needed but...) + set_field("exercise_assessments", "timegraded", 0, "id", $assessment->id); + set_field("exercise_assessments", "gradinggrade", 0, "id", $assessment->id); + + // any comment? + if (!empty($form->generalcomment)) { + set_field("exercise_assessments", "generalcomment", $form->generalcomment, "id", $assessment->id); + } + + // now calculate the (grading) grade of the student's assessment... + if (!$stassessment = get_record("exercise_assessments", "id", $form->said)) { + error("Update teacher assessment: student's assessment record not found"); + } $gradinggrade = exercise_compare_assessments($exercise, $assessment, $stassessment); - // ...and save the grade for the assessment - set_field("exercise_assessments", "gradinggrade", $gradinggrade, "id", $stassessment->id); - set_field("exercise_assessments", "timegraded", $timenow, "id", $stassessment->id); - set_field("exercise_assessments", "mailed", 0, "id", $stassessment->id); - echo "".get_string("savedok", "exercise")."
\n"; - - add_to_log($course->id, "exercise", "grade", "view.php?id=$cm->id", "$stassessment->id"); - + // ...and save the grade for the assessment + set_field("exercise_assessments", "gradinggrade", $gradinggrade, "id", $stassessment->id); + set_field("exercise_assessments", "timegraded", $timenow, "id", $stassessment->id); + set_field("exercise_assessments", "mailed", 0, "id", $stassessment->id); + echo "".get_string("savedok", "exercise")."
\n"; + + add_to_log($course->id, "exercise", "grade", "view.php?id=$cm->id", "$stassessment->id"); + // is user allowed to resubmit? - if ($form->resubmit == 1) { - set_field("exercise_submissions", "resubmit", 1, "id", $submission->id); - } - else { - // clear resubmit flag - set_field("exercise_submissions", "resubmit", 0, "id", $submission->id); - } - - add_to_log($course->id, "exercise", "assess", "view.php?id=$cm->id", "$assessment->id"); - - // set up return address - if (!$returnto = $form->returnto) { - $returnto = "view.php?id=$cm->id"; - } - - // show grade if grading strategy is not zero - if ($exercise->gradingstrategy) { + if ($form->resubmit == 1) { + set_field("exercise_submissions", "resubmit", 1, "id", $submission->id); + } + else { + // clear resubmit flag + set_field("exercise_submissions", "resubmit", 0, "id", $submission->id); + } + + add_to_log($course->id, "exercise", "assess", "view.php?id=$cm->id", "$assessment->id"); + + // set up return address + if (!$returnto = $form->returnto) { + $returnto = "view.php?id=$cm->id"; + } + + // show grade if grading strategy is not zero + if ($exercise->gradingstrategy) { redirect($returnto, "

".get_string("gradeforstudentsassessment", "exercise", $course->student).": ".number_format($gradinggrade * $exercise->gradinggrade / 100.0, 1). " (".get_string("maximumgrade")." ".number_format($exercise->gradinggrade, 1).")

". get_string("thegradeis", "exercise").": ".number_format($grade * $exercise->grade / 100.0, 1). " (".get_string("maximumgrade")." ".number_format($exercise->grade, 1).")

"); - } - else { - redirect($returnto); - } - } + } + else { + redirect($returnto); + } + } - /****************** update grading grade(by teacher) ***************************/ - elseif ($action == 'updategradinggrade') { + /****************** update grading grade(by teacher) ***************************/ + elseif ($action == 'updategradinggrade') { - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } require_variable($aid); // normalise gradinggrade $gradinggrade = $_POST['gradinggrade'] * 100 / $exercise->gradinggrade; - if (!set_field("exercise_assessments", "gradinggrade", $gradinggrade, "id", + if (!set_field("exercise_assessments", "gradinggrade", $gradinggrade, "id", $_POST['aid'])) { - error("Update grading grade: asseesment not updated"); - } + error("Update grading grade: asseesment not updated"); + } redirect("submissions.php?id=$cm->id&action=adminlist", get_string("savedok", "exercise"), 1); - } - - - /****************** user confirm delete ************************************/ - elseif ($action == 'userconfirmdelete' ) { - - if (empty($_GET['aid'])) { - error("User confirm delete: assessment id missing"); - } - - notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("assessment", "exercise")), - "assessments.php?action=userdelete&id=$cm->id&aid=$_GET[aid]", "view.php?id=$cm->id"); - } - - - /****************** user delete ************************************/ - elseif ($action == 'userdelete' ) { - - if (empty($_GET['aid'])) { - error("User delete: assessment id missing"); - } - - print_string("deleting", "exercise"); - // first delete all the associated records... - delete_records("exercise_grades", "assessmentid", $_GET['aid']); - // ...now delete the assessment... - delete_records("exercise_assessments", "id", $_GET['aid']); - - print_continue("view.php?id=$cm->id"); - } - - - /****************** view assessment ***********************/ - elseif ($action == 'viewassessment') { - - // get the assessment record - if (!$assessment = get_record("exercise_assessments", "id", $_GET['aid'])) { - error("Assessment record not found"); - } - - // show assessment but don't allow changes - exercise_print_assessment_form($exercise, $assessment); - - print_continue("view.php?id=$cm->id"); - } - - - /*************** no man's land **************************************/ - else { - error("Fatal Error: Unknown Action: ".$action."\n"); - } - - print_footer($course); + } + + + /****************** user confirm delete ************************************/ + elseif ($action == 'userconfirmdelete' ) { + + if (empty($_GET['aid'])) { + error("User confirm delete: assessment id missing"); + } + + notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("assessment", "exercise")), + "assessments.php?action=userdelete&id=$cm->id&aid=$_GET[aid]", "view.php?id=$cm->id"); + } + + + /****************** user delete ************************************/ + elseif ($action == 'userdelete' ) { + + if (empty($_GET['aid'])) { + error("User delete: assessment id missing"); + } + + print_string("deleting", "exercise"); + // first delete all the associated records... + delete_records("exercise_grades", "assessmentid", $_GET['aid']); + // ...now delete the assessment... + delete_records("exercise_assessments", "id", $_GET['aid']); + + print_continue("view.php?id=$cm->id"); + } + + + /****************** view assessment ***********************/ + elseif ($action == 'viewassessment') { + + // get the assessment record + if (!$assessment = get_record("exercise_assessments", "id", $_GET['aid'])) { + error("Assessment record not found"); + } + + // show assessment but don't allow changes + exercise_print_assessment_form($exercise, $assessment); + + print_continue("view.php?id=$cm->id"); + } + + + /*************** no man's land **************************************/ + else { + error("Fatal Error: Unknown Action: ".$action."\n"); + } + + print_footer($course); ?> diff --git a/mod/exercise/lib.php b/mod/exercise/lib.php index 3613b03774..ff18872310 100644 --- a/mod/exercise/lib.php +++ b/mod/exercise/lib.php @@ -175,7 +175,7 @@ function exercise_cron() { $USER->lang = $submissionowner->lang; $sendto = $submissionowner; // "Your assignment \"$submission->title\" has been assessed by" - $msg = get_string("mail1", "exercise", $submission->title)." $assessmentowner->firstname $assessmentowner->lastname.\n"; + $msg = get_string("mail1", "exercise", $submission->title).' '.fullname($assessmentowner).".\n"; // "The comments and grade can be seen in the exercise assignment '$exercise->name' $msg .= get_string("mail2", "exercise", $exercise->name)."\n\n"; @@ -334,7 +334,7 @@ function exercise_print_recent_activity($course, $isteacher, $timestart) { //Obtain the visible property from the instance if (instance_is_visible("exercise",$tempmod)) { $date = userdate($log->time, $strftimerecent); - echo "

$date - $log->firstname $log->lastname
"; + echo '

'.$date.' - '.fullname($log).'
'; echo "\"wwwroot/mod/exercise/$log->url\">"; echo "$log->name"; echo "\"

"; @@ -369,7 +369,7 @@ function exercise_print_recent_activity($course, $isteacher, $timestart) { //Obtain the visible property from the instance if (instance_is_visible("exercise",$tempmod)) { $date = userdate($log->time, $strftimerecent); - echo "

$date - $log->firstname $log->lastname
"; + echo '

'.$date.' - '.fullname($log).'
'; echo "\"wwwroot/mod/exercise/$log->url\">"; echo "$log->name"; echo "\"

"; @@ -404,7 +404,7 @@ function exercise_print_recent_activity($course, $isteacher, $timestart) { //Obtain the visible property from the instance if (instance_is_visible("exercise",$tempmod)) { $date = userdate($log->time, $strftimerecent); - echo "

$date - $log->firstname $log->lastname
"; + echo '

'.$date.' - '.fullname($log).'
'; echo "\"wwwroot/mod/exercise/$log->url\">"; echo "$log->name"; echo "\"

"; diff --git a/mod/exercise/locallib.php b/mod/exercise/locallib.php index 2af7c6ad42..8e8499689a 100644 --- a/mod/exercise/locallib.php +++ b/mod/exercise/locallib.php @@ -788,7 +788,7 @@ function exercise_list_submissions_for_admin($exercise) { $action =""; } $nassessments++; - $table->data[] = array("$user->firstname $user->lastname", $title, + $table->data[] = array(fullname($user), $title, userdate($assessment->timecreated), $action); } } @@ -900,7 +900,7 @@ function exercise_list_submissions_for_admin($exercise) { if ($submission->late) { $datesubmitted = "".$datesubmitted.""; } - $table->data[] = array("$user->firstname $user->lastname", $title. + $table->data[] = array(fullname($user), $title. " ".exercise_print_submission_assessments($exercise, $submission), $datesubmitted, $action); $nsubmissions++; @@ -1203,13 +1203,13 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { $action = "id&aid=$studentassessment->id&sid=$submission->id\">". get_string("edit", "exercise").""; $table->data[] = array(exercise_print_submission_title($exercise, $submission), - $submissionowner->firstname." ".$submissionowner->lastname, + fullname($submissionowner), $timegap, $action, $comment); } else { $action = "id&aid=$studentassessment->id&sid=$submission->id\">". get_string("assess", "exercise").""; $table->data[] = array(exercise_print_submission_title($exercise, $submission), - $submissionowner->firstname." ".$submissionowner->lastname, + fullname($submissionowner), $timegap, $action, $comment); } } else { @@ -1229,7 +1229,7 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { error("List unassessed student submissions: teacher record not found"); } $comment = get_string("resubmissionfor", "exercise", - "$teacher->firstname $teacher->lastname"); + fullname($teacher)); if ($assessment->timecreated > $timenow - $CFG->maxeditingtime) { $warm = true; } @@ -1247,7 +1247,7 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { $timegap = "".$timegap.""; } $table->data[] = array(exercise_print_submission_title($exercise, $submission), - $submissionowner->firstname." ".$submissionowner->lastname, + fullname($submissionowner), $timegap, $action, $comment); } if (!$teacherassessed) { @@ -1270,7 +1270,7 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { error("List unassessed student submissions: teacher record not found"); } $comment = get_string("resubmissionfor", "exercise", - "$teacher->firstname $teacher->lastname"); + fullname($teacher)); break; // no need to look further } @@ -1284,7 +1284,7 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { $timegap = "".$timegap.""; } $table->data[] = array(exercise_print_submission_title($exercise, $submission), - $submissionowner->firstname." ".$submissionowner->lastname, + fullname($submissionowner), $timegap, $action, $comment); } } @@ -1378,8 +1378,8 @@ function exercise_list_ungraded_assessments($exercise, $stype) { $submissionowner = get_record("user", "id", $submission->userid); $assessor = get_record("user", "id", $assessment->userid); $table->data[] = array(exercise_print_submission_title($exercise, $submission), - $submissionowner->firstname." ".$submissionowner->lastname, - $assessor->firstname." ".$assessor->lastname, userdate($assessment->timecreated), $action); + fullname($submissionowner), + fullname($assessor), userdate($assessment->timecreated), $action); } } if (isset($table->data)) { @@ -1499,7 +1499,7 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch } if ($exercisefound) { print_heading(get_string("theexerciseandthesubmissionby", "exercise", - "$submissionowner->firstname $submissionowner->lastname")); + fullname($submissionowner))); echo "
"; - echo ""; @@ -2164,7 +2164,7 @@ function exercise_print_league_table($exercise) { number_format($submission->grade * $exercise->grade / 100.0, 1)); } else { $table->data[] = array(exercise_print_submission_title($exercise, $submission), - $user->firstname." ".$user->lastname, + fullname($user), number_format($submission->grade * $exercise->grade / 100.0, 1)); } $n++; @@ -2328,15 +2328,15 @@ function exercise_print_teacher_assessment_form($exercise, $assessment, $submiss echo exercise_print_submission_title($exercise, $submission); echo "
cellcontent\">\n"; echo exercise_print_submission_title($exercise, $teachersubmission); @@ -1545,7 +1545,7 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch $formtitle = get_string("yourassessment", "exercise"); } else { - $formtitle = get_string("assessmentby", "exercise", "$assessmentowner->firstname $assessmentowner->lastname"); + $formtitle = get_string("assessmentby", "exercise", fullname($assessmentowner)); } } else { @@ -2004,7 +2004,7 @@ function exercise_print_assessments_by_user_for_admin($exercise, $user) { if ($assessments =exercise_get_user_assessments($exercise, $user)) { foreach ($assessments as $assessment) { - echo "

".get_string("assessmentby", "exercise", $user->firstname." ".$user->lastname)."

\n"; + echo "

".get_string("assessmentby", "exercise", fullname($user))."

\n"; exercise_print_assessment_form($exercise, $assessment); echo "

id&aid=$assessment->id\">". get_string("amend", "exercise")." ".get_string("gradeforstudentsassessment","exercise", @@ -2031,7 +2031,7 @@ function exercise_print_assessments_for_admin($exercise, $submission) { if (!$user = get_record("user", "id", $assessment->userid)) { error (" exercise_print_assessments_for_admin: unable to get user record"); } - echo "

".get_string("assessmentby", "exercise", $user->firstname." ".$user->lastname)."

\n"; + echo "

".get_string("assessmentby", "exercise", fullname($user))."

\n"; exercise_print_assessment_form($exercise, $assessment); echo "

id&aid=$assessment->id\">". get_string("delete", "exercise")."


\n"; @@ -2104,7 +2104,7 @@ function exercise_print_feedback($course, $submission) { echo "\n
body\" WIDTH=35 VALIGN=TOP>"; print_user_picture($teacher->id, $course->id, $teacher->picture); echo "cellheading\">$teacher->firstname $teacher->lastname"; + echo "cellheading\">".fullname($teacher); echo "  ".userdate($submission->timemarked).""; echo "

\n"; - ?> -
- - - - - - - + + + + + + + + firstname $submissionowner->lastname"), "grading", "exercise"); + fullname($submissionowner)), "grading", "exercise"); // is there an existing assessment for the submission if (!$assessment = exercise_get_submission_assessment($submission, $USER)) { @@ -2796,7 +2796,7 @@ function exercise_print_teacher_table($course) { $j++; } $grandtotal += $total; - $table->data[] = array_merge(array("$teacher->firstname $teacher->lastname"), array($total), $n); + $table->data[] = array_merge(array(fullname($teacher)), array($total), $n); } $table->data[] = array_merge(array(get_string("total")), array($grandtotal), $grand); print_heading(get_string("teacherassessmenttable", "exercise", $course->teacher)); diff --git a/mod/exercise/submissions.php b/mod/exercise/submissions.php index 0c23ba208e..12998931fc 100644 --- a/mod/exercise/submissions.php +++ b/mod/exercise/submissions.php @@ -280,7 +280,7 @@ $grade = "(".$grade.")"; $overallgrade = "(".$overallgrade.")"; } - echo "$user->firstname $user->lastname\n"; + echo "".fullname($user)."\n"; echo "".exercise_print_submission_title($exercise, $submission)."\n"; echo "$gradinggrade"; echo "$grade"; diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 14394597d5..9a74b3f054 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1224,6 +1224,8 @@ function forum_subscribed_users($course, $forum, $groupid=0) { ORDER BY u.email ASC"); } + + /// OTHER FUNCTIONS /////////////////////////////////////////////////////////// @@ -2271,7 +2273,7 @@ function forum_post_subscription($post) { return ""; } - $info->name = "$USER->firstname $USER->lastname"; + $info->name = fullname($USER); $info->forum = $forum->name; if (!empty($post->subscribe)) { diff --git a/mod/forum/report.php b/mod/forum/report.php index 9da4fbc81b..6af231e55b 100644 --- a/mod/forum/report.php +++ b/mod/forum/report.php @@ -58,9 +58,9 @@ } echo ""; print_user_picture($rating->id, $forum->course, $rating->picture); - echo "

$rating->firstname $rating->lastname

"; - echo "

".$scalemenu[$rating->rating]."

"; - echo "

".userdate($rating->time)."

"; + echo '

'.fullname($rating).'

'; + echo '

'.$scalemenu[$rating->rating]."

"; + echo '

'.userdate($rating->time)."

"; echo "\n"; } echo ""; diff --git a/mod/glossary/report.php b/mod/glossary/report.php index b44fd5694e..da72a7702d 100644 --- a/mod/glossary/report.php +++ b/mod/glossary/report.php @@ -54,9 +54,9 @@ } echo ""; print_user_picture($rating->id, $glossary->course, $rating->picture); - echo "

$rating->firstname $rating->lastname

"; - echo "

".$scalemenu[$rating->rating]."

"; - echo "

".userdate($rating->time)."

"; + echo '

'.fullname($rating).'

'; + echo '

'.$scalemenu[$rating->rating]."

"; + echo '

'.userdate($rating->time)."

"; echo "\n"; } echo ""; diff --git a/mod/workshop/assessments.php b/mod/workshop/assessments.php index eb0d78b067..a2b98b7175 100644 --- a/mod/workshop/assessments.php +++ b/mod/workshop/assessments.php @@ -1,41 +1,41 @@ id); - + $navigation = ""; if ($course->category) { $navigation = "id\">$course->shortname ->"; @@ -71,974 +71,997 @@ $strworkshop = get_string("modulename", "workshop"); $strassessments = get_string("assessments", "workshop"); - // ... print the header and... + // ... print the header and... print_header("$course->shortname: $workshop->name", "$course->fullname", "$navigation id>$strworkshops -> id\">$workshop->name -> $strassessments", "", "", true); - //...get the action - require_variable($action); - - - /*************** add comment to assessment (by author, assessor or teacher) ***************************/ - if ($action == 'addcomment') { - - print_heading_with_help(get_string("addacomment", "workshop"), "addingacomment", "workshop"); - // get assessment record - if (!$assessmentid = $_REQUEST['aid']) { // comes from link or hidden form variable - error("Assessment id not given"); - } - $assessment = get_record("workshop_assessments", "id", $assessmentid); - if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { - error("Submission not found"); - } - ?> - - - - -
- - \n"; - echo " \n"; - echo "

". get_string("comment", "workshop").":

\n"; - echo " \n"; - echo "
\n"; - echo "\n"; - echo "
\n"; - echo "

".get_string("assessment", "workshop"). "
\n"; - workshop_print_assessment($workshop, $assessment); - } - - - /******************* admin confirm delete ************************************/ - elseif ($action == 'adminconfirmdelete' ) { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - if (empty($_GET['aid'])) { - error("Admin confirm delete: assessment id missing"); - } - - notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("assessment", "workshop")), - "assessments.php?action=admindelete&id=$cm->id&aid=$_GET[aid]", "submissions.php?action=adminlist&id=$cm->id"); - } - - - /******************* admin delete ************************************/ - elseif ($action == 'admindelete' ) { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - if (empty($_GET['aid'])) { - error("Admin delete: submission id missing"); - } - - print_string("deleting", "workshop"); - // first delete all the associated records... - delete_records("workshop_comments", "assessmentid", $_GET['aid']); - delete_records("workshop_grades", "assessmentid", $_GET['aid']); - // ...now delete the assessment... - delete_records("workshop_assessments", "id", $_GET['aid']); - - print_continue("submissions.php?id=$cm->id&action=adminlist"); - } - - - /*********************** admin list of asssessments (of a submission) (by teachers)**************/ - elseif ($action == 'adminlist') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - if (empty($_GET['sid'])) { - error ("Workshop asssessments: adminlist called with no sid"); - } - $submission = get_record("workshop_submissions", "id", $_GET['sid']); - workshop_print_assessments_for_admin($workshop, $submission); - print_continue("submissions.php?action=adminlist&a=$workshop->id"); - } - - - /*********************** admin list of asssessments by a student (used by teachers only )******************/ - elseif ($action == 'adminlistbystudent') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - if (empty($_GET['userid'])) { - error ("Workshop asssessments: adminlistbystudent called with no userid"); - } - $user = get_record("user", "id", $_GET['userid']); - workshop_print_assessments_by_user_for_admin($workshop, $user); - print_continue("submissions.php?action=adminlist&a=$workshop->id"); - } - - - /*************** agree (to) assessment (by student) ***************************/ - elseif ($action == 'agreeassessment') { - $timenow = time(); - // assessment id comes from link or hidden form variable - if (!$assessment = get_record("workshop_assessments", "id", $_REQUEST['aid'])) { - error("Assessment : agree assessment failed"); - } - //save time of agreement - set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id); - echo "".get_string("savedok", "workshop")."
\n"; - - add_to_log($course->id, "workshop", "agree", "assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id", "$assessment->id"); - print_continue("view.php?id=$cm->id"); - } - - - /*************** Assess submission (by teacher or student) ***************************/ - elseif ($action == 'assesssubmission') { - - require_variable($sid); - - optional_variable($allowcomments); - if (!isset($allowcomments)) { - $allowcomments = false; - } - - if (! $submission = get_record("workshop_submissions", "id", $sid)) { - error("Assess submission is misconfigured - no submission record!"); - } - - // there can be an assessment record (for teacher submissions), if there isn't... - if (!$assessment = get_record("workshop_assessments", "submissionid", $submission->id, "userid", + //...get the action + require_variable($action); + + + /*************** add comment to assessment (by author, assessor or teacher) ***************************/ + if ($action == 'addcomment') { + + print_heading_with_help(get_string("addacomment", "workshop"), "addingacomment", "workshop"); + // get assessment record + if (!$assessmentid = $_REQUEST['aid']) { // comes from link or hidden form variable + error("Assessment id not given"); + } + $assessment = get_record("workshop_assessments", "id", $assessmentid); + if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { + error("Submission not found"); + } + ?> +
+ + + +
+ + \n"; + + echo " \n"; + + echo "

". get_string("comment", "workshop").":

\n"; + + echo " \n"; + + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "

".get_string("assessment", "workshop"). "
\n"; + workshop_print_assessment($workshop, $assessment); + } + + + + /******************* admin confirm delete ************************************/ + elseif ($action == 'adminconfirmdelete' ) { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_GET['aid'])) { + error("Admin confirm delete: assessment id missing"); + } + + notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("assessment", "workshop")), + "assessments.php?action=admindelete&id=$cm->id&aid=$_GET[aid]", "submissions.php?action=adminlist&id=$cm->id"); + } + + + /******************* admin delete ************************************/ + elseif ($action == 'admindelete' ) { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_GET['aid'])) { + error("Admin delete: submission id missing"); + } + + print_string("deleting", "workshop"); + // first delete all the associated records... + delete_records("workshop_comments", "assessmentid", $_GET['aid']); + delete_records("workshop_grades", "assessmentid", $_GET['aid']); + // ...now delete the assessment... + delete_records("workshop_assessments", "id", $_GET['aid']); + + print_continue("submissions.php?id=$cm->id&action=adminlist"); + } + + + /*********************** admin list of asssessments (of a submission) (by teachers)**************/ + elseif ($action == 'adminlist') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + if (empty($_GET['sid'])) { + error ("Workshop asssessments: adminlist called with no sid"); + } + $submission = get_record("workshop_submissions", "id", $_GET['sid']); + workshop_print_assessments_for_admin($workshop, $submission); + print_continue("submissions.php?action=adminlist&a=$workshop->id"); + } + + + /*********************** admin list of asssessments by a student (used by teachers only )******************/ + elseif ($action == 'adminlistbystudent') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + if (empty($_GET['userid'])) { + error ("Workshop asssessments: adminlistbystudent called with no userid"); + } + $user = get_record("user", "id", $_GET['userid']); + workshop_print_assessments_by_user_for_admin($workshop, $user); + print_continue("submissions.php?action=adminlist&a=$workshop->id"); + } + + + /*************** agree (to) assessment (by student) ***************************/ + elseif ($action == 'agreeassessment') { + $timenow = time(); + // assessment id comes from link or hidden form variable + if (!$assessment = get_record("workshop_assessments", "id", $_REQUEST['aid'])) { + error("Assessment : agree assessment failed"); + } + //save time of agreement + set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id); + echo "".get_string("savedok", "workshop")."
\n"; + + add_to_log($course->id, "workshop", "agree", "assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id", "$assessment->id"); + print_continue("view.php?id=$cm->id"); + } + + + + /*************** Assess submission (by teacher or student) ***************************/ + elseif ($action == 'assesssubmission') { + + require_variable($sid); + + optional_variable($allowcomments); + if (!isset($allowcomments)) { + $allowcomments = false; + } + + if (! $submission = get_record("workshop_submissions", "id", $sid)) { + error("Assess submission is misconfigured - no submission record!"); + } + + // there can be an assessment record (for teacher submissions), if there isn't... + if (!$assessment = get_record("workshop_assessments", "submissionid", $submission->id, "userid", $USER->id)) { - $yearfromnow = time() + 365 * 86400; - // ...create one and set timecreated way in the future, this is reset when record is updated - $assessment->workshopid = $workshop->id; - $assessment->submissionid = $submission->id; - $assessment->userid = $USER->id; - $assessment->grade = -1; // set impossible grade - $assessment->timecreated = $yearfromnow; - $assessment->timegraded = 0; - $assessment->timeagreed = 0; - $assessment->resubmission = 0; - if (!$assessment->id = insert_record("workshop_assessments", $assessment)) { - error("Could not insert workshop assessment!"); - } - } - - print_heading_with_help(get_string("assessthissubmission", "workshop"), "grading", "workshop"); - - // show assessment and allow changes - workshop_print_assessment($workshop, $assessment, true, $allowcomments, $_SERVER["HTTP_REFERER"]); - } - - - /*************** display grading form (viewed by student) *********************************/ - elseif ($action == 'displaygradingform') { - - print_heading_with_help(get_string("specimenassessmentform", "workshop"), "specimen", "workshop"); - - workshop_print_assessment($workshop); // called with no assessment - print_continue("view.php?a=$workshop->id"); - } - - - /*************** edit comment on assessment (by author, assessor or teacher) ***************************/ - elseif ($action == 'editcomment') { - - print_heading_with_help(get_string("editacomment", "workshop"), "editingacomment", "workshop"); - // get the comment record... - if (!$comment = get_record("workshop_comments", "id", $_GET['cid'])) { - error("Edit Comment: Comment not found"); - } - if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) { - error("Edit Comment: Assessment not found"); - } - if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { - error("Edit Comment: Submission not found"); - } - ?> -
- - - -
- - \n"; - echo " \n"; - echo "

". get_string("comment", "workshop").":

\n"; - echo " \n"; - echo "
\n"; - echo "\n"; - echo "
\n"; - workshop_print_assessment($workshop, $assessment); - } - - - /*********************** edit assessment elements (for teachers) ***********************/ - elseif ($action == 'editelements') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - $count = count_records("workshop_grades", "workshopid", $workshop->id); - if ($workshop->phase > 1 and $count) { - notify(get_string("warningonamendingelements", "workshop")); - } - // set up heading, form and table - print_heading_with_help(get_string("editingassessmentelements", "workshop"), "elements", "workshop"); - ?> -
- - -
- id, "elementno ASC" )) { - foreach ($elementsraw as $element) { - $elements[] = $element; // to renumber index 0,1,2... - } - } - // check for missing elements (this happens either the first time round or when the number of elements is icreased) - for ($i=0; $i<$workshop->nelements; $i++) { - if (!isset($elements[$i])) { - $elements[$i]->description = ''; - $elements[$i]->scale =0; - $elements[$i]->maxscore = 0; - $elements[$i]->weight = 11; - } - } + $yearfromnow = time() + 365 * 86400; + // ...create one and set timecreated way in the future, this is reset when record is updated + $assessment->workshopid = $workshop->id; + $assessment->submissionid = $submission->id; + $assessment->userid = $USER->id; + $assessment->grade = -1; // set impossible grade + $assessment->timecreated = $yearfromnow; + $assessment->timegraded = 0; + $assessment->timeagreed = 0; + $assessment->resubmission = 0; + if (!$assessment->id = insert_record("workshop_assessments", $assessment)) { + error("Could not insert workshop assessment!"); + } + } + + print_heading_with_help(get_string("assessthissubmission", "workshop"), "grading", "workshop"); + + // show assessment and allow changes + workshop_print_assessment($workshop, $assessment, true, $allowcomments, $_SERVER["HTTP_REFERER"]); + } + + + /*************** display grading form (viewed by student) *********************************/ + elseif ($action == 'displaygradingform') { + + print_heading_with_help(get_string("specimenassessmentform", "workshop"), "specimen", "workshop"); + + workshop_print_assessment($workshop); // called with no assessment + print_continue("view.php?a=$workshop->id"); + } + + + + /*************** edit comment on assessment (by author, assessor or teacher) ***************************/ + elseif ($action == 'editcomment') { + + print_heading_with_help(get_string("editacomment", "workshop"), "editingacomment", "workshop"); + // get the comment record... + if (!$comment = get_record("workshop_comments", "id", $_GET['cid'])) { + error("Edit Comment: Comment not found"); + } + if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) { + error("Edit Comment: Assessment not found"); + } + if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { + error("Edit Comment: Submission not found"); + } + ?> + + + + +
+
+ \n"; + echo " \n"; + echo "

". get_string("comment", "workshop").":

\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + workshop_print_assessment($workshop, $assessment); + } + + + /*********************** edit assessment elements (for teachers) ***********************/ + elseif ($action == 'editelements') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + $count = count_records("workshop_grades", "workshopid", $workshop->id); + if ($workshop->phase > 1 and $count) { + notify(get_string("warningonamendingelements", "workshop")); + } + // set up heading, form and table + print_heading_with_help(get_string("editingassessmentelements", "workshop"), "elements", "workshop"); + ?> +
+ + +
+ id, "elementno ASC" )) { + foreach ($elementsraw as $element) { + $elements[] = $element; // to renumber index 0,1,2... + } + } + // check for missing elements (this happens either the first time round or when the number of elements is icreased) + for ($i=0; $i<$workshop->nelements; $i++) { + if (!isset($elements[$i])) { + $elements[$i]->description = ''; + $elements[$i]->scale =0; + $elements[$i]->maxscore = 0; + $elements[$i]->weight = 11; + } + } - switch ($workshop->gradingstrategy) { - case 0: // no grading - for ($i=0; $i<$workshop->nelements; $i++) { - $iplus1 = $i+1; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - } - break; - - case 1: // accumulative grading - // set up scales name - foreach ($WORKSHOP_SCALES as $KEY => $SCALE) { - $SCALES[] = $SCALE['name']; - } - for ($i=0; $i<$workshop->nelements; $i++) { - $iplus1 = $i+1; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - } - break; - - case 2: // error banded grading - for ($i=0; $i<$workshop->nelements; $i++) { - $iplus1 = $i+1; - echo "\n"; - echo " \n"; - echo "\n"; - if ($elements[$i]->weight == '') { // not set - $elements[$i]->weight = 11; // unity - } - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - } - echo "

". get_string("element","workshop")." $iplus1:

\n"; - echo "
cellheading2\"> 

". get_string("element","workshop")." $iplus1:

\n"; - echo "

". get_string("typeofscale", "workshop"). ":

\n"; - choose_from_menu($SCALES, "scale[]", $elements[$i]->scale, ""); - if ($elements[$i]->weight == '') { // not set - $elements[$i]->weight = 11; // unity - } - echo "
".get_string("elementweight", "workshop").":\n"; - workshop_choose_from_menu($WORKSHOP_EWEIGHTS, "weight[]", $elements[$i]->weight, ""); - echo "
cellheading2\"> 

". get_string("element","workshop")." $iplus1:

\n"; - echo "
".get_string("elementweight", "workshop").":\n"; - workshop_choose_from_menu($WORKSHOP_EWEIGHTS, "weight[]", $elements[$i]->weight, ""); - echo "
cellheading2\"> 

\n"; - echo "

".get_string("gradetable","workshop")."
\n"; - echo "
\n"; - for ($j = $workshop->grade; $j >= 0; $j--) { - $numbers[$j] = $j; - } - for ($i=0; $i<=$workshop->nelements; $i++) { - echo "\n"; - } - echo "
". - get_string("numberofnegativeresponses", "workshop"); - echo "". get_string("suggestedgrade", "workshop")."
$i"; - if (!isset($elements[$i])) { // the "last one" will be! - $elements[$i]->description = ""; - $elements[$i]->maxscore = 0; - } - choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, ""); - echo "
\n"; - break; - - case 3: // criterion grading - for ($j = 100; $j >= 0; $j--) { - $numbers[$j] = $j; - } - for ($i=0; $i<$workshop->nelements; $i++) { - $iplus1 = $i+1; - echo "\n"; - echo "

". get_string("criterion","workshop")." $iplus1:\n"; - echo "\n"; - echo " \n"; - echo "". get_string("suggestedgrade", "workshop").":\n"; - choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, ""); - echo "\n"; - echo "\n"; - echo " cellheading2\"> \n"; - echo "\n"; - } - break; - - case 4: // rubric - for ($j = 100; $j >= 0; $j--) { - $numbers[$j] = $j; - } - if ($rubricsraw = get_records("workshop_rubrics", "workshopid", $workshop->id)) { - foreach ($rubricsraw as $rubric) { - $rubrics[$rubric->elementno][$rubric->rubricno] = $rubric->description; // reindex 0,1,2... - } - } - for ($i=0; $i<$workshop->nelements; $i++) { - $iplus1 = $i+1; - echo "\n"; - echo "

". get_string("element","workshop")." $iplus1:\n"; - echo "\n"; - echo " \n"; - echo "".get_string("elementweight", "workshop").":\n"; - workshop_choose_from_menu($WORKSHOP_EWEIGHTS, "weight[]", $elements[$i]->weight, ""); - echo " \n"; - echo "\n"; - - for ($j=0; $j<5; $j++) { - $jplus1 = $j+1; - if (empty($rubrics[$i][$j])) { - $rubrics[$i][$j] = ""; - } - echo "\n"; - echo "

". get_string("grade","workshop")." $j:\n"; - echo "\n"; - echo " \n"; - } - echo "\n"; - echo " cellheading2\"> \n"; - echo "\n"; - } - break; - } - // close table and form - ?> - - "> - "> -

-
- id)) { - error("Only teachers can look at this page"); - } - - // set up coment scale - for ($i=COMMENTSCALE; $i>=0; $i--) { - $num[$i] = $i; - } - - print_heading_with_help(get_string("gradeassessment", "workshop"), "gradingassessments", "workshop"); - // get assessment record - if (!$assessmentid = $_GET['aid']) { - error("Assessment id not given"); - } - $assessment = get_record("workshop_assessments", "id", $assessmentid); - if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { - error("Submission not found"); - } - // get the teacher's assessment first - if ($teachersassessment = workshop_get_submission_assessment($submission, $USER)) { - echo "

".get_string("teacherassessments", "workshop", $course->teacher)."
\n"; - workshop_print_assessment($workshop, $teachersassessment); - } - // now the student's assessment (don't allow changes) - $user = get_record("user", "id", $assessment->userid); - echo "

".get_string("assessmentby", "workshop", $user->firstname." ".$user->lastname)."
\n"; - workshop_print_assessment($workshop, $assessment); - - ?> -
- - - - -
- - \n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "

". get_string("teacherscomment", "workshop").":

\n"; - echo " \n"; - echo "
".get_string("gradeforstudentsassessment", "workshop")."\n"; - choose_from_menu($num, "gradinggrade", $assessment->gradinggrade, ""); - echo "
\n"; - echo "\n"; - echo "
\n"; - } - - - /*************** insert (new) comment (by author, assessor or teacher) ***************************/ - elseif ($action == 'insertcomment') { - $timenow = time(); - - $form = (object)$_POST; - - if (!$assessment = get_record("workshop_assessments", "id", $_POST['aid'])) { - error("Unable to insert comment"); - } - // save the comment... - $comment->workshopid = $workshop->id; - $comment->assessmentid = $assessment->id; - $comment->userid = $USER->id; - $comment->timecreated = $timenow; - $comment->comments = $form->comments; - if (!$comment->id = insert_record("workshop_comments", $comment)) { - error("Could not insert workshop comment!"); - } - - add_to_log($course->id, "workshop", "comment", "view.php?id=$cm->id", "$comment->id"); - - print_continue("assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id"); - } - - - /*********************** insert/update assignment elements (for teachers)***********************/ - elseif ($action == 'insertelements') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - $form = (object)$HTTP_POST_VARS; - - // let's not fool around here, dump the junk! - delete_records("workshop_elements", "workshopid", $workshop->id); - - // determine wich type of grading - switch ($workshop->gradingstrategy) { - case 0: // no grading - // Insert all the elements that contain something - foreach ($form->description as $key => $description) { - if ($description) { - unset($element); - $element->description = $description; - $element->workshopid = $workshop->id; - $element->elementno = $key; - if (!$element->id = insert_record("workshop_elements", $element)) { - error("Could not insert workshop element!"); - } - } - } - break; - - case 1: // accumulative grading - // Insert all the elements that contain something - foreach ($form->description as $key => $description) { - if ($description) { - unset($element); - $element->description = $description; - $element->workshopid = $workshop->id; - $element->elementno = $key; - if (isset($form->scale[$key])) { - $element->scale = $form->scale[$key]; - switch ($WORKSHOP_SCALES[$form->scale[$key]]['type']) { - case 'radio' : $element->maxscore = $WORKSHOP_SCALES[$form->scale[$key]]['size'] - 1; - break; - case 'selection' : $element->maxscore = $WORKSHOP_SCALES[$form->scale[$key]]['size']; - break; - } - } - if (isset($form->weight[$key])) { - $element->weight = $form->weight[$key]; - } - if (!$element->id = insert_record("workshop_elements", $element)) { - error("Could not insert workshop element!"); - } - } - } - break; - - case 2: // error banded grading... - case 3: // ...and criterion grading - // Insert all the elements that contain something, the number of descriptions is one less than the number of grades - foreach ($form->maxscore as $key => $themaxscore) { - unset($element); - $element->workshopid = $workshop->id; - $element->elementno = $key; - $element->maxscore = $themaxscore; - if (isset($form->description[$key])) { - $element->description = $form->description[$key]; - } - if (isset($form->weight[$key])) { - $element->weight = $form->weight[$key]; - } - if (!$element->id = insert_record("workshop_elements", $element)) { - error("Could not insert workshop element!"); - } - } - break; - - case 4: // ...and criteria grading - // Insert all the elements that contain something - foreach ($form->description as $key => $description) { - unset($element); - $element->workshopid = $workshop->id; - $element->elementno = $key; - $element->description = $description; - $element->weight = $form->weight[$key]; - for ($j=0;$j<5;$j++) { - if (empty($form->rubric[$key][$j])) - break; - } - $element->maxscore = $j - 1; - if (!$element->id = insert_record("workshop_elements", $element)) { - error("Could not insert workshop element!"); - } - } - // let's not fool around here, dump the junk! - delete_records("workshop_rubrics", "workshopid", $workshop->id); - for ($i=0;$i<$workshop->nelements;$i++) { - for ($j=0;$j<5;$j++) { - unset($element); - if (empty($form->rubric[$i][$j])) { // OK to have an element with fewer than 5 items - break; - } - $element->workshopid = $workshop->id; - $element->elementno = $i; - $element->rubricno = $j; - $element->description = $form->rubric[$i][$j]; - if (!$element->id = insert_record("workshop_rubrics", $element)) { - error("Could not insert workshop element!"); - } - } - } - break; - } // end of switch - - redirect("view.php?id=$cm->id", get_string("savedok","workshop")); - } - - - /*********************** list assessments for grading (Student submissions)(by teachers)***********************/ - elseif ($action == 'listungradedstudentsubmissions') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - workshop_list_ungraded_assessments($workshop, "student"); - print_continue("view.php?a=$workshop->id"); - } - - - /*********************** list assessments for grading (Teacher submissions) (by teachers)***********************/ - elseif ($action == 'listungradedteachersubmissions') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - workshop_list_ungraded_assessments($workshop, "teacher"); - print_continue("view.php?a=$workshop->id"); - } - - - /****************** list teacher submissions ***********************/ - elseif ($action == 'listteachersubmissions') { - - workshop_list_teacher_submissions($workshop, $USER); - print_continue("view.php?a=$workshop->id"); - } - - - /*************** update assessment (by teacher or student) ***************************/ - elseif ($action == 'updateassessment') { - - require_variable($aid); - if (! $assessment = get_record("workshop_assessments", "id", $aid)) { - error("workshop assessment is misconfigured"); - } - - // first get the assignment elements for maxscores and weights... - $elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC"); + switch ($workshop->gradingstrategy) { + case 0: // no grading + for ($i=0; $i<$workshop->nelements; $i++) { + $iplus1 = $i+1; + echo "\n"; + echo "

". get_string("element","workshop")." $iplus1:\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " cellheading2\"> \n"; + echo "\n"; + } + break; + + case 1: // accumulative grading + // set up scales name + foreach ($WORKSHOP_SCALES as $KEY => $SCALE) { + $SCALES[] = $SCALE['name']; + } + for ($i=0; $i<$workshop->nelements; $i++) { + $iplus1 = $i+1; + echo "\n"; + echo "

". get_string("element","workshop")." $iplus1:\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "

". get_string("typeofscale", "workshop"). ":

\n"; + echo "\n"; + choose_from_menu($SCALES, "scale[]", $elements[$i]->scale, ""); + if ($elements[$i]->weight == '') { // not set + $elements[$i]->weight = 11; // unity + } + echo "\n"; + echo "".get_string("elementweight", "workshop").":\n"; + workshop_choose_from_menu($WORKSHOP_EWEIGHTS, "weight[]", $elements[$i]->weight, ""); + echo " \n"; + echo "\n"; + echo "\n"; + echo " cellheading2\"> \n"; + echo "\n"; + } + break; + + case 2: // error banded grading + for ($i=0; $i<$workshop->nelements; $i++) { + $iplus1 = $i+1; + echo "\n"; + echo "

". get_string("element","workshop")." $iplus1:\n"; + echo "\n"; + echo " \n"; + if ($elements[$i]->weight == '') { // not set + $elements[$i]->weight = 11; // unity + } + echo "\n"; + echo "".get_string("elementweight", "workshop").":\n"; + workshop_choose_from_menu($WORKSHOP_EWEIGHTS, "weight[]", $elements[$i]->weight, ""); + echo " \n"; + echo "\n"; + echo "\n"; + echo " cellheading2\"> \n"; + echo "\n"; + } + echo "
\n"; + echo "

".get_string("gradetable","workshop")."
\n"; + echo "
\n"; + for ($j = $workshop->grade; $j >= 0; $j--) { + $numbers[$j] = $j; + } + for ($i=0; $i<=$workshop->nelements; $i++) { + echo "\n"; + } + echo "
". + get_string("numberofnegativeresponses", "workshop"); + echo "". get_string("suggestedgrade", "workshop")."
$i"; + if (!isset($elements[$i])) { // the "last one" will be! + $elements[$i]->description = ""; + $elements[$i]->maxscore = 0; + } + choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, ""); + echo "
\n"; + break; + + case 3: // criterion grading + for ($j = 100; $j >= 0; $j--) { + $numbers[$j] = $j; + } + for ($i=0; $i<$workshop->nelements; $i++) { + $iplus1 = $i+1; + echo "\n"; + echo "

". get_string("criterion","workshop")." $iplus1:\n"; + echo "\n"; + echo " \n"; + echo "". get_string("suggestedgrade", "workshop").":\n"; + choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, ""); + echo "\n"; + echo "\n"; + echo " cellheading2\"> \n"; + echo "\n"; + } + break; + + case 4: // rubric + for ($j = 100; $j >= 0; $j--) { + $numbers[$j] = $j; + } + if ($rubricsraw = get_records("workshop_rubrics", "workshopid", $workshop->id)) { + foreach ($rubricsraw as $rubric) { + $rubrics[$rubric->elementno][$rubric->rubricno] = $rubric->description; // reindex 0,1,2... + } + } + for ($i=0; $i<$workshop->nelements; $i++) { + $iplus1 = $i+1; + echo "\n"; + echo "

". get_string("element","workshop")." $iplus1:\n"; + + echo "\n"; + + echo " \n"; + echo "".get_string("elementweight", "workshop").":\n"; + workshop_choose_from_menu($WORKSHOP_EWEIGHTS, "weight[]", $elements[$i]->weight, ""); + echo " \n"; + echo "\n"; + + for ($j=0; $j<5; $j++) { + $jplus1 = $j+1; + if (empty($rubrics[$i][$j])) { + $rubrics[$i][$j] = ""; + } + echo "\n"; + + echo "

". get_string("grade","workshop")." $j:\n"; + + echo "\n"; + + echo " \n"; + } + echo "\n"; + + echo " cellheading2\"> \n"; + + echo "\n"; + } + break; + } + // close table and form + + ?> + + "> + "> + + + + id)) { + error("Only teachers can look at this page"); + } + + // set up coment scale + for ($i=COMMENTSCALE; $i>=0; $i--) { + $num[$i] = $i; + } + + print_heading_with_help(get_string("gradeassessment", "workshop"), "gradingassessments", "workshop"); + // get assessment record + if (!$assessmentid = $_GET['aid']) { + error("Assessment id not given"); + } + $assessment = get_record("workshop_assessments", "id", $assessmentid); + if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { + error("Submission not found"); + } + // get the teacher's assessment first + if ($teachersassessment = workshop_get_submission_assessment($submission, $USER)) { + echo "

".get_string("teacherassessments", "workshop", $course->teacher)."
\n"; + workshop_print_assessment($workshop, $teachersassessment); + } + // now the student's assessment (don't allow changes) + $user = get_record("user", "id", $assessment->userid); + echo "

".get_string("assessmentby", "workshop", fullname($user))."
\n"; + workshop_print_assessment($workshop, $assessment); + + ?> +
+ + + + +
+ + \n"; + echo " \n"; + + echo " \n"; + + echo "\n"; + + echo "

". get_string("teacherscomment", "workshop").":

\n"; + + echo " \n"; + + echo "
".get_string("gradeforstudentsassessment", "workshop")."\n"; + choose_from_menu($num, "gradinggrade", $assessment->gradinggrade, ""); + echo "
\n"; + echo "\n"; + echo "
\n"; + } + + + + /*************** insert (new) comment (by author, assessor or teacher) ***************************/ + elseif ($action == 'insertcomment') { + $timenow = time(); + + $form = (object)$_POST; + + if (!$assessment = get_record("workshop_assessments", "id", $_POST['aid'])) { + error("Unable to insert comment"); + } + // save the comment... + $comment->workshopid = $workshop->id; + $comment->assessmentid = $assessment->id; + $comment->userid = $USER->id; + $comment->timecreated = $timenow; + $comment->comments = $form->comments; + if (!$comment->id = insert_record("workshop_comments", $comment)) { + error("Could not insert workshop comment!"); + } + + add_to_log($course->id, "workshop", "comment", "view.php?id=$cm->id", "$comment->id"); + + print_continue("assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id"); + } + + + + /*********************** insert/update assignment elements (for teachers)***********************/ + elseif ($action == 'insertelements') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + $form = (object)$HTTP_POST_VARS; + + // let's not fool around here, dump the junk! + delete_records("workshop_elements", "workshopid", $workshop->id); + + // determine wich type of grading + switch ($workshop->gradingstrategy) { + case 0: // no grading + // Insert all the elements that contain something + foreach ($form->description as $key => $description) { + if ($description) { + unset($element); + $element->description = $description; + $element->workshopid = $workshop->id; + $element->elementno = $key; + if (!$element->id = insert_record("workshop_elements", $element)) { + error("Could not insert workshop element!"); + } + } + } + break; + + case 1: // accumulative grading + // Insert all the elements that contain something + foreach ($form->description as $key => $description) { + if ($description) { + unset($element); + $element->description = $description; + $element->workshopid = $workshop->id; + $element->elementno = $key; + if (isset($form->scale[$key])) { + $element->scale = $form->scale[$key]; + switch ($WORKSHOP_SCALES[$form->scale[$key]]['type']) { + case 'radio' : $element->maxscore = $WORKSHOP_SCALES[$form->scale[$key]]['size'] - 1; + break; + case 'selection' : $element->maxscore = $WORKSHOP_SCALES[$form->scale[$key]]['size']; + break; + } + } + if (isset($form->weight[$key])) { + $element->weight = $form->weight[$key]; + } + if (!$element->id = insert_record("workshop_elements", $element)) { + error("Could not insert workshop element!"); + } + } + } + break; + + case 2: // error banded grading... + case 3: // ...and criterion grading + // Insert all the elements that contain something, the number of descriptions is one less than the number of grades + foreach ($form->maxscore as $key => $themaxscore) { + unset($element); + $element->workshopid = $workshop->id; + $element->elementno = $key; + $element->maxscore = $themaxscore; + if (isset($form->description[$key])) { + $element->description = $form->description[$key]; + } + if (isset($form->weight[$key])) { + $element->weight = $form->weight[$key]; + } + if (!$element->id = insert_record("workshop_elements", $element)) { + error("Could not insert workshop element!"); + } + } + break; + + case 4: // ...and criteria grading + // Insert all the elements that contain something + foreach ($form->description as $key => $description) { + unset($element); + $element->workshopid = $workshop->id; + $element->elementno = $key; + $element->description = $description; + $element->weight = $form->weight[$key]; + for ($j=0;$j<5;$j++) { + if (empty($form->rubric[$key][$j])) + break; + } + $element->maxscore = $j - 1; + if (!$element->id = insert_record("workshop_elements", $element)) { + error("Could not insert workshop element!"); + } + } + // let's not fool around here, dump the junk! + delete_records("workshop_rubrics", "workshopid", $workshop->id); + for ($i=0;$i<$workshop->nelements;$i++) { + for ($j=0;$j<5;$j++) { + unset($element); + if (empty($form->rubric[$i][$j])) { // OK to have an element with fewer than 5 items + break; + } + $element->workshopid = $workshop->id; + $element->elementno = $i; + $element->rubricno = $j; + $element->description = $form->rubric[$i][$j]; + if (!$element->id = insert_record("workshop_rubrics", $element)) { + error("Could not insert workshop element!"); + } + } + } + break; + } // end of switch + + redirect("view.php?id=$cm->id", get_string("savedok","workshop")); + } + + + /*********************** list assessments for grading (Student submissions)(by teachers)***********************/ + elseif ($action == 'listungradedstudentsubmissions') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + workshop_list_ungraded_assessments($workshop, "student"); + print_continue("view.php?a=$workshop->id"); + } + + + /*********************** list assessments for grading (Teacher submissions) (by teachers)***********************/ + elseif ($action == 'listungradedteachersubmissions') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + workshop_list_ungraded_assessments($workshop, "teacher"); + print_continue("view.php?a=$workshop->id"); + } + + + /****************** list teacher submissions ***********************/ + elseif ($action == 'listteachersubmissions') { + + workshop_list_teacher_submissions($workshop, $USER); + print_continue("view.php?a=$workshop->id"); + } + + + /*************** update assessment (by teacher or student) ***************************/ + elseif ($action == 'updateassessment') { + + require_variable($aid); + if (! $assessment = get_record("workshop_assessments", "id", $aid)) { + error("workshop assessment is misconfigured"); + } + + // first get the assignment elements for maxscores and weights... + $elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC"); if (count($elementsraw) < $workshop->nelements) { - print_string("noteonassignmentelements", "workshop"); - } - if ($elementsraw) { - foreach ($elementsraw as $element) { - $elements[] = $element; // to renumber index 0,1,2... - } - } else { + print_string("noteonassignmentelements", "workshop"); + } + if ($elementsraw) { + foreach ($elementsraw as $element) { + $elements[] = $element; // to renumber index 0,1,2... + } + } else { $elements = null; } - $timenow = time(); + $timenow = time(); // don't fiddle about, delete all the old and add the new! - delete_records("workshop_grades", "assessmentid", $assessment->id); - - $form = (object)$HTTP_POST_VARS; - - //determine what kind of grading we have - switch ($workshop->gradingstrategy) { - case 0: // no grading - // Insert all the elements that contain something - foreach ($form->feedback as $key => $thefeedback) { - unset($element); - $element->workshopid = $workshop->id; - $element->assessmentid = $assessment->id; - $element->elementno = $key; - $element->feedback = $thefeedback; - if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop element!"); - } - } - $grade = 0; // set to satisfy save to db - break; - - case 1: // accumulative grading - // Insert all the elements that contain something - foreach ($form->grade as $key => $thegrade) { - unset($element); - $element->workshopid = $workshop->id; - $element->assessmentid = $assessment->id; - $element->elementno = $key; - $element->feedback = $form->feedback[$key]; - $element->grade = $thegrade; - if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop element!"); - } - } - // now work out the grade... - $rawgrade=0; - $totalweight=0; - foreach ($form->grade as $key => $grade) { - $maxscore = $elements[$key]->maxscore; - $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight]; - if ($weight > 0) { - $totalweight += $weight; - } - $rawgrade += ($grade / $maxscore) * $weight; - // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade
"; - } - $grade = $workshop->grade * ($rawgrade / $totalweight); - break; - - case 2: // error banded graded - // Insert all the elements that contain something - $error = 0.0; - for ($i =0; $i < $workshop->nelements; $i++) { - unset($element); - $element->workshopid = $workshop->id; - $element->assessmentid = $assessment->id; - $element->elementno = $i; - $element->feedback = $form->feedback[$i]; - $element->grade = $form->grade[$i]; - if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop element!"); - } - if (empty($form->grade[$i])){ - $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight]; - } - } - // now save the adjustment - unset($element); - $i = $workshop->nelements; - $element->workshopid = $workshop->id; - $element->assessmentid = $assessment->id; - $element->elementno = $i; - $element->grade = $form->grade[$i]; - if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop element!"); - } - $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]); - echo "

".get_string("weightederrorcount", "workshop", intval($error + 0.5))."\n"; - break; - - case 3: // criteria grading - // save in the selected criteria value in element zero, - unset($element); - $element->workshopid = $workshop->id; - $element->assessmentid = $assessment->id; - $element->elementno = 0; - $element->grade = $form->grade[0]; - if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop element!"); - } - // now save the adjustment in element one - unset($element); - $element->workshopid = $workshop->id; - $element->assessmentid = $assessment->id; - $element->elementno = 1; - $element->grade = $form->grade[1]; - if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop element!"); - } - $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * $workshop->grade / 100; - break; - - case 4: // rubric grading (identical to accumulative grading) - // Insert all the elements that contain something - foreach ($form->grade as $key => $thegrade) { - unset($element); - $element->workshopid = $workshop->id; - $element->assessmentid = $assessment->id; - $element->elementno = $key; - $element->feedback = $form->feedback[$key]; - $element->grade = $thegrade; - if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop element!"); - } - } - // now work out the grade... - $rawgrade=0; - $totalweight=0; - foreach ($form->grade as $key => $grade) { - $maxscore = $elements[$key]->maxscore; - $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight]; - if ($weight > 0) { - $totalweight += $weight; - } - $rawgrade += ($grade / $maxscore) * $weight; - } - $grade = $workshop->grade * ($rawgrade / $totalweight); - break; - - } // end of switch - - // update the time of the assessment record (may be re-edited)... - set_field("workshop_assessments", "timecreated", $timenow, "id", $assessment->id); - - if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { - error ("Updateassessment: submission record not found"); - } - - // if the workshop does need peer agreement AND it's self assessment then set timeagreed - if ($workshop->agreeassessments and ($submission->userid == $assessment->userid)) { - set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id); - } - - set_field("workshop_assessments", "grade", $grade, "id", $assessment->id); - // ...and clear any grading of this assessment... - set_field("workshop_assessments", "timegraded", 0, "id", $assessment->id); - set_field("workshop_assessments", "gradinggrade", 0, "id", $assessment->id); - // ...and the resubmission flag + delete_records("workshop_grades", "assessmentid", $assessment->id); + + $form = (object)$HTTP_POST_VARS; + + //determine what kind of grading we have + switch ($workshop->gradingstrategy) { + case 0: // no grading + // Insert all the elements that contain something + foreach ($form->feedback as $key => $thefeedback) { + unset($element); + $element->workshopid = $workshop->id; + $element->assessmentid = $assessment->id; + $element->elementno = $key; + $element->feedback = $thefeedback; + if (!$element->id = insert_record("workshop_grades", $element)) { + error("Could not insert workshop element!"); + } + } + $grade = 0; // set to satisfy save to db + break; + + case 1: // accumulative grading + // Insert all the elements that contain something + foreach ($form->grade as $key => $thegrade) { + unset($element); + $element->workshopid = $workshop->id; + $element->assessmentid = $assessment->id; + $element->elementno = $key; + $element->feedback = $form->feedback[$key]; + $element->grade = $thegrade; + if (!$element->id = insert_record("workshop_grades", $element)) { + error("Could not insert workshop element!"); + } + } + // now work out the grade... + $rawgrade=0; + $totalweight=0; + foreach ($form->grade as $key => $grade) { + $maxscore = $elements[$key]->maxscore; + $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight]; + if ($weight > 0) { + $totalweight += $weight; + } + $rawgrade += ($grade / $maxscore) * $weight; + // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade
"; + } + $grade = $workshop->grade * ($rawgrade / $totalweight); + break; + + case 2: // error banded graded + // Insert all the elements that contain something + $error = 0.0; + for ($i =0; $i < $workshop->nelements; $i++) { + unset($element); + $element->workshopid = $workshop->id; + $element->assessmentid = $assessment->id; + $element->elementno = $i; + $element->feedback = $form->feedback[$i]; + $element->grade = $form->grade[$i]; + if (!$element->id = insert_record("workshop_grades", $element)) { + error("Could not insert workshop element!"); + } + if (empty($form->grade[$i])){ + $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight]; + } + } + // now save the adjustment + unset($element); + $i = $workshop->nelements; + $element->workshopid = $workshop->id; + $element->assessmentid = $assessment->id; + $element->elementno = $i; + $element->grade = $form->grade[$i]; + if (!$element->id = insert_record("workshop_grades", $element)) { + error("Could not insert workshop element!"); + } + $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]); + echo "

".get_string("weightederrorcount", "workshop", intval($error + 0.5))."\n"; + break; + + case 3: // criteria grading + // save in the selected criteria value in element zero, + unset($element); + $element->workshopid = $workshop->id; + $element->assessmentid = $assessment->id; + $element->elementno = 0; + $element->grade = $form->grade[0]; + if (!$element->id = insert_record("workshop_grades", $element)) { + error("Could not insert workshop element!"); + } + // now save the adjustment in element one + unset($element); + $element->workshopid = $workshop->id; + $element->assessmentid = $assessment->id; + $element->elementno = 1; + $element->grade = $form->grade[1]; + if (!$element->id = insert_record("workshop_grades", $element)) { + error("Could not insert workshop element!"); + } + $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * $workshop->grade / 100; + break; + + case 4: // rubric grading (identical to accumulative grading) + // Insert all the elements that contain something + foreach ($form->grade as $key => $thegrade) { + unset($element); + $element->workshopid = $workshop->id; + $element->assessmentid = $assessment->id; + $element->elementno = $key; + $element->feedback = $form->feedback[$key]; + $element->grade = $thegrade; + if (!$element->id = insert_record("workshop_grades", $element)) { + error("Could not insert workshop element!"); + } + } + // now work out the grade... + $rawgrade=0; + $totalweight=0; + foreach ($form->grade as $key => $grade) { + $maxscore = $elements[$key]->maxscore; + $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight]; + if ($weight > 0) { + $totalweight += $weight; + } + $rawgrade += ($grade / $maxscore) * $weight; + } + $grade = $workshop->grade * ($rawgrade / $totalweight); + break; + + } // end of switch + + // update the time of the assessment record (may be re-edited)... + set_field("workshop_assessments", "timecreated", $timenow, "id", $assessment->id); + + if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { + error ("Updateassessment: submission record not found"); + } + + // if the workshop does need peer agreement AND it's self assessment then set timeagreed + if ($workshop->agreeassessments and ($submission->userid == $assessment->userid)) { + set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id); + } + + set_field("workshop_assessments", "grade", $grade, "id", $assessment->id); + // ...and clear any grading of this assessment... + set_field("workshop_assessments", "timegraded", 0, "id", $assessment->id); + set_field("workshop_assessments", "gradinggrade", 0, "id", $assessment->id); + // ...and the resubmission flag set_field("workshop_assessments", "resubmission", 0, "id", $assessment->id); - + // any comment? - if (!empty($form->generalcomment)) { - set_field("workshop_assessments", "generalcomment", $form->generalcomment, "id", $assessment->id); - } - - add_to_log($course->id, "workshop", "assess", + if (!empty($form->generalcomment)) { + set_field("workshop_assessments", "generalcomment", $form->generalcomment, "id", $assessment->id); + } + + add_to_log($course->id, "workshop", "assess", "assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id", "$assessment->id", "$cm->id"); - - // set up return address - if (!$returnto = $form->returnto) { - $returnto = "view.php?id=$cm->id"; - } - - // show grade if grading strategy is not zero - if ($workshop->gradingstrategy) { - redirect($returnto, get_string("thegradeis", "workshop").": ".number_format($grade, 2). + + // set up return address + if (!$returnto = $form->returnto) { + $returnto = "view.php?id=$cm->id"; + } + + // show grade if grading strategy is not zero + if ($workshop->gradingstrategy) { + redirect($returnto, get_string("thegradeis", "workshop").": ".number_format($grade, 2). " (".get_string("maximumgrade")." ".number_format($workshop->grade).")"); - } - else { - redirect($returnto); - } - } - - - /****************** update comment (by author, assessor or teacher) ********************/ - elseif ($action == 'updatecomment') { - $timenow = time(); - - $form = (object)$_POST; - - // get the comment record... - if (!$comment = get_record("workshop_comments", "id", $_POST['cid'])) { - error("Update to Comment failed"); - } - if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) { - error("Update Comment: Assessment not found"); - } - //save the comment for the assessment... - if (isset($form->comments)) { - set_field("workshop_comments", "comments", $form->comments, "id", $comment->id); - set_field("workshop_comments", "timecreated", $timenow, "id", $comment->id); - // ..and kick to comment into life (probably not needed but just in case) - set_field("workshop_comments", "mailed", 0, "id", $comment->id); - echo "".get_string("savedok", "workshop")."
\n"; - - add_to_log($course->id, "workshop", "comment", + } + else { + redirect($returnto); + } + } + + + /****************** update comment (by author, assessor or teacher) ********************/ + elseif ($action == 'updatecomment') { + $timenow = time(); + + $form = (object)$_POST; + + // get the comment record... + if (!$comment = get_record("workshop_comments", "id", $_POST['cid'])) { + error("Update to Comment failed"); + } + if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) { + error("Update Comment: Assessment not found"); + } + //save the comment for the assessment... + if (isset($form->comments)) { + set_field("workshop_comments", "comments", $form->comments, "id", $comment->id); + set_field("workshop_comments", "timecreated", $timenow, "id", $comment->id); + // ..and kick to comment into life (probably not needed but just in case) + set_field("workshop_comments", "mailed", 0, "id", $comment->id); + echo "".get_string("savedok", "workshop")."
\n"; + + add_to_log($course->id, "workshop", "comment", "assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id", "$comment->id"); - } - - print_continue("assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id"); - } - - - /****************** update grading (by teacher) ***************************/ - elseif ($action == 'updategrading') { - $timenow = time(); - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - $form = (object)$_POST; - - if (!$assessment = get_record("workshop_assessments", "id", $_POST['aid'])) { - error("Update Grading failed"); - } - //save the comment and grade for the assessment - if (isset($form->teachercomment)) { - set_field("workshop_assessments", "teachercomment", $form->teachercomment, "id", $assessment->id); - set_field("workshop_assessments", "gradinggrade", $form->gradinggrade, "id", $assessment->id); - set_field("workshop_assessments", "timegraded", $timenow, "id", $assessment->id); - set_field("workshop_assessments", "mailed", 0, "id", $assessment->id); - echo "".get_string("savedok", "workshop")."
\n"; - - add_to_log($course->id, "workshop", "grade", + } + + print_continue("assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id"); + } + + + /****************** update grading (by teacher) ***************************/ + elseif ($action == 'updategrading') { + $timenow = time(); + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + $form = (object)$_POST; + + if (!$assessment = get_record("workshop_assessments", "id", $_POST['aid'])) { + error("Update Grading failed"); + } + //save the comment and grade for the assessment + if (isset($form->teachercomment)) { + set_field("workshop_assessments", "teachercomment", $form->teachercomment, "id", $assessment->id); + set_field("workshop_assessments", "gradinggrade", $form->gradinggrade, "id", $assessment->id); + set_field("workshop_assessments", "timegraded", $timenow, "id", $assessment->id); + set_field("workshop_assessments", "mailed", 0, "id", $assessment->id); + echo "".get_string("savedok", "workshop")."
\n"; + + add_to_log($course->id, "workshop", "grade", "assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id", "$assessment->id", "$cm->id"); - } - switch ($form->stype) { - case "student" : - redirect("assessments.php?action=listungradedstudentsubmissions&id=$cm->id"); - break; - case "teacher" : - redirect("assessments.php?action=listungradedteachersubmissions&id=$cm->id"); - break; - } - } - - - /****************** user confirm delete ************************************/ - elseif ($action == 'userconfirmdelete' ) { - - if (empty($_GET['aid'])) { - error("User confirm delete: assessment id missing"); - } - - notice_yesno(get_string("confirmdeletionofthisitem","workshop", + } + switch ($form->stype) { + case "student" : + redirect("assessments.php?action=listungradedstudentsubmissions&id=$cm->id"); + break; + case "teacher" : + redirect("assessments.php?action=listungradedteachersubmissions&id=$cm->id"); + break; + } + } + + + /****************** user confirm delete ************************************/ + elseif ($action == 'userconfirmdelete' ) { + + if (empty($_GET['aid'])) { + error("User confirm delete: assessment id missing"); + } + + notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("assessment", "workshop")), "assessments.php?action=userdelete&id=$cm->id&aid=$_GET[aid]", "view.php?id=$cm->id"); - } - - - /****************** user delete ************************************/ - elseif ($action == 'userdelete' ) { - - if (empty($_GET['aid'])) { - error("User delete: assessment id missing"); - } - - print_string("deleting", "workshop"); - // first delete all the associated records... - delete_records("workshop_comments", "assessmentid", $_GET['aid']); - delete_records("workshop_grades", "assessmentid", $_GET['aid']); - // ...now delete the assessment... - delete_records("workshop_assessments", "id", $_GET['aid']); - - print_continue("view.php?id=$cm->id"); - } - - - /****************** view all assessments ***********************/ - elseif ($action == 'viewallassessments') { - - if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) { - error("View All Assessments: submission record not found"); - } - - if ($assessments = workshop_get_assessments($submission)) { - foreach ($assessments as $assessment) { - workshop_print_assessment($workshop, $assessment); - } - } - // only called from list all submissions - print_continue("submissions.php?action=listallsubmissions&id=$cm->id"); - } - - - /****************** view assessment *****************************/ - elseif ($action == 'viewassessment') { - - optional_variable($allowcomments); - if (!isset($allowcomments)) { - $allowcomments = false; - } - - // get the assessment record - if (!$assessment = get_record("workshop_assessments", "id", $_GET['aid'])) { - error("Assessment record not found"); - } - - // show assessment but don't allow changes - workshop_print_assessment($workshop, $assessment, false, $allowcomments); - - print_continue("view.php?a=$workshop->id"); - } - - - /*************** no man's land **************************************/ - else { - error("Fatal Error: Unknown Action: ".$action."\n"); - } - - print_footer($course); + } + + + /****************** user delete ************************************/ + elseif ($action == 'userdelete' ) { + + if (empty($_GET['aid'])) { + error("User delete: assessment id missing"); + } + + print_string("deleting", "workshop"); + // first delete all the associated records... + delete_records("workshop_comments", "assessmentid", $_GET['aid']); + delete_records("workshop_grades", "assessmentid", $_GET['aid']); + // ...now delete the assessment... + delete_records("workshop_assessments", "id", $_GET['aid']); + + print_continue("view.php?id=$cm->id"); + } + + + /****************** view all assessments ***********************/ + elseif ($action == 'viewallassessments') { + + if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) { + error("View All Assessments: submission record not found"); + } + + if ($assessments = workshop_get_assessments($submission)) { + foreach ($assessments as $assessment) { + workshop_print_assessment($workshop, $assessment); + } + } + // only called from list all submissions + print_continue("submissions.php?action=listallsubmissions&id=$cm->id"); + } + + + /****************** view assessment *****************************/ + elseif ($action == 'viewassessment') { + + optional_variable($allowcomments); + if (!isset($allowcomments)) { + $allowcomments = false; + } + + // get the assessment record + if (!$assessment = get_record("workshop_assessments", "id", $_GET['aid'])) { + error("Assessment record not found"); + } + + // show assessment but don't allow changes + workshop_print_assessment($workshop, $assessment, false, $allowcomments); + + print_continue("view.php?a=$workshop->id"); + } + + + /*************** no man's land **************************************/ + else { + error("Fatal Error: Unknown Action: ".$action."\n"); + } + + print_footer($course); ?> diff --git a/mod/workshop/submissions.php b/mod/workshop/submissions.php index 69e9d8d592..a1dead0718 100644 --- a/mod/workshop/submissions.php +++ b/mod/workshop/submissions.php @@ -1,22 +1,22 @@ shortname: $workshop->name", "$course->fullname", "$navigation id>$strworkshops -> id\">$workshop->name -> $strsubmissions", "", "", true); - //...get the action or set up an suitable default - optional_variable($action); - if (empty($action)) { - $action = "listallsubmissions"; - } - - - /******************* admin amend title ************************************/ - if ($action == 'adminamendtitle' ) { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - if (empty($_GET['sid'])) { - error("Admin Amend Title: submission id missing"); - } - - $submission = get_record("workshop_submissions", "id", $_GET['sid']); - print_heading(get_string("amendtitle", "workshop")); - ?> -

- - - -
- - \n"; - echo " \n"; - echo "

". get_string("title", "workshop").":

\n"; - echo " title\">\n"; - echo "
\n"; - echo "\n"; - echo "
\n"; - - } - - - /******************* admin confirm delete ************************************/ - elseif ($action == 'adminconfirmdelete' ) { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - if (empty($_GET['sid'])) { - error("Admin confirm delete: submission id missing"); - } - - notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("submission", "workshop")), - "submissions.php?action=admindelete&id=$cm->id&sid=$_GET[sid]", "submissions.php?id=$cm->id&action=adminlist"); - } - - - /******************* admin delete ************************************/ - elseif ($action == 'admindelete' ) { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - if (empty($_GET['sid'])) { - error("Admin delete: submission id missing"); - } - - if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) { - error("Admin delete: can not get submission record"); - } - print_string("deleting", "workshop"); - // first get any assessments... - if ($assessments = workshop_get_assessments($submission, 'ALL')) { - foreach($assessments as $assessment) { - // ...and all the associated records... - delete_records("workshop_comments", "assessmentid", $assessment->id); - delete_records("workshop_grades", "assessmentid", $assessment->id); - echo "."; - } - // ...now delete the assessments... - delete_records("workshop_assessments", "submissionid", $submission->id); - } - // ...and the submission record... - delete_records("workshop_submissions", "id", $submission->id); - // ..and finally the submitted file - workshop_delete_submitted_files($workshop, $submission); - - print_continue("submissions.php?id=$cm->id&action=adminlist"); - } - - - /******************* list all submissions ************************************/ - elseif ($action == 'adminlist' ) { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - if (empty($_GET['order'])) { - $order = "name"; - } - else { - $order = $_GET['order']; - } - - workshop_list_submissions_for_admin($workshop, $order); - print_continue("view.php?id=$cm->id"); - - } - - - /******************* admin update title ************************************/ - elseif ($action == 'adminupdatetitle' ) { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - if (empty($_POST['sid'])) { - error("Admin Update Title: submission id missing"); - } - - if (set_field("workshop_submissions", "title", $_POST['title'], "id", $_POST['sid'])) { - print_heading(get_string("amendtitle", "workshop")." ".get_string("ok")); - } - print_continue("submissions.php?id=$cm->id&action=adminlist"); - } - - - /*************** analysis of assessments (by teacher) ***************************/ - elseif ($action == 'analysisofassessments') { + //...get the action or set up an suitable default + optional_variable($action); + if (empty($action)) { + $action = "listallsubmissions"; + } + + + /******************* admin amend title ************************************/ + if ($action == 'adminamendtitle' ) { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_GET['sid'])) { + error("Admin Amend Title: submission id missing"); + } + + $submission = get_record("workshop_submissions", "id", $_GET['sid']); + print_heading(get_string("amendtitle", "workshop")); + ?> +
+ + + +
+ + \n"; + echo " \n"; + echo "

". get_string("title", "workshop").":

\n"; + echo " title\">\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + + } + + + /******************* admin confirm delete ************************************/ + elseif ($action == 'adminconfirmdelete' ) { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_GET['sid'])) { + error("Admin confirm delete: submission id missing"); + } + + notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("submission", "workshop")), + "submissions.php?action=admindelete&id=$cm->id&sid=$_GET[sid]", "submissions.php?id=$cm->id&action=adminlist"); + } + + + /******************* admin delete ************************************/ + elseif ($action == 'admindelete' ) { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_GET['sid'])) { + error("Admin delete: submission id missing"); + } + + if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) { + error("Admin delete: can not get submission record"); + } + print_string("deleting", "workshop"); + // first get any assessments... + if ($assessments = workshop_get_assessments($submission, 'ALL')) { + foreach($assessments as $assessment) { + // ...and all the associated records... + delete_records("workshop_comments", "assessmentid", $assessment->id); + delete_records("workshop_grades", "assessmentid", $assessment->id); + echo "."; + } + // ...now delete the assessments... + delete_records("workshop_assessments", "submissionid", $submission->id); + } + // ...and the submission record... + delete_records("workshop_submissions", "id", $submission->id); + // ..and finally the submitted file + workshop_delete_submitted_files($workshop, $submission); + + print_continue("submissions.php?id=$cm->id&action=adminlist"); + } + + + /******************* list all submissions ************************************/ + elseif ($action == 'adminlist' ) { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_GET['order'])) { + $order = "name"; + } + else { + $order = $_GET['order']; + } + + workshop_list_submissions_for_admin($workshop, $order); + print_continue("view.php?id=$cm->id"); + + } + + + /******************* admin update title ************************************/ + elseif ($action == 'adminupdatetitle' ) { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_POST['sid'])) { + error("Admin Update Title: submission id missing"); + } + + if (set_field("workshop_submissions", "title", $_POST['title'], "id", $_POST['sid'])) { + print_heading(get_string("amendtitle", "workshop")." ".get_string("ok")); + } + print_continue("submissions.php?id=$cm->id&action=adminlist"); + } + + + /*************** analysis of assessments (by teacher) ***************************/ + elseif ($action == 'analysisofassessments') { // timeout after 10 minutes @set_time_limit(600); - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } // this analysis does not use bias or reliability... set_field("workshop", "biasweight", 0, "id", $workshop->id); @@ -237,9 +237,9 @@ echo "\n"; echo "".get_string("percentageofassessments", "workshop").":\n"; echo ""; - for ($i = 0; $i <= 100; $i++) { - $numbers[$i] = $i; - } + for ($i = 0; $i <= 100; $i++) { + $numbers[$i] = $i; + } choose_from_menu($numbers, "assessmentstodrop", $assessmentstodrop, ""); echo "\n"; echo "
\n"; @@ -248,10 +248,10 @@ // set up the array of users who have made assessments - if (!$students = get_course_students($course->id, "u.lastname, u.firstname")) { - print_heading(get_string("nostudentsyet")); - print_footer($course); - exit; + if (!$students = get_course_students($course->id, "u.lastname, u.firstname")) { + print_heading(get_string("nostudentsyet")); + print_footer($course); + exit; } $teachers = get_course_teachers($course->id); $users = array_merge($students, $teachers); @@ -328,7 +328,7 @@ } } } - } + } reset($num); if (!$loop) { echo "

".get_string("numberofsubmissions", "workshop", count($num))."

\n"; @@ -459,8 +459,8 @@ } else { $vargood[$userid] = 0; } - // echo "$user->firstname $user->lastname Error: {$newassessors[$userid]}; n: $n
\n"; - } + // echo fullname($user)." Error: {$newassessors[$userid]}; n: $n
\n"; + } // echo "
\n"; @@ -520,17 +520,17 @@ // echo "

".get_string("expectederror", "workshop", $varguess)."

\n"; print_heading(get_string("errortable", "workshop")); - $table->head = array(" ",get_string("name"), get_string("averageerror", "workshop"), + $table->head = array(" ",get_string("name"), get_string("averageerror", "workshop"), get_string("averageerror", "workshop")."
". get_string("excludingdroppedassessments", "workshop"), get_string("numberofassessments", "workshop")); - $table->align = array ("left","left", "center", "center", "center"); - $table->size = array ("*", "*", "*", "*", "*"); - $table->cellpadding = 2; - $table->cellspacing = 0; + $table->align = array ("left","left", "center", "center", "center"); + $table->size = array ("*", "*", "*", "*", "*"); + $table->cellpadding = 2; + $table->cellspacing = 0; $n = 1; - foreach ($assessors as $userid => $error) { - if (!$user = get_record("user", "id", $userid)) { + foreach ($assessors as $userid => $error) { + if (!$user = get_record("user", "id", $userid)) { error("Assessment analysis: user record not found"); } if ($vargood[$userid]) { @@ -547,27 +547,27 @@ number_format($error * 100 / $varguess, 2)."%", $vargoodtext, $numtext); $n++; - } - print_table($table); + } + print_table($table); echo "

< > ".get_string("assessmentsexcluded", "workshop", $course->student)."

\n"; echo "

".get_string("submissionsused", "workshop", count($num))."

\n";; // display student grades print_heading(get_string("gradetable", "workshop")); unset($table); - $table->head = array(get_string("name"), get_string("submission", "workshop"), + $table->head = array(get_string("name"), get_string("submission", "workshop"), get_string("assessmentsdone", "workshop"), get_string("assessments", "workshop"), get_string("studentassessments", "workshop", $course->teacher), get_string("studentassessments", "workshop", $course->student), get_string("submission", "workshop"), get_string("overallgrade", "workshop")); - $table->align = array ("left", "center", "center", "center", "center", "center", "center", "center"); - $table->size = array ("*", "*", "*", "*", "*", "*", "*", "*"); - $table->cellpadding = 2; - $table->cellspacing = 0; + $table->align = array ("left", "center", "center", "center", "center", "center", "center", "center"); + $table->size = array ("*", "*", "*", "*", "*", "*", "*", "*"); + $table->cellpadding = 2; + $table->cellspacing = 0; $table->data[] = array("".get_string("weight", "workshop")."", " ", " ", "".$WORKSHOP_FWEIGHTS[$workshop->gradingweight]."", " ", " ","1", " "); $maxassessments = $workshop->nsassessments + $workshop->ntassessments; - foreach ($students as $user) { + foreach ($students as $user) { if ($assessments = workshop_get_user_assessments_done($workshop, $user)) { $n = 0; foreach ($assessments as $assessment) { @@ -602,7 +602,7 @@ } $finalgrade = ($assessmentgrade * $WORKSHOP_FWEIGHTS[$workshop->gradingweight] + $submissiongrade) / ($WORKSHOP_FWEIGHTS[$workshop->gradingweight] + 1.0); - if ($n) { + if ($n) { $table->data[] = array(fullname($user), workshop_print_submission_title($workshop, $submission), workshop_print_user_assessments($workshop, $user), @@ -612,7 +612,7 @@ number_format($submissiongrade, 2), number_format($finalgrade, 2)); } else { - $table->data[] = array(fullname($user), + $table->data[] = array(fullname($user), workshop_print_submission_title($workshop, $submission), workshop_print_user_assessments($workshop, $user), number_format($assessmentgrade, 2), @@ -635,838 +635,842 @@ // no submissions $finalgrade = ($assessmentgrade * $WORKSHOP_FWEIGHTS[$workshop->gradingweight]) / ($WORKSHOP_FWEIGHTS[$workshop->gradingweight] + 1.0); - $table->data[] = array(fullname($user), + $table->data[] = array(fullname($user), "-", workshop_print_user_assessments($workshop, $user), number_format($assessmentgrade, 2), "-", "-", get_string("nosubmission", "workshop"), number_format($finalgrade,2)); } - } - print_table($table); + } + print_table($table); echo "

< > ".get_string("assessmentdropped", "workshop")."

\n"; echo ""; - print_continue("view.php?a=$workshop->id"); + print_continue("view.php?a=$workshop->id"); } - /*************** calculate final grades (by teacher) ***************************/ - elseif ($action == 'calculatefinalgrades') { - - $form = (object)$_POST; - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - // Get all the students in surname order - if (!$users = get_course_students($course->id, "u.firstname, u.lastname")) { - print_heading(get_string("nostudentsyet")); - print_footer($course); - exit; - } - - // set up the weights from the calculate final grades form... - if (isset($form->teacherweight)) { - $teacherweight = $form->teacherweight; - // ...and save them - set_field("workshop", "teacherweight", $teacherweight, "id", "$workshop->id"); - } - - if (isset($form->peerweight)) { - $peerweight = $form->peerweight; - // ...and save them - set_field("workshop", "peerweight", $peerweight, "id", "$workshop->id"); - } - - // get the include teachers grade flag - if (isset($form->includeteachersgrade)) { - $includeteachersgrade = $form->includeteachersgrade; - set_field("workshop", "includeteachersgrade", $includeteachersgrade, "id", "$workshop->id"); - } - - if (isset($form->biasweight)) { - $biasweight = $form->biasweight; - // ...and save them - set_field("workshop", "biasweight", $biasweight, "id", "$workshop->id"); - } - - if (isset($form->reliabilityweight)) { - $reliabilityweight = $form->reliabilityweight; - // ...and save them - set_field("workshop", "reliabilityweight", $reliabilityweight, "id", "$workshop->id"); - } - - if (isset($form->gradingweight)) { - $gradingweight = $form->gradingweight; - // ...and save them - set_field("workshop", "gradingweight", $gradingweight, "id", "$workshop->id"); - } - - // save number of entries in showleaguetable option - if ($form->nentries == 'All') { - $form->nentries = 99; - } - set_field("workshop", "showleaguetable", $form->nentries, "id", "$workshop->id"); - - // save the anonymous option - set_field("workshop", "anonymous", $form->anonymous, "id", "$workshop->id"); - - // work out what to show in the final grades tables and what to include in the calculation of the final grade - // teacher grades? - if ($workshop->gradingstrategy and $teacherweight) { - $useteachersgrades = 1; - } - else { - $useteachersgrades = 0; - } - // peergrades? - if ($workshop->gradingstrategy and $workshop->nsassessments and $peerweight) { - $usepeergrades = 1; - } - else { - $usepeergrades = 0; - } - // bias grades? - if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and ($useteachersgrades or $usepeergrades) - and $biasweight ) { - $usebiasgrades = 1; - } - else { - $usebiasgrades = 0; - } - // reliability grades? - if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and ($useteachersgrades or $usepeergrades) - and $reliabilityweight ) { - $usereliabilitygrades = 1; - } - else { - $usereliabilitygrades = 0; - } - // grading grades? - if (($workshop->ntassessments or $workshop->nsassessments) and $gradingweight ) { - $usegradinggrades = 1; - } - else { - $usegradinggrades = 0; - } - - // start to calculate the grand means - $sumallteachergrades = 0.0; - $nallteachergrades = 0; - $sumallpeergrades = 0.0; - $nallpeergrades = 0; - // get the grades of each student's submission... - // the method used allowed a submission to be graded by more than one teacher - if (workshop_count_student_submissions($workshop)) { - echo "
".get_string("studentsubmissions", "workshop", $course->student); - echo "
\n"; - echo "\n"; - echo "\n"; - if ($useteachersgrades) { - echo "\n"; - echo "\n"; - } - if ($usepeergrades) { - echo "\n"; - echo "\n"; - } - if ($useteachersgrades or $usepeergrades) { - echo "\n"; - } - // display weights - echo "\n"; - echo "\n"; - if ($useteachersgrades) { - echo "\n"; - } - if ($usepeergrades) { - echo "\n"; - } - if ($useteachersgrades or $usepeergrades) { - echo "\n"; - } - echo "\n"; - // go through the submissions in "user" order, makes comparing the two tables easier - foreach ($users as $user) { - if ($submissions = workshop_get_user_submissions($workshop, $user)) { - foreach ($submissions as $submission) { - $sumteachergrades = 0.0; - $nteachergrades = 0; - $sumpeergrades = 0.0; - $npeergrades = 0; - // have a look at each assessment and add to arrays - if ($assessments = workshop_get_assessments($submission)) { - foreach ($assessments as $assessment) { - if (isteacher($workshop->course, $assessment->userid)) { - // it's a teacher's - $sumteachergrades += $assessment->grade; - $nteachergrades++; - if ($includeteachersgrade) { // add it to the student grades - $sumpeergrades += $assessment->grade; - $npeergrades++; - } - } - else { - // its' a student's - $sumpeergrades += $assessment->grade; - $npeergrades++; - } - } - } - if ($nteachergrades) { - $teachergrade = intval($sumteachergrades / $nteachergrades + 0.5); - $sumallteachergrades += $teachergrade; - $nallteachergrades++; - } - else { - $teachergrade = 0; - } - if ($npeergrades) { - $peergrade = intval($sumpeergrades / $npeergrades + 0.5); - $sumallpeergrades += $peergrade; - $nallpeergrades++; - } - else { - $peergrade = 0; - } - if ($teacherweight + $peerweight > 0) { - $grade = intval((($useteachersgrades * $teachergrade * $WORKSHOP_FWEIGHTS[$teacherweight] + - $usepeergrades * $peergrade * $WORKSHOP_FWEIGHTS[$peerweight]) / - ($useteachersgrades * $WORKSHOP_FWEIGHTS[$teacherweight] + - $usepeergrades * $WORKSHOP_FWEIGHTS[$peerweight])) + 0.5); - } - else { - $grade = 0; - } - // display the grades... - echo "\n"; - echo "\n"; - if ($useteachersgrades) { - echo "\n"; - echo "\n"; - } - if ($usepeergrades) { - echo "\n"; - echo "\n"; - } - if ($useteachersgrades or $usepeergrades) { - echo "\n"; - } - // ...and save in the database - set_field("workshop_submissions", "teachergrade", $teachergrade, "id", $submission->id); - set_field("workshop_submissions", "peergrade", $peergrade, "id", $submission->id); - } - } - } - echo "
cellheading2\">$course->studentcellheading2\">".get_string("submissions","workshop")."cellheading2\">".get_string("assessmentsby", "workshop", $course->teachers)."cellheading2\">".get_string("numberofassessments", "workshop")."cellheading2\">".get_string("assessmentsby", "workshop", $course->students)."cellheading2\">".get_string("numberofassessments", "workshop")."cellheading2\">".get_string("gradeofsubmission", "workshop")."
cellheading2\">".get_string("weights","workshop")."cellheading2\"> cellheading2\">
$WORKSHOP_FWEIGHTS[$teacherweight]
cellheading2\">
$WORKSHOP_FWEIGHTS[$peerweight]
cellheading2\"> 
".fullname($user)."".workshop_print_submission_title($workshop, $submission)."$teachergrade[$nteachergrades]$peergrade[$npeergrades]$grade
\n"; - } - // now display the overall teacher and peer means - if ($nallteachergrades) { - $grandteachergrade = $sumallteachergrades / $nallteachergrades; - } - else { - $grandteachergrade = 0; - } - if ($nallpeergrades) { - $grandpeergrade = $sumallpeergrades / $nallpeergrades; - } - else { - $grandpeergrade = 0; - } - if ($useteachersgrades) { - echo "

".get_string("overallteachergrade", "workshop", number_format($grandteachergrade, 2))." [$nallteachergrades]\n"; - } - if ($usepeergrades) { - echo "

".get_string("overallpeergrade", "workshop", number_format($grandpeergrade, 2))." [$nallpeergrades]
\n"; - } - // run thru each users and see how their assessments faired, we may junk the grading stats but what the heck! - foreach ($users as $user) { - // we need to calculate a user bias before we can calculate their reliability - $sumbias = 0.0; - // nbias is used later to show how many peer assessments the user has done - $nbias[$user->id] = 0; - if ($workshop->nsassessments) { // peer assessments? - // run thru this user's assessments on the STUDENT submissions - if ($assessments = workshop_get_student_assessments($workshop, $user)) { - foreach ($assessments as $assessment) { - $submission = get_record("workshop_submissions", "id", $assessment->submissionid); - // calculate the sum of "validity" values, the bias in a user's grading... - $sumbias += $submission->peergrade - $assessment->grade; - $nbias[$user->id]++; - } - } - } - if ($nbias[$user->id] > 1) { - // we could divide by n-1 to remove own score from calculation of mean but we don't because we re-use bias - // values in the calculation of reliability, and it's all relative anyway - $bias[$user->id] = $sumbias / $nbias[$user->id]; - } - else { - $bias[$user->id] = 0.0; - } - // now look at all the user's assessments of both the TEACHER's submissions and the STUDENT submissions - // to calculate their overall grading grade - $sumgradinggrade = 0.0; - $ngradinggrades = 0; - if ($workshop->ntassessments or $workshop->nsassessments) { // worth looking? - if ($assessments = workshop_get_user_assessments($workshop, $user)) { - foreach ($assessments as $assessment) { - if ($assessment->timegraded > 0) { - $sumgradinggrade += $assessment->gradinggrade; - $ngradinggrades++; - } - } - } - } - if ($ngradinggrades) { - $gradinggrade[$user->id] = $sumgradinggrade / $ngradinggrades; - } - else { - $gradinggrade[$user->id] = 0.0; - } - } - - // calculate the mean value of "reliability", the accuracy of a user's grading (disregarding bias) - // use a linear function rather than a squared function for reliability - // at the same time calculate a reliability of a "dumb user" whose grades everything at the grand mean value - $sumdumbreliability = 0.0; - $ndumbreliability =0; - foreach ($users as $user) { - $sumreliability = 0.0; - $nreliability = 0; - if ($workshop->nsassessments) { // worth a look? - // look only at the user's assessment of STUDENT submissions - if ($assessments = workshop_get_student_assessments($workshop, $user)) { - foreach ($assessments as $assessment) { - $submission = get_record("workshop_submissions", "id", $assessment->submissionid); - $sumreliability += abs($submission->peergrade - $assessment->grade - $bias[$user->id]); - $nreliability++; - $sumdumbreliability += abs($submission->peergrade - $grandpeergrade); - $ndumbreliability++; - } - } - } - // calculate the mean reliability values - if ($nreliability) { - $reliability[$user->id] = $sumreliability / $nreliability; - } - else { - $reliability[$user->id] = 999999; // big number - } - } - if ($ndumbreliability) { - $dumbreliability = $sumdumbreliability / $ndumbreliability; - } - else { - $dumbreliability = 999999; // big number - } - - // convert bias and reliability values into scales where 1 is prefect, 0 is no grading done... - // ...but first find the largest (absolute) value of the bias measures - if (max($bias) > abs(min($bias))) { - $maxbias = max($bias); - } - else { - $maxbias = abs(min($bias)); - } - - echo "

".get_string("studentgrades", "workshop", $course->student)."
\n"; - echo "
- \n"; - if ($useteachersgrades) { - echo "\n"; - } - if ($usepeergrades) { - echo "\n"; - } - if ($usebiasgrades) { - echo "\n"; - } - if ($usereliabilitygrades) { - echo "\n"; - } - if ($usegradinggrades) { - echo "\n"; - } - echo "\n"; - // now display the weights - echo "\n"; - if ($useteachersgrades) { - echo "\n"; - } - if ($usepeergrades) { - echo "\n"; - } - if ($usebiasgrades) { - echo "\n"; - } - if ($usereliabilitygrades) { - echo "\n"; - } - if ($usegradinggrades) { - echo "\n"; - } - echo "\n"; - foreach ($users as $user) { - // get user's best submission - $bestgrade = -1; - $teachergrade = 0; - $peergrade = 0; - if ($submissions = workshop_get_user_submissions($workshop, $user)) { - foreach ($submissions as $submission) { - $grade = ($submission->teachergrade * $WORKSHOP_FWEIGHTS[$teacherweight] + - $submission->peergrade * $WORKSHOP_FWEIGHTS[$peerweight]) / - ($WORKSHOP_FWEIGHTS[$teacherweight] + $WORKSHOP_FWEIGHTS[$peerweight]); - if ($grade > $bestgrade) { - $bestgrade = $grade; - $teachergrade = $submission->teachergrade; - $peergrade = $submission->peergrade; - $bestsubmission = $submission; - } - } - } - else { // funny this user did not submit - create a dummy submission to hold any grades they might have - unset($bestsubmission); + /*************** calculate final grades (by teacher) ***************************/ + elseif ($action == 'calculatefinalgrades') { + + $form = (object)$_POST; + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + // Get all the students in surname order + if (!$users = get_course_students($course->id, "u.firstname, u.lastname")) { + print_heading(get_string("nostudentsyet")); + print_footer($course); + exit; + } + + // set up the weights from the calculate final grades form... + if (isset($form->teacherweight)) { + $teacherweight = $form->teacherweight; + // ...and save them + set_field("workshop", "teacherweight", $teacherweight, "id", "$workshop->id"); + } + + if (isset($form->peerweight)) { + $peerweight = $form->peerweight; + // ...and save them + set_field("workshop", "peerweight", $peerweight, "id", "$workshop->id"); + } + + // get the include teachers grade flag + if (isset($form->includeteachersgrade)) { + $includeteachersgrade = $form->includeteachersgrade; + set_field("workshop", "includeteachersgrade", $includeteachersgrade, "id", "$workshop->id"); + } + + if (isset($form->biasweight)) { + $biasweight = $form->biasweight; + // ...and save them + set_field("workshop", "biasweight", $biasweight, "id", "$workshop->id"); + } + + if (isset($form->reliabilityweight)) { + $reliabilityweight = $form->reliabilityweight; + // ...and save them + set_field("workshop", "reliabilityweight", $reliabilityweight, "id", "$workshop->id"); + } + + if (isset($form->gradingweight)) { + $gradingweight = $form->gradingweight; + // ...and save them + set_field("workshop", "gradingweight", $gradingweight, "id", "$workshop->id"); + } + + // save number of entries in showleaguetable option + if ($form->nentries == 'All') { + $form->nentries = 99; + } + set_field("workshop", "showleaguetable", $form->nentries, "id", "$workshop->id"); + + // save the anonymous option + set_field("workshop", "anonymous", $form->anonymous, "id", "$workshop->id"); + + // work out what to show in the final grades tables and what to include in the calculation of the final grade + // teacher grades? + if ($workshop->gradingstrategy and $teacherweight) { + $useteachersgrades = 1; + } + else { + $useteachersgrades = 0; + } + // peergrades? + if ($workshop->gradingstrategy and $workshop->nsassessments and $peerweight) { + $usepeergrades = 1; + } + else { + $usepeergrades = 0; + } + // bias grades? + if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and ($useteachersgrades or $usepeergrades) + and $biasweight ) { + $usebiasgrades = 1; + } + else { + $usebiasgrades = 0; + } + // reliability grades? + if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and ($useteachersgrades or $usepeergrades) + and $reliabilityweight ) { + $usereliabilitygrades = 1; + } + else { + $usereliabilitygrades = 0; + } + // grading grades? + if (($workshop->ntassessments or $workshop->nsassessments) and $gradingweight ) { + $usegradinggrades = 1; + } + else { + $usegradinggrades = 0; + } + + // start to calculate the grand means + $sumallteachergrades = 0.0; + $nallteachergrades = 0; + $sumallpeergrades = 0.0; + $nallpeergrades = 0; + // get the grades of each student's submission... + // the method used allowed a submission to be graded by more than one teacher + if (workshop_count_student_submissions($workshop)) { + echo "
".get_string("studentsubmissions", "workshop", $course->student); + echo "
cellheading2\">$course->studentcellheading2\">".get_string("assessmentsby", "workshop", $course->teachers)."cellheading2\">".get_string("assessmentsby", "workshop", $course->students)."cellheading2\">".get_string("gradeforbias", "workshop")."cellheading2\">".get_string("gradeforreliability", "workshop")."cellheading2\">".get_string("gradeforassessments", "workshop")."cellheading2\">".get_string("overallgrade", "workshop")."
cellheading2\">".get_string("weights","workshop")."cellheading2\">$WORKSHOP_FWEIGHTS[$teacherweight]cellheading2\">$WORKSHOP_FWEIGHTS[$peerweight]cellheading2\">$WORKSHOP_FWEIGHTS[$biasweight]cellheading2\">$WORKSHOP_FWEIGHTS[$reliabilityweight]cellheading2\">$WORKSHOP_FWEIGHTS[$gradingweight]cellheading2\"> 
\n"; + echo "\n"; + echo "\n"; + if ($useteachersgrades) { + echo "\n"; + echo "\n"; + } + if ($usepeergrades) { + echo "\n"; + echo "\n"; + } + if ($useteachersgrades or $usepeergrades) { + echo "\n"; + } + // display weights + echo "\n"; + echo "\n"; + if ($useteachersgrades) { + echo "\n"; + } + if ($usepeergrades) { + echo "\n"; + } + if ($useteachersgrades or $usepeergrades) { + echo "\n"; + } + echo "\n"; + // go through the submissions in "user" order, makes comparing the two tables easier + foreach ($users as $user) { + if ($submissions = workshop_get_user_submissions($workshop, $user)) { + foreach ($submissions as $submission) { + $sumteachergrades = 0.0; + $nteachergrades = 0; + $sumpeergrades = 0.0; + $npeergrades = 0; + // have a look at each assessment and add to arrays + if ($assessments = workshop_get_assessments($submission)) { + foreach ($assessments as $assessment) { + if (isteacher($workshop->course, $assessment->userid)) { + // it's a teacher's + $sumteachergrades += $assessment->grade; + $nteachergrades++; + if ($includeteachersgrade) { // add it to the student grades + $sumpeergrades += $assessment->grade; + $npeergrades++; + } + } + else { + // its' a student's + $sumpeergrades += $assessment->grade; + $npeergrades++; + } + } + } + if ($nteachergrades) { + $teachergrade = intval($sumteachergrades / $nteachergrades + 0.5); + $sumallteachergrades += $teachergrade; + $nallteachergrades++; + } + else { + $teachergrade = 0; + } + if ($npeergrades) { + $peergrade = intval($sumpeergrades / $npeergrades + 0.5); + $sumallpeergrades += $peergrade; + $nallpeergrades++; + } + else { + $peergrade = 0; + } + if ($teacherweight + $peerweight > 0) { + $grade = intval((($useteachersgrades * $teachergrade * $WORKSHOP_FWEIGHTS[$teacherweight] + + $usepeergrades * $peergrade * $WORKSHOP_FWEIGHTS[$peerweight]) / + ($useteachersgrades * $WORKSHOP_FWEIGHTS[$teacherweight] + + $usepeergrades * $WORKSHOP_FWEIGHTS[$peerweight])) + 0.5); + } + else { + $grade = 0; + } + // display the grades... + echo "\n"; + echo "\n"; + if ($useteachersgrades) { + echo "\n"; + echo "\n"; + } + if ($usepeergrades) { + echo "\n"; + echo "\n"; + } + if ($useteachersgrades or $usepeergrades) { + echo "\n"; + } + // ...and save in the database + set_field("workshop_submissions", "teachergrade", $teachergrade, "id", $submission->id); + set_field("workshop_submissions", "peergrade", $peergrade, "id", $submission->id); + } + } + } + echo "
cellheading2\">$course->studentcellheading2\">".get_string("submissions","workshop")."cellheading2\">".get_string("assessmentsby", "workshop", $course->teachers)."cellheading2\">".get_string("numberofassessments", "workshop")."cellheading2\">".get_string("assessmentsby", "workshop", $course->students)."cellheading2\">".get_string("numberofassessments", "workshop")."cellheading2\">".get_string("gradeofsubmission", "workshop")."
cellheading2\">".get_string("weights","workshop")."cellheading2\"> cellheading2\">
$WORKSHOP_FWEIGHTS[$teacherweight]
cellheading2\">
$WORKSHOP_FWEIGHTS[$peerweight]
cellheading2\"> 
".fullname($user)."".workshop_print_submission_title($workshop, $submission)."$teachergrade[$nteachergrades]$peergrade[$npeergrades]$grade
\n"; + } + // now display the overall teacher and peer means + if ($nallteachergrades) { + $grandteachergrade = $sumallteachergrades / $nallteachergrades; + } + else { + $grandteachergrade = 0; + } + if ($nallpeergrades) { + $grandpeergrade = $sumallpeergrades / $nallpeergrades; + } + else { + $grandpeergrade = 0; + } + if ($useteachersgrades) { + echo "

".get_string("overallteachergrade", "workshop", number_format($grandteachergrade, 2))." [$nallteachergrades]\n"; + } + if ($usepeergrades) { + echo "

".get_string("overallpeergrade", "workshop", number_format($grandpeergrade, 2))." [$nallpeergrades]
\n"; + } + // run thru each users and see how their assessments faired, we may junk the grading stats but what the heck! + foreach ($users as $user) { + // we need to calculate a user bias before we can calculate their reliability + $sumbias = 0.0; + // nbias is used later to show how many peer assessments the user has done + $nbias[$user->id] = 0; + if ($workshop->nsassessments) { // peer assessments? + // run thru this user's assessments on the STUDENT submissions + if ($assessments = workshop_get_student_assessments($workshop, $user)) { + foreach ($assessments as $assessment) { + $submission = get_record("workshop_submissions", "id", $assessment->submissionid); + // calculate the sum of "validity" values, the bias in a user's grading... + $sumbias += $submission->peergrade - $assessment->grade; + $nbias[$user->id]++; + } + } + } + if ($nbias[$user->id] > 1) { + // we could divide by n-1 to remove own score from calculation of mean but we don't because we re-use bias + // values in the calculation of reliability, and it's all relative anyway + $bias[$user->id] = $sumbias / $nbias[$user->id]; + } + else { + $bias[$user->id] = 0.0; + } + // now look at all the user's assessments of both the TEACHER's submissions and the STUDENT submissions + // to calculate their overall grading grade + $sumgradinggrade = 0.0; + $ngradinggrades = 0; + if ($workshop->ntassessments or $workshop->nsassessments) { // worth looking? + if ($assessments = workshop_get_user_assessments($workshop, $user)) { + foreach ($assessments as $assessment) { + if ($assessment->timegraded > 0) { + $sumgradinggrade += $assessment->gradinggrade; + $ngradinggrades++; + } + } + } + } + if ($ngradinggrades) { + $gradinggrade[$user->id] = $sumgradinggrade / $ngradinggrades; + } + else { + $gradinggrade[$user->id] = 0.0; + } + } + + // calculate the mean value of "reliability", the accuracy of a user's grading (disregarding bias) + // use a linear function rather than a squared function for reliability + // at the same time calculate a reliability of a "dumb user" whose grades everything at the grand mean value + $sumdumbreliability = 0.0; + $ndumbreliability =0; + foreach ($users as $user) { + $sumreliability = 0.0; + $nreliability = 0; + if ($workshop->nsassessments) { // worth a look? + // look only at the user's assessment of STUDENT submissions + if ($assessments = workshop_get_student_assessments($workshop, $user)) { + foreach ($assessments as $assessment) { + $submission = get_record("workshop_submissions", "id", $assessment->submissionid); + $sumreliability += abs($submission->peergrade - $assessment->grade - $bias[$user->id]); + $nreliability++; + $sumdumbreliability += abs($submission->peergrade - $grandpeergrade); + $ndumbreliability++; + } + } + } + // calculate the mean reliability values + if ($nreliability) { + $reliability[$user->id] = $sumreliability / $nreliability; + } + else { + $reliability[$user->id] = 999999; // big number + } + } + if ($ndumbreliability) { + $dumbreliability = $sumdumbreliability / $ndumbreliability; + } + else { + $dumbreliability = 999999; // big number + } + + // convert bias and reliability values into scales where 1 is prefect, 0 is no grading done... + // ...but first find the largest (absolute) value of the bias measures + if (max($bias) > abs(min($bias))) { + $maxbias = max($bias); + } + else { + $maxbias = abs(min($bias)); + } + + echo "

".get_string("studentgrades", "workshop", $course->student)."
\n"; + echo "
+ \n"; + if ($useteachersgrades) { + echo "\n"; + } + if ($usepeergrades) { + echo "\n"; + } + if ($usebiasgrades) { + echo "\n"; + } + if ($usereliabilitygrades) { + echo "\n"; + } + if ($usegradinggrades) { + echo "\n"; + } + echo "\n"; + // now display the weights + echo "\n"; + if ($useteachersgrades) { + echo "\n"; + } + if ($usepeergrades) { + echo "\n"; + } + if ($usebiasgrades) { + echo "\n"; + } + if ($usereliabilitygrades) { + echo "\n"; + } + if ($usegradinggrades) { + echo "\n"; + } + echo "\n"; + foreach ($users as $user) { + // get user's best submission + $bestgrade = -1; + $teachergrade = 0; + $peergrade = 0; + if ($submissions = workshop_get_user_submissions($workshop, $user)) { + foreach ($submissions as $submission) { + $grade = ($submission->teachergrade * $WORKSHOP_FWEIGHTS[$teacherweight] + + $submission->peergrade * $WORKSHOP_FWEIGHTS[$peerweight]) / + ($WORKSHOP_FWEIGHTS[$teacherweight] + $WORKSHOP_FWEIGHTS[$peerweight]); + if ($grade > $bestgrade) { + $bestgrade = $grade; + $teachergrade = $submission->teachergrade; + $peergrade = $submission->peergrade; + $bestsubmission = $submission; + } + } + } + else { // funny this user did not submit - create a dummy submission to hold any grades they might have + unset($bestsubmission); $bestsubmission->workshopid = $workshop->id; - $bestsubmission->userid = $user->id; - $bestsubmission->title = "No Submission"; - $bestsubmission->timecreated = 0; - if (!$bestsubmission->id = insert_record("workshop_submissions", $bestsubmission)) { - error("Unable to create dummy submission record"); - } - } - // biasgrade is scaled between zero and one NEED TO ADD TEST FOR NO PEER ASSESSMENTS OF SUBMITTED WORK - if ($maxbias) { - $biasgrade = max(($nbias[$user->id] / $workshop->nsassessments) - (abs($bias[$user->id]) / $maxbias), - 0.0); - } - else { - $biasgrade = 0; - } - // reliabilitygrade is scaled between zero and one - - if ($dumbreliability and $workshop->nsassessments) { - // nbias used here as it contains the number of assessments the user has done - $reliabilitygrade = max(($nbias[$user->id] / $workshop->nsassessments) - - ($reliability[$user->id] / $dumbreliability), 0.0); - } - else { - $reliabilitygrade = 0; - } - $biasscaled = intval($biasgrade * $workshop->grade + 0.5); - $reliabilityscaled = intval($reliabilitygrade * $workshop->grade + 0.5); - $gradingscaled = intval($gradinggrade[$user->id] * $workshop->grade / COMMENTSCALE + 0.5); - $finalgrade = intval((($teachergrade * $WORKSHOP_FWEIGHTS[$teacherweight] * $useteachersgrades) + - ($peergrade * $WORKSHOP_FWEIGHTS[$peerweight] * $usepeergrades) + - ($biasscaled * $WORKSHOP_FWEIGHTS[$biasweight] * $usebiasgrades) + - ($reliabilityscaled * $WORKSHOP_FWEIGHTS[$reliabilityweight] * $usereliabilitygrades) + - ($gradingscaled * $WORKSHOP_FWEIGHTS[$gradingweight] * $usegradinggrades) + 0.5) / - (($WORKSHOP_FWEIGHTS[$teacherweight] * $useteachersgrades) + - ($WORKSHOP_FWEIGHTS[$peerweight] * $usepeergrades) + - ($WORKSHOP_FWEIGHTS[$biasweight] * $usebiasgrades) + - ($WORKSHOP_FWEIGHTS[$reliabilityweight] * $usereliabilitygrades) + - ($WORKSHOP_FWEIGHTS[$gradingweight] * $usegradinggrades))); - echo ""; - if ($useteachersgrades) { - echo ""; - } - if ($usepeergrades) { - echo ""; - } - if ($usebiasgrades) { - echo ""; - } - if ($usereliabilitygrades) { - echo ""; - } - if ($usegradinggrades) { - echo ""; - } - echo "\n"; - - // save the grades - set_field("workshop_submissions", "biasgrade", $biasscaled, "id", $bestsubmission->id); - set_field("workshop_submissions", "reliabilitygrade", $reliabilityscaled, "id", $bestsubmission->id); - set_field("workshop_submissions", "gradinggrade", $gradingscaled, "id", $bestsubmission->id); - set_field("workshop_submissions", "finalgrade", $finalgrade, "id", $bestsubmission->id); - } - echo "
cellheading2\">$course->studentcellheading2\">".get_string("assessmentsby", "workshop", $course->teachers)."cellheading2\">".get_string("assessmentsby", "workshop", $course->students)."cellheading2\">".get_string("gradeforbias", "workshop")."cellheading2\">".get_string("gradeforreliability", "workshop")."cellheading2\">".get_string("gradeforassessments", "workshop")."cellheading2\">".get_string("overallgrade", "workshop")."
cellheading2\">".get_string("weights","workshop")."cellheading2\">$WORKSHOP_FWEIGHTS[$teacherweight]cellheading2\">$WORKSHOP_FWEIGHTS[$peerweight]cellheading2\">$WORKSHOP_FWEIGHTS[$biasweight]cellheading2\">$WORKSHOP_FWEIGHTS[$reliabilityweight]cellheading2\">$WORKSHOP_FWEIGHTS[$gradingweight]cellheading2\"> 
".fullname($user)."$teachergrade$peergrade$biasscaled$reliabilityscaled$gradingscaled$finalgrade

\n"; - print_string("allgradeshaveamaximumof", "workshop", $workshop->grade); - echo "

\n"; - - print_continue("view.php?a=$workshop->id"); - } - - - /*************** display final grades (by teacher) ***************************/ - elseif ($action == 'displayfinalgrades') { - // Get all the students - if (!$users = get_course_students($course->id, "u.lastname, u.firstname")) { - print_heading(get_string("nostudentsyet")); - print_footer($course); - exit; - } - - // get the final weights from the database - $teacherweight = get_field("workshop","teacherweight", "id", $workshop->id); - $peerweight = get_field("workshop","peerweight", "id", $workshop->id); - $includeteachersgrade = get_field("workshop","includeteachersgrade", "id", $workshop->id); - $biasweight = get_field("workshop","biasweight", "id", $workshop->id); - $reliabilityweight = get_field("workshop","reliabilityweight", "id", $workshop->id); - $gradingweight = get_field("workshop","gradingweight", "id", $workshop->id); - // work out what to show in the final grades tables and what to include in the calculation of the final grade - // teacher grades? - if ($workshop->gradingstrategy and $teacherweight) { - $useteachersgrades = 1; - } - else { - $useteachersgrades = 0; - } - // peergrades? - if ($workshop->gradingstrategy and $workshop->nsassessments and $peerweight) { - $usepeergrades = 1; - } - else { - $usepeergrades = 0; - } - // bias grades? - if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and ($useteachersgrades or $usepeergrades) - and $biasweight ) { - $usebiasgrades = 1; - } - else { - $usebiasgrades = 0; - } - // reliability grades? - if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and ($useteachersgrades or $usepeergrades) - and $reliabilityweight ) { - $usereliabilitygrades = 1; - } - else { - $usereliabilitygrades = 0; - } - // grading grades? - if (($workshop->ntassessments or $workshop->nsassessments) and $gradingweight ) { - $usegradinggrades = 1; - } - else { - $usegradinggrades = 0; - } - - // show the final grades as stored in the tables... - print_heading_with_help(get_string("displayoffinalgrades", "workshop"), "finalgrades", "workshop"); - echo "
- "; - echo ""; - if ($useteachersgrades) { - echo ""; - } - if ($usepeergrades) { - echo ""; - } - echo ""; - if ($usebiasgrades) { - echo ""; - } - if ($usereliabilitygrades) { - echo ""; - } - if ($usegradinggrades) { - echo ""; - } - echo "\n"; - // now the weights - echo ""; - echo "\n"; - if ($useteachersgrades) { - echo "\n"; - } - if ($usepeergrades) { - echo "\n"; - } - echo "\n"; - if ($usebiasgrades) { - echo "\n"; - } - if ($usereliabilitygrades) { - echo "\n"; - } - if ($usegradinggrades) { - echo "\n"; - } - echo "\n"; - foreach ($users as $user) { - if ($submissions = workshop_get_user_submissions($workshop, $user)) { - foreach ($submissions as $submission) { - echo ""; - echo "\n"; - if ($useteachersgrades) { - echo ""; - } - if ($usepeergrades) { - echo ""; - } - echo ""; - if ($usebiasgrades) { - echo ""; - } - if ($usereliabilitygrades) { - echo ""; - } - if ($usegradinggrades) { - echo ""; - } - echo "\n"; - } - } - } - echo "
cellheading2\">".$course->student."cellheading2\">".get_string("submission", "workshop")."cellheading2\" align=\"center\">".get_string("assessmentsby", "workshop", $course->teachers)."cellheading2\" align=\"center\">".get_string("assessmentsby", "workshop", $course->students)."cellheading2\" align=\"center\">".get_string("assessmentsdone", "workshop")."cellheading2\" align=\"center\">".get_string("gradeforbias", "workshop")."cellheading2\" align=\"center\">".get_string("gradeforreliability", "workshop")."cellheading2\" align=\"center\">".get_string("gradeforassessments", "workshop")."cellheading2\" align=\"center\">".get_string("overallgrade", "workshop")."
cellheading2\">".get_string("weights", "workshop")."cellheading2\" align=\"center\"> cellheading2\" align=\"center\">$WORKSHOP_FWEIGHTS[$teacherweight]cellheading2\" align=\"center\">$WORKSHOP_FWEIGHTS[$peerweight]cellheading2\" align=\"center\"> cellheading2\" align=\"center\">$WORKSHOP_FWEIGHTS[$biasweight]cellheading2\" align=\"center\">$WORKSHOP_FWEIGHTS[$reliabilityweight]cellheading2\" align=\"center\">$WORKSHOP_FWEIGHTS[$gradingweight]cellheading2\"> 
".fullname($user)".".workshop_print_submission_title($workshop, $submission)."".workshop_print_submission_assessments($workshop, $submission, "teacher")."".workshop_print_submission_assessments($workshop, $submission, "student")."".workshop_print_user_assessments($workshop, $user)."$submission->biasgrade$submission->reliabilitygrade$submission->gradinggrade$submission->finalgrade

\n"; - if ($workshop->showleaguetable) { - workshop_print_league_table($workshop); - if ($workshop->anonymous) { - echo "

".get_string("namesnotshowntostudents", "workshop", $course->students)."

\n"; - } - } - echo "

".get_string("allgradeshaveamaximumof", "workshop", $workshop->grade)."

\n"; - print_continue("view.php?a=$workshop->id"); - } - - - /*************** display final weights (by teacher) ***************************/ - elseif ($action == 'displayfinalweights') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - if ($workshop->phase != 5) { // is this at the expected phase? - print_heading(get_string("assignmentnotinthecorrectphase", "workshop")); - print_continue("view.php?a=$workshop->id"); - } - else { - - ?> -
- - -
- id); - $peerweight = get_field("workshop","peerweight", "id", $workshop->id); - $includeteachersgrade = get_field("workshop","includeteachersgrade", "id", $workshop->id); - $biasweight = get_field("workshop","biasweight", "id", $workshop->id); - $reliabilityweight = get_field("workshop","reliabilityweight", "id", $workshop->id); - $gradingweight = get_field("workshop","gradingweight", "id", $workshop->id); - - // now show the weights used in the final grades - print_heading_with_help(get_string("calculationoffinalgrades", "workshop"), "calculatingfinalgrade", "workshop"); - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
cellheading2\">
". - get_string("weightsusedforfinalgrade", "workshop")."
".get_string("weightforteacherassessments", "workshop", $course->teacher).":"; - workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "teacherweight", $teacherweight, ""); - echo "
".get_string("weightforpeerassessments", "workshop").":"; - workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "peerweight", $peerweight, ""); - echo "
".get_string("weightforbias", "workshop").":"; - workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "biasweight", $biasweight, ""); - echo "
".get_string("weightforreliability", "workshop").":"; - workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "reliabilityweight", $reliabilityweight, ""); - echo "
".get_string("weightforgradingofassessments", "workshop").":"; - workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "gradingweight", $gradingweight, ""); - echo "
cellheading2\">
". - get_string("optionforpeergrade", "workshop")."
".get_string("includeteachersgrade", "workshop").":"; - $options[0] = get_string("no"); $options[1] = get_string("yes"); - choose_from_menu($options, "includeteachersgrade", $includeteachersgrade, ""); - helpbutton("includeteachersgrade", get_string("includeteachersgrade", "workshop"), "workshop"); - echo "
\n"; - - print_heading_with_help(get_string("leaguetable", "workshop"), "leaguetable", "workshop"); - echo "\n"; - echo "\n"; - echo "\n"; - echo ""; + if ($useteachersgrades) { + echo ""; + } + if ($usepeergrades) { + echo ""; + } + if ($usebiasgrades) { + echo ""; + } + if ($usereliabilitygrades) { + echo ""; + } + if ($usegradinggrades) { + echo ""; + } + echo "\n"; + + // save the grades + set_field("workshop_submissions", "biasgrade", $biasscaled, "id", $bestsubmission->id); + set_field("workshop_submissions", "reliabilitygrade", $reliabilityscaled, "id", $bestsubmission->id); + set_field("workshop_submissions", "gradinggrade", $gradingscaled, "id", $bestsubmission->id); + set_field("workshop_submissions", "finalgrade", $finalgrade, "id", $bestsubmission->id); + } + echo "
".get_string("numberofentries", "workshop").":"; - $numbers[22] = 'All'; - $numbers[21] = 50; - for ($i=20; $i>=0; $i--) { - $numbers[$i] = $i; - } - $nentries = $workshop->showleaguetable; - if ($nentries == 99) { - $nentries = 'All'; - } - choose_from_menu($numbers, "nentries", "$nentries", ""); - echo "

".get_string("hidenamesfromstudents", "workshop", $course->students)."

\n"; + $bestsubmission->userid = $user->id; + $bestsubmission->title = "No Submission"; + $bestsubmission->timecreated = 0; + if (!$bestsubmission->id = insert_record("workshop_submissions", $bestsubmission)) { + error("Unable to create dummy submission record"); + } + } + // biasgrade is scaled between zero and one NEED TO ADD TEST FOR NO PEER ASSESSMENTS OF SUBMITTED WORK + if ($maxbias) { + $biasgrade = max(($nbias[$user->id] / $workshop->nsassessments) - (abs($bias[$user->id]) / $maxbias), + 0.0); + } + else { + $biasgrade = 0; + } + // reliabilitygrade is scaled between zero and one + + if ($dumbreliability and $workshop->nsassessments) { + // nbias used here as it contains the number of assessments the user has done + $reliabilitygrade = max(($nbias[$user->id] / $workshop->nsassessments) - + ($reliability[$user->id] / $dumbreliability), 0.0); + } + else { + $reliabilitygrade = 0; + } + $biasscaled = intval($biasgrade * $workshop->grade + 0.5); + $reliabilityscaled = intval($reliabilitygrade * $workshop->grade + 0.5); + $gradingscaled = intval($gradinggrade[$user->id] * $workshop->grade / COMMENTSCALE + 0.5); + $finalgrade = intval((($teachergrade * $WORKSHOP_FWEIGHTS[$teacherweight] * $useteachersgrades) + + ($peergrade * $WORKSHOP_FWEIGHTS[$peerweight] * $usepeergrades) + + ($biasscaled * $WORKSHOP_FWEIGHTS[$biasweight] * $usebiasgrades) + + ($reliabilityscaled * $WORKSHOP_FWEIGHTS[$reliabilityweight] * $usereliabilitygrades) + + ($gradingscaled * $WORKSHOP_FWEIGHTS[$gradingweight] * $usegradinggrades) + 0.5) / + (($WORKSHOP_FWEIGHTS[$teacherweight] * $useteachersgrades) + + ($WORKSHOP_FWEIGHTS[$peerweight] * $usepeergrades) + + ($WORKSHOP_FWEIGHTS[$biasweight] * $usebiasgrades) + + ($WORKSHOP_FWEIGHTS[$reliabilityweight] * $usereliabilitygrades) + + ($WORKSHOP_FWEIGHTS[$gradingweight] * $usegradinggrades))); + echo "
".fullname($user)."$teachergrade$peergrade$biasscaled$reliabilityscaled$gradingscaled$finalgrade

\n"; + print_string("allgradeshaveamaximumof", "workshop", $workshop->grade); + echo "

\n"; + + print_continue("view.php?a=$workshop->id"); + } + + + /*************** display final grades (by teacher) ***************************/ + elseif ($action == 'displayfinalgrades') { + // Get all the students + if (!$users = get_course_students($course->id, "u.lastname, u.firstname")) { + print_heading(get_string("nostudentsyet")); + print_footer($course); + exit; + } + + // get the final weights from the database + $teacherweight = get_field("workshop","teacherweight", "id", $workshop->id); + $peerweight = get_field("workshop","peerweight", "id", $workshop->id); + $includeteachersgrade = get_field("workshop","includeteachersgrade", "id", $workshop->id); + $biasweight = get_field("workshop","biasweight", "id", $workshop->id); + $reliabilityweight = get_field("workshop","reliabilityweight", "id", $workshop->id); + $gradingweight = get_field("workshop","gradingweight", "id", $workshop->id); + // work out what to show in the final grades tables and what to include in the calculation of the final grade + // teacher grades? + if ($workshop->gradingstrategy and $teacherweight) { + $useteachersgrades = 1; + } + else { + $useteachersgrades = 0; + } + // peergrades? + if ($workshop->gradingstrategy and $workshop->nsassessments and $peerweight) { + $usepeergrades = 1; + } + else { + $usepeergrades = 0; + } + // bias grades? + if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and ($useteachersgrades or $usepeergrades) + and $biasweight ) { + $usebiasgrades = 1; + } + else { + $usebiasgrades = 0; + } + // reliability grades? + if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and ($useteachersgrades or $usepeergrades) + and $reliabilityweight ) { + $usereliabilitygrades = 1; + } + else { + $usereliabilitygrades = 0; + } + // grading grades? + if (($workshop->ntassessments or $workshop->nsassessments) and $gradingweight ) { + $usegradinggrades = 1; + } + else { + $usegradinggrades = 0; + } + + // show the final grades as stored in the tables... + print_heading_with_help(get_string("displayoffinalgrades", "workshop"), "finalgrades", "workshop"); + echo "
+ "; + echo ""; + if ($useteachersgrades) { + echo ""; + } + if ($usepeergrades) { + echo ""; + } + echo ""; + if ($usebiasgrades) { + echo ""; + } + if ($usereliabilitygrades) { + echo ""; + } + if ($usegradinggrades) { + echo ""; + } + echo "\n"; + // now the weights + echo ""; + echo "\n"; + if ($useteachersgrades) { + echo "\n"; + } + if ($usepeergrades) { + echo "\n"; + } + echo "\n"; + if ($usebiasgrades) { + echo "\n"; + } + if ($usereliabilitygrades) { + echo "\n"; + } + if ($usegradinggrades) { + echo "\n"; + } + echo "\n"; + foreach ($users as $user) { + if ($submissions = workshop_get_user_submissions($workshop, $user)) { + foreach ($submissions as $submission) { + echo ""; + echo "\n"; + if ($useteachersgrades) { + echo ""; + } + if ($usepeergrades) { + echo ""; + } + echo ""; + if ($usebiasgrades) { + echo ""; + } + if ($usereliabilitygrades) { + echo ""; + } + if ($usegradinggrades) { + echo ""; + } + echo "\n"; + } + } + } + echo "
cellheading2\">".$course->student."cellheading2\">".get_string("submission", "workshop")."cellheading2\" align=\"center\">".get_string("assessmentsby", "workshop", $course->teachers)."cellheading2\" align=\"center\">".get_string("assessmentsby", "workshop", $course->students)."cellheading2\" align=\"center\">".get_string("assessmentsdone", "workshop")."cellheading2\" align=\"center\">".get_string("gradeforbias", "workshop")."cellheading2\" align=\"center\">".get_string("gradeforreliability", "workshop")."cellheading2\" align=\"center\">".get_string("gradeforassessments", "workshop")."cellheading2\" align=\"center\">".get_string("overallgrade", "workshop")."
cellheading2\">".get_string("weights", "workshop")."cellheading2\" align=\"center\"> cellheading2\" align=\"center\">$WORKSHOP_FWEIGHTS[$teacherweight]cellheading2\" align=\"center\">$WORKSHOP_FWEIGHTS[$peerweight]cellheading2\" align=\"center\"> cellheading2\" align=\"center\">$WORKSHOP_FWEIGHTS[$biasweight]cellheading2\" align=\"center\">$WORKSHOP_FWEIGHTS[$reliabilityweight]cellheading2\" align=\"center\">$WORKSHOP_FWEIGHTS[$gradingweight]cellheading2\"> 
".fullname($user)".".workshop_print_submission_title($workshop, $submission)."".workshop_print_submission_assessments($workshop, $submission, "teacher")."".workshop_print_submission_assessments($workshop, $submission, "student")."".workshop_print_user_assessments($workshop, $user)."$submission->biasgrade$submission->reliabilitygrade$submission->gradinggrade$submission->finalgrade

\n"; + if ($workshop->showleaguetable) { + workshop_print_league_table($workshop); + if ($workshop->anonymous) { + echo "

".get_string("namesnotshowntostudents", "workshop", $course->students)."

\n"; + } + } + echo "

".get_string("allgradeshaveamaximumof", "workshop", $workshop->grade)."

\n"; + print_continue("view.php?a=$workshop->id"); + } + + + /*************** display final weights (by teacher) ***************************/ + elseif ($action == 'displayfinalweights') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + if ($workshop->phase != 5) { // is this at the expected phase? + print_heading(get_string("assignmentnotinthecorrectphase", "workshop")); + print_continue("view.php?a=$workshop->id"); + } + else { + + ?> + + + +
+ id); + $peerweight = get_field("workshop","peerweight", "id", $workshop->id); + $includeteachersgrade = get_field("workshop","includeteachersgrade", "id", $workshop->id); + $biasweight = get_field("workshop","biasweight", "id", $workshop->id); + $reliabilityweight = get_field("workshop","reliabilityweight", "id", $workshop->id); + $gradingweight = get_field("workshop","gradingweight", "id", $workshop->id); + + // now show the weights used in the final grades + print_heading_with_help(get_string("calculationoffinalgrades", "workshop"), "calculatingfinalgrade", "workshop"); + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
cellheading2\">
". + get_string("weightsusedforfinalgrade", "workshop")."
".get_string("weightforteacherassessments", "workshop", $course->teacher).":"; + workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "teacherweight", $teacherweight, ""); + echo "
".get_string("weightforpeerassessments", "workshop").":"; + workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "peerweight", $peerweight, ""); + echo "
".get_string("weightforbias", "workshop").":"; + workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "biasweight", $biasweight, ""); + echo "
".get_string("weightforreliability", "workshop").":"; + workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "reliabilityweight", $reliabilityweight, ""); + echo "
".get_string("weightforgradingofassessments", "workshop").":"; + workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "gradingweight", $gradingweight, ""); + echo "
cellheading2\">
". + get_string("optionforpeergrade", "workshop")."
".get_string("includeteachersgrade", "workshop").":"; + $options[0] = get_string("no"); $options[1] = get_string("yes"); + choose_from_menu($options, "includeteachersgrade", $includeteachersgrade, ""); + helpbutton("includeteachersgrade", get_string("includeteachersgrade", "workshop"), "workshop"); + echo "
\n"; + + print_heading_with_help(get_string("leaguetable", "workshop"), "leaguetable", "workshop"); + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; - echo "
".get_string("numberofentries", "workshop").":"; + $numbers[22] = 'All'; + $numbers[21] = 50; + for ($i=20; $i>=0; $i--) { + $numbers[$i] = $i; + } + $nentries = $workshop->showleaguetable; + if ($nentries == 99) { + $nentries = 'All'; + } + choose_from_menu($numbers, "nentries", "$nentries", ""); + echo "

".get_string("hidenamesfromstudents", "workshop", $course->students)."

\n"; $options[0] = get_string("no"); $options[1] = get_string("yes"); - choose_from_menu($options, "anonymous", $workshop->anonymous, ""); - echo "

\n"; - echo "\n"; - echo "
"; - echo "\n"; - } - } - - - /******************* list all submissions ************************************/ - elseif ($action == 'listallsubmissions' ) { - if (!$users = get_course_students($course->id)) { - print_heading(get_string("nostudentsyet")); - print_footer($course); - exit; - } - print_heading(get_string("listofallsubmissions", "workshop").":", "CENTER"); - workshop_list_all_submissions($workshop, $USER); - print_continue("view.php?id=$cm->id"); - - } - - - /******************* list for assessment student (submissions) ************************************/ - elseif ($action == 'listforassessmentstudent' ) { - if (!$users = get_course_students($course->id)) { - print_heading(get_string("nostudentsyet")); - print_footer($course); - exit; - } - workshop_list_unassessed_student_submissions($workshop, $USER); - print_continue("view.php?id=$cm->id"); - - } - - - /******************* list for assessment teacher (submissions) ************************************/ - elseif ($action == 'listforassessmentteacher' ) { - if (!$users = get_course_students($course->id)) { - print_heading(get_string("nostudentsyet")); - print_footer($course); - exit; - } - workshop_list_unassessed_teacher_submissions($workshop, $USER); - print_continue("view.php?id=$cm->id"); - - } - - - /******************* save analysis options (for teachers only) ************************************/ - elseif ($action == 'saveanalysisoptions' ) { - + choose_from_menu($options, "anonymous", $workshop->anonymous, ""); + echo "\n"; + echo "
\n"; + echo "\n"; + echo "
"; + echo "\n"; + } + } + + + /******************* list all submissions ************************************/ + elseif ($action == 'listallsubmissions' ) { + if (!$users = get_course_students($course->id)) { + print_heading(get_string("nostudentsyet")); + print_footer($course); + exit; + } + print_heading(get_string("listofallsubmissions", "workshop").":", "CENTER"); + workshop_list_all_submissions($workshop, $USER); + print_continue("view.php?id=$cm->id"); + + } + + + /******************* list for assessment student (submissions) ************************************/ + elseif ($action == 'listforassessmentstudent' ) { + if (!$users = get_course_students($course->id)) { + print_heading(get_string("nostudentsyet")); + print_footer($course); + exit; + } + workshop_list_unassessed_student_submissions($workshop, $USER); + print_continue("view.php?id=$cm->id"); + + } + + + /******************* list for assessment teacher (submissions) ************************************/ + elseif ($action == 'listforassessmentteacher' ) { + if (!$users = get_course_students($course->id)) { + print_heading(get_string("nostudentsyet")); + print_footer($course); + exit; + } + workshop_list_unassessed_teacher_submissions($workshop, $USER); + print_continue("view.php?id=$cm->id"); + + } + + + /******************* save analysis options (for teachers only) ************************************/ + elseif ($action == 'saveanalysisoptions' ) { + if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } + error("Only teachers can look at this page"); + } - set_field("workshop", "teacherloading", $_POST['teacherloading'], "id", "$workshop->id"); - set_field("workshop", "gradingweight", $_POST['gradingweight'], "id", "$workshop->id"); - set_field("workshop", "assessmentstodrop", $_POST['assessmentstodrop'], "id", "$workshop->id"); - redirect("submissions.php?id=$cm->id&action=analysisofassessments", + set_field("workshop", "teacherloading", $_POST['teacherloading'], "id", "$workshop->id"); + set_field("workshop", "gradingweight", $_POST['gradingweight'], "id", "$workshop->id"); + set_field("workshop", "assessmentstodrop", $_POST['assessmentstodrop'], "id", "$workshop->id"); + redirect("submissions.php?id=$cm->id&action=analysisofassessments", get_string("savedok", "workshop")); - - } - - - /*************** update (league table options teacher) ***************************/ - elseif ($action == 'updateleaguetable') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - $form = (object)$_POST; - - // save number of entries in showleaguetable option - if ($form->nentries == 'All') { - $form->nentries = 99; - } - set_field("workshop", "showleaguetable", $form->nentries, "id", "$workshop->id"); - - // save the anonymous option - set_field("workshop", "anonymous", $form->anonymous, "id", "$workshop->id"); - add_to_log($course->id, "workshop", "league table", "view.php?id=$cm->id", $form->nentries, $cm->id); - - redirect("submissions.php?action=adminlist&id=$cm->id"); - } - - - /*************** update over allocation (by teacher) ***************************/ - elseif ($action == 'updateoverallocation') { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - - $form = (object)$_POST; - - set_field("workshop", "overallocation", $form->overallocation, "id", $workshop->id); - echo "

".get_string("overallocation", "workshop").": $form->overallocation

\n"; - add_to_log($course->id, "workshop", "over allocation", "view.php?id=$cm->id", $form->overallocation,$cm->id); - - redirect("submissions.php?action=adminlist&id=$cm->id"); - } - - - /******************* user confirm delete ************************************/ - elseif ($action == 'userconfirmdelete' ) { - - if (empty($_GET['sid'])) { - error("User Confirm Delete: submission id missing"); - } - - notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("submission", "workshop")), - "submissions.php?action=userdelete&id=$cm->id&sid=$_GET[sid]", "view.php?id=$cm->id"); - } - - - /******************* user delete ************************************/ - elseif ($action == 'userdelete' ) { - - if (empty($_GET['sid'])) { - error("User Delete: submission id missing"); - } - - if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) { - error("User Delete: can not get submission record"); - } - print_string("deleting", "workshop"); - // first get any assessments... - if ($assessments = workshop_get_assessments($submission, 'ALL')) { - foreach($assessments as $assessment) { - // ...and all the associated records... - delete_records("workshop_comments", "assessmentid", $assessment->id); - delete_records("workshop_grades", "assessmentid", $assessment->id); - echo "."; - } - // ...now delete the assessments... - delete_records("workshop_assessments", "submissionid", $submission->id); - } - // ...and the submission record... - delete_records("workshop_submissions", "id", $submission->id); - // ..and finally the submitted file - workshop_delete_submitted_files($workshop, $submission); - - print_continue("view.php?id=$cm->id"); - } - - - /*************** no man's land **************************************/ - else { - error("Fatal Error: Unknown Action: ".$action."\n"); - } - - print_footer($course); + + } + + + /*************** update (league table options teacher) ***************************/ + elseif ($action == 'updateleaguetable') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + $form = (object)$_POST; + + // save number of entries in showleaguetable option + if ($form->nentries == 'All') { + $form->nentries = 99; + } + set_field("workshop", "showleaguetable", $form->nentries, "id", "$workshop->id"); + + // save the anonymous option + set_field("workshop", "anonymous", $form->anonymous, "id", "$workshop->id"); + add_to_log($course->id, "workshop", "league table", "view.php?id=$cm->id", $form->nentries, $cm->id); + + redirect("submissions.php?action=adminlist&id=$cm->id"); + } + + + /*************** update over allocation (by teacher) ***************************/ + elseif ($action == 'updateoverallocation') { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + + $form = (object)$_POST; + + set_field("workshop", "overallocation", $form->overallocation, "id", $workshop->id); + echo "

".get_string("overallocation", "workshop").": $form->overallocation

\n"; + add_to_log($course->id, "workshop", "over allocation", "view.php?id=$cm->id", $form->overallocation,$cm->id); + + redirect("submissions.php?action=adminlist&id=$cm->id"); + } + + + /******************* user confirm delete ************************************/ + elseif ($action == 'userconfirmdelete' ) { + + if (empty($_GET['sid'])) { + error("User Confirm Delete: submission id missing"); + } + + notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("submission", "workshop")), + "submissions.php?action=userdelete&id=$cm->id&sid=$_GET[sid]", "view.php?id=$cm->id"); + } + + + /******************* user delete ************************************/ + elseif ($action == 'userdelete' ) { + + if (empty($_GET['sid'])) { + error("User Delete: submission id missing"); + } + + if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) { + error("User Delete: can not get submission record"); + } + print_string("deleting", "workshop"); + // first get any assessments... + if ($assessments = workshop_get_assessments($submission, 'ALL')) { + foreach($assessments as $assessment) { + // ...and all the associated records... + delete_records("workshop_comments", "assessmentid", $assessment->id); + delete_records("workshop_grades", "assessmentid", $assessment->id); + echo "."; + } + // ...now delete the assessments... + delete_records("workshop_assessments", "submissionid", $submission->id); + } + // ...and the submission record... + delete_records("workshop_submissions", "id", $submission->id); + // ..and finally the submitted file + workshop_delete_submitted_files($workshop, $submission); + + print_continue("view.php?id=$cm->id"); + } + + + /*************** no man's land **************************************/ + + else { + + error("Fatal Error: Unknown Action: ".$action."\n"); + + } + + + print_footer($course); ?> -- 2.39.5