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("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)); $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.0, 6 => 1.5, 7 => 2.0, 8 => 3.0, 9 => 5.0, 10 => 7.5, 11=> 10.0, 12=>50.0); if (!defined("COMMENTSCALE")) { define("COMMENTSCALE", 20); } /*** Standard Moodle functions ****************** workshop_add_instance($workshop) workshop_cron () workshop_delete_instance($id) workshop_grades($workshopid) workshop_print_recent_activity(&$logs, $isteacher=false) workshop_update_instance($workshop) workshop_user_complete($course, $user, $mod, $workshop) workshop_user_outline($course, $user, $mod, $workshop) **********************************************/ /////////////////////////////////////////////////////////////////////////////// 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_cron () { // Function to be run periodically according to the moodle cron global $CFG, $USER; // Find all workshop notifications that have yet to be mailed out, and mails them $cutofftime = time() - $CFG->maxeditingtime; // look for new assessments if ($assessments = workshop_get_unmailed_assessments($cutofftime)) { $timenow = time(); foreach ($assessments as $assessment) { echo "Processing workshop assessment $assessment->id\n"; // only process the entry once if (! set_field("workshop_assessments", "mailed", "1", "id", "$assessment->id")) { echo "Could not update the mailed field for id $assessment->id\n"; } if (! $submission = get_record("workshop_submissions", "id", "$assessment->submissionid")) { echo "Could not find submission $assessment->submissionid\n"; continue; } if (! $workshop = get_record("workshop", "id", $submission->workshopid)) { echo "Could not find workshop id $submission->workshopid\n"; continue; } if (! $course = get_record("course", "id", $workshop->course)) { error("Could not find course id $workshop->course"); continue; } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { error("Course Module ID was incorrect"); continue; } if (! $submissionowner = get_record("user", "id", "$submission->userid")) { echo "Could not find user $submission->userid\n"; continue; } if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) { echo "Could not find user $assessment->userid\n"; continue; } if (! isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) { continue; // Not an active participant } if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) { continue; // Not an active participant } // don't sent self assessment if ($submissionowner->id == $assessmentowner->id) { continue; } $strworkshops = get_string("modulenameplural", "workshop"); $strworkshop = get_string("modulename", "workshop"); // it's an assessment, tell the submission owner $USER->lang = $submissionowner->lang; $sendto = $submissionowner; // "Your assignment \"$submission->title\" has been assessed by" if (isstudent($course->id, $assessmentowner->id)) { $msg = get_string("mail1", "workshop", $submission->title)." a $course->student.\n"; } else { $msg = get_string("mail1", "workshop", $submission->title). " $assessmentowner->firstname $assessmentowner->lastname.\n"; } // "The comments and grade can be seen in the workshop assignment '$workshop->name' $msg .= get_string("mail2", "workshop", $workshop->name)."\n\n"; $postsubject = "$course->shortname: $strworkshops: $workshop->name"; $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n"; $posttext .= "---------------------------------------------------------------------\n"; $posttext .= $msg; // "You can see it in your workshop assignment" $posttext .= get_string("mail3", "workshop").":\n"; $posttext .= " $CFG->wwwroot/mod/workshop/view.php?id=$cm->id\n"; $posttext .= "---------------------------------------------------------------------\n"; if ($sendto->mailformat == 1) { // HTML $posthtml = "

". "wwwroot/course/view.php?id=$course->id\">$course->shortname ->". "wwwroot/mod/workshop/index.php?id=$course->id\">$strworkshops ->". "wwwroot/mod/workshop/view.php?id=$cm->id\">$workshop->name

"; $posthtml .= "
"; $posthtml .= "

$msg

"; $posthtml .= "

".get_string("mail3", "workshop"). " wwwroot/mod/workshop/view.php?id=$cm->id\">$workshop->name.


"; } else { $posthtml = ""; } if (!$teacher = get_teacher($course->id)) { echo "Error: can not find teacher for course $course->id!\n"; } if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) { echo "Error: workshop cron: Could not send out mail for id $submission->id to user $sendto->id ($sendto->email)\n"; } } } // look for new assessments of resubmissions if ($assessments = workshop_get_unmailed_resubmissions($cutofftime)) { $timenow = time(); foreach ($assessments as $assessment) { echo "Processing workshop assessment $assessment->id\n"; // only process the entry once if (! set_field("workshop_assessments", "mailed", "1", "id", "$assessment->id")) { echo "Could not update the mailed field for id $assessment->id\n"; } if (! $submission = get_record("workshop_submissions", "id", "$assessment->submissionid")) { echo "Could not find submission $assessment->submissionid\n"; continue; } if (! $workshop = get_record("workshop", "id", $submission->workshopid)) { echo "Could not find workshop id $submission->workshopid\n"; continue; } if (! $course = get_record("course", "id", $workshop->course)) { error("Could not find course id $workshop->course"); continue; } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { error("Course Module ID was incorrect"); continue; } if (! $submissionowner = get_record("user", "id", "$submission->userid")) { echo "Could not find user $submission->userid\n"; continue; } if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) { echo "Could not find user $assessment->userid\n"; continue; } if (! isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) { continue; // Not an active participant } if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) { continue; // Not an active participant } $strworkshops = get_string("modulenameplural", "workshop"); $strworkshop = get_string("modulename", "workshop"); // it's a resubission assessment, tell the assessment owner to (re)assess $USER->lang = $assessmentowner->lang; $sendto = $assessmentowner; // "The assignment \"$submission->title\" is a revised piece of work. " $msg = get_string("mail8", "workshop", $submission->title)."\n"; // "Please assess it in the workshop assignment '$workshop->name' $msg .= get_string("mail9", "workshop", $workshop->name)."\n\n"; $postsubject = "$course->shortname: $strworkshops: $workshop->name"; $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n"; $posttext .= "---------------------------------------------------------------------\n"; $posttext .= $msg; // "You can assess it in your workshop assignment" $posttext .= get_string("mail10", "workshop").":\n"; $posttext .= " $CFG->wwwroot/mod/workshop/view.php?id=$cm->id\n"; $posttext .= "---------------------------------------------------------------------\n"; if ($sendto->mailformat == 1) { // HTML $posthtml = "

". "wwwroot/course/view.php?id=$course->id\">$course->shortname ->". "wwwroot/mod/workshop/index.php?id=$course->id\">$strworkshops ->". "wwwroot/mod/workshop/view.php?id=$cm->id\">$workshop->name

"; $posthtml .= "
"; $posthtml .= "

$msg

"; $posthtml .= "

".get_string("mail3", "workshop"). " wwwroot/mod/workshop/view.php?id=$cm->id\">$workshop->name.


"; } else { $posthtml = ""; } if (!$teacher = get_teacher($course->id)) { echo "Error: can not find teacher for course $course->id!\n"; } if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) { echo "Error: workshop cron: Could not send out mail for id $submission->id to user $sendto->id ($sendto->email)\n"; } } } // look for new comments if ($comments = workshop_get_unmailed_comments($cutofftime)) { $timenow = time(); foreach ($comments as $comment) { echo "Processing workshop comment $comment->id\n"; // only process the entry once if (! set_field("workshop_comments", "mailed", "1", "id", "$comment->id")) { echo "Could not update the mailed field for comment id $comment->id\n"; } if (! $assessment = get_record("workshop_assessments", "id", "$comment->assessmentid")) { echo "Could not find assessment $comment->assessmentid\n"; continue; } if (! $submission = get_record("workshop_submissions", "id", "$assessment->submissionid")) { echo "Could not find submission $assessment->submissionid\n"; continue; } if (! $workshop = get_record("workshop", "id", $submission->workshopid)) { echo "Could not find workshop id $submission->workshopid\n"; continue; } if (! $course = get_record("course", "id", $workshop->course)) { error("Could not find course id $workshop->course"); continue; } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { error("Course Module ID was incorrect"); continue; } if (! $submissionowner = get_record("user", "id", "$submission->userid")) { echo "Could not find user $submission->userid\n"; continue; } if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) { echo "Could not find user $assessment->userid\n"; continue; } if (! isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) { continue; // Not an active participant } if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) { continue; // Not an active participant } $strworkshops = get_string("modulenameplural", "workshop"); $strworkshop = get_string("modulename", "workshop"); // see if the submission owner needs to be told if ($comment->userid != $submission->userid) { $USER->lang = $submissionowner->lang; $sendto = $submissionowner; // "A comment has been added to the assignment \"$submission->title\" by if (isstudent($course->id, $assessmentowner->id)) { $msg = get_string("mail4", "workshop", $submission->title)." a $course->student.\n"; } else { $msg = get_string("mail4", "workshop", $submission->title)." $assessmentowner->firstname $assessmentowner->lastname.\n"; } // "The new comment can be seen in the workshop assignment '$workshop->name' $msg .= get_string("mail5", "workshop", $workshop->name)."\n\n"; $postsubject = "$course->shortname: $strworkshops: $workshop->name"; $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n"; $posttext .= "---------------------------------------------------------------------\n"; $posttext .= $msg; // "You can see it in your workshop assignment" $posttext .= get_string("mail3", "workshop").":\n"; $posttext .= " $CFG->wwwroot/mod/workshop/view.php?id=$cm->id\n"; $posttext .= "---------------------------------------------------------------------\n"; if ($sendto->mailformat == 1) { // HTML $posthtml = "

". "wwwroot/course/view.php?id=$course->id\">$course->shortname ->". "wwwroot/mod/workshop/index.php?id=$course->id\">$strworkshops ->". "wwwroot/mod/workshop/view.php?id=$cm->id\">$workshop->name

"; $posthtml .= "
"; $posthtml .= "

$msg

"; $posthtml .= "

".get_string("mail3", "workshop"). " wwwroot/mod/workshop/view.php?id=$cm->id\">$workshop->name .


"; } else { $posthtml = ""; } if (!$teacher = get_teacher($course->id)) { echo "Error: can not find teacher for course $course->id!\n"; } if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) { echo "Error: workshop cron: Could not send out mail for id $submission->id to user $sendto->id ($sendto->email)\n"; } } // see if the assessor needs to to told if ($comment->userid != $assessment->userid) { $USER->lang = $assessmentowner->lang; $sendto = $assessmentowner; // "A comment has been added to the assignment \"$submission->title\" by if (isstudent($course->id, $submissionowner->id)) { $msg = get_string("mail4", "workshop", $submission->title)." a $course->student.\n"; } else { $msg = get_string("mail4", "workshop", $submission->title). " $submissionowner->firstname $submissionowner->lastname.\n"; } // "The new comment can be seen in the workshop assignment '$workshop->name' $msg .= get_string("mail5", "workshop", $workshop->name)."\n\n"; $postsubject = "$course->shortname: $strworkshops: $workshop->name"; $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n"; $posttext .= "---------------------------------------------------------------------\n"; $posttext .= $msg; // "You can see it in your workshop assignment" $posttext .= get_string("mail3", "workshop").":\n"; $posttext .= " $CFG->wwwroot/mod/workshop/view.php?id=$cm->id\n"; $posttext .= "---------------------------------------------------------------------\n"; if ($sendto->mailformat == 1) { // HTML $posthtml = "

". "wwwroot/course/view.php?id=$course->id\">$course->shortname ->". "wwwroot/mod/workshop/index.php?id=$course->id\">$strworkshops ->". "wwwroot/mod/workshop/view.php?id=$cm->id\">$workshop->name

"; $posthtml .= "
"; $posthtml .= "

$msg

"; $posthtml .= "

".get_string("mail3", "workshop"). " wwwroot/mod/workshop/view.php?id=$cm->id\">$workshop->name.


"; } else { $posthtml = ""; } if (!$teacher = get_teacher($course->id)) { echo "Error: can not find teacher for course $course->id!\n"; } if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) { echo "Error: workshop cron: Could not send out mail for id $submission->id to user $sendto->id ($sendto->email)\n"; } if (! set_field("workshop_comments", "mailed", "1", "id", "$comment->id")) { echo "Could not update the mailed field for comment id $comment->id\n"; } } } } // look for new gradings if ($assessments = workshop_get_unmailed_graded_assessments($cutofftime)) { $timenow = time(); foreach ($assessments as $assessment) { echo "Processing workshop assessment $assessment->id (graded)\n"; // only process the entry once if (! set_field("workshop_assessments", "mailed", "1", "id", "$assessment->id")) { echo "Could not update the mailed field for id $assessment->id\n"; } if (! $submission = get_record("workshop_submissions", "id", "$assessment->submissionid")) { echo "Could not find submission $assessment->submissionid\n"; continue; } if (! $workshop = get_record("workshop", "id", $submission->workshopid)) { echo "Could not find workshop id $submission->workshopid\n"; continue; } if (! $course = get_record("course", "id", $workshop->course)) { error("Could not find course id $workshop->course"); continue; } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { error("Course Module ID was incorrect"); continue; } if (! $submissionowner = get_record("user", "id", "$submission->userid")) { echo "Could not find user $submission->userid\n"; continue; } if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) { echo "Could not find user $assessment->userid\n"; continue; } if (! isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) { continue; // Not an active participant } if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) { continue; // Not an active participant } $strworkshops = get_string("modulenameplural", "workshop"); $strworkshop = get_string("modulename", "workshop"); // it's a grading tell the assessment owner $USER->lang = $assessmentowner->lang; $sendto = $assessmentowner; // Your assessment of the assignment \"$submission->title\" has by reviewed $msg = get_string("mail6", "workshop", $submission->title).".\n"; // The comments given by the $course->teacher can be seen in the Workshop Assignment $msg .= get_string("mail7", "workshop", $course->teacher)." '$workshop->name'.\n\n"; $postsubject = "$course->shortname: $strworkshops: $workshop->name"; $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n"; $posttext .= "---------------------------------------------------------------------\n"; $posttext .= $msg; // "You can see it in your workshop assignment" $posttext .= get_string("mail3", "workshop").":\n"; $posttext .= " $CFG->wwwroot/mod/workshop/view.php?id=$cm->id\n"; $posttext .= "---------------------------------------------------------------------\n"; if ($sendto->mailformat == 1) { // HTML $posthtml = "

". "wwwroot/course/view.php?id=$course->id\">$course->shortname ->". "wwwroot/mod/workshop/index.php?id=$course->id\">$strworkshops ->". "wwwroot/mod/workshop/view.php?id=$cm->id\">$workshop->name

"; $posthtml .= "
"; $posthtml .= "

$msg

"; $posthtml .= "

".get_string("mail3", "workshop"). " wwwroot/mod/workshop/view.php?id=$cm->id\">$workshop->name.


"; } else { $posthtml = ""; } if (!$teacher = get_teacher($course->id)) { echo "Error: can not find teacher for course $course->id!\n"; } if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) { echo "Error: workshop cron: Could not send out mail for id $submission->id to user $sendto->id ($sendto->email)\n"; } } } return true; } /////////////////////////////////////////////////////////////////////////////// function workshop_delete_instance($id) { // Given an ID of an instance of this module, // this function will permanently delete the instance // and any data that depends on it. if (! $workshop = get_record("workshop", "id", "$id")) { return false; } // delete all the associated records in the workshop tables, start positive... $result = true; if (! delete_records("workshop_comments", "workshopid", "$workshop->id")) { $result = false; } if (! delete_records("workshop_grades", "workshopid", "$workshop->id")) { $result = false; } if (! delete_records("workshop_elements", "workshopid", "$workshop->id")) { $result = false; } if (! delete_records("workshop_assessments", "workshopid", "$workshop->id")) { $result = false; } if (! delete_records("workshop_submissions", "workshopid", "$workshop->id")) { $result = false; } if (! delete_records("workshop", "id", "$workshop->id")) { $result = false; } return $result; } /////////////////////////////////////////////////////////////////////////////// function workshop_grades($workshopid) { /// Must return an array of grades, indexed by user, and a max grade. /// only retruns grades in phase 6 global $CFG; if ($workshop = get_record("workshop", "id", $workshopid)) { if ($workshop->phase == 6) { if ($bestsubmissions = get_records_sql("SELECT userid, max(finalgrade) finalgrade FROM {$CFG->prefix}workshop_submissions WHERE workshopid = $workshopid GROUP BY userid")) { foreach ($bestsubmissions as $bestgrade) { $return->grades[$bestgrade->userid] = $bestgrade->finalgrade; } } } $return->maxgrade = $workshop->grade; } return $return; } /////////////////////////////////////////////////////////////////////////////// function workshop_print_recent_activity($course, $isteacher, $timestart) { global $CFG; // have a look for agreed assessments for this user (agree) $agreecontent = false; if (!$isteacher) { // teachers only need to see submissions if ($logs = workshop_get_agree_logs($course, $timestart)) { // got some, see if any belong to a visible module foreach ($logs as $log) { // Create a temp valid module structure (only need courseid, moduleid) $tempmod->course = $course->id; $tempmod->id = $log->workshopid; //Obtain the visible property from the instance if (instance_is_visible("workshop",$tempmod)) { $agreecontent = true; break; } } // if we got some "live" ones then output them if ($agreecontent) { $strftimerecent = get_string("strftimerecent"); print_headline(get_string("workshopagreedassessments", "workshop").":"); foreach ($logs as $log) { //Create a temp valid module structure (only need courseid, moduleid) $tempmod->course = $course->id; $tempmod->id = $log->workshopid; //Obtain the visible property from the instance if (instance_is_visible("workshop",$tempmod)) { $date = userdate($log->time, $strftimerecent); if (isteacher($course->id, $log->userid)) { echo "

$date - $log->firstname $log->lastname
"; } else { // don't break anonymous rule echo "

$date - A $course->student
"; } echo "\"wwwroot/mod/workshop/$log->url\">"; echo "$log->name"; echo "\"

"; } } } } } // have a look for new assessments for this user (assess) $assesscontent = false; if (!$isteacher) { // teachers only need to see submissions if ($logs = workshop_get_assess_logs($course, $timestart)) { // got some, see if any belong to a visible module foreach ($logs as $log) { // Create a temp valid module structure (only need courseid, moduleid) $tempmod->course = $course->id; $tempmod->id = $log->workshopid; //Obtain the visible property from the instance if (instance_is_visible("workshop",$tempmod)) { $assesscontent = true; break; } } // if we got some "live" ones then output them if ($assesscontent) { $strftimerecent = get_string("strftimerecent"); print_headline(get_string("workshopassessments", "workshop").":"); foreach ($logs as $log) { //Create a temp valid module structure (only need courseid, moduleid) $tempmod->course = $course->id; $tempmod->id = $log->workshopid; //Obtain the visible property from the instance if (instance_is_visible("workshop",$tempmod)) { $date = userdate($log->time, $strftimerecent); if (isteacher($course->id, $log->userid)) { echo "

$date - $log->firstname $log->lastname
"; } else { // don't break anonymous rule echo "

$date - A $course->student
"; } echo "\"wwwroot/mod/workshop/$log->url\">"; echo "$log->name"; echo "\"

"; } } } } } // have a look for new comments for this user (comment) $commentcontent = false; if (!$isteacher) { // teachers only need to see submissions if ($logs = workshop_get_comment_logs($course, $timestart)) { // got some, see if any belong to a visible module foreach ($logs as $log) { // Create a temp valid module structure (only need courseid, moduleid) $tempmod->course = $course->id; $tempmod->id = $log->workshopid; //Obtain the visible property from the instance if (instance_is_visible("workshop",$tempmod)) { $commentcontent = true; break; } } // if we got some "live" ones then output them if ($commentcontent) { $strftimerecent = get_string("strftimerecent"); print_headline(get_string("workshopcomments", "workshop").":"); foreach ($logs as $log) { //Create a temp valid module structure (only need courseid, moduleid) $tempmod->course = $course->id; $tempmod->id = $log->workshopid; //Obtain the visible property from the instance if (instance_is_visible("workshop",$tempmod)) { $date = userdate($log->time, $strftimerecent); echo "

$date - A $course->student
"; echo "\"wwwroot/mod/workshop/$log->url\">"; echo "$log->name"; echo "\"

"; } } } } } // have a look for new assessment gradings for this user (grade) $gradecontent = false; if ($logs = workshop_get_grade_logs($course, $timestart)) { // got some, see if any belong to a visible module foreach ($logs as $log) { // Create a temp valid module structure (only need courseid, moduleid) $tempmod->course = $course->id; $tempmod->id = $log->workshopid; //Obtain the visible property from the instance if (instance_is_visible("workshop",$tempmod)) { $gradecontent = true; break; } } // if we got some "live" ones then output them if ($gradecontent) { $strftimerecent = get_string("strftimerecent"); print_headline(get_string("workshopfeedback", "workshop").":"); foreach ($logs as $log) { //Create a temp valid module structure (only need courseid, moduleid) $tempmod->course = $course->id; $tempmod->id = $log->workshopid; //Obtain the visible property from the instance if (instance_is_visible("workshop",$tempmod)) { $date = userdate($log->time, $strftimerecent); echo "

$date - $course->teacher
"; echo "\"wwwroot/mod/workshop/$log->url\">"; echo "$log->name"; echo "\"

"; } } } } // have a look for new submissions (only show to teachers) (submit) $submitcontent = false; if ($isteacher) { if ($logs = workshop_get_submit_logs($course, $timestart)) { // got some, see if any belong to a visible module foreach ($logs as $log) { // Create a temp valid module structure (only need courseid, moduleid) $tempmod->course = $course->id; $tempmod->id = $log->workshopid; //Obtain the visible property from the instance if (instance_is_visible("workshop",$tempmod)) { $submitcontent = true; break; } } // if we got some "live" ones then output them if ($submitcontent) { $strftimerecent = get_string("strftimerecent"); print_headline(get_string("workshopsubmissions", "workshop").":"); foreach ($logs as $log) { //Create a temp valid module structure (only need courseid, moduleid) $tempmod->course = $course->id; $tempmod->id = $log->workshopid; //Obtain the visible property from the instance if (instance_is_visible("workshop",$tempmod)) { $date = userdate($log->time, $strftimerecent); echo "

$date - $log->firstname $log->lastname
"; echo "\"wwwroot/mod/workshop/$log->url\">"; echo "$log->name"; echo "\"

"; } } } } } return $agreecontent or $assesscontent or $commentcontent or $gradecontent or $submitcontent; } /////////////////////////////////////////////////////////////////////////////// function workshop_update_instance($workshop) { // Given an object containing all the necessary data, // (defined by the form in mod.html) this function // will update an existing instance with new data. $workshop->timemodified = time(); $workshop->deadline = make_timestamp($workshop->deadlineyear, $workshop->deadlinemonth, $workshop->deadlineday, $workshop->deadlinehour, $workshop->deadlineminute); $workshop->id = $workshop->instance; return update_record("workshop", $workshop); } /////////////////////////////////////////////////////////////////////////////// function workshop_user_complete($course, $user, $mod, $workshop) { if ($submission = workshop_get_student_submission($workshop, $user)) { if ($basedir = workshop_file_area($workshop, $user)) { if ($files = get_directory_list($basedir)) { $countfiles = count($files)." ".get_string("submissions", "workshop"); foreach ($files as $file) { $countfiles .= "; $file"; } } } print_simple_box_start(); //workshop_print_user_files($workshop, $user); echo "Submission was made but no way to show you yet."; //xxx //workshop_print_feedback($course, $submission); print_simple_box_end(); } else { print_string("notsubmittedyet", "workshop"); } } /////////////////////////////////////////////////////////////////////////////// function workshop_user_outline($course, $user, $mod, $workshop) { if ($submissions = workshop_get_user_submissions($workshop, $user)) { $result->info = count($submissions)." ".get_string("submissions", "workshop"); // workshop_get_user_submissions returns the newest one first foreach ($submissions as $submission) { $result->time = $submission->timecreated; break; } return $result; } return NULL; } ////////////////////////////////////////////////////////////////////////////////////// function workshop_get_participants($workshopid) { //Returns the users with data in one workshop //(users with records in workshop_submissions, workshop_assessments and workshop_comments, students) global $CFG; //Get students from workshop_submissions $st_submissions = get_records_sql("SELECT DISTINCT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}workshop_submissions s WHERE s.workshopid = '$workshopid' and u.id = s.userid"); //Get students from workshop_assessments $st_assessments = get_records_sql("SELECT DISTINCT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}workshop_assessments a WHERE a.workshopid = '$workshopid' and u.id = a.userid"); //Get students from workshop_comments $st_comments = get_records_sql("SELECT DISTINCT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}workshop_comments c WHERE c.workshopid = '$workshopid' and u.id = c.userid"); //Add st_assessments to st_submissions if ($st_assessments) { foreach ($st_assessments as $st_assessment) { $st_submissions[$st_assessment->id] = $st_assessment; } } //Add st_comments to st_submissions if ($st_comments) { foreach ($st_comments as $st_comment) { $st_submissions[$st_comment->id] = $st_comment; } } //Return st_submissions array (it contains an array of unique users) return ($st_submissions); } ////////////////////////////////////////////////////////////////////////////////////// /*** Functions for the workshop module ****** workshop_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) { workshop_count_all_submissions_for_assessment($workshop, $user) { workshop_count_assessments($submission) { 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($workshop, $user) { workshop_count_teacher_submissions($workshop) { workshop_count_teacher_submissions_for_assessment($workshop, $user) { 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) { workshop_file_area_name($workshop, $submission) { workshop_get_assessments($submission) { workshop_get_comments($assessment) { workshop_get_participants($workshopid) { workshop_get_student_assessments($workshop, $user) { workshop_get_student_submission($workshop, $user) { workshop_get_student_submission_assessments($workshop) { workshop_get_student_submissions($workshop) { workshop_get_submission_assessment($submission, $user) { 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) { workshop_get_user_submissions($workshop, $user) { workshop_get_users_done($workshop) { 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($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_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_tabbed_table($table) { workshop_print_time_to_deadline($time) { workshop_print_upload_form($workshop) { workshop_print_user_assessments($workshop, $user) { 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 = "id\">\n"; echo "\n"; echo "
\n"; echo "\n"; echo "

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

\n"; for ($i=2; $i>=0; $i--) { $numbers[$i] = $i; } choose_from_menu($numbers, "overallocation", "$workshop->overallocation", ""); echo "

\n"; echo "\n"; echo "
\n"; print_simple_box_end(); } echo "
"; print_simple_box_start("center"); print_heading_with_help(get_string("leaguetable", "workshop"), "leaguetable", "workshop"); echo "
\n"; echo "id\">\n"; echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "

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

"; unset($numbers); $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 "
\n"; print_simple_box_end(); // list any teacher submissions $table->head = array (get_string("title", "workshop"), get_string("submittedby", "workshop"), get_string("action", "workshop")); $table->align = array ("left", "left", "left"); $table->size = array ("*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; if ($submissions = workshop_get_teacher_submissions($workshop)) { foreach ($submissions as $submission) { $action = "id&sid=$submission->id\">". get_string("amendtitle", "workshop").""; // has user already assessed this submission if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id AND userid = $USER->id")) { $curtime = time(); if ($assessment->timecreated > $curtime) { // it's a "hanging" assessment $action .= " | id&sid=$submission->id\">". get_string("assess", "workshop").""; } elseif (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) { $action .= " | id&sid=$submission->id\">" .get_string("reassess", "workshop").""; } else { // there's still time left to edit... $action .= " | id&sid=$submission->id\">". get_string("edit", "workshop").""; } } else { // user has not graded this submission $action .= " | id&sid=$submission->id\">". get_string("assess", "workshop").""; } if ($assessments = workshop_get_assessments($submission)) { $action .= " | id&sid=$submission->id\">". get_string("listassessments", "workshop").""; } $action .= " | id&sid=$submission->id\">". get_string("delete", "workshop").""; $table->data[] = array(workshop_print_submission_title($workshop, $submission), $course->teacher, $action); } print_heading(get_string("studentsubmissions", "workshop", $course->teacher), "center"); print_table($table); } // list student assessments // Get all the students... if ($users = get_course_students($course->id, "u.firstname, u.lastname")) { $timenow = time(); print_heading(get_string("studentassessments", "workshop", $course->student)); unset($table); $table->head = array(get_string("name"), get_string("title", "workshop"), get_string("action", "workshop")); $table->align = array ("left", "left", "left"); $table->size = array ("*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; foreach ($users as $user) { // list the assessments which have been done (exclude the hot ones) if ($assessments = workshop_get_user_assessments_done($workshop, $user)) { $title =''; foreach ($assessments as $assessment) { if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { error("Workshop_list_submissions_for_admin: Submission record not found!"); } $title .= $submission->title; // test for allocated assesments which have not been done if ($assessment->timecreated < $timenow) { $title .= " {".number_format($assessment->grade, 0); } else { // assessment record created but user has not yet assessed this submission $title .= " {-"; } if ($assessment->timegraded) { $title .= "/".number_format($assessment->gradinggrade * 100 / COMMENTSCALE, 0)."%"; } $title .= "} "; if ($realassessments = workshop_count_user_assessments_done($workshop, $user)) { $action = "id&userid=$user->id\">". get_string("liststudentsassessments", "workshop")." ($realassessments)"; } else { $action =""; } } $table->data[] = array("$user->firstname $user->lastname", $title, $action); } } if (isset($table->data)) { print_table($table); } } // now the sudent submissions unset($table); switch ($order) { case "title" : $table->head = array("id&order=name\">". get_string("submittedby", "workshop")."", get_string("title", "workshop"), get_string("action", "workshop")); break; case "name" : $table->head = array (get_string("submittedby", "workshop"), "id&order=title\">". get_string("title", "workshop")."", get_string("action", "workshop")); break; } $table->align = array ("left", "left", "left"); $table->size = array ("*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; if ($submissions = workshop_get_student_submissions($workshop, $order)) { foreach ($submissions as $submission) { if (!$user = get_record("user", "id", $submission->userid)) { error("workshop_list_submissions_for_admin: failure to get user record"); } $action = "id&sid=$submission->id\">". get_string("amendtitle", "workshop").""; // has teacher already assessed this submission if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id AND userid = $USER->id")) { $curtime = time(); if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) { $action .= " | id&sid=$submission->id\">". get_string("reassess", "workshop").""; } else { // there's still time left to edit... $action .= " | id&sid=$submission->id\">". get_string("edit", "workshop").""; } } else { // user has not assessed this submission $action .= " | id&sid=$submission->id\">". get_string("assess", "workshop").""; } if ($nassessments = workshop_count_assessments($submission)) { $action .= " | id&sid=$submission->id\">". get_string("listassessments", "workshop")." ($nassessments)"; } $action .= " | id&sid=$submission->id\">". get_string("delete", "workshop").""; $table->data[] = array("$user->firstname $user->lastname", $submission->title. " ".workshop_print_submission_assessments($workshop, $submission, "teacher"). " ".workshop_print_submission_assessments($workshop, $submission, "student"), $action); } print_heading(get_string("studentsubmissions", "workshop", $course->student), "center"); print_table($table); } } ////////////////////////////////////////////////////////////////////////////////////// function workshop_list_teacher_assessments($workshop, $user) { global $CFG; if (! $course = get_record("course", "id", $workshop->course)) { error("Course is misconfigured"); } $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop")); $table->align = array ("LEFT", "LEFT", "LEFT"); $table->size = array ("*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; // get user's submissions if ($submissions = workshop_get_user_submissions($workshop, $user)) { foreach ($submissions as $submission) { // get the assessments if ($assessments = workshop_get_assessments($submission)) { foreach ($assessments as $assessment) { if (isteacher($workshop->course, $assessment->userid)) { // assessments by teachers only $action = "id&aid=$assessment->id\">". get_string("view", "workshop").""; // has teacher commented on teacher's assessment? shouldn't happen but leave test in if ($assessment->timegraded and ($timenow - $assessment->timegraded > $CFG->maxeditingtime)) { $comment = get_string("gradedbyteacher", "workshop", $course->teacher); } else { $comment = userdate($assessment->timecreated); } $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment); } } } } } if (isset($table->data)) { print_table($table); } else { echo "
".get_string("noassessmentsdone", "workshop")."
\n"; } } ////////////////////////////////////////////////////////////////////////////////////// function workshop_list_teacher_submissions($workshop, $user) { global $CFG; if (! $course = get_record("course", "id", $workshop->course)) { error("Course is misconfigured"); } $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop")); $table->align = array ("LEFT", "LEFT", "LEFT"); $table->size = array ("*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; // get the number of assessments this user has done $nassessed = count_records_select("workshop_assessments", "workshopid = $workshop->id AND userid = $user->id"); if ($nassessed < $workshop->ntassessments) { // if user has not assessed enough, set up "future" assessment records for this user for the teacher submissions... // ... first count the number of assessments for each teacher submission... if ($submissions = workshop_get_teacher_submissions($workshop)) { srand ((float)microtime()*1000000); // initialise random number generator foreach ($submissions as $submission) { $n = count_records("workshop_assessments", "submissionid", $submission->id); // ...OK to have zero, we add a small random number to randomise things... $nassessments[$submission->id] = $n + rand(0, 99) / 100; } // ...put the submissions with the lowest number of assessments first... asort($nassessments); reset($nassessments); foreach ($nassessments as $submissionid => $n) { // break out of loop when we allocated enough assessments... $submission = get_record("workshop_submissions", "id", $submissionid); // ... provided the user has NOT already assessed that submission... if (!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; if (!$assessment->id = insert_record("workshop_assessments", $assessment)) { error("Could not insert workshop assessment!"); } $nassessed++; if ($nassessed >= $workshop->ntassessments) { break; } } } } } // now list user's assessments (but only list those which come from teacher submissions) if ($assessments = workshop_get_user_assessments($workshop, $user)) { $timenow = time(); foreach ($assessments as $assessment) { if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { error ("workshop_list_teacher_submissions: unable to get submission"); } // submission from a teacher? if (isteacher($workshop->course, $submission->userid)) { $comment = ''; // user assessment has three states: record created but not assessed (date created in the future); // just assessed but still editable; and "static" (may or may not have been graded by teacher, that // is shown in the comment) if ($assessment->timecreated> $timenow) { // user needs to assess this submission $action = "id&sid=$submission->id\">". get_string("assess", "workshop").""; } elseif (($timenow - $assessment->timecreated) < $CFG->maxeditingtime) { // there's still time left to edit... $action = "id&sid=$submission->id\">". get_string("edit", "workshop").""; } else { $action = "id&aid=$assessment->id\">" .get_string("view", "workshop").""; } // see if teacher has graded assessment if ($assessment->timegraded and (($timenow - $assessment->timegraded) > $CFG->maxeditingtime)) { $comment .= get_string("thereisfeedbackfromtheteacher", "workshop", $course->teacher); } $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment); } } } print_table($table); } ////////////////////////////////////////////////////////////////////////////////////// function workshop_list_unassessed_student_submissions($workshop, $user) { // list the student submissions not assessed by this user global $CFG; $table->head = array (get_string("title", "workshop"), get_string("submittedby", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop")); $table->align = array ("LEFT", "LEFT", "LEFT", "LEFT"); $table->size = array ("*", "*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; if ($submissions = workshop_get_student_submissions($workshop)) { foreach ($submissions as $submission) { $comment = ""; // see if user already graded this assessment if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id AND userid = $user->id")) { $timenow = time(); if (($timenow - $assessment->timecreated < $CFG->maxeditingtime)) { // last chance salon $submissionowner = get_record("user", "id", $submission->userid); $action = "id&sid=$submission->id\">". get_string("edit", "workshop").""; $table->data[] = array(workshop_print_submission_title($workshop, $submission), $submissionowner->firstname." ".$submissionowner->lastname, $action, $comment); } } else { // no assessment $submissionowner = get_record("user", "id", $submission->userid); $action = "id&sid=$submission->id\">". get_string("assess", "workshop").""; $table->data[] = array(workshop_print_submission_title($workshop, $submission), $submissionowner->firstname." ".$submissionowner->lastname, $action, $comment); } } if (isset($table->data)) { print_table($table); } } } ////////////////////////////////////////////////////////////////////////////////////// function workshop_list_unassessed_teacher_submissions($workshop, $user) { // list the teacher submissions not assessed by this user global $CFG; $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop")); $table->align = array ("LEFT", "LEFT", "LEFT"); $table->size = array ("*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; if ($submissions = workshop_get_teacher_submissions($workshop)) { foreach ($submissions as $submission) { $comment = ""; // see if user already graded this assessment if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id AND userid = $user->id")) { $timenow = time(); if (($timenow - $assessment->timecreated < $CFG->maxeditingtime)) { // last chance salon $action = "id&sid=$submission->id\">". get_string("edit", "workshop").""; $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment); } } else { // no assessment $action = "id&sid=$submission->id\">". get_string("assess", "workshop").""; $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment); } } if (isset($table->data)) { print_table($table); } } } ////////////////////////////////////////////////////////////////////////////////////// function workshop_list_ungraded_assessments($workshop, $stype) { global $CFG; // lists all the assessments of student submissions for grading by teacher $table->head = array (get_string("title", "workshop"), get_string("submittedby", "workshop"), get_string("assessor", "workshop"), get_string("timeassessed", "workshop"), get_string("action", "workshop")); $table->align = array ("LEFT", "LEFT", "LEFT", "LEFT"); $table->size = array ("*", "*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; $timenow = time(); switch ($stype) { case "student" : $assessments = workshop_get_ungraded_assessments_student($workshop); break; case "teacher" : $assessments = workshop_get_ungraded_assessments_teacher($workshop); break; } if ($assessments) { foreach ($assessments as $assessment) { if (!isteacher($workshop->course, $assessment->userid)) { // don't let teacher grade their own assessments if (($timenow - $assessment->timegraded) < $CFG->maxeditingtime) { $action = "id&stype=$stype&aid=$assessment->id\">". get_string("edit", "workshop").""; } else { $action = "id&stype=$stype&aid=$assessment->id\">". get_string("grade", "workshop").""; } $submission = get_record("workshop_submissions", "id", $assessment->submissionid); $submissionowner = get_record("user", "id", $submission->userid); $assessor = get_record("user", "id", $assessment->userid); $table->data[] = array(workshop_print_submission_title($workshop, $submission), $submissionowner->firstname." ".$submissionowner->lastname, $assessor->firstname." ".$assessor->lastname, userdate($assessment->timecreated), $action); } } if (isset($table->data)) { print_table($table); } } } ////////////////////////////////////////////////////////////////////////////////////// function workshop_list_user_submissions($workshop, $user) { global $CFG; $timenow = time(); $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("submitted", "assignment"), get_string("assessments", "workshop")); $table->align = array ("LEFT", "LEFT", "LEFT", "LEFT"); $table->size = array ("*", "*", "*", "*"); $table->cellpadding = 2; $table->cellspacing = 0; if ($submissions = workshop_get_user_submissions($workshop, $user)) { foreach ($submissions as $submission) { // allow user to delete a submission if it's warm if ($submission->timecreated > ($timenow - $CFG->maxeditingtime)) { $action = "id&sid=$submission->id\">". get_string("delete", "workshop").""; } else { $action = ''; } $n = count_records_select("workshop_assessments", "submissionid = $submission->id AND timecreated < ($timenow - $CFG->maxeditingtime)"); $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, userdate($submission->timecreated), $n); } print_table($table); } } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_assessment($workshop, $assessment = false, $allowchanges = false, $showcommentlinks = false, $returnto = '') { // $allowchanges added 14/7/03 // $returnto added 28/8/03 global $CFG, $THEME, $USER, $WORKSHOP_SCALES, $WORKSHOP_EWEIGHTS; 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"); } $timenow = time(); // reset the internal flags if ($assessment) { $showgrades = false; } else { // if no assessment, i.e. specimen grade form always show grading scales $showgrades = true; } if ($assessment) { // set the internal flag is necessary if ($allowchanges or !$workshop->agreeassessments or !$workshop->hidegrades or $assessment->timeagreed) { $showgrades = true; } echo "
cellcontent\">\n"; if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { error ("Workshop_print_assessment: Submission record not found"); } echo workshop_print_submission_title($workshop, $submission); echo "

\n"; // see if this is a pre-filled assessment for a re-submission... if ($assessment->resubmission) { // ...and print an explaination print_heading(get_string("assessmentofresubmission", "workshop")); } // print agreement time if the workshop requires peer agreement if ($workshop->agreeassessments and $assessment->timeagreed) { echo "

".get_string("assessmentwasagreedon", "workshop", userdate($assessment->timeagreed)); } // first print any comments on this assessment if ($comments = workshop_get_comments($assessment)) { echo "\n"; $firstcomment = TRUE; foreach ($comments as $comment) { echo "\n"; } echo "
cellheading2\">

". get_string("commentby","workshop")." "; if (isteacher($workshop->course, $comment->userid)) { echo $course->teacher; } elseif ($assessment->userid == $comment->userid) { print_string("assessor", "workshop"); } else { print_string("authorofsubmission", "workshop"); } echo " ".get_string("on", "workshop", userdate($comment->timecreated))."

\n"; echo text_to_html($comment->comments)." \n"; // add the links if needed if ($firstcomment and $showcommentlinks and !$assessment->timeagreed) { // show links depending on who doing the viewing $firstcomment = FALSE; if (isteacher($workshop->course, $USER->id) and ($comment->userid != $USER->id)) { echo "

id&aid=$assessment->id\">". get_string("reply", "workshop")."\n"; } elseif (($comment->userid ==$USER->id) and (($timenow - $comment->timecreated) < $CFG->maxeditingtime)) { echo "

id&cid=$comment->id\">". get_string("edit", "workshop")."\n"; if ($USER->id == $submission->userid) { echo " | id&aid=$assessment->id\">". get_string("agreetothisassessment", "workshop")."\n"; } } elseif (($comment->userid != $USER->id) and (($USER->id == $assessment->userid) or ($USER->id == $submission->userid))) { echo "

id&aid=$assessment->id\">". get_string("reply", "workshop")."\n"; if ($USER->id == $submission->userid) { echo " | id&aid=$assessment->id\">". get_string("agreetothisassessment", "workshop")."\n"; } } } echo "

\n"; } // only show the grade if grading strategy > 0 and the grade is positive if ($showgrades and $workshop->gradingstrategy and $assessment->grade >= 0) { echo "

".get_string("thegradeis", "workshop").": ".number_format($assessment->grade, 2)." (". get_string("maximumgrade")." ".number_format($workshop->grade, 0).")

\n"; } } // now print the grading form with the teacher's comments if any // FORM is needed for Mozilla browsers, else radio bttons are not checked ?>
\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 "

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

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

".text_to_html($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 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("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 "
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"; 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"; 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"; 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"; // only show the grading grade if it's the teacher if (isteacher($course->id)) { 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:".text_to_html($elements[$i]->description). "

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

cellheading2\" align=\"center\">".get_string("select", "workshop")."cellheading2\">". get_string("criterion","workshop")."
".text_to_html($rubrics[$j]->description)."

". get_string("feedback").":

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

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

". get_string("reasonforadjustment", "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, 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 ($assessments =workshop_get_user_assessments($workshop, $user)) { foreach ($assessments as $assessment) { 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_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_assignment_info($workshop) { 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 $strdifference = format_time($workshop->deadline - time()); if (($workshop->deadline - time()) < 0) { $strdifference = "$strdifference"; } $strduedate = userdate($workshop->deadline)." ($strdifference)"; print_simple_box_start("center"); print_heading($workshop->name, "center"); print_simple_box_start("center"); echo "".get_string("duedate", "assignment").": $strduedate
"; echo "".get_string("maximumgrade").": $workshop->grade
"; echo "".get_string("detailsofassessment", "workshop").": id&action=displaygradingform\">". get_string("specimenassessmentform", "workshop")."
"; print_simple_box_end(); echo "
"; echo format_text($workshop->description, $workshop->format); print_simple_box_end(); echo "
"; } ////////////////////////////////////////////////////////////////////////////////////// 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_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"); } $nentries = $workshop->showleaguetable; if ($nentries == 99) { $nentries = 999999; // a large number } if ($workshop->anonymous and isstudent($course->id)) { $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, "grade")) { $n = 1; foreach ($submissions as $submission) { if (!$user = get_record("user", "id", $submission->userid)) { error("Print league table: user not found"); } if ($workshop->anonymous and isstudent($course->id)) { $table->data[] = array(workshop_print_submission_title($workshop, $submission), workshop_print_submission_assessments($workshop, $submission, "teacher"), workshop_print_submission_assessments($workshop, $submission, "student"), number_format(($workshop->teacherweight * $submission->teachergrade + $workshop->peerweight * $submission->peergrade) / ($workshop->teacherweight + $workshop->peerweight), 1)) ; } else { $table->data[] = array(workshop_print_submission_title($workshop, $submission), $user->firstname." ". $user->lastname, workshop_print_submission_assessments($workshop, $submission, "teacher"), workshop_print_submission_assessments($workshop, $submission, "student"), number_format(($workshop->teacherweight * $submission->teachergrade + $workshop->peerweight * $submission->peergrade) / ($workshop->teacherweight + $workshop->peerweight), 1)) ; } $n++; if ($n > $nentries) { break; } } print_heading(get_string("leaguetable", "workshop")); print_table($table); } } ////////////////////////////////////////////////////////////////////////////////////// function workshop_print_submission_assessments($workshop, $submission, $type) { // Returns the teacher or peer grade and a hyperlinked list of grades for this submission $str = ''; if ($assessments = workshop_get_assessments($submission)) { switch ($type) { case "teacher" : if ($submission->teachergrade) { // if there's a final teacher's grade... $str = "$submission->teachergrade "; } foreach ($assessments as $assessment) { if (isteacher($workshop->course, $assessment->userid)) { $str .= "id&aid=$assessment->id\">"; if ($assessment->donotuse) { $str .= "<"; } else { $str .= "["; } $str .= number_format($assessment->grade, 0); if ($assessment->gradinggrade) { // funny, teacher is grading self! $str .= "/".number_format($assessment->gradinggrade*100/COMMENTSCALE, 0)."%"; } if ($assessment->donotuse) { $str .= "> "; } else { $str .= "] "; } } } break; case "student" : if ($submission->peergrade) { // if there's a final peer grade... $str = "$submission->peergrade "; } foreach ($assessments as $assessment) { if (isstudent($workshop->course, $assessment->userid)) { $str .= "id&aid=$assessment->id\">"; if ($assessment->donotuse) { $str .= "<"; } else { $str .= "{"; } $str .= number_format($assessment->grade, 0); if ($assessment->gradinggrade) { $str .= "/".number_format($assessment->gradinggrade*100/COMMENTSCALE, 0)."%"; } if ($assessment->donotuse) { $str .= "> "; } else { $str .= "} "; } } } break; } } if (!$str) { $str = " "; // be kind to Mozilla browsers! } 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_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; 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"; } } else { $tabcontents[$key] = "$name"; } } } if (empty($tabs->width)) { $tabs->width = "80%"; } if (empty($tabs->cellpadding)) { $tabs->cellpadding = "5"; } // print_simple_box_start("center", "$table->width", "#ffffff", 0); echo "cellpadding\" cellspacing=\"0\" class=\"generaltable\">\n"; if (!empty($tabs->names)) { echo ""; echo "\n"; foreach ($tabcontents as $key => $tab) { if (isset($align[$key])) { $alignment = "align=\"$align[$key]\""; } else { $alignment = "align=\"center\""; } if (isset($size[$key])) { $width = "width=\"$size[$key]\""; } else { $width = ""; } if (isset($wrap[$key])) { $wrapping = "no wrap"; } else { $wrapping = ""; } if ($key == $tabs->highlight) { echo "\n"; } else { echo "\n"; } echo "\n"; } echo "\n"; } else { echo "\n"; } // bottom stripe $ncells = count($tabs->names)*2 +1; $height = 2; echo "\n"; echo "
". "wwwroot/pix/spacer.gif\" alt=\"\">cellheading2\">$tabcellheading\">$tab". "wwwroot/pix/spacer.gif\" alt=\"\">
No names specified
cellheading2\">". "wwwroot/pix/spacer.gif\" alt=\"\">
\n"; // print_simple_box_end(); return true; } 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 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"); } echo "
"; echo "
"; echo " maxbytes\">"; echo " id\">"; echo "".get_string("title", "workshop").":

\n"; echo " "; echo " "; echo "
"; echo "
"; } ////////////////////////////////////////////////////////////////////////////////////// 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_done($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\">"; if ($assessment->donotuse) { $str .= "<".number_format($assessment->grade, 0)."> "; } else { $str .= number_format($assessment->grade, 0)." "; } } } $str .= ")"; } else { $str ="0"; } 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; } ?>