From: rkingdon Date: Tue, 2 Sep 2003 20:23:29 +0000 (+0000) Subject: Tidy up the handling of "hanging" assessments. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=203add24ab4d713a85724f5da79d1089126bef2e;p=moodle.git Tidy up the handling of "hanging" assessments. --- diff --git a/mod/workshop/assessments.php b/mod/workshop/assessments.php index 27a4935655..bd65d98ead 100644 --- a/mod/workshop/assessments.php +++ b/mod/workshop/assessments.php @@ -28,7 +28,7 @@ ************************************************/ require("../../config.php"); - require("lib.php"); + require("lib.php"); optional_variable($id); // Course Module ID optional_variable($a); // workshop ID diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index f4857fe2b6..6ea1e04671 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -2,9 +2,6 @@ include_once("$CFG->dirroot/files/mimetypes.php"); -// reset error reporting -error_reporting($CFG->debug); - /*** Constants **********************************/ $WORKSHOP_TYPE = array (0 => get_string("notgraded", "workshop"), @@ -38,6 +35,7 @@ if (!defined("COMMENTSCALE")) { define("COMMENTSCALE", 20); } + /*** Standard Moodle functions ****************** function workshop_add_instance($workshop) function workshop_update_instance($workshop) @@ -209,10 +207,10 @@ function workshop_user_complete($course, $user, $mod, $workshop) { function workshop_cron () { // Function to be run periodically according to the moodle cron -// Finds all workshop notifications that have yet to be mailed out, and mails them global $CFG, $USER; - + + // Find all workshop notifications that have yet to be mailed out, and mails them $cutofftime = time() - $CFG->maxeditingtime; // look for new assessments @@ -1392,7 +1390,18 @@ function workshop_list_assessed_submissions($workshop, $user) { foreach ($assessments as $assessment) { $comment = ""; $submission = get_record("workshop_submissions", "id", $assessment->submissionid); - if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) { + // the assessment may be in three states: 1. "hanging", created but not completed (timecreated is in the future) + // 2. just created and still capable of being edited, and 3. fixed (after the editing time) + if ($assessment->timecreated > $timenow) { // funny but it does happen! + $action = "id&sid=$submission->id\">". + get_string("assess", "workshop").""; + } + elseif (($timenow - $assessment->timecreated) < $CFG->maxeditingtime) { // still time to edit + $action = "id&sid=$submission->id\">". + get_string("edit", "workshop")." | id&aid=$assessment->id\">". + get_string("delete", "workshop").""; + } + else { // it's gone cold $action = "id&aid=$assessment->id&". "allowcomments=$workshop->agreeassessments\">". get_string("view", "workshop").""; @@ -1401,12 +1410,12 @@ function workshop_list_assessed_submissions($workshop, $user) { get_string("reassess", "workshop").""; } } - else { // there's still time left to edit... - $action = "id&sid=$submission->id\">". - get_string("edit", "workshop")." | id&aid=$assessment->id\">". - get_string("delete", "workshop").""; + if ($assessment->timecreated < $timenow) { // only show the date if it's in the past (future dates cause confusion + $comment = get_string("assessedon", "workshop", userdate($assessment->timecreated)); + } + else { + $comment = ''; } - $comment = get_string("assessedon", "workshop", userdate($assessment->timecreated)); if ($submission->userid == $user->id) { // self assessment? $comment .= "; ".get_string("ownwork", "workshop"); // just in case they don't know! } @@ -1620,7 +1629,11 @@ function workshop_list_submissions_for_admin($workshop, $order) { if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id AND userid = $USER->id")) { $curtime = time(); - if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) { + 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").""; }