From 5c2ba38c45e1c165bda82326f196682b41f63209 Mon Sep 17 00:00:00 2001 From: rkingdon Date: Thu, 8 May 2003 20:24:41 +0000 Subject: [PATCH] version 1.1 with peer agreement --- mod/workshop/assessments.php | 193 ++++++++++-- mod/workshop/db/mysql.php | 25 +- mod/workshop/db/mysql.sql | 26 +- mod/workshop/lib.php | 554 ++++++++++++++++++++++++++--------- mod/workshop/mod.html | 64 +++- mod/workshop/submissions.php | 4 +- mod/workshop/todo.txt | 16 +- mod/workshop/version.php | 2 +- mod/workshop/view.php | 13 +- 9 files changed, 700 insertions(+), 197 deletions(-) diff --git a/mod/workshop/assessments.php b/mod/workshop/assessments.php index ffe4241db1..35afcdb3ce 100644 --- a/mod/workshop/assessments.php +++ b/mod/workshop/assessments.php @@ -4,15 +4,20 @@ /************************************************* ACTIONS handled are: + addcomment + agreeassessment assesssubmission - displayelements + displaygradingform + editcomment editelements (teachers only) gradeassessment (teachers only) + insertcomment insertelements (for teachers) listungradedstudentsubmissions (for teachers) listungradedteachersubmissions (for teachers) listteachersubmissions updateassessment + updatecomment updategrading viewassessment @@ -21,9 +26,7 @@ require("../../config.php"); require("lib.php"); - error_reporting(15); - - optional_variable($id); // Course Module ID + optional_variable($id); // Course Module ID optional_variable($a); // workshop ID // get some useful stuff... @@ -72,8 +75,59 @@ require_variable($action); -/*************** Assess submission (by teacher or student) ***************************/ - if ($action == 'assesssubmission') { + /*************** add comment to assessment (by author, assessor or teacher) ***************************/ + if ($action == 'addcomment') { + + print_heading_with_help(get_string("addacomment", "workshop"), "addingacomment", "workshop"); + // get assessment record + if (!$assessmentid = $_REQUEST['aid']) { // comes from link or hidden form variable + error("Assessment id not given"); + } + $assessment = get_record("workshop_assessments", "id", $assessmentid); + if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { + error("Submission not found"); + } + ?> +
+ + + +
+ + \n"; + echo " \n"; + echo "

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

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

".get_string("assessment", "workshop"). "
\n"; + workshop_print_assessment($workshop, $assessment); + } + + + /*************** agree (to) assessment (by student) ***************************/ + elseif ($action == 'agreeassessment') { + $timenow = time(); + + if (!$assessment = get_record("workshop_assessments", "id", $_GET['aid'])) { + error("Assessment : agree assessment failed"); + } + //save time of agreement + set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id); + echo "".get_string("savedok", "workshop")."
\n"; + + add_to_log($course->id, "workshop", "agree", "view.php?id=$cm->id", "$workshop->id"); + print_continue("view.php?id=$cm->id"); + } + + + /*************** Assess submission (by teacher or student) ***************************/ + elseif ($action == 'assesssubmission') { require_variable($sid); @@ -89,6 +143,7 @@ $assessment->userid = $USER->id; $assessment->grade = -1; // set impossible grade $assessment->timecreated = $yearfromnow; + $assessment->timeagreed = 0; $assessment->timegraded = 0; if (!$assessment->id = insert_record("workshop_assessments", $assessment)) { error("Could not insert workshop assessment!"); @@ -97,22 +152,59 @@ print_heading_with_help(get_string("assessthissubmission", "workshop"), "grading", "workshop"); - echo "
cellcontent\">"; - echo workshop_print_submission_title($workshop, $submission); - echo "

\n"; - workshop_print_assessment($workshop, $assessment, TRUE); + workshop_print_assessment($workshop, $assessment, TRUE, TRUE); } - /*************** display elements (viewed by student) *********************************/ + /*************** display grading form (viewed by student) *********************************/ elseif ($action == 'displaygradingform') { print_heading_with_help(get_string("specimengradingform", "workshop"), "specimen", "workshop"); - $assessment = ''; // needed? - workshop_print_assessment($workshop, $assessment); + + workshop_print_assessment($workshop); // called with no assessment + print_continue("view.php?a=$workshop->id"); } + /*************** edit comment on assessment (by author, assessor or teacher) ***************************/ + elseif ($action == 'editcomment') { + + print_heading_with_help(get_string("editacomment", "workshop"), "editingacomment", "workshop"); + // get the comment record... + if (!$comment = get_record("workshop_comments", "id", $_GET['cid'])) { + error("Edit Comment: Comment not found"); + } + if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) { + error("Edit Comment: Assessment not found"); + } + if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { + error("Edit Comment: Submission not found"); + } + ?> +
+ + + +
+ + \n"; + echo " \n"; + echo "

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

\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + workshop_print_assessment($workshop, $assessment); + } + + /*********************** edit assessment elements (for teachers) ***********************/ elseif ($action == 'editelements') { @@ -298,15 +390,14 @@ if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { error("Submission not found"); } - echo "

".workshop_print_submission_title($workshop, $submission)."

\n"; // get the teacher's assessment first if ($teachersassessment = workshop_get_submission_assessment($submission, $USER)) { - echo "

".get_string("teachersassessment", "workshop")."\n"; + echo "

".get_string("teachersassessment", "workshop")."
\n"; workshop_print_assessment($workshop, $teachersassessment); } // now the student's assessment - echo "

".get_string("studentsassessment", "workshop")."\n"; - workshop_print_assessment($workshop, $assessment); + echo "

".get_string("studentsassessment", "workshop")."
\n"; + workshop_print_assessment($workshop, $assessment, true); ?>
@@ -337,6 +428,31 @@ } + /*************** insert (new) comment (by author, assessor or teacher) ***************************/ + elseif ($action == 'insertcomment') { + $timenow = time(); + + $form = (object)$_POST; + + if (!$assessment = get_record("workshop_assessments", "id", $_POST['aid'])) { + error("Unable to insert comment"); + } + // save the comment... + $comment->workshopid = $workshop->id; + $comment->assessmentid = $assessment->id; + $comment->userid = $USER->id; + $comment->timecreated = $timenow; + $comment->comments = $form->comments; + if (!$comment->id = insert_record("workshop_comments", $comment)) { + error("Could not insert workshop comment!"); + } + + add_to_log($course->id, "workshop", "comment", "view.php?id=$cm->id", "$workshop->id"); + + print_continue("assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id"); + } + + /*********************** insert/update assignment elements (for teachers)***********************/ elseif ($action == 'insertelements') { @@ -574,6 +690,10 @@ // update the time of the assessment record (may be re-edited)... set_field("workshop_assessments", "timecreated", $timenow, "id", $assessment->id); + // if the workshop does NOT have allow peer agreement then set timeagreed + if (!$workshop->agreeassessments) { + set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id); + } set_field("workshop_assessments", "grade", $grade, "id", $assessment->id); // ...and clear any grading of this assessment set_field("workshop_assessments", "timegraded", 0, "id", $assessment->id); @@ -596,6 +716,34 @@ } + /*************** update comment (by author, assessor or teacher) ***************************/ + elseif ($action == 'updatecomment') { + $timenow = time(); + + $form = (object)$_POST; + + // get the comment record... + if (!$comment = get_record("workshop_comments", "id", $_POST['cid'])) { + error("Update to Comment failed"); + } + if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) { + error("Update Comment: Assessment not found"); + } + //save the comment for the assessment... + if (isset($form->comments)) { + set_field("workshop_comments", "comments", $form->comments, "id", $comment->id); + set_field("workshop_comments", "timecreated", $timenow, "id", $comment->id); + // ..and kick to comment into life (probably not needed but just in case) + set_field("workshop_comments", "mailed", 0, "id", $comment->id); + echo "".get_string("savedok", "workshop")."

\n"; + + add_to_log($course->id, "workshop", "comment", "view.php?id=$cm->id", "$workshop->id"); + } + + print_continue("assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id"); + } + + /*************** update grading (by teacher) ***************************/ elseif ($action == 'updategrading') { $timenow = time(); @@ -638,9 +786,6 @@ } if ($assessments = workshop_get_assessments($submission)) { - echo "
cellcontent\">"; - echo workshop_print_submission_title($workshop, $submission); - echo "

\n"; foreach ($assessments as $assessment) { workshop_print_assessment($workshop, $assessment); } @@ -657,12 +802,8 @@ error("Assessment record not found"); } - echo "
cellcontent\">"; - $submission = get_record("workshop_submissions", "id", $assessment->submissionid); - echo workshop_print_submission_title($workshop, $submission); - echo "

\n"; - - workshop_print_assessment($workshop, $assessment); + workshop_print_assessment($workshop, $assessment, true); + print_continue("view.php?a=$workshop->id"); } diff --git a/mod/workshop/db/mysql.php b/mod/workshop/db/mysql.php index 919c7d9281..289c146522 100644 --- a/mod/workshop/db/mysql.php +++ b/mod/workshop/db/mysql.php @@ -1,14 +1,33 @@ prefix}workshop` CHANGE `graded` `agreeassessments` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL"); + execute_sql(" ALTER TABLE `{$CFG->prefix}workshop` CHANGE `showgrades` `hidegrades` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL"); + + execute_sql(" ALTER TABLE `{$CFG->prefix}workshop_assessments` ADD `timeagreed` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `timecreated`"); - } + execute_sql(" + CREATE TABLE `{$CFG->prefix}workshop_comments` ( + `id` int(10) unsigned NOT NULL auto_increment, + # workshopid not necessary just makes deleting instance easier + `workshopid` int(10) unsigned NOT NULL default '0', + `assessmentid` int(10) unsigned NOT NULL default '0', + `userid` int(10) unsigned NOT NULL default '0', + `timecreated` int(10) unsigned NOT NULL default '0', + `mailed` tinyint(2) unsigned NOT NULL default '0', + `comments` text NOT NULL, + PRIMARY KEY (`id`) + ) COMMENT='Defines comments' + "); + + } return true; } diff --git a/mod/workshop/db/mysql.sql b/mod/workshop/db/mysql.sql index 65ac98fa3b..a78f8111dc 100644 --- a/mod/workshop/db/mysql.sql +++ b/mod/workshop/db/mysql.sql @@ -7,13 +7,13 @@ CREATE TABLE `prefix_workshop` ( `course` int(10) unsigned NOT NULL default '0', `name` varchar(255) NOT NULL default '', `description` text NOT NULL, - `nelements` tinyint(3) unsigned NOT NULL default '10', + `nelements` tinyint(3) unsigned NOT NULL default '1', `phase` tinyint(2) unsigned NOT NULL default '0', `format` tinyint(2) unsigned NOT NULL default '0', `gradingstrategy` tinyint(2) unsigned NOT NULL default '1', `resubmit` tinyint(2) unsigned NOT NULL default '0', - `graded` tinyint(2) unsigned NOT NULL default '1', - `showgrades` tinyint(2) unsigned NOT NULL default '0', + `agreeassessments` tinyint(2) unsigned NOT NULL default '0', + `hidegrades` tinyint(2) unsigned NOT NULL default '0', `anonymous` tinyint(2) unsigned NOT NULL default '0', `includeself` tinyint(2) unsigned NOT NULL default '0', `maxbytes` int(10) unsigned NOT NULL default '100000', @@ -66,6 +66,7 @@ CREATE TABLE `prefix_workshop_assessments` ( `userid` int(10) unsigned NOT NULL default '0', `timecreated` int(10) unsigned NOT NULL default '0', `timegraded` int(10) unsigned NOT NULL default '0', + `timeagreed` int(10) unsigned NOT NULL default '0', `grade` float NOT NULL default '0', `gradinggrade` int(3) NOT NULL default '0', `mailed` tinyint(2) unsigned NOT NULL default '0', @@ -97,7 +98,6 @@ CREATE TABLE `prefix_workshop_elements` ( CREATE TABLE `prefix_workshop_grades` ( `id` int(10) unsigned NOT NULL auto_increment, -# workshop not necessary just makes deleting instance easier `workshopid` int(10) unsigned NOT NULL default '0', `assessmentid` int(10) unsigned NOT NULL default '0', `elementno` int(10) unsigned NOT NULL default '0', @@ -107,6 +107,24 @@ CREATE TABLE `prefix_workshop_grades` ( ) COMMENT='Info about individual grades given to each element'; # -------------------------------------------------------- +# +# Table structure for table `workshop_comments` +# + +CREATE TABLE `{$CFG->prefix}workshop_comments` ( + `id` int(10) unsigned NOT NULL auto_increment, + `workshopid` int(10) unsigned NOT NULL default '0', + `assessmentid` int(10) unsigned NOT NULL default '0', + `userid` int(10) unsigned NOT NULL default '0', + `timecreated` int(10) unsigned NOT NULL default '0', + `mailed` tinyint(2) unsigned NOT NULL default '0', + `comments` text NOT NULL, + PRIMARY KEY (`id`) +) COMMENT='Defines comments'; +# -------------------------------------------------------- + + + INSERT INTO `prefix_log_display` VALUES ('workshop', 'assess', 'workshop', 'name'); INSERT INTO `prefix_log_display` VALUES ('workshop', 'close', 'workshop', 'name'); INSERT INTO `prefix_log_display` VALUES ('workshop', 'display grades', 'workshop', 'name'); diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index 05856e3a08..284bc02824 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -1,14 +1,7 @@ dirroot/files/mimetypes.php"); - /*** Constants **********************************/ $WORKSHOP_TYPE = array (0 => get_string("notgraded", "workshop"), @@ -37,6 +30,9 @@ $WORKSHOP_EWEIGHTS = array( 0 => -4.0, 1 => -2.0, 2 => -1.5, 3 => -1.0, 4 => -0 $WORKSHOP_FWEIGHTS = array( 0 => 0, 1 => 0.1, 2 => 0.25, 3 => 0.5, 4 => 0.75, 5 => 1, 6 => 1.5, 7 => 2.0, 8 => 3.0, 9 => 5.0, 10 => 7.5, 11=> 10.0); +if (!defined("COMMENTSCALE")) { + define("COMMENTSCALE", 20); + } /*** Standard Moodle functions ****************** function workshop_add_instance($workshop) @@ -141,6 +137,10 @@ function workshop_delete_instance($id) { // 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; } @@ -222,82 +222,201 @@ function workshop_cron () { foreach ($assessments as $assessment) { - echo "Processing workshop assessment $assessment->id\n"; - + echo "Processing workshop assessment $assessment->id\n"; if (! $submission = get_record("workshop_submissions", "id", "$assessment->submissionid")) { - echo "Could not find submission $assessment->submissionid\n"; - continue; - } - + echo "Could not find submission $assessment->submissionid\n"; + continue; + } if (! $submissionowner = get_record("user", "id", "$submission->userid")) { - echo "Could not find user $submission->userid\n"; - continue; - } - + 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 (! $course = get_record("course", "id", "$assessment->course")) { - echo "Could not find course $assessment->course\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 - } - - if (! $workshop = get_coursemodule_from_instance("workshop", $assessment->workshopid, $course->id)) { - echo "Could not find course module for workshop id $submission->workshop\n"; - continue; - } - - $strworkshops = get_string("modulenameplural", "workshop"); - $strworkshop = get_string("modulename", "workshop"); - + echo "Could not find user $assessment->userid\n"; + continue; + } + if (! $course = get_record("course", "id", "$assessment->course")) { + echo "Could not find course $assessment->course\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 + } + if (! $workshop = get_coursemodule_from_instance("workshop", $assessment->workshopid, $course->id)) { + echo "Could not find course module for workshop id $submission->workshop\n"; + 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; $msg = "Your assignment \"$submission->title\" has been assessed.\n". "The comments and grade can be seen in ". "the workshop assignment '$workshop->name'\n\n"; - + $postsubject = "$course->shortname: $strworkshops: $workshop->name"; - $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n"; - $posttext .= "---------------------------------------------------------------------\n"; - $posttext .= $msg; - $posttext .= "You can see it in your workshop assignment:\n"; - $posttext .= " $CFG->wwwroot/mod/workshop/view.php?id=$workshop->id\n"; - $posttext .= "---------------------------------------------------------------------\n"; - if ($user->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?a=$pgassessment->id\">$workshop->name

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

$msg

"; - $posthtml .= "

You can see it wwwroot/mod/workshop/view.php?id=$workshop->id\">"; - $posthtml .= "in to your peer graded assignment.


"; - } else { - $posthtml = ""; - } - + $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n"; + $posttext .= "---------------------------------------------------------------------\n"; + $posttext .= $msg; + $posttext .= "You can see it in your workshop assignment:\n"; + $posttext .= " $CFG->wwwroot/mod/workshop/view.php?a=$workshop->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?a=$workshop->id\">$workshop->name

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

$msg

"; + $posthtml .= "

You can see it wwwroot/mod/workshop/view.php?a=$workshop->id\">"; + $posthtml .= "in to your peer graded assignment.


"; + } 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_assessments", "mailed", "1", "id", "$assessment->id")) { - echo "Could not update the mailed field for id $assessment->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_assessments", "mailed", "1", "id", "$assessment->id")) { + echo "Could not update the mailed field for id $assessment->id\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"; + 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 (! $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 (! $course = get_record("course", "id", "$comment->course")) { + echo "Could not find course $comment->course\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 + } + if (! $workshop = get_coursemodule_from_instance("workshop", $assessment->workshopid, $course->id)) { + echo "Could not find course module for workshop id $submission->workshop\n"; + continue; + } + + $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; + $msg = "A comment has been added to the assignment \"$submission->title\".\n". + "The new comment can be seen in ". + "the workshop assignment '$workshop->name'\n\n"; + + $postsubject = "$course->shortname: $strworkshops: $workshop->name"; + $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n"; + $posttext .= "---------------------------------------------------------------------\n"; + $posttext .= $msg; + $posttext .= "You can see it in your workshop assignment:\n"; + $posttext .= " $CFG->wwwroot/mod/workshop/view.php?a=$workshop->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?a=$workshop->id\">$workshop->name

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

$msg

"; + $posthtml .= "

You can see it wwwroot/mod/workshop/view.php?a=$workshop->id\">"; + $posthtml .= "in to your workshop assignment.


"; + } + 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"; + } + } + // see if the assessor needs to to told + if ($comment->userid != $assessment->userid) { + $USER->lang = $assessmentowner->lang; + $sendto = $assessmentowner; + $msg = "A comment has been added to the assignment \"$submission->title\".\n". + "The new comment can be seen in ". + "the workshop assignment '$workshop->name'\n\n"; + + $postsubject = "$course->shortname: $strworkshops: $workshop->name"; + $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n"; + $posttext .= "---------------------------------------------------------------------\n"; + $posttext .= $msg; + $posttext .= "You can see it in your workshop assignment:\n"; + $posttext .= " $CFG->wwwroot/mod/workshop/view.php?a=$workshop->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?a=$workshop->id\">$workshop->name

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

$msg

"; + $posthtml .= "

You can see it wwwroot/mod/workshop/view.php?a=$workshop->id\">"; + $posthtml .= "in to your workshop assignment.


"; + } + 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)) { @@ -349,8 +468,6 @@ function workshop_cron () { $msg = "Your assessment of the assignment \"$submission->title\" has by graded.\n". "The comments and grade given by the $course->teacher can be seen in ". "the workshop assignment '$workshop->name'\n\n"; - } - $postsubject = "$course->shortname: $strworkshops: $workshop->name"; $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n"; @@ -359,11 +476,11 @@ function workshop_cron () { $posttext .= "You can see it in your workshop assignment:\n"; $posttext .= " $CFG->wwwroot/mod/workshop/view.php?a=$workshop->id\n"; $posttext .= "---------------------------------------------------------------------\n"; - if ($user->mailformat == 1) { // HTML + 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?a=$pgassessment->id\">$workshop->name

"; + "wwwroot/mod/workshop/view.php?a=$workshop->id\">$workshop->name

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

$msg

"; $posthtml .= "

You can see it wwwroot/mod/workshop/view.php?a=$workshop->id\">"; @@ -531,6 +648,7 @@ function workshop_grades($workshopid) { function workshop_count_all_assessments($workshop, $user) { function workshop_count_all_submissions_for_assessment($workshop, $user) { +function workshop_count_comments($assessment) { function workshop_count_peer_assessments($workshop, $user) { function workshop_count_student_submissions($workshop) { function workshop_count_student_submissions_for_assessment($workshop, $user) { @@ -546,6 +664,7 @@ function workshop_file_area($workshop, $submission) { function workshop_file_area_name($workshop, $submission) { function workshop_get_assessments($submission) { +function workshop_get_comments($assessment) { function workshop_get_student_assessments($workshop, $user) { function workshop_get_student_submission_assessments($workshop) { function workshop_get_student_submissions($workshop) { @@ -625,6 +744,13 @@ function workshop_count_assessments($workshop, $stype, $user) { } +function workshop_count_comments($assessment) { + // Return the number comments for this assessment provided they are newer than the assessment, + return count_records_select("workshop_comments", "(assessmentid = $assessment->id) AND + timecreated > $assessment->timecreated"); +} + + function workshop_count_peer_assessments($workshop, $user) { // returns the number of assessments made by students on user's submissions @@ -801,7 +927,7 @@ function workshop_file_area_name($workshop, $submission) { function workshop_get_assessments($submission) { - // Return all assessments for this submission provided they are after the editing time, oredered oldest first, newest last + // Return all assessments for this submission provided they are after the editing time, ordered oldest first, newest last global $CFG; $timenow = time(); @@ -810,6 +936,15 @@ function workshop_get_assessments($submission) { } +function workshop_get_comments($assessment) { + // Return all comments for this assessment provided they are newer than the assessment, + // and ordered oldest first, newest last + return get_records_select("workshop_comments", "(assessmentid = $assessment->id) AND + timecreated > $assessment->timecreated", + "timecreated DESC"); +} + + function workshop_get_student_assessments($workshop, $user) { // Return all assessments on the student submissions by a user, order by youngest first, oldest last global $CFG; @@ -939,6 +1074,17 @@ function workshop_get_unmailed_assessments($cutofftime) { } +function workshop_get_unmailed_comments($cutofftime) { + /// Return list of comments that have not been mailed out + global $CFG; + return get_records_sql("SELECT c.*, g.course, g.name + FROM {$CFG->prefix}workshop_comments c, {$CFG->prefix}workshop g + WHERE c.mailed = 0 + AND c.timecreated < $cutofftime + AND g.id = c.workshopid"); +} + + function workshop_get_unmailed_graded_assessments($cutofftime) { /// Return list of graded assessments that have not been mailed out global $CFG; @@ -1130,17 +1276,25 @@ function workshop_list_assessed_submissions($workshop, $user) { if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) { $action = "id&aid=$assessment->id\">". get_string("view", "workshop").""; - // has teacher graded user's assessment? - if ($assessment->timegraded) { - if (($timenow - $assessment->timegraded) > $CFG->maxeditingtime) { - $comment = get_string("gradedbyteacher", "workshop", $course->teacher); - } - } } else { // there's still time left to edit... $action = "id&sid=$submission->id\">". get_string("edit", "workshop").""; } + $comment = get_string("assessedon", "workshop", userdate($assessment->timecreated)); + // has teacher commented on user's assessment? + if ($assessment->timegraded and ($timenow - $assessment->timegraded > $CFG->maxeditingtime)) { + $comment .= "; ".get_string("gradedbyteacher", "workshop", $course->teacher); + } + // if peer agrrements show whether agreement has been reached + if ($workshop->agreeassessments) { + if ($assessment->timeagreed) { + $comment .= "; ".get_string("assessmentwasagreedon", "workshop", userdate($assessment->timeagreed)); + } + else { + $comment .= "; ".get_string("assessmentnotyetagreed", "workshop"); + } + } $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment); } } @@ -1176,12 +1330,19 @@ function workshop_list_peer_assessments($workshop, $user) { if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) { $action = "id&aid=$assessment->id\">". get_string("view", "workshop").""; + $comment = get_string("assessedon", "workshop", userdate($assessment->timecreated)); // has teacher commented on user's assessment? if ($assessment->timegraded and ($timenow - $assessment->timegraded > $CFG->maxeditingtime)) { - $comment = get_string("gradedbyteacher", "workshop", $course->teacher); + $comment .= "; ".get_string("gradedbyteacher", "workshop", $course->teacher); } - else { - $comment = userdate($assessment->timecreated); + // if peer agrrements show whether agreement has been reached + if ($workshop->agreeassessments) { + if ($assessment->timeagreed) { + $comment .= "; ".get_string("assessmentwasagreedon", "workshop", userdate($assessment->timeagreed)); + } + else { + $comment .= "; ".get_string("assessmentnotyetagreed", "workshop"); + } } $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment); } @@ -1510,31 +1671,117 @@ function workshop_list_user_submissions($workshop, $user) { } -function workshop_print_assessment($workshop, $assessment, $allowchanges = FALSE) { - global $CFG, $WORKSHOP_SCALES, $WORKSHOP_EWEIGHTS, $THEME; +function workshop_print_assessment($workshop, $assessment = FALSE, $showcommentlinks = FALSE) { + 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 + $allowchanges = false; + 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 (($assessment->userid == $USER->id) and !$assessment->timeagreed) { + $allowchanges = true; + } + 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"; + + // print agreement time if the workshop requires peer agreement + if ($workshop->agreeassessments and $assessment->timeagreed) { + echo "

".get_string("assessmentwasagreedon", "workshop", userdate($assessment->timeagreed)); + } - // only show the grade if grading strategy > 0 and the grade is positive - if ($workshop->gradingstrategy and $assessment->grade >= 0) { - echo "

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

\n"; + // 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 $assessment->grade >= 0) { + echo "
".get_string("thegradeis", "workshop").": ".number_format($assessment->grade, 2)."% (". + get_string("maximumgrade")." ".number_format($workshop->grade)."%)

\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")) { @@ -1546,10 +1793,19 @@ function workshop_print_assessment($workshop, $assessment, $allowchanges = FALSE } } - // 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... + 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; } } @@ -1594,54 +1850,56 @@ function workshop_print_assessment($workshop, $assessment, $allowchanges = FALSE echo "

Weight: " .number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight],2)."\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"; @@ -1864,10 +2127,19 @@ function workshop_print_assessment($workshop, $assessment, $allowchanges = FALSE echo "\n"; } - // ...and close the table, show submit button if needed and close the form + // ...and close the table, show submit button if needed... echo "
cellheading2\">
".get_string("assessment", "workshop"). + "

". 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; + if ($showgrades) { + 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; + else { // there's no previous grade so check the lowest option + if ($j == 0) { + $checked = true; + } + } + if ($checked) { + echo "    \n"; + } + else { + echo "    \n"; } } - if ($checked) { - 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 { - echo "    \n"; + choose_from_menu($numbers, "grade[$i]", 0, ""); } - } - 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; + break; + } + + echo "

". get_string("feedback").":

\n"; @@ -1834,8 +2092,13 @@ function workshop_print_assessment($workshop, $assessment, $allowchanges = FALSE echo "\n"; } else { - if (isset($assessment->generalcomment)) { - echo text_to_html($assessment->generalcomment); + if ($assessment) { + if (isset($assessment->generalcomment)) { + echo text_to_html($assessment->generalcomment); + } + } + else { + print_string("yourfeedbackgoeshere", "workshop"); } } echo " 
\n"; - if ($allowchanges) { - echo "\n"; + if ($assessment) { + if ($allowchanges and ($assessment->userid == $USER->id)) { // second test is OK as dummy assessment record is created + echo "\n"; + } + // ...if user is author, assessment not agreed and there are no comments then show some buttons + if (($submission->userid == $USER->id) and !$assessment->timeagreed and !$comments) { + echo "\n"; + echo "\n"; + } } echo "
"; echo "\n"; diff --git a/mod/workshop/mod.html b/mod/workshop/mod.html index cd17c94e08..10f3ade391 100644 --- a/mod/workshop/mod.html +++ b/mod/workshop/mod.html @@ -1,4 +1,5 @@ name)) { + $form->name = ""; + } + if (empty($form->description)) { + $form->description = ""; + } + if (empty($form->format)) { + $form->format = ""; + } + if (!isset($form->grade)) { + $form->grade = 100; + } + if (!isset($form->nelements)) { + $form->nelements = 1; + } + if (empty($form->resubmit)) { + $form->resubmit = ""; + } + if (!isset($form->ntassessments)) { + $form->ntassessments = 0; + } + if (!isset($form->nsassessments)) { + $form->nsassessments = 0; + } + if (empty($form->includeself)) { + $form->includeself = ""; + } + if (empty($form->agreeassessments)) { + $form->agreeassessments = ""; + } + if (empty($form->hidegrades)) { + $form->hidegrades = ""; + } + if (empty($form->maxbytes)) { + $form->maxbytes = ""; + } + if (empty($form->deadline)) { + $form->deadline = ""; + } ?>
action=""> @@ -127,6 +168,28 @@ + +

:

+ + agreeassessments, ""); + helpbutton("agreeassessments", get_string("assessmentsmustbeagreed", "workshop"), "workshop"); + ?> + + + + +

:

+ + hidegrades, ""); + helpbutton("showinggrades", get_string("hidegradesbeforeagreement", "workshop"), "workshop"); + ?> + + +

:

@@ -159,7 +222,6 @@ print_date_selector("deadlineday", "deadlinemonth", "deadlineyear", $form->deadline); echo " - "; print_time_selector("deadlinehour", "deadlineminute", $form->deadline); - formerr($err["deadline"]); ?> diff --git a/mod/workshop/submissions.php b/mod/workshop/submissions.php index 8812390a78..3cac81f38d 100644 --- a/mod/workshop/submissions.php +++ b/mod/workshop/submissions.php @@ -17,9 +17,7 @@ require("../../config.php"); require("lib.php"); - error_reporting(15); - - optional_variable($id); // Course Module ID + optional_variable($id); // Course Module ID optional_variable($a); // workshop ID // get some useful stuff... diff --git a/mod/workshop/todo.txt b/mod/workshop/todo.txt index 183ee749e1..a230affab6 100644 --- a/mod/workshop/todo.txt +++ b/mod/workshop/todo.txt @@ -4,20 +4,14 @@ To Do Use a better method to measure bias in peer grades, probably based on the percentage difference rather the relative difference used at present. -When there are many peer gradings the grade comments page needs to be - broken into manageable chunks. **DONE** +Add time-agreed test to calculation of final grades. -Allow teacher to add a set of submissions (from say a previous cohort) for the - students to grade. **Probably better as a separate module** - -Add option to allow the teacher's grade and mean peer grade to be merged in - the final grades table (to avoid disputes!). - -Add alternative grading strategies: Simple Grading (= assignment style grading); - Accumulative Grading (current strategy); Criteria Grading; and Error Banding. +Comments are seen by a third party, is this standard Moodle behaviour? +Cron function should email something to the assessor when an assessment is + agreed. Ray Kingdon -06 Feb 2003 +8 May 2003 diff --git a/mod/workshop/version.php b/mod/workshop/version.php index 17713497f1..bffff6cde4 100644 --- a/mod/workshop/version.php +++ b/mod/workshop/version.php @@ -5,7 +5,7 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2003043000; +$module->version = 2003050400; $module->cron = 60; ?> diff --git a/mod/workshop/view.php b/mod/workshop/view.php index 67337b32b2..091e9a9d80 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -18,9 +18,7 @@ require("../../config.php"); require("lib.php"); - error_reporting(15); - - optional_variable($id); // Course Module ID + optional_variable($id); // Course Module ID optional_variable($a); // workshop ID // get some useful stuff... @@ -124,14 +122,14 @@ $gradingweight = get_field("workshop","gradingweight", "id", $workshop->id); // work out what to show in the final grades tables and what to include in the calculation of the final grade // teacher grades? - if ($workshop->graded and $teacherweight) { + if ($workshop->gradingstrategy and $teacherweight) { $useteachersgrades = 1; } else { $useteachersgrades = 0; } // peergrades? - if ($workshop->graded and $workshop->nsassessments and $peerweight) { + if ($workshop->gradingstrategy and $workshop->nsassessments and $peerweight) { $usepeergrades = 1; } else { @@ -322,7 +320,7 @@ echo "".get_string("duedate", "assignment").": $strduedate
"; echo "".get_string("maximumgrade").": $workshop->grade
"; echo "".get_string("detailsofassessment", "workshop").": - id&action=displayelements\">". + id&action=displaygradingform\">". get_string("specimenassessmentform", "workshop")."
"; print_simple_box_end(); echo "
"; @@ -354,8 +352,9 @@ workshop_list_teacher_assessments($workshop, $USER); } // if student assessments show any to assess... - if ($workshop->nsassessments) { // if there are student assessment display them... + if ($workshop->nsassessments) { // if there are student assessments display them... workshop_list_student_submissions($workshop, $USER); + // ..and any they have already done... echo "

".get_string("yourassessments", "workshop")."

\n"; workshop_list_assessed_submissions($workshop, $USER); // ... and show peer assessments -- 2.39.5