From dbda4a92ad53c6efdd09a417674eb0e5848a4b58 Mon Sep 17 00:00:00 2001 From: rkingdon Date: Fri, 18 Jun 2004 09:24:20 +0000 Subject: [PATCH] Split lib.php into locallib.php and lib.php; Fixed bug # 1435; Possibly fixed bug #1489 --- mod/workshop/assessments.php | 18 +- mod/workshop/index.php | 3 +- mod/workshop/lib.php | 2800 +--------------------------------- mod/workshop/locallib.php | 2714 ++++++++++++++++++++++++++++++++ mod/workshop/submissions.php | 1 + mod/workshop/upload.php | 23 +- mod/workshop/view.php | 9 +- 7 files changed, 2797 insertions(+), 2771 deletions(-) create mode 100644 mod/workshop/locallib.php diff --git a/mod/workshop/assessments.php b/mod/workshop/assessments.php index 43597a6750..eb0d78b067 100644 --- a/mod/workshop/assessments.php +++ b/mod/workshop/assessments.php @@ -28,7 +28,8 @@ ************************************************/ require("../../config.php"); - require("lib.php"); + require("lib.php"); + require("locallib.php"); optional_variable($id); // Course Module ID optional_variable($a); // workshop ID @@ -235,7 +236,7 @@ // show assessment and allow changes workshop_print_assessment($workshop, $assessment, true, $allowcomments, $_SERVER["HTTP_REFERER"]); - } + } /*************** display grading form (viewed by student) *********************************/ @@ -293,8 +294,8 @@ if (!isteacher($course->id)) { error("Only teachers can look at this page"); } - - $count = count_records("workshop_grades", "workshop", $workshop->id); + + $count = count_records("workshop_grades", "workshopid", $workshop->id); if ($workshop->phase > 1 and $count) { notify(get_string("warningonamendingelements", "workshop")); } @@ -712,14 +713,17 @@ } // first get the assignment elements for maxscores and weights... - if (!$elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC")) { + $elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC"); + if (count($elementsraw) < $workshop->nelements) { print_string("noteonassignmentelements", "workshop"); } - else { + if ($elementsraw) { foreach ($elementsraw as $element) { $elements[] = $element; // to renumber index 0,1,2... } - } + } else { + $elements = null; + } $timenow = time(); // don't fiddle about, delete all the old and add the new! diff --git a/mod/workshop/index.php b/mod/workshop/index.php index 0d2e169481..8f8fad3d0b 100644 --- a/mod/workshop/index.php +++ b/mod/workshop/index.php @@ -1,7 +1,8 @@ dirroot/files/mimetypes.php"); /*** Constants **********************************/ @@ -991,492 +996,6 @@ function workshop_get_participants($workshopid) { 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")."
pixpath/t/right.gif\"> $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); - echo "

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

\n"; - } - } - - -////////////////////////////////////////////////////////////////////////////////////// -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 "pixpath/f/$icon\" HEIGHT=16 WIDTH=16 BORDER=0 ALT=\"File\">". - " id\" HREF=\"$CFG->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; - } - -function workshop_get_recent_mod_activity(&$activities, &$index, $sincetime, $courseid, - $workshop="0", $user="", $groupid="") { - // Returns all workshop posts since a given time. If workshop is specified then - // this restricts the results - - global $CFG; - - if ($workshop) { - $workshopselect = " AND cm.id = '$workshop'"; - } else { - $workshopselect = ""; - } - - if ($user) { - $userselect = " AND u.id = '$user'"; - } else { - $userselect = ""; - } - - $posts = get_records_sql("SELECT s.*, u.firstname, u.lastname, - u.picture, cm.instance, w.name, cm.section - FROM {$CFG->prefix}workshop_submissions s, - {$CFG->prefix}user u, - {$CFG->prefix}course_modules cm, - {$CFG->prefix}workshop w - WHERE s.timecreated > '$sincetime' $workshopselect - AND s.userid = u.id $userselect - AND w.course = '$courseid' $groupselect - AND cm.instance = w.id - AND cm.course = w.course - AND s.workshopid = w.id - ORDER BY s.id"); - - - if (empty($posts)) { - return; - } - - foreach ($posts as $post) { - - if (empty($groupid) || ismember($groupid, $post->userid)) { - $tmpactivity->type = "workshop"; - $tmpactivity->defaultindex = $index; - $tmpactivity->instance = $post->instance; - $tmpactivity->name = $post->name; - $tmpactivity->section = $post->section; - - $tmpactivity->content->id = $post->id; - $tmpactivity->content->title = $post->title; - - $tmpactivity->user->userid = $post->userid; - $tmpactivity->user->fullname = fullname($post); - $tmpactivity->user->picture = $post->picture; - - $tmpactivity->timestamp = $post->timecreated; - $activities[] = $tmpactivity; - - $index++; - } - } - - return; -} - -function workshop_print_recent_mod_activity($activity, $course, $detail=false) { - - global $CFG; - - echo ''; - - if ($activity->content->parent) { - $openformat = ""; - $closeformat = ""; - } else { - $openformat = ""; - $closeformat = ""; - } - - echo ""; - echo "
cellcontent2\" class=\"workshoppostpicture\" width=\"35\" valign=\"top\">"; - print_user_picture($activity->user->userid, $course, $activity->user->picture); - echo "$openformat"; - - if ($detail) { - echo "modpixpath/$activity->type/icon.gif\" ". - "height=16 width=16 alt=\"$activity->name\"> "; - } - echo "wwwroot/mod/workshop/view.php?" - . "#" . $activity->content->id . "\">".$activity->content->title; - - echo "$closeformat"; - - echo "
"; - echo "wwwroot/user/view.php?id=" . $activity->user->userid . "&course=" . "$course\">" - . $activity->user->fullname . ""; - echo " - " . userdate($activity->timestamp) . "
"; - - return; - -} - - - ?> diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php new file mode 100644 index 0000000000..103725c74a --- /dev/null +++ b/mod/workshop/locallib.php @@ -0,0 +1,2714 @@ +\n"; + if ($nothing) { + $output .= "