get_string('notgraded', 'workshop'), 1 => get_string('accumulative', 'workshop'), 2 => get_string('errorbanded', 'workshop'), 3 => get_string('criterion', 'workshop'), 4 => get_string('rubric', 'workshop') ); $WORKSHOP_SHOWGRADES = array (0 => get_string('dontshowgrades', 'workshop'), 1 => get_string('showgrades', 'workshop') ); $WORKSHOP_SCALES = array( 0 => array( 'name' => get_string('scaleyes', 'workshop'), 'type' => 'radio', 'size' => 2, 'start' => get_string('yes'), 'end' => get_string('no')), 1 => array( 'name' => get_string('scalepresent', 'workshop'), 'type' => 'radio', 'size' => 2, 'start' => get_string('present', 'workshop'), 'end' => get_string('absent', 'workshop')), 2 => array( 'name' => get_string('scalecorrect', 'workshop'), 'type' => 'radio', 'size' => 2, 'start' => get_string('correct', 'workshop'), 'end' => get_string('incorrect', 'workshop')), 3 => array( 'name' => get_string('scalegood3', 'workshop'), 'type' => 'radio', 'size' => 3, 'start' => get_string('good', 'workshop'), 'end' => get_string('poor', 'workshop')), 4 => array( 'name' => get_string('scaleexcellent4', 'workshop'), 'type' => 'radio', 'size' => 4, 'start' => get_string('excellent', 'workshop'), 'end' => get_string('verypoor', 'workshop')), 5 => array( 'name' => get_string('scaleexcellent5', 'workshop'), 'type' => 'radio', 'size' => 5, 'start' => get_string('excellent', 'workshop'), 'end' => get_string('verypoor', 'workshop')), 6 => array( 'name' => get_string('scaleexcellent7', 'workshop'), 'type' => 'radio', 'size' => 7, 'start' => get_string('excellent', 'workshop'), 'end' => get_string('verypoor', 'workshop')), 7 => array( 'name' => get_string('scale10', 'workshop'), 'type' => 'selection', 'size' => 10), 8 => array( 'name' => get_string('scale20', 'workshop'), 'type' => 'selection', 'size' => 20), 9 => array( 'name' => get_string('scale100', 'workshop'), 'type' => 'selection', 'size' => 100)); ////////////////////////////////////////////////////////////////////////////////////// /*** Functions for the workshop module ****** workshop_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) { workshop_compare_assessments($workshop, $assessment1, $assessment2) { ---> in lib.php workshop_count_all_submissions_for_assessment($workshop, $user) { workshop_count_assessments($submission) { ---> in lib.php workshop_count_comments($assessment) { workshop_count_peer_assessments($workshop, $user) { workshop_count_self_assessments($workshop, $user) { workshop_count_student_submissions($workshop) { workshop_count_student_submissions_for_assessment($workshop, $user) { workshop_count_teacher_assessments($courseid, $submission) { workshop_count_teacher_assessments_by_user($workshop, $user) { workshop_count_teacher_submissions($workshop) { workshop_count_teacher_submissions_for_assessment($workshop, $user) { workshop_count_ungraded_assessments($workshop) { --->in lib.php workshop_count_ungraded_assessments_student($workshop) { workshop_count_ungraded_assessments_teacher($workshop) { workshop_count_user_assessments($worshop, $user, $type = "all") { $type is all, student or teacher workshop_count_user_submissions($workshop, $user) { workshop_delete_submitted_files($workshop, $submission) { workshop_delete_user_files($workshop, $user, $exception) { workshop_file_area($workshop, $submission) { ---> in lib.php workshop_file_area_name($workshop, $submission) { ---> in lib.php workshop_get_all_teacher_assessments($workshop) { workshop_get_assessments($submission, $all = '') { ---> in lib.php workshop_get_comments($assessment) { workshop_get_participants($workshopid) { workshop_get_student_assessments($workshop, $user) { workshop_get_student_submission($workshop, $user) { ---> in lib.php workshop_get_student_submission_assessments($workshop) { workshop_get_student_submissions($workshop) { ---> in lib.php workshop_get_submission_assessment($submission, $user) { workshop_get_teacher_assessments($courseid, $submission) { workshop_get_teacher_submission_assessments($workshop) { workshop_get_teacher_submissions($workshop) { workshop_get_ungraded_assessments($workshop) { workshop_get_unmailed_assessments($cutofftime) { workshop_get_unmailed_marked_assessments($cutofftime) { workshop_get_user_assessments($workshop, $user) { ---> in lib.php workshop_get_user_submissions($workshop, $user) { ---> in lib.php workshop_get_users_done($workshop) { workshop_grade_assessments($workshop) { ---> in lib.php workshop_list_all_submissions($workshop) { workshop_list_all_ungraded_assessments($workshop) { workshop_list_assessed_submissions($workshop, $user) { workshop_list_peer_assessments($workshop, $user) { workshop_list_student_submissions($workshop, $user) { workshop_list_submissions_for_admin($workshop, $order) { workshop_list_teacher_assessments_by_user($workshop, $user) { workshop_list_teacher_submissions($workshop) { workshop_list_unassessed_student_submissions($workshop, $user) { workshop_list_unassessed_teacher_submissions($workshop, $user) { workshop_list_ungraded_assessments($workshop, $stype) { workshop_list_user_submissions($workshop, $user) { workshop_calculate_phase($workshop, $style='') { workshop_print_assessment($workshop, $assessment, $allowchanges, $showcommentlinks, $returnto) workshop_print_assessments_by_user_for_admin($workshop, $user) { workshop_print_assessments_for_admin($workshop, $submission) { workshop_print_assignment_info($cm, $workshop) { workshop_print_difference($time) { workshop_print_feedback($course, $submission) { workshop_print_league_table($workshop) { workshop_print_submission_assessments($workshop, $submission, $type) { workshop_print_submission_title($workshop, $user) { workshop_print_time_to_deadline($time) { workshop_print_upload_form($workshop) { workshop_print_user_assessments($workshop, $user) { workshop_submission_grade($submission) { ---> in lib.php workshop_test_user_assessments($workshop, $user) { ***************************************/ /////////////////////////////////////////////////////////////////////////////// function workshop_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) { /// Given an array of value, creates a popup menu to be part of a form /// $options["value"]["label"] if ($nothing == "choose") { $nothing = get_string("choose")."..."; } if ($script) { $javascript = "onChange=\"$script\""; } else { $javascript = ""; } $output = "
\n"; echo " \n"; echo "\n"; // only show the grade if grading strategy > 0 and the grade is positive if ($assessment and $showgrades and $workshop->gradingstrategy and $assessment->grade >= 0) { echo "\n \n"; } // get the assignment elements... $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 { $elements = null; } if ($assessment) { // get any previous grades... if ($gradesraw = get_records_select("workshop_grades", "assessmentid = $assessment->id", "elementno")) { foreach ($gradesraw as $grade) { $grades[] = $grade; // to renumber index 0,1,2... } } } else { // setup dummy grades array for($i = 0; $i < count($elementsraw); $i++) { // gives a suitable sized loop $grades[$i]->feedback = get_string("yourfeedbackgoeshere", "workshop"); $grades[$i]->grade = 0; } } // determine what sort of grading switch ($workshop->gradingstrategy) { case 0: // no grading // now print the form for ($i=0; $i < count($elements); $i++) { $iplus1 = $i+1; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; // if active and the teacher show stock comments... if ($allowchanges and workshop_is_teacher($workshop, $USER->id)) { echo "\n"; } echo "\n"; echo " \n"; echo "\n"; } break; case 1: // accumulative grading // now print the form for ($i=0; $i < count($elements); $i++) { $iplus1 = $i+1; echo "\n"; echo " \n"; echo " \n"; if ($showgrades) { echo "\n"; echo " \n"; echo " \n"; echo "\n"; } echo "\n"; echo " \n"; echo " \n"; echo "\n"; // if active and the teacher show stock comments... if ($allowchanges and workshop_is_teacher($workshop, $USER->id)) { echo "\n"; } echo "\n"; echo " \n"; echo "\n"; } break; case 2: // error banded grading // now run through the elements $negativecount = 0; for ($i=0; $i < count($elements) - 1; $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"; // if active and the teacher show stock comments... if ($allowchanges and workshop_is_teacher($workshop, $USER->id)) { echo "\n"; } echo "\n"; echo " \n"; echo "\n"; if (empty($grades[$i]->grade)) { $negativecount++; } } // print the number of negative elements // echo "\n"; // echo "\n"; // echo " \n"; echo "
"; if ($assessment and workshop_is_teacher($workshop)) { $user = get_record('user', 'id', $assessment->userid); print_string("assessmentby", "workshop", fullname($user)); } else { print_string('assessment', 'workshop'); } echo '
'.userdate(@$assessment->timecreated)."
".get_string("thegradeis", "workshop").": ". number_format($assessment->grade * $workshop->grade / 100, 2)." (". get_string("maximumgrade")." ".number_format($workshop->grade, 0).")
 

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

".format_text($elements[$i]->description); echo "

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo format_text($grades[$i]->feedback); } echo "
\n"; helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop"); echo "\n"; if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id AND elementno = $i", "id")) { // show comments in fixed order (oldest first) foreach ($stockcomments as $stockcomment) { echo "comments)."';\"><<$stockcomment->comments>>\n"; if (workshop_is_teacheredit($workshop, $USER->id)) { echo " id;getElementById('assessmentform').submit();\"> <--".get_string("delete","workshop")."\n"; } echo "
\n"; } } echo "
 

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

".format_text($elements[$i]->description); echo "

".get_string("weight", "workshop").": ". number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight], 2)."

\n"; echo "

". get_string("grade"). ":

\n"; // get the appropriate scale $scalenumber=$elements[$i]->scale; $SCALE = (object)$WORKSHOP_SCALES[$scalenumber]; switch ($SCALE->type) { case 'radio' : // show selections highest first echo "
$SCALE->start   "; for ($j = $SCALE->size - 1; $j >= 0 ; $j--) { $checked = false; if (isset($grades[$i]->grade)) { if ($j == $grades[$i]->grade) { $checked = true; } } else { // there's no previous grade so check the lowest option if ($j == 0) { $checked = true; } } if ($checked) { echo "    \n"; } else { echo "    \n"; } } echo "   $SCALE->end
\n"; break; case 'selection' : unset($numbers); for ($j = $SCALE->size; $j >= 0; $j--) { $numbers[$j] = $j; } if (isset($grades[$i]->grade)) { choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, ""); } else { choose_from_menu($numbers, "grade[$i]", 0, ""); } break; } echo "

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo format_text($grades[$i]->feedback); } echo "
\n"; helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop"); echo "\n"; if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id AND elementno = $i", "id")) { // get comments in a fixed order - oldest first foreach ($stockcomments as $stockcomment) { echo "comments). "';\"><<$stockcomment->comments>>\n"; if (workshop_is_teacheredit($workshop, $USER->id)) { echo " id;getElementById('assessmentform').submit();\"> <--".get_string("delete","workshop")."\n"; } echo "
\n"; } } echo "
 

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

".format_text($elements[$i]->description); echo "

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

". get_string("grade"). ":

\n"; // get the appropriate scale - yes/no scale (0) $SCALE = (object) $WORKSHOP_SCALES[0]; switch ($SCALE->type) { case 'radio' : // show selections highest first echo "
$SCALE->start   "; for ($j = $SCALE->size - 1; $j >= 0 ; $j--) { $checked = false; if (isset($grades[$i]->grade)) { if ($j == $grades[$i]->grade) { $checked = true; } } else { // there's no previous grade so check the lowest option if ($j == 0) { $checked = true; } } if ($checked) { echo "    \n"; } else { echo "    \n"; } } echo "   $SCALE->end
\n"; break; case 'selection' : unset($numbers); for ($j = $SCALE->size; $j >= 0; $j--) { $numbers[$j] = $j; } if (isset($grades[$i]->grade)) { choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, ""); } else { choose_from_menu($numbers, "grade[$i]", 0, ""); } break; } echo "

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { if (isset($grades[$i]->feedback)) { echo format_text($grades[$i]->feedback); } } echo " 
\n"; helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop"); echo "\n"; if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id AND elementno = $i", "id")) { // get comments in a fixed order - oldest first foreach ($stockcomments as $stockcomment) { echo "comments). "';\"><<$stockcomment->comments>>\n"; if (workshop_is_teacheredit($workshop, $USER->id)) { echo " id;getElementById('assessmentform').submit();\"> <--".get_string("delete","workshop")."\n"; } echo "
\n"; } } echo "
 
".get_string("numberofnegativeitems", "workshop")."$negativecount
 
\n"; // now print the grade table echo "

".get_string("gradetable","workshop")."
\n"; echo "
\n"; for ($j = 100; $j >= 0; $j--) { $numbers[$j] = $j; } for ($i=0; $i<=$workshop->nelements; $i++) { if ($i == $negativecount) { echo "\n"; } else { echo "\n"; } } echo "
". get_string("numberofnegativeresponses", "workshop"); echo "". get_string("suggestedgrade", "workshop")."
pixpath/t/right.gif\" alt=\"\" /> $i{$elements[$i]->maxscore}
$i{$elements[$i]->maxscore}
\n"; echo "

\n"; break; case 3: // criteria grading echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; // find which criteria has been selected (saved in the zero element), if any if (isset($grades[0]->grade)) { $selection = $grades[0]->grade; } else { $selection = 0; } // now run through the elements for ($i=0; $i < count($elements); $i++) { $iplus1 = $i+1; echo "\n"; echo " \n"; if ($selection == $i) { echo " \n"; } else { echo " \n"; } echo "\n"; } echo "
".get_string("optionaladjustment", "workshop")."\n"; unset($numbers); for ($j = 20; $j >= -20; $j--) { $numbers[$j] = $j; } if (isset($grades[$workshop->nelements]->grade)) { choose_from_menu($numbers, "grade[$workshop->nelements]", $grades[$workshop->nelements]->grade, ""); } else { choose_from_menu($numbers, "grade[$workshop->nelements]", 0, ""); } echo "
 ". get_string("criterion","workshop")."".get_string("select", "workshop")."".get_string("suggestedgrade", "workshop")."
$iplus1".format_text($elements[$i]->description)."{$elements[$i]->maxscore}
\n"; echo "

\n"; break; case 4: // rubric grading // now run through the elements... for ($i=0; $i < count($elements); $i++) { $iplus1 = $i+1; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; if (isset($grades[$i])) { $selection = $grades[$i]->grade; } else { $selection = 0; } // ...and the rubrics if ($rubricsraw = get_records_select("workshop_rubrics", "workshopid = $workshop->id AND elementno = $i", "rubricno ASC")) { unset($rubrics); foreach ($rubricsraw as $rubic) { $rubrics[] = $rubic; // to renumber index 0,1,2... } for ($j=0; $j<5; $j++) { if (empty($rubrics[$j]->description)) { break; // out of inner for loop } echo "\n"; if ($selection == $j) { echo " \n"; } else { echo " \n"; } echo "\n"; } echo "\n"; echo " \n"; echo " \n"; echo "\n"; // if active and the teacher show stock comments... if ($allowchanges and workshop_is_teacher($workshop, $USER->id)) { echo "\n"; } echo "\n"; echo " \n"; echo "\n"; } } break; } // end of outer switch // now get the general comment (present in all types) echo "\n"; switch ($workshop->gradingstrategy) { case 0: case 1: case 4 : // no grading, accumulative and rubic echo " \n"; break; default : echo " \n"; } echo " \n"; echo "\n"; // if active and the teacher show stock comments... if ($allowchanges and workshop_is_teacher($workshop, $USER->id)) { echo "\n"; } $timenow = time(); // now show the grading grade if available... if ($assessment and $assessment->timegraded) { echo "\n"; echo "\n"; echo "\n"; if ($assessment->teachercomment) { echo "\n"; echo " \n"; echo " \n"; echo "\n"; } echo "\n"; echo " \n"; echo "\n"; } echo "\n"; echo " \n"; echo "\n"; // ...and close the table, show submit button if needed... echo "
".get_string("optionaladjustment", "workshop")."\n"; unset($numbers); for ($j = 20; $j >= -20; $j--) { $numbers[$j] = $j; } if (isset($grades[1]->grade)) { choose_from_menu($numbers, "grade[1]", $grades[1]->grade, ""); } else { choose_from_menu($numbers, "grade[1]", 0, ""); } echo "
".get_string("element", "workshop")." $iplus1:".format_text($elements[$i]->description). "

".get_string("weight", "workshop").": ". number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight], 2)."

".get_string("select", "workshop"). "". get_string("criterion","workshop"). "
".format_text($rubrics[$j]->description)."

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo format_text($grades[$i]->feedback); } echo "
\n"; helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop"); echo "\n"; if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id AND elementno = $i", "id")) { // show comments in fixed (creation) order foreach ($stockcomments as $stockcomment) { echo "comments). "';\"><<$stockcomment->comments>>\n"; if (workshop_is_teacheredit($workshop, $USER->id)) { echo " id;getElementById('assessmentform').submit();\"> <--".get_string("delete","workshop")."\n"; } echo "
\n"; } } echo "
 

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

".get_string("generalcomment", "workshop")."/
". get_string("reasonforadjustment", "workshop").":

\n"; if ($allowchanges) { echo " \n"; } else { if ($assessment) { if (isset($assessment->generalcomment)) { echo format_text($assessment->generalcomment); } } else { print_string("yourfeedbackgoeshere", "workshop"); } } echo " 
\n"; helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop"); echo "\n"; if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id AND elementno = 99", "id")) { // show in the same order (oldest at the top) foreach ($stockcomments as $stockcomment) { echo "comments)."';\"><<$stockcomment->comments>>\n"; if (workshop_is_teacheredit($workshop, $USER->id)) { echo " id;getElementById('assessmentform').submit();\"> <--".get_string("delete","workshop")."\n"; } echo "
\n"; } } echo "
". get_string('gradeforstudentsassessment', 'workshop')."

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

\n"; echo text_to_html($assessment->teachercomment); echo " 

"; print_string('grade', 'workshop'); echo ":

\n"; echo number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0); echo " 
 
\n"; if ($assessment) { if ($allowchanges) { echo "\n"; } // ...if user is author, assessment not agreed, there's no comments, the showcommentlinks flag is set and // it's not self assessment then show some buttons! if (($submission->userid == $USER->id) and !$assessment->timeagreed and !$comments and $showcommentlinks and $submission->userid != $assessment->userid) { echo "\n"; echo "\n"; } } echo "
"; echo "\n"; } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_assessments_by_user_for_admin($workshop, $user) { if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { error("Course Module ID was incorrect"); } if ($assessments = workshop_get_user_assessments_done($workshop, $user)) { foreach ($assessments as $assessment) { workshop_print_assessment($workshop, $assessment); echo "

". ''. get_string('assessthisassessment', 'workshop').' | '. "id&aid=$assessment->id\">". get_string("delete", "workshop")."


\n"; } } } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_assessments_for_admin($workshop, $submission) { if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { error("Course Module ID was incorrect"); } if ($assessments =workshop_get_assessments($submission)) { foreach ($assessments as $assessment) { if (!$user = get_record("user", "id", $assessment->userid)) { error (" workshop_print_assessments_for_admin: unable to get user record"); } echo "

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

\n"; workshop_print_assessment($workshop, $assessment); echo "

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


\n"; } } } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_assignment_info($workshop) { global $CFG; if (! $course = get_record("course", "id", $workshop->course)) { error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { error("Course Module ID was incorrect"); } // print standard assignment heading print_heading(format_string($workshop->name), "center"); print_simple_box_start("center"); // print phase and date info $string = ''.get_string('currentphase', 'workshop').': '.workshop_phase($workshop).'
'; $dates = array( 'submissionstart' => $workshop->submissionstart, 'submissionend' => $workshop->submissionend, 'assessmentstart' => $workshop->assessmentstart, 'assessmentend' => $workshop->assessmentend ); foreach ($dates as $type => $date) { if ($date) { $strdifference = format_time($date - time()); if (($date - time()) < 0) { $strdifference = "$strdifference"; } $string .= ''.get_string($type, 'workshop').': '.userdate($date)." ($strdifference)
"; } } echo $string; $grade = $workshop->gradinggrade + $workshop->grade; echo "
".get_string("maximumgrade").": $grade "; // print link to specimen assessment form echo "(id&action=displaygradingform\">". get_string("specimenassessmentform", "workshop").""; // print edit icon if (workshop_is_teacheredit($workshop) and $workshop->nelements) { echo " id&action=editelements\">". "pixpath/t/edit.gif\" ". 'class="iconsmall" alt="'.get_string('amendassessmentelements', 'workshop').'" />'; } echo ")
"; print_simple_box_end(); } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_difference($time) { if ($time < 0) { $timetext = get_string("late", "assignment", format_time($time)); return " ($timetext)"; } else { $timetext = get_string("early", "assignment", format_time($time)); return " ($timetext)"; } } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_key($workshop) { // print an explaination of the grades if (!$course = get_record("course", "id", $workshop->course)) { error("Print key: course not found"); } echo "
\n"; echo "

{} ".get_string("assessmentby", "workshop", $course->student).";  \n"; echo "[] ".get_string("assessmentby", "workshop", $course->teacher).";  \n"; echo "<> ".get_string("assessmentdropped", "workshop").";\n"; if ($workshop->agreeassessments) echo "<<>> ".get_string("assessmentnotyetagreed", "workshop").";\n"; echo "
() ".get_string("automaticgradeforassessment", "workshop").";  \n"; echo "[] ".get_string("teachergradeforassessment", "workshop", $course->teacher).".\n"; echo "
".get_string("gradesforsubmissionsare", "workshop", $workshop->grade).";  \n"; echo get_string("gradesforassessmentsare", "workshop", $workshop->gradinggrade).".

\n"; echo "
\n"; return; } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_league_table($workshop) { // print an order table of (student) submissions showing teacher's and student's assessments if (! $course = get_record("course", "id", $workshop->course)) { error("Print league table: Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { error("Course Module ID was incorrect"); } // set $groupid if workshop is in SEPARATEGROUPS mode if (groupmode($course, $cm) == SEPARATEGROUPS) { $groupid = get_current_group($course->id); } else { $groupid = 0; } $nentries = $workshop->showleaguetable; if ($workshop->anonymous and workshop_is_student($workshop)) { $table->head = array (get_string("title", "workshop"), get_string("teacherassessments", "workshop", $course->teacher), get_string("studentassessments", "workshop", $course->student), get_string("overallgrade", "workshop")); $table->align = array ("left", "center", "center", "center"); $table->size = array ("*", "*", "*", "*"); } else { // show names $table->head = array (get_string("title", "workshop"), get_string("name"), get_string("teacherassessments", "workshop", $course->teacher), get_string("studentassessments", "workshop", $course->student), get_string("overallgrade", "workshop")); $table->align = array ("left", "left", "center", "center", "center"); $table->size = array ("*", "*", "*", "*", "*"); } $table->cellpadding = 2; $table->cellspacing = 0; if ($submissions = workshop_get_student_submissions($workshop)) { foreach ($submissions as $submission) { if ($groupid) { // check submission's group if (!groups_is_member($groupid, $submission->userid)) { continue; // skip this submission } } $grades[$submission->id] = workshop_submission_grade($workshop, $submission); } arsort($grades); // largest grade first reset($grades); $n = 1; while (list($submissionid, $grade) = each($grades)) { if (!$submission = get_record("workshop_submissions", "id", $submissionid)) { error("Print league table: submission not found"); } if (!$user = get_record("user", "id", $submission->userid)) { error("Print league table: user not found"); } if ($workshop->anonymous and workshop_is_student($workshop)) { $table->data[] = array(workshop_print_submission_title($workshop, $submission), workshop_print_submission_assessments($workshop, $submission, "teacher"), workshop_print_submission_assessments($workshop, $submission, "student"), $grade); } else { $table->data[] = array(workshop_print_submission_title($workshop, $submission), fullname($user), workshop_print_submission_assessments($workshop, $submission, "teacher"), workshop_print_submission_assessments($workshop, $submission, "student"), $grade); } $n++; if ($n > $nentries) { break; } } print_heading(get_string("leaguetable", "workshop")); print_table($table); workshop_print_key($workshop); } } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_submission($workshop, $submission) { // prints the submission with optional attachments global $CFG; if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { error("Course Module ID was incorrect"); } print_simple_box(format_text($submission->description), 'center'); if ($workshop->nattachments) { $n = 1; echo "\n"; $filearea = workshop_file_area_name($workshop, $submission); if ($basedir = workshop_file_area($workshop, $submission)) { if ($files = get_directory_list($basedir)) { require_once($CFG->libdir .'/filelib.php'); foreach ($files as $file) { $icon = mimeinfo("icon", $file); $ffurl = get_file_url("$filearea/$file"); echo ""; $n++; } } } echo "
".get_string("attachment", "workshop")." $n: \n"; // removed target=\"uploadedfile\" as it does not validate // MDL-7861 echo "pixpath/f/$icon\" class=\"icon\" alt=\"".get_string('file')."\" />". " $file
\n"; } return; } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_submission_assessments($workshop, $submission, $type) { global $USER, $CFG; // Returns the teacher or peer grade and a hyperlinked list of grades for this submission if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { error("Course Module ID was incorrect"); } $str = ''; // get the assessments in grade order, highest first if ($assessments = workshop_get_assessments($submission, "", "grade DESC")) { if ($type == 'teacher' or $type == 'all') { // students can see teacher assessments only if the release date has passed $timenow = time(); if (workshop_is_teacher($workshop, $USER->id) or ($timenow > $workshop->releasegrades)) { foreach ($assessments as $assessment) { if (workshop_is_teacher($workshop, $assessment->userid)) { if ($type == 'all') { $str .= workshop_fullname($assessment->userid, $workshop->course).': '; } $str .= "id\">" . "[".number_format($assessment->grade *$workshop->grade / 100, 0)."]"; if (workshop_is_teacher($workshop, $USER->id)) { $str .= ' id&sid=$submission->id\">pixpath/t/edit.gif\" ". ' class="iconsmall" alt="'.get_string('reassess', 'workshop').'" />'; $str .= ' id&aid=$assessment->id\">pixpath/t/delete.gif\" ". ' class="iconsmall" alt="'.get_string('delete', 'workshop').'" />
'; } } } } } if ($type == 'student' or $type == 'all') { foreach ($assessments as $assessment) { if (workshop_is_student($workshop, $assessment->userid)) { if ($type == 'all') { $str .= workshop_fullname($assessment->userid, $workshop->course).': '; } $str .= "id\">"; if ($workshop->agreeassessments and !$assessment->timeagreed and workshop_is_student($workshop, $submission->userid)) { // agreement on student work only $str .= "<<".number_format($assessment->grade * $workshop->grade / 100, 0)." (". number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0). ")>> "; } elseif ($assessment->timegraded) { if ($assessment->gradinggrade) { $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0); if ($assessment->teachergraded) { $str .= " [".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0). "]} "; } else { $str .= " (".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0). ")} "; } } else { $str .= "<".number_format($assessment->grade * $workshop->grade / 100, 0). " (0)> "; } } else { $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0)."} "; } $str .= '
'; } } } } if (!$str) { $str = " "; // be kind to Mozilla browsers! } return $str; } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_submission_title($workshop, $submission) { // Arguments are objects if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { error("Course Module ID was incorrect"); } if (!$submission->timecreated) { // a "no submission" return $submission->title; } return "id\" href=\"submissions.php?id=$cm->id&action=showsubmission&sid=$submission->id\">$submission->title"; } function workshop_print_time_to_deadline($time) { if ($time < 0) { $timetext = get_string("afterdeadline", "workshop", format_time($time)); return " ($timetext)"; } else { $timetext = get_string("beforedeadline", "workshop", format_time($time)); return " ($timetext)"; } } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_upload_form($workshop) { global $CFG; if (! $course = get_record("course", "id", $workshop->course)) { error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { error("Course Module ID was incorrect"); } $usehtmleditor = can_use_html_editor(); echo "
"; echo "
"; echo "
"; echo " id\" />"; echo "\n"; // now get the submission echo "
". get_string("title", "workshop").":\n"; echo "\n"; echo "
".get_string("submission", "workshop").":
\n"; print_textarea($usehtmleditor, 25,70, 630, 400, "description"); use_html_editor("description"); echo "
\n"; if ($workshop->nattachments) { require_once($CFG->dirroot.'/lib/uploadlib.php'); for ($i=0; $i < $workshop->nattachments; $i++) { $iplus1 = $i + 1; $tag[$i] = get_string("attachment", "workshop")." $iplus1:"; } upload_print_form_fragment($workshop->nattachments,null,$tag,false,null,$course->maxbytes, $workshop->maxbytes,false); } echo "
\n"; echo " "; echo "
"; echo "
"; } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_user_assessments($workshop, $user, &$gradinggrade) { // Returns the number of assessments and a hyperlinked list of grading grades for the assessments made by this user if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { error("Course Module ID was incorrect"); } $gradinggrade = 0; $n = 0; $str = ''; if ($assessments = workshop_get_user_assessments_done($workshop, $user)) { foreach ($assessments as $assessment) { $gradinggrade += $assessment->gradinggrade; $n++; $str .= "id\">"; if ($assessment->timegraded) { if ($assessment->gradinggrade) { $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0); if ($assessment->teachergraded) { $str .= " [".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100)."]} "; } else { $str .= " (".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100).")} "; } } else { $str .= "<".number_format($assessment->grade * $workshop->grade / 100, 0)." (0)> "; } } else { $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0)." (-)} "; } $str .= '
'; } } else { $str ="0"; } if ($n = max($n, $workshop->ntassessments + $workshop->nsassessments)) { $gradinggrade = number_format($gradinggrade/$n * $workshop->gradinggrade / 100, 1); } return $str; } ////////////////////////////////////////////////////////////////////////////////////// function workshop_test_user_assessments($workshop, $user) { // see if user has assessed required number of assessments of teachers submissions... global $CFG; $result = true; $n = 0; $timenow =time(); if ($submissions = workshop_get_teacher_submissions($workshop)) { foreach ($submissions as $submission) { if ($assessment = workshop_get_submission_assessment($submission, $user)) { // ...the date stamp on the assessment should be in the past if ($assessment->timecreated < $timenow) { $n++; } } } if ($n < min($workshop->ntassessments, workshop_count_teacher_submissions($workshop))) { $result = false; } } return $result; } ?>