diff --git a/mod/workshop/assessments.php b/mod/workshop/assessments.php index 7addaa2cf63..bc75104cd55 100644 --- a/mod/workshop/assessments.php +++ b/mod/workshop/assessments.php @@ -1,4 +1,4 @@ -description = ''; $elements[$i]->scale =0; + $elements[$i]->maxscore = 0; $elements[$i]->weight = 11; } } @@ -362,17 +363,6 @@ break; case 2: // error banded grading - if ($elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC" )) { - foreach ($elementsraw as $element) { - $elements[] = $element; // to renumber index 0,1,2... - } - } - else { // set up the elements array with default values - for ($i=0; $i<=$workshop->nelements; $i++) { - $elements[$i]->description = ''; - $elements[$i]->maxscore =0; - } - } for ($i=0; $i<$workshop->nelements; $i++) { $iplus1 = $i+1; echo "\n"; @@ -401,24 +391,17 @@ } for ($i=0; $i<=$workshop->nelements; $i++) { echo "$i"; + if (!isset($elements[$i])) { // the "last one" will be! + $elements[$i]->description = ""; + $elements[$i]->maxscore = 0; + } choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, ""); echo "\n"; } echo "\n"; break; - case 3: // criteria grading - if ($elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC" )) { - foreach ($elementsraw as $element) { - $elements[] = $element; // to renumber index 0,1,2... - } - } - else { // set up the elements array with default values - for ($i=0; $i<=$workshop->nelements; $i++) { - $elements[$i]->description = ''; - $elements[$i]->maxscore =0; - } - } + case 3: // criterion grading for ($j = 100; $j >= 0; $j--) { $numbers[$j] = $j; } @@ -436,6 +419,42 @@ echo "\n"; } break; + + case 4: // rubric + for ($j = 100; $j >= 0; $j--) { + $numbers[$j] = $j; + } + if ($rubricsraw = get_records("workshop_rubrics", "workshopid", $workshop->id)) { + foreach ($rubricsraw as $rubric) { + $rubrics[$rubric->elementno][$rubric->rubricno] = $rubric->description; // reindex 0,1,2... + } + } + for ($i=0; $i<$workshop->nelements; $i++) { + $iplus1 = $i+1; + echo "\n"; + echo "

". get_string("element","workshop")." $iplus1:\n"; + echo "\n"; + echo " \n"; + echo "".get_string("elementweight", "workshop").":\n"; + workshop_choose_from_menu($WORKSHOP_EWEIGHTS, "weight[]", $elements[$i]->weight, ""); + echo " \n"; + echo "\n"; + + for ($j=0; $j<5; $j++) { + $jplus1 = $j+1; + if (empty($rubrics[$i][$j])) { + $rubrics[$i][$j] = ""; + } + echo "\n"; + echo "

". get_string("grade","workshop")." $j:\n"; + echo "\n"; + echo " \n"; + } + echo "\n"; + echo " cellheading2\"> \n"; + echo "\n"; + } + break; } // close table and form ?> @@ -471,7 +490,7 @@ } // get the teacher's assessment first if ($teachersassessment = workshop_get_submission_assessment($submission, $USER)) { - echo "

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

".get_string("teacherassessments", "workshop", $course->teacher)."
\n"; workshop_print_assessment($workshop, $teachersassessment); } // now the student's assessment (don't allow changes) @@ -590,7 +609,7 @@ break; case 2: // error banded grading... - case 3: // ...and criteria grading + case 3: // ...and criterion grading // Insert all the elements that contain something, the number of descriptions is one less than the number of grades foreach ($form->maxscore as $key => $themaxscore) { unset($element); @@ -608,6 +627,42 @@ } } break; + + case 4: // ...and criteria grading + // Insert all the elements that contain something + foreach ($form->description as $key => $description) { + unset($element); + $element->workshopid = $workshop->id; + $element->elementno = $key; + $element->description = $description; + $element->weight = $form->weight[$key]; + for ($j=0;$j<5;$j++) { + if (empty($form->rubric[$key][$j])) + break; + } + $element->maxscore = $j - 1; + if (!$element->id = insert_record("workshop_elements", $element)) { + error("Could not insert workshop element!"); + } + } + // let's not fool around here, dump the junk! + delete_records("workshop_rubrics", "workshopid", $workshop->id); + for ($i=0;$i<$workshop->nelements;$i++) { + for ($j=0;$j<5;$j++) { + unset($element); + if (empty($form->rubric[$i][$j])) { // OK to have an element with fewer than 5 items + break; + } + $element->workshopid = $workshop->id; + $element->elementno = $i; + $element->rubricno = $j; + $element->description = $form->rubric[$i][$j]; + if (!$element->id = insert_record("workshop_rubrics", $element)) { + error("Could not insert workshop element!"); + } + } + } + break; } // end of switch echo "

\n"; @@ -766,6 +821,35 @@ error("Could not insert workshop element!"); } $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * $workshop->grade / 100; + break; + + case 4: // rubric grading (identical to accumulative grading) + // Insert all the elements that contain something + foreach ($form->grade as $key => $thegrade) { + unset($element); + $element->workshopid = $workshop->id; + $element->assessmentid = $assessment->id; + $element->elementno = $key; + $element->feedback = $form->feedback[$key]; + $element->grade = $thegrade; + if (!$element->id = insert_record("workshop_grades", $element)) { + error("Could not insert workshop element!"); + } + } + // now work out the grade... + $rawgrade=0; + $totalweight=0; + foreach ($form->grade as $key => $grade) { + $maxscore = $elements[$key]->maxscore; + $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight]; + if ($weight > 0) { + $totalweight += $weight; + } + $rawgrade += ($grade / $maxscore) * $weight; + } + $grade = $workshop->grade * ($rawgrade / $totalweight); + break; + } // end of switch // update the time of the assessment record (may be re-edited)... diff --git a/mod/workshop/db/mysql.php b/mod/workshop/db/mysql.php index cb92e3edb6a..565a18cc67b 100644 --- a/mod/workshop/db/mysql.php +++ b/mod/workshop/db/mysql.php @@ -45,6 +45,13 @@ function workshop_upgrade($oldversion) { "); } + + if ($oldversion < 2003082200) { + + execute_sql(" ALTER TABLE `{$CFG->prefix}workshop_rubrics` CHANGE `elementid` `elementno` INT(10) UNSIGNED NOT NULL DEFAULT '0'"); + + } + return true; } diff --git a/mod/workshop/db/mysql.sql b/mod/workshop/db/mysql.sql index 59688922290..8bccf74f6c8 100644 --- a/mod/workshop/db/mysql.sql +++ b/mod/workshop/db/mysql.sql @@ -101,7 +101,7 @@ CREATE TABLE `prefix_workshop_elements` ( 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', + `elementno` int(10) unsigned NOT NULL default '0', `rubricno` tinyint(3) unsigned NOT NULL default '0', `description` text NOT NULL, PRIMARY KEY (`id`) diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index 83b06f8ef95..49e62077e4b 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -1,4 +1,4 @@ -dirroot/files/mimetypes.php"); @@ -9,7 +9,8 @@ error_reporting(15); $WORKSHOP_TYPE = array (0 => get_string("notgraded", "workshop"), 1 => get_string("accumulative", "workshop"), 2 => get_string("errorbanded", "workshop"), - 3 => get_string("criteria", "workshop") ); + 3 => get_string("criterion", "workshop"), + 4 => get_string("rubric", "workshop") ); $WORKSHOP_SHOWGRADES = array (0 => get_string("dontshowgrades", "workshop"), 1 => get_string("showgrades", "workshop") ); @@ -29,7 +30,7 @@ $WORKSHOP_SCALES = array( $WORKSHOP_EWEIGHTS = array( 0 => -4.0, 1 => -2.0, 2 => -1.5, 3 => -1.0, 4 => -0.75, 5 => -0.5, 6 => -0.25, 7 => 0.0, 8 => 0.25, 9 => 0.5, 10 => 0.75, 11=> 1.0, 12 => 1.5, 13=> 2.0, 14 => 4.0); -$WORKSHOP_FWEIGHTS = array( 0 => 0, 1 => 0.1, 2 => 0.25, 3 => 0.5, 4 => 0.75, 5 => 1, 6 => 1.5, +$WORKSHOP_FWEIGHTS = array( 0 => 0, 1 => 0.1, 2 => 0.25, 3 => 0.5, 4 => 0.75, 5 => 1.0, 6 => 1.5, 7 => 2.0, 8 => 3.0, 9 => 5.0, 10 => 7.5, 11=> 10.0); if (!defined("COMMENTSCALE")) { @@ -702,6 +703,7 @@ function workshop_print_assessments_by_user_for_admin($workshop, $user) { function workshop_print_assessments_for_admin($workshop, $submission) { function workshop_print_difference($time) { function workshop_print_feedback($course, $submission) { +function workshop_print_league_table($workshop) { function workshop_print_submission_assessments($workshop, $submission, $type) { function workshop_print_submission_title($workshop, $user) { function workshop_print_tabbed_table($table) { @@ -1074,7 +1076,10 @@ function workshop_get_student_submissions($workshop, $order = "title") { if ($order == "name") { $order = "a.firstname, a.lastname"; } - return get_records_sql("SELECT s.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_students u, + if ($order == "grade") { + $order = "$workshop->teacherweight * s.teachergrade + $workshop->peerweight * s.peergrade DESC"; + } + return get_records_sql("SELECT s.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_students u, {$CFG->prefix}user a WHERE u.course = $workshop->course AND s.userid = u.userid @@ -1644,7 +1649,7 @@ function workshop_list_submissions_for_admin($workshop, $order) { $title .= " {-"; } if ($assessment->timegraded) { - $title .= "/".number_format($assessment->gradinggrade*100/COMMENTSCALE,0)."%"; + $title .= "/".number_format($assessment->gradinggrade * 100 / COMMENTSCALE, 0)."%"; } $title .= "} "; if ($realassessments = workshop_count_user_assessments_done($workshop, $user)) { @@ -1976,6 +1981,9 @@ function workshop_list_ungraded_assessments($workshop, $stype) { function workshop_list_user_submissions($workshop, $user) { + global $CFG; + + $timenow = time(); $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("submitted", "assignment"), get_string("assessments", "workshop")); $table->align = array ("LEFT", "LEFT", "LEFT", "LEFT"); @@ -1985,8 +1993,8 @@ function workshop_list_user_submissions($workshop, $user) { if ($submissions = workshop_get_user_submissions($workshop, $user)) { foreach ($submissions as $submission) { - // allow user to delete submissions if there is more than one submission - if (count($submissions) > 1) { + // allow user to delete submissions if there is more than one submission or if it's fresh + if ((count($submissions) > 1) or (($timenow - $submission->timecreated) < $CFG->maxeditingtime)) { $action = "id&sid=$submission->id\">". get_string("delete", "workshop").""; } @@ -2093,7 +2101,7 @@ function workshop_print_assessment($workshop, $assessment = false, $allowchanges // 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"; + get_string("maximumgrade")." ".number_format($workshop->grade, 0)."%)
\n"; } } @@ -2177,7 +2185,7 @@ function workshop_print_assessment($workshop, $assessment = false, $allowchanges echo "

". get_string("element","workshop")." $iplus1:

\n"; echo " ".text_to_html($elements[$i]->description); echo "

Weight: " - .number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight],2)."\n"; + .number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight], 2)."\n"; echo "\n"; if ($showgrades) { echo "\n"; @@ -2259,7 +2267,7 @@ function workshop_print_assessment($workshop, $assessment = false, $allowchanges echo "

". get_string("element","workshop")." $iplus1:

\n"; echo " ".text_to_html($elements[$i]->description); echo "

Weight: " - .number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight],2)."\n"; + .number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight], 2)."\n"; echo "\n"; echo "\n"; echo "

". get_string("grade"). ":

\n"; @@ -2407,12 +2415,71 @@ function workshop_print_assessment($workshop, $assessment = false, $allowchanges choose_from_menu($numbers, "grade[1]", 0, ""); } echo "\n"; + break; + + case 4: // rubric grading + // now run through the elements... + for ($i=0; $i < count($elements); $i++) { + $iplus1 = $i+1; + echo "\n"; + echo "".get_string("element", "workshop")." $iplus1:\n"; + echo "".text_to_html($elements[$i]->description). + "

Weight: " + .number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight], 2)."\n"; + echo "\n"; + echo " cellheading2\" align=\"center\">".get_string("select", "workshop")."\n"; + echo " cellheading2\">". get_string("criterion","workshop")."\n"; + if (isset($grades[$i])) { + $selection = $grades[$i]->grade; + } else { + $selection = 0; + } + // ...and the rubrics + if ($rubricsraw = get_records_select("workshop_rubrics", "workshopid = $workshop->id AND + elementno = $i", "rubricno ASC")) { + unset($rubrics); + foreach ($rubricsraw as $rubic) { + $rubrics[] = $rubic; // to renumber index 0,1,2... + } + for ($j=0; $j<5; $j++) { + if (empty($rubrics[$j]->description)) { + break; // out of inner for loop + } + echo "\n"; + if ($selection == $j) { + echo " \n"; + }else { + echo " \n"; + } + echo "".text_to_html($rubrics[$j]->description)."\n"; + } + echo "\n"; + echo "

". get_string("feedback").":

\n"; + echo " \n"; + if ($allowchanges) { + echo " \n"; + } + else { + echo text_to_html($grades[$i]->feedback); + } + echo " \n"; + echo "\n"; + echo "\n"; + echo " cellheading2\"> \n"; + echo "\n"; + } + } + break; } // end of outer switch // now get the general comment (present in all types) - echo "\n"; - echo "

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

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

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

\n"; + echo " \n"; if ($allowchanges) { echo "