dirroot/files/mimetypes.php"); /*** Constants **********************************/ $WORKSHOP_TYPE = array (0 => get_string("notgraded", "workshop"), 1 => get_string("accumulative", "workshop"), 2 => get_string("errorbanded", "workshop"), 3 => get_string("criteria", "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' => 'yes', 'end' => 'no'), 1 => array( 'name' => get_string("scalepresent", "workshop"), 'type' => 'radio', 'size' => 2, 'start' => 'present', 'end' => 'absent'), 2 => array( 'name' => get_string("scalecorrect", "workshop"), 'type' => 'radio', 'size' => 2, 'start' => 'correct', 'end' => 'incorrect'), 3 => array( 'name' => get_string("scalegood3", "workshop"), 'type' => 'radio', 'size' => 3, 'start' => 'good', 'end' => 'poor'), 4 => array( 'name' => get_string("scaleexcellent4", "workshop"), 'type' => 'radio', 'size' => 4, 'start' => 'excellent', 'end' => 'very poor'), 5 => array( 'name' => get_string("scaleexcellent5", "workshop"), 'type' => 'radio', 'size' => 5, 'start' => 'excellent', 'end' => 'very poor'), 6 => array( 'name' => get_string("scaleexcellent7", "workshop"), 'type' => 'radio', 'size' => 7, 'start' => 'excellent', 'end' => 'very poor'), 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)); $WORKSHOP_EWEIGHTS = array( 0 => -4.0, 1 => -2.0, 2 => -1.5, 3 => -1.0, 4 => -0.75, 5 => -0.5, 6 => -0.25, 7 => 0.0, 8 => 0.25, 9 => 0.5, 10 => 0.75, 11=> 1.0, 12 => 1.5, 13=> 2.0, 14 => 4.0); $WORKSHOP_FWEIGHTS = array( 0 => 0, 1 => 0.1, 2 => 0.25, 3 => 0.5, 4 => 0.75, 5 => 1, 6 => 1.5, 7 => 2.0, 8 => 3.0, 9 => 5.0, 10 => 7.5, 11=> 10.0); if (!defined("COMMENTSCALE")) { define("COMMENTSCALE", 20); } /*** Standard Moodle functions ****************** function workshop_add_instance($workshop) function workshop_update_instance($workshop) function workshop_delete_instance($id) function workshop_user_outline($course, $user, $mod, $workshop) function workshop_user_complete($course, $user, $mod, $workshop) function workshop_cron () function workshop_print_recent_activity(&$logs, $isteacher=false) function workshop_grades($workshopid) **********************************************/ function workshop_add_instance($workshop) { // Given an object containing all the necessary data, // (defined by the form in mod.html) this function // will create a new instance and return the id number // of the new instance. $workshop->timemodified = time(); $workshop->deadline = make_timestamp($workshop->deadlineyear, $workshop->deadlinemonth, $workshop->deadlineday, $workshop->deadlinehour, $workshop->deadlineminute); return insert_record("workshop", $workshop); } 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"; // get the assignment elements... if (!$elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC")) { print_string("noteonassignmentelements", "workshop"); } else { foreach ($elementsraw as $element) { $elements[] = $element; // to renumber index 0,1,2... } } 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"; 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"; 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"; 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 "
cellheading2\">
".get_string("assessment", "workshop"). "

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

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

". get_string("feedback").":

\n"; if ($allowchanges) { echo " \n"; } else { echo text_to_html($grades[$i]->feedback); } echo "
cellheading2\"> 

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

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

Weight: " .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 text_to_html($grades[$i]->feedback); } echo "
cellheading2\"> 

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

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

Weight: " .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 text_to_html($grades[$i]->feedback); } } echo " 
cellheading2\"> 
".get_string("numberofnegativeitems", "workshop")."$negativecount
cellheading2\"> 
\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")."
$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("adjustment", "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 "
cellheading2\"> cellheading2\">". get_string("criterion","workshop")."cellheading2\">".get_string("select", "workshop")."cellheading2\">".get_string("suggestedgrade", "workshop")."
$iplus1".text_to_html($elements[$i]->description)."{$elements[$i]->maxscore}
\n"; echo "

\n"; } // end of outer switch // now get the general comment (present in all types) echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; $timenow = time(); // now show the teacher's comment if available... if ($assessment->timegraded and (($timenow - $assessment->timegraded) > $CFG->maxeditingtime)) { echo "\n"; 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("adjustment", "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("generalcomment", "workshop").":

\n"; if ($allowchanges) { echo " \n"; } else { if ($assessment) { if (isset($assessment->generalcomment)) { echo text_to_html($assessment->generalcomment); } } else { print_string("yourfeedbackgoeshere", "workshop"); } } echo " 
cellheading2\"> 

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

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

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

\n"; echo number_format($assessment->gradinggrade*100/COMMENTSCALE,0)."%"; echo " 
cellheading2\"> 
\n"; if ($assessment) { if ($allowchanges) { echo "\n"; } // ...if user is author, assessment not agreed and there are no comments and it's not self assessment then show some buttons if (($submission->userid == $USER->id) and !$assessment->timeagreed and !$comments and $submission->userid != $assessment->userid) { echo "\n"; echo "\n"; } } echo "
"; echo "\n"; } function workshop_print_assessments_for_admin($workshop, $submission) { 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", $user->firstname." ".$user->lastname)."

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

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


\n"; } } } 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_feedback($course, $submission) { global $CFG, $THEME, $RATING; if (! $teacher = get_record("user", "id", $submission->teacher)) { error("Weird workshop error"); } echo "\n
"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "\n
body\" WIDTH=35 VALIGN=TOP>"; print_user_picture($teacher->id, $course->id, $teacher->picture); echo "cellheading\">$teacher->firstname $teacher->lastname"; echo "  ".userdate($submission->timemarked).""; echo "
cellcontent\">"; echo "

"; if ($submission->grade) { echo get_string("grade").": $submission->grade"; } else { echo get_string("nograde"); } echo "

"; echo text_to_html($submission->assessorcomment); echo "
"; echo "
"; } function workshop_print_submission_assessments($workshop, $submission, $type) { // Returns the teacher or peer grade and a hyperlinked list of grades for this submission if ($assessments = workshop_get_assessments($submission)) { switch ($type) { case "teacher" : $str = "$submission->teachergrade ("; foreach ($assessments as $assessment) { if (isteacher($workshop->course, $assessment->userid)) { $str .= "id&aid=$assessment->id\">"; $str .= number_format($assessment->grade, 1)." "; } } break; case "student" : $str = "$submission->peergrade ("; foreach ($assessments as $assessment) { if (isstudent($workshop->course, $assessment->userid)) { $str .= "id&aid=$assessment->id\">"; $str .= number_format($assessment->grade, 1)." "; } } break; } $str .= ")"; } else { $str ="0"; } return $str; } function workshop_print_submission_title($workshop, $submission) { // Arguments are objects global $CFG; if (!$submission->timecreated) { // a "no submission" return $submission->title; } $filearea = workshop_file_area_name($workshop, $submission); if ($basedir = workshop_file_area($workshop, $submission)) { if (list($file) = get_directory_list($basedir)) { $icon = mimeinfo("icon", $file); if ($CFG->slasharguments) { $ffurl = "file.php/$filearea/$file"; } else { $ffurl = "file.php?file=/$filearea/$file"; } return "wwwroot/files/pix/$icon\" HEIGHT=16 WIDTH=16 BORDER=0 ALT=\"File\">". " wwwroot/$ffurl\">$submission->title"; } } } function workshop_print_user_assessments($workshop, $user) { // Returns the number of assessments and a hyperlinked list of grading grades for the assessments made by this user if ($assessments = workshop_get_user_assessments($workshop, $user)) { $n = count($assessments); $str = "$n ("; foreach ($assessments as $assessment) { if ($assessment->timegraded) { $gradingscaled = intval($assessment->gradinggrade * $workshop->grade / COMMENTSCALE); $str .= "id&aid=$assessment->id\">"; $str .= "$gradingscaled "; } else { $str .= "id&aid=$assessment->id\">"; $str .= "- "; } } $str .= ")"; } else { $str ="0"; } return $str; } 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) { // Arguments are objects, needs title coming in echo "
"; echo "
"; echo " maxbytes\">"; echo " id\">"; echo get_string("title", "workshop")."

\n"; echo " "; echo " "; echo "
"; echo "
"; } function workshop_test_user_assessments($workshop, $user) { // see if user has passed the required number of assessments of teachers submissions global $CFG; $result = TRUE; $n = 0; $timenow =time(); if ($workshop->ntassessments) { // they have to pass some! if ($submissions = workshop_get_teacher_submissions($workshop)) { foreach ($submissions as $submission) { if ($assessment = workshop_get_submission_assessment($submission, $user)) { if (($assessment->gradinggrade >= COMMENTSCALE*0.4) and (($timenow - $assessment->timegraded) > $CFG->maxeditingtime)) { $n++; } } } } if ($n < min($workshop->ntassessments, workshop_count_teacher_submissions($workshop))) { $result = FALSE; } } return $result; } ?>