From 5c2ba38c45e1c165bda82326f196682b41f63209 Mon Sep 17 00:00:00 2001
From: rkingdon ".workshop_print_submission_title($workshop, $submission)." ".get_string("teachersassessment", "workshop")."\n";
+ echo " ".get_string("studentsassessment", "workshop")."\n";
- workshop_print_assessment($workshop, $assessment);
+ echo " ".
- "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 $msg You can see it wwwroot/mod/workshop/view.php?id=$workshop->id\">";
- $posthtml .= "in to your peer graded assignment. ".
+ "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 $msg You can see it wwwroot/mod/workshop/view.php?a=$workshop->id\">";
+ $posthtml .= "in to your peer graded assignment. ".
+ "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 $msg You can see it wwwroot/mod/workshop/view.php?a=$workshop->id\">";
+ $posthtml .= "in to your workshop assignment. ".
+ "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 $msg You can see it wwwroot/mod/workshop/view.php?a=$workshop->id\">";
+ $posthtml .= "in to your workshop assignment. ".
"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
\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";
+ 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 "
\n";
// get the teacher's assessment first
if ($teachersassessment = workshop_get_submission_assessment($submission, $USER)) {
- echo "
\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 = "
";
- $posthtml .= "
";
- } 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 = "
";
+ $posthtml .= "
";
+ } 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 = "
";
+ $posthtml .= "
";
+ }
+ 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 = "
";
+ $posthtml .= "
";
+ }
+ 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 = "
$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 " |
".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 "
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 " |