From: rkingdon Date: Tue, 15 Jul 2003 15:24:58 +0000 (+0000) Subject: Minor corrections, addition of rubics table - July 2003 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=bd89f04f539aa9d01823472d4fac79fc5a655566;p=moodle.git Minor corrections, addition of rubics table - July 2003 --- diff --git a/mod/workshop/assessments.php b/mod/workshop/assessments.php index a84c3cd418..e4b0db9ac3 100644 --- a/mod/workshop/assessments.php +++ b/mod/workshop/assessments.php @@ -112,7 +112,7 @@ /******************* admin confirm delete ************************************/ - if ($action == 'adminconfirmdelete' ) { + elseif ($action == 'adminconfirmdelete' ) { if (!isteacher($course->id)) { error("Only teachers can look at this page"); @@ -183,6 +183,11 @@ elseif ($action == 'assesssubmission') { require_variable($sid); + + optional_variable($allowcomments); + if (!isset($allowcomments)) { + $allowcomments = false; + } if (! $submission = get_record("workshop_submissions", "id", $sid)) { error("assess submission is misconfigured"); @@ -205,7 +210,8 @@ print_heading_with_help(get_string("assessthissubmission", "workshop"), "grading", "workshop"); - workshop_print_assessment($workshop, $assessment, TRUE, TRUE); + // show assessment and allow changes + workshop_print_assessment($workshop, $assessment, true, $allowcomments); } @@ -448,9 +454,10 @@ 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, true); + // now the student's assessment (don't allow changes) + $user = get_record("user", "id", $assessment->userid); + echo "

".get_string("assessmentby", "workshop", $user->firstname." ".$user->lastname)."
\n"; + workshop_print_assessment($workshop, $assessment); ?>
@@ -743,13 +750,16 @@ // 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 or it's self assessment then set timeagreed + if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { error ("Updateassessment: submission record not found"); } - if (!$workshop->agreeassessments or ($submission->userid == $USER->id)) { + + // if the workshop does need peer agreement AND it's self assessment then set timeagreed + if ($workshop->agreeassessments and ($submission->userid == $assessment->userid)) { 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); @@ -853,12 +863,19 @@ /*********************** view assessment ***********************/ elseif ($action == 'viewassessment') { + + optional_variable($allowcomments); + if (!isset($allowcomments)) { + $allowcomments = false; + } + // get the assessment record if (!$assessment = get_record("workshop_assessments", "id", $_GET['aid'])) { error("Assessment record not found"); } - workshop_print_assessment($workshop, $assessment, true); + // show assessment but don't allow changes + workshop_print_assessment($workshop, $assessment, false, $allowcomments); print_continue("view.php?a=$workshop->id"); } diff --git a/mod/workshop/db/mysql.php b/mod/workshop/db/mysql.php index 289c146522..cb92e3edb6 100644 --- a/mod/workshop/db/mysql.php +++ b/mod/workshop/db/mysql.php @@ -28,6 +28,23 @@ function workshop_upgrade($oldversion) { "); } + + if ($oldversion < 2003051400) { + + execute_sql(" ALTER TABLE `{$CFG->prefix}workshop` ADD `showleaguetable` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `gradingweight`"); + + execute_sql(" + CREATE TABLE `{$CFG->prefix}workshop_rubrics` ( + `id` int(10) unsigned NOT NULL auto_increment, + `workshopid` int(10) unsigned NOT NULL default '0', + `elementid` int(10) unsigned NOT NULL default '0', + `rubricno` tinyint(3) unsigned NOT NULL default '0', + `description` text NOT NULL, + PRIMARY KEY (`id`) + ) COMMENT='Info about the rubrics marking scheme' + "); + + } return true; } diff --git a/mod/workshop/db/mysql.sql b/mod/workshop/db/mysql.sql index e1b98a755c..5968892229 100644 --- a/mod/workshop/db/mysql.sql +++ b/mod/workshop/db/mysql.sql @@ -29,6 +29,7 @@ CREATE TABLE `prefix_workshop` ( `biasweight` tinyint(3) unsigned NOT NULL default '5', `reliabilityweight` tinyint(3) unsigned NOT NULL default '5', `gradingweight` tinyint(3) unsigned NOT NULL default '5', + `showleaguetable` tinyint(3) unsigned NOT NULL default '0', PRIMARY KEY (`id`) ) COMMENT='Defines workshop'; # -------------------------------------------------------- @@ -92,6 +93,21 @@ CREATE TABLE `prefix_workshop_elements` ( ) COMMENT='Info about marking scheme of assignment'; # -------------------------------------------------------- + +# +# Table structure for table `workshop_rubrics` +# + +CREATE TABLE `prefix_workshop_rubrics` ( + `id` int(10) unsigned NOT NULL auto_increment, + `workshopid` int(10) unsigned NOT NULL default '0', + `elementid` int(10) unsigned NOT NULL default '0', + `rubricno` tinyint(3) unsigned NOT NULL default '0', + `description` text NOT NULL, + PRIMARY KEY (`id`) +) COMMENT='Info about the rubrics marking scheme'; +# -------------------------------------------------------- + # # Table structure for table `workshop_grades` # diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index 39638b1586..550a0c7d90 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -34,6 +34,10 @@ if (!defined("COMMENTSCALE")) { define("COMMENTSCALE", 20); } +if (!defined("PASSGRADE")) { + define("PASSGRADE", 8); // 40% of COMMENTSCALE + } + /*** Standard Moodle functions ****************** function workshop_add_instance($workshop) function workshop_update_instance($workshop) @@ -271,10 +275,10 @@ function workshop_cron () { $posthtml = "

". "wwwroot/course/view.php?id=$course->id\">$course->shortname ->". "wwwroot/mod/workshop/index.php?id=$course->id\">$strworkshops ->". - "wwwroot/mod/workshop/view.php?id=$workshop->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?id=$workshop->id\">"; + $posthtml .= "

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


"; } else { $posthtml = ""; @@ -347,16 +351,16 @@ function workshop_cron () { $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 .= " $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?id=$workshop->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?id=$workshop->id\">"; + $posthtml .= "

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


"; } else { @@ -387,13 +391,13 @@ function workshop_cron () { $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 .= " $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?id=$workshop->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\">"; @@ -506,130 +510,122 @@ function workshop_cron () { } -function workshop_print_recent_activity(&$logs, $isteacher=false) { - global $CFG, $COURSE_TEACHER_COLOR; +function workshop_print_recent_activity($course, $isteacher, $timestart) { + global $CFG; $content = false; - $workshops = NULL; - $timenow = time(); - - foreach ($logs as $log) { - if ($log->module == "workshop" and $log->action == "submit") { - $workshops[$log->info] = get_record_sql("SELECT a.name, u.firstname, u.lastname - FROM {$CFG->prefix}workshop a, {$CFG->prefix}user u - WHERE a.id = '$log->info' AND u.id = '$log->userid'"); - $workshops[$log->info]->time = $log->time; - $workshops[$log->info]->url = $log->url; - } - } - - if ($workshops) { - $content = true; - print_headline(get_string("submissions", "workshop").":"); - foreach ($workshops as $workshop) { - $date = userdate($workshop->time, "%d %b, %H:%M"); - echo "

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

"; - } - } - - $workshops = NULL; + $submissions = NULL; + + // only show submissions and assessments to teachers + if ($isteacher) { + if ($logs = get_records_select("log", "time > '$timestart' AND ". + "course = '$course->id' AND ". + "module = 'workshop' AND ". + "action = 'submit' ", "time ASC")) { + + foreach ($logs as $log) { + //Create a temp valid module structure (course,id) + $tempmod->course = $log->course; + $tempmod->id = $log->info; + //Obtain the visible property from the instance + $modvisible = instance_is_visible($log->module,$tempmod); + + //Only if the mod is visible + if ($modvisible) { + $submissions[$log->info] = workshop_log_info($log); + $submissions[$log->info]->time = $log->time; + $submissions[$log->info]->url = $log->url; + } + } + + if ($submissions) { + $strftimerecent = get_string("strftimerecent"); + $content = true; + print_headline(get_string("newsubmissions", "workshop").":"); + foreach ($submissions as $submission) { + $date = userdate($submission->time, $strftimerecent); + echo "

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

"; + } + } + } + + + $assessments = NULL; - foreach ($logs as $log) { - if ($log->module == "workshop" and $log->action == "assess") { - if ($workshops[$log->userid] = get_record_sql("SELECT a.name, u.firstname, u.lastname - FROM {$CFG->prefix}workshop a, {$CFG->prefix}user u - WHERE a.id = '$log->info' AND u.id = '$log->userid'")) { - $workshops[$log->userid]->time = $log->time; - $workshops[$log->userid]->url = $log->url; + if ($logs = get_records_select("log", "time > '$timestart' AND ". + "course = '$course->id' AND ". + "module = 'workshop' AND ". + "action = 'assess' ", "time ASC")) { + + foreach ($logs as $log) { + //Create a temp valid module structure (course,id) + $tempmod->course = $log->course; + $tempmod->id = $log->info; + //Obtain the visible property from the instance + $modvisible = instance_is_visible($log->module,$tempmod); + + //Only if the mod is visible + if ($modvisible) { + $assessments[$log->info] = workshop_log_info($log); + $assessments[$log->info]->time = $log->time; + $assessments[$log->info]->url = $log->url; } } - } - - if ($workshops) { - $content = true; - print_headline(get_string("assessments", "workshop").":"); - foreach ($workshops as $workshop) { - $date = userdate($workshop->time, "%d %b, %H:%M"); - echo "

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

"; - } - } - - $workshops = NULL; - - foreach ($logs as $log) { - if ($log->module == "workshop" and $log->action == "grade") { - $workshops[$log->userid] = get_record_sql("SELECT a.name, u.firstname, u.lastname - FROM {$CFG->prefix}workshop a, {$CFG->prefix}user u - WHERE a.id = '$log->info' AND u.id = '$log->userid'"); - $workshops[$log->userid]->time = $log->time; - $workshops[$log->userid]->url = $log->url; - } - } - - if ($workshops) { - $content = true; - print_headline(get_string("graded", "workshop").":"); - foreach ($workshops as $workshop) { - $date = userdate($workshop->time, "%d %b, %H:%M"); - echo "

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

"; - } - } - - $workshops = NULL; - - foreach ($logs as $log) { - if ($log->module == "workshop" and $log->action == "close") { - $workshops[$log->userid] = get_record_sql("SELECT a.name, u.firstname, u.lastname - FROM {$CFG->prefix}workshop a, {$CFG->prefix}user u - WHERE a.id = '$log->info' AND u.id = '$log->userid'"); - $workshops[$log->userid]->time = $log->time; - $workshops[$log->userid]->url = $log->url; - } - } + + if ($assessments) { + $strftimerecent = get_string("strftimerecent"); + $content = true; + print_headline(get_string("newassessments", "workshop").":"); + foreach ($assessments as $assessment) { + $date = userdate($assessment->time, $strftimerecent); + echo "

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

"; + } + } + } + } + + $gradings = NULL; - if ($workshops) { - $content = true; - print_headline(get_string("closeassignment", "workshop").":"); - foreach ($workshops as $workshop) { - $date = userdate($workshop->time, "%d %b, %H:%M"); - echo "

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

"; - } - } + if ($logs = get_records_select("log", "time > '$timestart' AND ". + "course = '$course->id' AND ". + "module = 'workshop' AND ". + "action = 'grade' ", "time ASC")) { - foreach ($logs as $log) { - if ($log->module == "workshop" and $log->action == "open") { - $workshops[$log->userid] = get_record_sql("SELECT a.name, u.firstname, u.lastname - FROM {$CFG->prefix}workshop a, {$CFG->prefix}user u - WHERE a.id = '$log->info' AND u.id = '$log->userid'"); - $workshops[$log->userid]->time = $log->time; - $workshops[$log->userid]->url = $log->url; - } - } + foreach ($logs as $log) { + //Create a temp valid module structure (course,id) + $tempmod->course = $log->course; + $tempmod->id = $log->info; + //Obtain the visible property from the instance + $modvisible = instance_is_visible($log->module,$tempmod); + + //Only if the mod is visible + if ($modvisible) { + $gradings[$log->info] = workshop_log_info($log); + $gradings[$log->info]->time = $log->time; + $gradings[$log->info]->url = $log->url; + } + } + + if ($gradings) { + $strftimerecent = get_string("strftimerecent"); + $content = true; + print_headline(get_string("newgradings", "workshop").":"); + foreach ($gradings as $grading) { + $date = userdate($grading->time, $strftimerecent); + echo "

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

"; + } + } + } - if ($workshops) { - $content = true; - print_headline(get_string("openassignment", "workshop").":"); - foreach ($workshops as $workshop) { - $date = userdate($workshop->time, "%d %b, %H:%M"); - echo "

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

"; - } - } - return $content; } @@ -642,6 +638,17 @@ function workshop_grades($workshopid) { return $return; } + +function workshop_log_info($log) { + global $CFG; + return get_record_sql("SELECT a.name, u.firstname, u.lastname + FROM {$CFG->prefix}workshop a, + {$CFG->prefix}user u + WHERE a.id = '$log->info' + AND u.id = '$log->userid'"); +} + + ////////////////////////////////////////////////////////////////////////////////////// /*** Functions for the workshop module ****** @@ -693,7 +700,7 @@ function workshop_list_ungraded_assessments($workshop, $stype) { function workshop_list_user_submissions($workshop, $user) { -function workshop_print_assessment($workshop, $assessment, $allowchanges) +function workshop_print_assessment($workshop, $assessment, $allowchanges, $showcommentlinks) function workshop_print_difference($time) { function workshop_print_feedback($course, $submission) { function workshop_print_submission_assessments($workshop, $submission, $type) { @@ -1014,10 +1021,6 @@ function workshop_get_student_submissions($workshop, $order = "title") { ORDER BY $order"); } -function workshop_get_submission() { -// Just a stub - return NULL; -} function workshop_get_submission_assessment($submission, $user) { // Return the user's assessment for this submission @@ -1073,7 +1076,7 @@ function workshop_get_ungraded_assessments_student($workshop) { AND a.submissionid = s.id AND (a.timegraded = 0 OR a.timegraded > $cutofftime) AND a.timecreated < $cutofftime - ORDER BY a.timecreated DESC"); + ORDER BY a.timecreated ASC"); } @@ -1090,7 +1093,7 @@ function workshop_get_ungraded_assessments_teacher($workshop) { AND a.submissionid = s.id AND (a.timegraded = 0 OR a.timegraded > $cutofftime) AND a.timecreated < $cutofftime - ORDER BY a.timecreated DESC"); + ORDER BY a.timecreated ASC"); } @@ -1306,8 +1309,13 @@ function workshop_list_assessed_submissions($workshop, $user) { $comment = ""; $submission = get_record("workshop_submissions", "id", $assessment->submissionid); if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) { - $action = "id&aid=$assessment->id\">". + $action = "id&aid=$assessment->id&". + "allowcomments=$workshop->agreeassessments\">". get_string("view", "workshop").""; + if ($workshop->agreeassessments and !$assessment->timeagreed) { + $action .= " | id&sid=$submission->id\">". + get_string("reassess", "workshop").""; + } } else { // there's still time left to edit... $action = "id&sid=$submission->id\">". @@ -1360,7 +1368,8 @@ function workshop_list_peer_assessments($workshop, $user) { if (isstudent($workshop->course, $assessment->userid)) { // assessments by students only $timenow = time(); if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) { - $action = "id&aid=$assessment->id\">". + $action = "id&aid=$assessment->id&". + "allowcomments=$workshop->agreeassessments\">". get_string("view", "workshop").""; $comment = get_string("assessedon", "workshop", userdate($assessment->timecreated)); // has teacher commented on user's assessment? @@ -1412,23 +1421,31 @@ function workshop_list_student_submissions($workshop, $user) { // count the number of assessments for each student submission if ($submissions = workshop_get_student_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 - $nassessments[$submission->id] = $n; + // ...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); - $comment = ""; + $nsassessments = $workshop->nsassessments; + if ($workshop->includeself) { // add one if self assessment flag is set + $nsassessments++; + } foreach ($nassessments as $submissionid =>$n) { + $comment = ""; $submission = get_record("workshop_submissions", "id", $submissionid); if (($submission->userid != $user->id) or $workshop->includeself) { // add if user has NOT already assessed this submission if (!$assessment = get_record_select("workshop_assessments", "submissionid = $submissionid AND userid = $user->id")) { - if ($nassessed < $workshop->nsassessments) { + if ($submission->userid == $user->id) { + $comment = get_string("ownwork", "workshop"); + } + if ($nassessed < $nsassessments) { $action = "id&sid=$submission->id\">". get_string("assess", "workshop").""; $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment); @@ -1468,28 +1485,30 @@ function workshop_list_submissions_for_admin($workshop, $order) { 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 (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) { - $action = "id&aid=$assessment->id\">" + $action .= " | id&aid=$assessment->id\">" .get_string("reassess", "workshop").""; } else { // there's still time left to edit... - $action = "id&sid=$submission->id\">". + $action .= " | id&sid=$submission->id\">". get_string("edit", "workshop").""; } } else { // user has not graded this submission - $action = "id&sid=$submission->id\">". + $action .= " | id&sid=$submission->id\">". get_string("assess", "workshop").""; } if ($assessments = workshop_get_assessments($submission)) { - $action .= " | "."id&sid=$submission->id\">". + $action .= " | id&sid=$submission->id\">". get_string("listassessments", "workshop").""; } - $action .= " | "."id&sid=$submission->id\">". + $action .= " | id&sid=$submission->id\">". get_string("delete", "workshop").""; $table->data[] = array(workshop_print_submission_title($workshop, $submission), $course->teacher, $action); } @@ -1518,21 +1537,23 @@ function workshop_list_submissions_for_admin($workshop, $order) { 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&aid=$assessment->id\">". + $action .= " | id&aid=$assessment->id\">". get_string("reassess", "workshop").""; } else { // there's still time left to edit... - $action = "id&sid=$submission->id\">". + $action .= " | id&sid=$submission->id\">". get_string("edit", "workshop").""; } } else { // user has not assessed this submission - $action = "id&sid=$submission->id\">". + $action .= " | id&sid=$submission->id\">". get_string("assess", "workshop").""; } if ($assessments = workshop_get_assessments($submission)) { @@ -1607,65 +1628,74 @@ function workshop_list_teacher_submissions($workshop, $user) { // get the number of assessments this user has done $nassessed = count_records_select("workshop_assessments", "workshopid = $workshop->id AND userid = $user->id"); - // count the number of assessments for each teacher submission - if ($submissions = workshop_get_teacher_submissions($workshop)) { - foreach ($submissions as $submission) { - $n = count_records("workshop_assessments", "submissionid", $submission->id); - // OK to have zero - $nassessments[$submission->id] = $n; - } + if ($nassessed < $workshop->ntassessments) { + // if user has not successfully assessed enough display one of 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); + + echo "
";
+			print_r($nassessments);
 			
-		// put the submissions with the lowest number of assessments first
-		asort($nassessments);
-		reset($nassessments);
-		$comment = "";
-		foreach ($nassessments as $submissionid => $n) {
-			$comment = '';
-			$submission = get_record("workshop_submissions", "id", $submissionid);
-			// add if user has NOT already assessed this submission
-			if (!$assessment = get_record_select("workshop_assessments", "submissionid = $submissionid
-					AND userid = $user->id")) {
-				if ($nassessed < $workshop->ntassessments) { 
+			reset($nassessments);
+			$comment = "";
+			foreach ($nassessments as $submissionid => $n) { // actually only the first one is displayed...
+				$comment = '';
+				$submission = get_record("workshop_submissions", "id", $submissionid);
+				// ... provided the user has NOT already assessed that submission
+				if (!$assessment = get_record_select("workshop_assessments", "submissionid = $submissionid
+						AND userid = $user->id")) {
 					$action = "id&sid=$submission->id\">".
 						get_string("assess", "workshop")."";
 					$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
-					$nassessed++;
-					}
-				else {
 					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");
+		}
+	// 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: still fresh; graded but not passed; and static (may or may not be graded 
+				if (($timenow - $assessment->timecreated) < $CFG->maxeditingtime) { // there's still time left to edit...
+					$action = "id&sid=$submission->id\">".
+						get_string("edit", "workshop")."";
 					}
-				// submission from a teacher?
-				if (isteacher($workshop->course, $submission->userid)) {
-					$comment = '';
-					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")."";
-						}
-					$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
+				// has teacher graded user's assessment and it has not passed?
+				elseif ($assessment->timegraded and (($timenow - $assessment->timegraded) > $CFG->maxeditingtime) and 
+						($assessment->gradinggrade < PASSGRADE)) { // allow the user to have another go 
+					$action = "id&sid=$submission->id\">"
+						.get_string("reassess", "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("gradedbyteacher", "workshop", $course->teacher);
+					$comment .= " (".number_format($assessment->gradinggrade*100/COMMENTSCALE,0)."%)";
 					}
+				$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
 				}
 			}
-		print_table($table);
 		}
+	print_table($table);
 	}
 
 
@@ -1747,9 +1777,9 @@ 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("timeassessed", "workshop"), get_string("action", "workshop"));
-	$table->align = array ("LEFT", "LEFT", "LEFT");
-	$table->size = array ("*", "*", "*");
+	$table->head = array (get_string("title", "workshop"), get_string("name"),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();
@@ -1774,8 +1804,9 @@ function workshop_list_ungraded_assessments($workshop, $stype) {
 						get_string("grade", "workshop")."";
 					}
 				$submission = get_record("workshop_submissions", "id", $assessment->submissionid);
+				$user = get_record("user", "id", $assessment->userid);
 				$table->data[] = array(workshop_print_submission_title($workshop, $submission), 
-					userdate($assessment->timecreated), $action);
+					$user->firstname." ".$user->lastname, userdate($assessment->timecreated), $action);
 				}
 			}
 		if (isset($table->data)) {
@@ -1802,7 +1833,9 @@ function workshop_list_user_submissions($workshop, $user) {
 	}
 
 
-function workshop_print_assessment($workshop, $assessment = FALSE, $showcommentlinks = FALSE) {
+function workshop_print_assessment($workshop, $assessment = false, $allowchanges = false, 
+	$showcommentlinks = false) {
+	// $allowchanges added 14/7/03
 	global $CFG, $THEME, $USER, $WORKSHOP_SCALES, $WORKSHOP_EWEIGHTS;
 	if (! $course = get_record("course", "id", $workshop->course)) {
 		error("Course is misconfigured");
@@ -1814,7 +1847,6 @@ function workshop_print_assessment($workshop, $assessment = FALSE, $showcommentl
 	$timenow = time();
 
 	// reset the internal flags
-	$allowchanges = false;
 	if ($assessment) {
 		$showgrades = false;
 		}
@@ -1824,10 +1856,6 @@ function workshop_print_assessment($workshop, $assessment = FALSE, $showcommentl
 	
 	if ($assessment) {
 		// set the internal flag is necessary
-		if (($assessment->userid == $USER->id) and ((($timenow - $assessment->timecreated) < $CFG->maxeditingtime) or 
-				!$assessment->timeagreed)) {
-			$allowchanges = true;
-			}
 		if ($allowchanges or !$workshop->agreeassessments or !$workshop->hidegrades or $assessment->timeagreed) {
 			$showgrades = true;
 			}
@@ -2265,8 +2293,9 @@ function workshop_print_assessment($workshop, $assessment = FALSE, $showcommentl
 		if ($allowchanges) {  
 			echo "\n";
 			}
-		// ...if user is author, assessment not agreed and there are no comments and it's not self assessment then show some buttons
-		if (($submission->userid == $USER->id) and !$assessment->timeagreed and !$comments and 
+		// ...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";
@@ -2452,14 +2481,14 @@ function workshop_test_user_assessments($workshop, $user) {
 	// see if user has passed the required number of assessments of teachers submissions
 	global $CFG;
 	
-	$result = TRUE;
+	$result = true;
 	$n = 0;
 	$timenow =time();
 	if ($workshop->ntassessments) { // they have to pass some!
 		if ($submissions = workshop_get_teacher_submissions($workshop)) {
 			foreach ($submissions as $submission) {
 				if ($assessment = workshop_get_submission_assessment($submission, $user)) {
-					if (($assessment->gradinggrade >= COMMENTSCALE*0.4) and 
+					if (($assessment->gradinggrade >= PASSGRADE) and 
 							(($timenow - $assessment->timegraded) > $CFG->maxeditingtime)) {
 						$n++;
 						}
@@ -2467,7 +2496,7 @@ function workshop_test_user_assessments($workshop, $user) {
 				}
 			}
 		if ($n < min($workshop->ntassessments, workshop_count_teacher_submissions($workshop))) {
-			$result = FALSE; 
+			$result = false; 
 			}
 		}
 	return $result;
diff --git a/mod/workshop/submissions.php b/mod/workshop/submissions.php
index 92724543ce..f4b493f24c 100644
--- a/mod/workshop/submissions.php
+++ b/mod/workshop/submissions.php
@@ -73,7 +73,40 @@
 
 
 	/******************* admin confirm delete ************************************/
-	if ($action == 'adminconfirmdelete' ) {
+	if ($action == 'adminamendtitle' ) {
+
+		if (!isteacher($course->id)) {
+			error("Only teachers can look at this page");
+			}
+		if (empty($_GET['sid'])) {
+			error("Admin Amend Title: submission id missing");
+			}
+		
+		$submission = get_record("workshop_submissions", "id", $_GET['sid']);
+		print_heading(get_string("amendtitle", "workshop"));
+		?>
+		
+		
+		
+		
+		
+ + \n"; + echo " \n"; + echo "

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

\n"; + echo " title\">\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + + } + + + /******************* admin confirm delete ************************************/ + elseif ($action == 'adminconfirmdelete' ) { if (!isteacher($course->id)) { error("Only teachers can look at this page"); @@ -141,6 +174,23 @@ } + /******************* admin update title ************************************/ + elseif ($action == 'adminupdatetitle' ) { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_POST['sid'])) { + error("Admin Update Title: submission id missing"); + } + + if (set_field("workshop_submissions", "title", $_POST['title'], "id", $_POST['sid'])) { + print_heading(get_string("amendtitle", "workshop")." ".get_string("ok")); + } + print_continue("submissions.php?id=$cm->id&action=adminlist"); + } + + /*************** calculate final grades (by teacher) ***************************/ elseif ($action == 'calculatefinalgrades') { @@ -716,7 +766,7 @@ } if ($workshop->phase != 3) { // is this at the expected phase? - echo "
".get_string("assignmentnotinthecorrectphase", "workshop")."
\n"; + print_heading(get_string("assignmentnotinthecorrectphase", "workshop")); print_continue("view.php?a=$workshop->id"); } else { diff --git a/mod/workshop/todo.txt b/mod/workshop/todo.txt index e836973d1a..e153923bb6 100644 --- a/mod/workshop/todo.txt +++ b/mod/workshop/todo.txt @@ -14,7 +14,12 @@ Cron function should email something to the assessor when an assessment is Self assessments may need special handling, remove duplication in student view +Add student names to assessments and submissions for teachers. + +Add a league table of submissions in the final phase for students. + + Ray Kingdon -13 May 2003 +17 June 2003 diff --git a/mod/workshop/upload.php b/mod/workshop/upload.php index cb9fe237b2..7b6e36d257 100644 --- a/mod/workshop/upload.php +++ b/mod/workshop/upload.php @@ -53,7 +53,7 @@ $newsubmission->title = $title; $newsubmission->timecreated = time(); if (!$newsubmission->id = insert_record("workshop_submissions", $newsubmission)) { - error("Failure to create new submission record!"); + error("Workshop upload: Failure to create new submission record!"); } if (! $dir = workshop_file_area($workshop, $newsubmission)) { error("Sorry, an error in the system prevents you from uploading files: contact your teacher or system administrator"); diff --git a/mod/workshop/version.php b/mod/workshop/version.php index bffff6cde4..3094840052 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 = 2003050400; +$module->version = 2003051400; $module->cron = 60; ?> diff --git a/mod/workshop/view.php b/mod/workshop/view.php index 06480dfdf6..912f71bd5f 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -78,9 +78,9 @@ } } elseif (!isguest()) { // it's a student then - if (!$cm->visible) { - notice(get_string("activityiscurrentlyhidden")); - } + if (!$cm->visible) { + notice(get_string("activityiscurrentlyhidden")); + } switch ($workshop->phase) { case 0 : case 1 : $action = 'notavailable'; break; @@ -314,70 +314,70 @@ // print standard assignment heading $strdifference = format_time($workshop->deadline - time()); if (($workshop->deadline - time()) < 0) { - $strdifference = "$strdifference"; + $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")."
"; + 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 "
"; echo format_text($workshop->description, $workshop->format); print_simple_box_end(); - echo "
"; + echo "
"; // in Stage 1? - assess teacher's submissions to a satisfactory level if (!workshop_test_user_assessments($workshop, $USER)) { - echo "
".get_string("pleaseassesstheseexamplesfromtheteacher", "workshop", $course->teacher)."

\n"; + print_heading(get_string("pleaseassesstheseexamplesfromtheteacher", "workshop", $course->teacher)); + print_heading(get_string("theseasessmentsaregradedbytheteacher", "workshop", $course->teacher), "center", 5); workshop_list_teacher_submissions($workshop, $USER); - echo "
".get_string("theseasessmentsaregradedbytheteacher", "workshop", $course->teacher)."

\n"; } // in stage 2? - submit own first attempt else { if ($workshop->ntassessments) { // display message if student had to assess the teacher's examples - echo "

id\">". - get_string("assessmentsareok", "workshop")."
\n"; + print_heading("id\">". + get_string("assessmentsareok", "workshop").""); } if (!workshop_get_user_submissions($workshop, $USER)) { // print upload form - print_heading(get_string("submitassignment", "assignment").":", "CENTER"); + print_heading(get_string("submitassignment", "assignment").":"); workshop_print_upload_form($workshop); } // in stage 3? - grade other student's submissions, resubmit and list all submissions else { // list any assessments by teachers if (workshop_count_teacher_assessments($workshop, $USER)) { - echo "

".get_string("assessmentsby", "workshop", $course->teachers)."

\n"; + print_heading(get_string("assessmentsby", "workshop", $course->teachers)); workshop_list_teacher_assessments($workshop, $USER); } // if student assessments show any to assess... 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"; + print_heading(get_string("yourassessments", "workshop")); workshop_list_assessed_submissions($workshop, $USER); // ... and show peer assessments if (workshop_count_peer_assessments($workshop, $USER)) { - echo "

".get_string("assessmentsby", "workshop", $course->students)."

\n"; + print_heading(get_string("assessmentsby", "workshop", $course->students)); workshop_list_peer_assessments($workshop, $USER); } } // list previous submissions - echo "

".get_string("submissions", "workshop")."

\n"; + print_heading(get_string("submissions", "workshop")); workshop_list_user_submissions($workshop, $USER); echo "
"; if ($workshop->resubmit) { // if resubmissions allowed print upload form - print_heading(get_string("submitassignment", "assignment").":", "CENTER"); + print_heading(get_string("submitassignment", "assignment").":"); workshop_print_upload_form($workshop); echo "
"; } - echo "
id\">". - get_string("listofallsubmissions", "workshop")."
\n"; + print_heading("id\">". + get_string("listofallsubmissions", "workshop")); } } }