From 94cc7ed0f1051d34162cbed4e42c56d58adc2af3 Mon Sep 17 00:00:00 2001 From: rkingdon Date: Fri, 6 Aug 2004 14:42:23 +0000 Subject: [PATCH] Removal teacher assessment of student assessments; addition of Groups, various improvements. --- mod/exercise/assessments.php | 144 ++-- mod/exercise/db/mysql.php | 9 +- mod/exercise/db/mysql.sql | 8 +- mod/exercise/db/oci8po.sql | 1 + mod/exercise/db/postgres7.php | 9 + mod/exercise/db/postgres7.sql | 6 +- mod/exercise/index.php | 56 +- mod/exercise/lib.php | 147 +--- mod/exercise/locallib.php | 1516 ++++++++++++--------------------- mod/exercise/mod.html | 75 +- mod/exercise/submissions.php | 38 +- mod/exercise/version.php | 2 +- mod/exercise/view.php | 41 +- 13 files changed, 824 insertions(+), 1228 deletions(-) diff --git a/mod/exercise/assessments.php b/mod/exercise/assessments.php index 65979be2e4..6d0e23fabc 100644 --- a/mod/exercise/assessments.php +++ b/mod/exercise/assessments.php @@ -3,7 +3,8 @@ /************************************************* ACTIONS handled are: - adminconfirmdelete + adminamendgradinggrading + adminconfirmdelete admindelete adminedit adminlist @@ -19,7 +20,7 @@ teacherassessment (for teachers) teachertable updateassessment - updatedualassessment + updateteacherassessment userconfirmdelete userdelete viewassessment @@ -45,6 +46,7 @@ error("Course module is incorrect"); } + exercise_add_custom_scales($exercise); require_login($course->id); @@ -67,42 +69,6 @@ require_variable($action); - /******************* admin confirm delete ************************************/ - if ($action == 'adminconfirmdelete' ) { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - if (empty($_GET['aid'])) { - error("Admin confirm delete: assessment id missing"); - } - - notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("assessment", "exercise")), - "assessments.php?action=admindelete&id=$cm->id&aid=$_GET[aid]", - "submissions.php?action=adminlist&id=$cm->id"); - } - - - /******************* admin delete ************************************/ - elseif ($action == 'admindelete' ) { - - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } - if (empty($_GET['aid'])) { - error("Admin delete: submission id missing"); - } - - print_string("deleting", "exercise"); - // first delete all the associated records... - delete_records("exercise_grades", "assessmentid", $_GET['aid']); - // ...now delete the assessment... - delete_records("exercise_assessments", "id", $_GET['aid']); - - print_continue("submissions.php?id=$cm->id&action=adminlist"); - } - - /******************* admin amend Grading Grade ************************************/ if ($action == 'adminamendgradinggrade' ) { @@ -126,10 +92,11 @@ echo "".get_string("gradeforstudentsassessment", "exercise", $course->student)." :\n"; // set up coment scale - for ($i=COMMENTSCALE; $i>=0; $i--) { + for ($i=$exercise->gradinggrade; $i>=0; $i--) { $num[$i] = $i; } - choose_from_menu($num, "gradinggrade", $assessment->gradinggrade, ""); + choose_from_menu($num, "gradinggrade", + number_format($exercise->gradinggrade * $assessment->gradinggrade / 100, 0), ""); echo "\n"; echo ""; echo "\n"; @@ -137,10 +104,43 @@ echo "\n"; echo ""; echo "\n"; + } + + /******************* admin confirm delete ************************************/ + elseif ($action == 'adminconfirmdelete' ) { + + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_GET['aid'])) { + error("Admin confirm delete: assessment id missing"); + } + + notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("assessment", "exercise")), + "assessments.php?action=admindelete&id=$cm->id&aid=$_GET[aid]", + "submissions.php?action=adminlist&id=$cm->id"); + } + + /******************* admin delete ************************************/ + elseif ($action == 'admindelete' ) { - } + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } + if (empty($_GET['aid'])) { + error("Admin delete: submission id missing"); + } + + print_string("deleting", "exercise"); + // first delete all the associated records... + delete_records("exercise_grades", "assessmentid", $_GET['aid']); + // ...now delete the assessment... + delete_records("exercise_assessments", "id", $_GET['aid']); + + print_continue("submissions.php?id=$cm->id&action=adminlist"); + } /*********************** admin list of asssessments (of a submission) (by teachers)**************/ @@ -258,7 +258,7 @@ if (!isteacher($course->id)) { error("Only teachers can look at this page"); } - + $count = count_records("exercise_grades", "exerciseid", $exercise->id); if ($exercise->phase > 1 and $count) { notify(get_string("warningonamendingelements", "exercise")); @@ -308,6 +308,7 @@ foreach ($EXERCISE_SCALES as $KEY => $SCALE) { $SCALES[] = $SCALE['name']; } + for ($i=0; $i<$exercise->nelements; $i++) { $iplus1 = $i+1; echo "\n"; @@ -455,7 +456,7 @@ // let's not fool around here, dump the junk! delete_records("exercise_elements", "exerciseid", $exercise->id); - + // determine wich type of grading switch ($exercise->gradingstrategy) { case 0: // no grading @@ -607,7 +608,7 @@ if (!$submission = get_record("exercise_submissions", "id", $sid)) { error("Teacher assessment: User's submission record not found"); } - exercise_print_dual_assessment_form($exercise, $assessment, $submission, $_SERVER["HTTP_REFERER"]); + exercise_print_teacher_assessment_form($exercise, $assessment, $submission, $_SERVER["HTTP_REFERER"]); } @@ -835,37 +836,23 @@ } - /****************** update dual assessment (by teacher only) ***************************/ - elseif ($action == 'updatedualassessment') { + /****************** update teacher assessment (by teacher only) ***************************/ + elseif ($action == 'updateteacherassessment') { if (!isteacher($course->id)) { error("Only teachers can look at this page"); - } + } $timenow = time(); $form = (object)$HTTP_POST_VARS; - // first do the teacher's comments and grading grade of the user's assessment - if (!$assessment = get_record("exercise_assessments", "id", $form->aid)) { - error("Update dual assessment: user's assessment record not found"); - } - //save the comment and grade for the assessment - if (isset($form->teachercomment)) { - set_field("exercise_assessments", "teachercomment", $form->teachercomment, "id", $assessment->id); - set_field("exercise_assessments", "gradinggrade", $form->gradinggrade, "id", $assessment->id); - set_field("exercise_assessments", "timegraded", $timenow, "id", $assessment->id); - set_field("exercise_assessments", "mailed", 0, "id", $assessment->id); - echo "".get_string("savedok", "exercise")."
\n"; - - add_to_log($course->id, "exercise", "grade", "view.php?id=$cm->id", "$assessment->id"); - } - - // now do the assessment of a user's submission + + // first do the (teacher's) assessment of the student's submission if (! $submission = get_record("exercise_submissions", "id", $form->sid)) { - error("Update dual assessment: user's submission record not found"); + error("Update teacher assessment: student's submission record not found"); } if (!$assessment = exercise_get_submission_assessment($submission, $USER)) { - error("Update dual assessment: teacher's assessment record not found"); + error("Update teacher assessment: teacher's assessment record not found"); } // first get the assignment elements for maxscores and weights... @@ -1020,7 +1007,20 @@ set_field("exercise_assessments", "generalcomment", $form->generalcomment, "id", $assessment->id); } - // is user allowed to resubmit? + // now calculate the (grading) grade of the student's assessment... + if (!$stassessment = get_record("exercise_assessments", "id", $form->said)) { + error("Update teacher assessment: student's assessment record not found"); + } + $gradinggrade = exercise_compare_assessments($exercise, $assessment, $stassessment); + // ...and save the grade for the assessment + set_field("exercise_assessments", "gradinggrade", $gradinggrade, "id", $stassessment->id); + set_field("exercise_assessments", "timegraded", $timenow, "id", $stassessment->id); + set_field("exercise_assessments", "mailed", 0, "id", $stassessment->id); + echo "".get_string("savedok", "exercise")."
\n"; + + add_to_log($course->id, "exercise", "grade", "view.php?id=$cm->id", "$stassessment->id"); + + // is user allowed to resubmit? if ($form->resubmit == 1) { set_field("exercise_submissions", "resubmit", 1, "id", $submission->id); } @@ -1038,9 +1038,11 @@ // show grade if grading strategy is not zero if ($exercise->gradingstrategy) { - redirect($returnto, "

".get_string("thegradeis", "exercise").": ". - number_format($grade * $exercise->grade / 100.0, 1)." (".get_string("maximumgrade"). - " ".number_format($exercise->grade).")

", 1); + redirect($returnto, "

".get_string("gradeforstudentsassessment", + "exercise", $course->student).": ".number_format($gradinggrade * $exercise->gradinggrade / 100.0, 1). + " (".get_string("maximumgrade")." ".number_format($exercise->gradinggrade, 1).")

". + get_string("thegradeis", "exercise").": ".number_format($grade * $exercise->grade / 100.0, 1). + " (".get_string("maximumgrade")." ".number_format($exercise->grade, 1).")

"); } else { redirect($returnto); @@ -1056,7 +1058,9 @@ } require_variable($aid); - if (!set_field("exercise_assessments", "gradinggrade", $_POST['gradinggrade'], "id", + // normalise gradinggrade + $gradinggrade = $_POST['gradinggrade'] * 100 / $exercise->gradinggrade; + if (!set_field("exercise_assessments", "gradinggrade", $gradinggrade, "id", $_POST['aid'])) { error("Update grading grade: asseesment not updated"); } diff --git a/mod/exercise/db/mysql.php b/mod/exercise/db/mysql.php index 954aab1e30..2538b788f7 100644 --- a/mod/exercise/db/mysql.php +++ b/mod/exercise/db/mysql.php @@ -17,7 +17,14 @@ function exercise_upgrade($oldversion) { if ($oldversion < 2003121000) { execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_submissions` ADD `late` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0'"); } - + + if ($oldversion < 2004062300) { + table_column("exercise", "", "gradinggrade", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade"); + table_column("exercise", "", "assessmentcomps", "INTEGER", "4", "UNSIGNED", "2", "NOT NULL", "usemaximum"); + execute_sql("ALTER TABLE `{$CFG->prefix}exercise` DROP COLUMN `teacherweight`"); + execute_sql("ALTER TABLE `{$CFG->prefix}exercise` DROP COLUMN `gradingweight`"); + } + return true; } diff --git a/mod/exercise/db/mysql.sql b/mod/exercise/db/mysql.sql index 916109f4d9..39fb61f725 100644 --- a/mod/exercise/db/mysql.sql +++ b/mod/exercise/db/mysql.sql @@ -10,13 +10,13 @@ CREATE TABLE `prefix_exercise` ( `phase` tinyint(3) unsigned NOT NULL default '0', `gradingstrategy` tinyint(3) unsigned NOT NULL default '1', `usemaximum` tinyint(3) unsigned NOT NULL default '0', - `anonymous` tinyint(3) unsigned NOT NULL default '0', + `assessmentcomps` tinyint(3) unsigned NOT NULL default '2', + `anonymous` tinyint(3) unsigned NOT NULL default '1', `maxbytes` int(10) unsigned NOT NULL default '100000', `deadline` int(10) unsigned NOT NULL default '0', - `grade` tinyint(3) NOT NULL default '0', `timemodified` int(10) unsigned NOT NULL default '0', - `teacherweight` tinyint(3) unsigned NOT NULL default '5', - `gradingweight` tinyint(3) unsigned NOT NULL default '5', + `grade` tinyint(3) NOT NULL default '0', + `gradinggrade` tinyint(3) NOT NULL default '0', `showleaguetable` tinyint(3) unsigned NOT NULL default '0', PRIMARY KEY (`id`) ) COMMENT='Defines exercise'; diff --git a/mod/exercise/db/oci8po.sql b/mod/exercise/db/oci8po.sql index 412817fb9a..0e0531294e 100755 --- a/mod/exercise/db/oci8po.sql +++ b/mod/exercise/db/oci8po.sql @@ -11,6 +11,7 @@ CREATE TABLE prefix_exercise ( phase number(3) default '0' not null, gradingstrategy number(3) default '1' not null, usemaximum number(3) default '0' not null, + assessmentcomps number(3) default '2' not null, anonymous number(3) default '0' not null, maxbytes number(10) default '100000' not null, deadline number(10) default '0' not null, diff --git a/mod/exercise/db/postgres7.php b/mod/exercise/db/postgres7.php index 2a788980d1..202a3ae87c 100644 --- a/mod/exercise/db/postgres7.php +++ b/mod/exercise/db/postgres7.php @@ -6,6 +6,15 @@ function exercise_upgrade($oldversion) { global $CFG; + if ($oldversion < 2003121000) { + execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_submissions` ADD `late` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0'"); + } + + if ($oldversion < 2004062300) { + table_column("exercise", "", "gradinggrade", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade"); + table_column("exercise", "", "assessmentcomps", "INTEGER", "4", "UNSIGNED", "2", "NOT NULL", "usemaximum"); + } + return true; } diff --git a/mod/exercise/db/postgres7.sql b/mod/exercise/db/postgres7.sql index e5b443f113..7b402d0d71 100644 --- a/mod/exercise/db/postgres7.sql +++ b/mod/exercise/db/postgres7.sql @@ -10,13 +10,13 @@ CREATE TABLE prefix_exercise ( phase INT NOT NULL default '0', gradingstrategy INT NOT NULL default '1', usemaximum INT NOT NULL default '0', + assessmentcomps INT NOT NULL default '2', anonymous INT NOT NULL default '0', maxbytes INT8 NOT NULL default '100000', deadline INT8 NOT NULL default '0', - grade INT NOT NULL default '0', timemodified INT8 NOT NULL default '0', - teacherweight INT NOT NULL default '5', - gradingweight INT NOT NULL default '5', + grade INT NOT NULL default '0', + gradinggrade INT NOT NULL default '0', showleaguetable INT NOT NULL default '0' ); # -------------------------------------------------------- diff --git a/mod/exercise/index.php b/mod/exercise/index.php index 4699a8b4cb..f5e48ca14d 100644 --- a/mod/exercise/index.php +++ b/mod/exercise/index.php @@ -78,48 +78,46 @@ switch ($exercise->phase) { case 1: $phase = get_string("phase1short", "exercise"); break; - case 2: $phase = get_string("phase2short", "exercise"); + case 2: $phase = get_string("phase2short", "exercise")." [". + get_string("unassessed", "exercise", + exercise_count_unassessed_student_submissions($exercise))."]"; break; - case 3: $phase = get_string("phase3short", "exercise"); + case 3: $phase = get_string("phase3short", "exercise")." [". + get_string("unassessed", "exercise", + exercise_count_unassessed_student_submissions($exercise))."]"; break; } $table->data[] = array ($exercise->section, $link, $title, $phase, $submitted, $due); - } else { - $assessed = false; - if ($exercise->usemaximum) { - $maximum = exercise_get_best_grade($submission); - if (isset($maximum)) { - $grade = $maximum->grade; - $assessed = true; + } else { // it's a student + if ($assessments = exercise_get_user_assessments($exercise, $USER)) { // should be only one... + foreach ($assessments as $studentassessment) { + break; } - }else { // use mean value - $mean = exercise_get_mean_grade($submission); - if (isset($mean->grade)) { - $grade = $mean->grade; - $assessed = true; - } - } - if ($assessed) { - $actualgrade = number_format($grade * $exercise->grade / 100.0, 1); - if ($submission->late) { - $actualgrade = "(".$actualgrade.")"; + if ($studentassessment->timegraded) { // it's been assessed + if ($teacherassessment = exercise_get_submission_assessment($submission)) { + $actualgrade = number_format(($studentassessment->gradinggrade * + $exercise->gradinggrade / 100.0) + ($teacherassessment->grade * + $exercise->grade / 100.0), 1); + if ($submission->late) { + $actualgrade = "(".$actualgrade.")"; + } + $actualgrade .= " (".get_string("maximumshort").": ". + number_format($exercise->gradinggrade + $exercise->grade, 0).")"; + $table->data[] = array ($exercise->section, $link, $title, $actualgrade, + $submitted, $due); + } } else { - } - $table->data[] = array ($exercise->section, $link, $title, - $actualgrade, $submitted, $due); - } else { - $table->data[] = array ($exercise->section, $link, $title, + $table->data[] = array ($exercise->section, $link, $title, "-", $submitted, $due); + } } } - } - else { + } else { $table->data[] = array ($link, $submitted, $due); } } - } - else { + } else { $submitted = get_string("no"); $title = ''; $link = "coursemodule\">$exercise->name"; diff --git a/mod/exercise/lib.php b/mod/exercise/lib.php index 6b262d5e49..3613b03774 100644 --- a/mod/exercise/lib.php +++ b/mod/exercise/lib.php @@ -26,14 +26,14 @@ $EXERCISE_SCALES = array( 9 => array( 'name' => get_string("scale100", "exercise"), 'type' => 'selection', 'size' => 100)); $EXERCISE_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); + 7 => 0.0, 8 => 0.25, 9 => 0.5, 10 => 0.75, 11=> 1.0, 12 => 1.5, 13=> 2.0, 14 => 4.0); -$EXERCISE_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")) { - define("COMMENTSCALE", 20); - } +$EXERCISE_ASSESSMENT_COMPS = array ( + 0 => array('name' => get_string("verylax", "exercise"), 'value' => 1), + 1 => array('name' => get_string("lax", "exercise"), 'value' => 0.6), + 2 => array('name' => get_string("fair", "exercise"), 'value' => 0.4), + 3 => array('name' => get_string("strict", "exercise"), 'value' => 0.33), + 4 => array('name' => get_string("verystrict", "exercise"), 'value' => 0.2) ); /*** Standard Moodle functions ****************** function exercise_add_instance($exercise) @@ -114,7 +114,7 @@ function exercise_choose_from_menu ($options, $name, $selected="", $nothing="cho /*******************************************************************/ -function exercise_cron () { +function exercise_cron() { // Function to be run periodically according to the moodle cron // Finds all exercise notifications that have yet to be mailed out, and mails them @@ -127,8 +127,11 @@ function exercise_cron () { $timenow = time(); foreach ($assessments as $assessment) { - echo "Processing exercise assessment $assessment->id\n"; + // switch on mailed + if (! set_field("exercise_assessments", "mailed", "1", "id", "$assessment->id")) { + echo "Could not update the mailed field for id $assessment->id\n"; + } if (! $submission = get_record("exercise_submissions", "id", "$assessment->submissionid")) { echo "Could not find submission $assessment->submissionid\n"; continue; @@ -160,6 +163,11 @@ function exercise_cron () { continue; // Not an active participant } + // if the submission belongs to a teacher it's a student assessment. No need to email anything. + if (isteacher($course->id, $submissionowner->id)) { + continue; + } + $strexercises = get_string("modulenameplural", "exercise"); $strexercise = get_string("modulename", "exercise"); @@ -194,93 +202,11 @@ function exercise_cron () { 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: exercise cron: Could not send out mail for id $submission->id to user $sendto->id ($sendto->email)\n"; - } - if (! set_field("exercise_assessments", "mailed", "1", "id", "$assessment->id")) { - echo "Could not update the mailed field for id $assessment->id\n"; - } - } - } - - // look for new gradings - if ($assessments = exercise_get_unmailed_graded_assessments($cutofftime)) { - $timenow = time(); - - foreach ($assessments as $assessment) { - - echo "Processing exercise assessment $assessment->id (graded)\n"; - - if (! $submission = get_record("exercise_submissions", "id", "$assessment->submissionid")) { - echo "Could not find submission $assessment->submissionid\n"; - continue; - } - if (! $exercise = get_record("exercise", "id", $submission->exerciseid)) { - echo "Could not find exercise record for id $submission->exerciseid\n"; - continue; - } - if (! $course = get_record("course", "id", "$exercise->course")) { - echo "Could not find course $exercise->course\n"; - continue; } - if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); - continue; - } - - if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) { - echo "Could not find user $assessment->userid\n"; - continue; - } - - if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) { - continue; // Not an active participant - } - - $strexercises = get_string("modulenameplural", "exercise"); - $strexercise = get_string("modulename", "exercise"); - - // it's a grading tell the assessment owner - $USER->lang = $assessmentowner->lang; - $sendto = $assessmentowner; - // Your assessment of the assignment \"$submission->title\" has by reviewed - $msg = get_string("mail6", "exercise", $submission->title).".\n"; - // The comments given by the $course->teacher can be seen in the exercise Assignment - $msg .= get_string("mail7", "exercise", $course->teacher)." '$exercise->name'.\n\n"; - - $postsubject = "$course->shortname: $strexercises: $exercise->name"; - $posttext = "$course->shortname -> $strexercises -> $exercise->name\n"; - $posttext .= "---------------------------------------------------------------------\n"; - $posttext .= $msg; - // "You can see it in your exercise assignment" - $posttext .= get_string("mail3", "exercise").":\n"; - $posttext .= " $CFG->wwwroot/mod/exercise/view.php?id=$cm->id\n"; - $posttext .= "---------------------------------------------------------------------\n"; - if ($sendto->mailformat == 1) { // HTML - $posthtml = "

". - "wwwroot/course/view.php?id=$course->id\">$course->shortname ->". - "wwwroot/mod/exercise/index.php?id=$cm->id\">$strexercises ->". - "wwwroot/mod/exercise/view.php?a=$exercise->id\">$exercise->name

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

$msg

"; - $posthtml .= "

".get_string("mail3", "exercise"). - " wwwroot/mod/exercise/view.php?id=$cm->id\">$exercise->name.


"; - } 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: exercise cron: Could not send out mail for id $submission->id to user $sendto->id ($sendto->email)\n"; } - if (! set_field("exercise_assessments", "mailed", "1", "id", "$assessment->id")) { - echo "Could not update the mailed field for id $assessment->id\n"; - } } } return true; @@ -331,7 +257,6 @@ function exercise_delete_instance($id) { /*******************************************************************/ function exercise_grades($exerciseid) { /// Must return an array of grades, indexed by user, and a max grade. -global $EXERCISE_FWEIGHTS; if (!$exercise = get_record("exercise", "id", $exerciseid)) { error("Exercise record not found"); @@ -339,28 +264,23 @@ global $EXERCISE_FWEIGHTS; if (! $course = get_record("course", "id", $exercise->course)) { error("Course is misconfigured"); } - if (!$return->maxgrade = $exercise->grade) { + if (!$return->maxgrade = ($exercise->grade + $exercise->gradinggrade)) { return NULL; } - // calculate scaling factor - $scaling = $exercise->grade / (100.0 * ($EXERCISE_FWEIGHTS[$exercise->gradingweight] + - $EXERCISE_FWEIGHTS[$exercise->teacherweight])); // how to handle multiple submissions? if ($exercise->usemaximum) { // first get the teacher's grade for the best submission if ($bestgrades = exercise_get_best_submission_grades($exercise)) { foreach ($bestgrades as $grade) { - $usergrade[$grade->userid] = $grade->grade * - $EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling; + $usergrade[$grade->userid] = $grade->grade * $exercise->grade / 100.0; } } } else { // use mean values if ($meangrades = exercise_get_mean_submission_grades($exercise)) { foreach ($meangrades as $grade) { - $usergrade[$grade->userid] = $grade->grade * - $EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling; + $usergrade[$grade->userid] = $grade->grade * $exercise->grade / 100.0; } } } @@ -369,8 +289,7 @@ global $EXERCISE_FWEIGHTS; foreach ($assessments as $assessment) { // add the grading grade if the student's work has been assessed if (isset($usergrade[$assessment->userid])) { - $usergrade[$assessment->userid] += $assessment->gradinggrade * - $EXERCISE_FWEIGHTS[$exercise->gradingweight] * $scaling * 100.0 / COMMENTSCALE; + $usergrade[$assessment->userid] += $assessment->gradinggrade * $exercise->gradinggrade / 100.0; } } } @@ -650,7 +569,7 @@ function exercise_get_best_grade($submission) { // Returns the best grade of students' submission (there may, occassionally be more than one assessment) global $CFG; - return get_record_sql("SELECT MAX(a.grade) grade FROM + return get_record_sql("SELECT MAX(a.grade) AS grade FROM {$CFG->prefix}exercise_assessments a WHERE a.submissionid = $submission->id GROUP BY a.submissionid"); @@ -686,7 +605,7 @@ function exercise_get_mean_submission_grades($exercise) { global $CFG; $timenow = time(); - $grades = get_records_sql("SELECT DISTINCT u.userid, AVG(a.grade) grade FROM + $grades = get_records_sql("SELECT DISTINCT u.userid, AVG(a.grade) AS grade FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u WHERE u.course = $exercise->course @@ -735,25 +654,11 @@ function exercise_get_teacher_submission_assessments($exercise) { function exercise_get_unmailed_assessments($cutofftime) { /// Return list of (ungraded) assessments that have not been mailed out global $CFG; - return get_records_sql("SELECT a.*, g.course, g.name - FROM {$CFG->prefix}exercise_assessments a, {$CFG->prefix}exercise g + return get_records_sql("SELECT a.*, e.course, e.name + FROM {$CFG->prefix}exercise_assessments a, {$CFG->prefix}exercise e WHERE a.mailed = 0 - AND a.timegraded = 0 AND a.timecreated < $cutofftime - AND g.id = a.exerciseid"); -} - - -/////////////////////////////////////////////////////////////////////////////////////////////// -function exercise_get_unmailed_graded_assessments($cutofftime) { - /// Return list of graded assessments that have not been mailed out - global $CFG; - return get_records_sql("SELECT a.*, g.course, g.name - FROM {$CFG->prefix}exercise_assessments a, {$CFG->prefix}exercise g - WHERE a.mailed = 0 - AND a.timegraded < $cutofftime - AND a.timegraded > 0 - AND g.id = a.exerciseid"); + AND e.id = a.exerciseid"); } diff --git a/mod/exercise/locallib.php b/mod/exercise/locallib.php index be30932af9..7edab054b4 100644 --- a/mod/exercise/locallib.php +++ b/mod/exercise/locallib.php @@ -6,6 +6,8 @@ /*** Functions for the exercise module ****** +function exercise_add_custom_scales($exercise) { +function exercise_compare_assessments($exercise, $assessment1, $assessment2) { function exercise_copy_assessment($assessment, $submission, $withfeedback = false) { function exercise_count_all_submissions_for_assessment($exercise, $user) { function exercise_count_assessments($submission) { @@ -59,12 +61,12 @@ function exercise_print_assessments_by_user_for_admin($exercise, $user) { function exercise_print_assessments_for_admin($exercise, $submission) { function exercise_print_assignment_info($exercise) { function exercise_print_difference($time) { -function exercise_print_dual_assessment_form($exercise, $assessment, $submission, $returnto) function exercise_print_feedback($course, $submission) { function exercise_print_league_table($exercise) { function exercise_print_submission_assessments($exercise, $submission, $type) { function exercise_print_submission_title($exercise, $submission) { <--- in lib.php function exercise_print_tabbed_table($table) { +function exercise_print_teacher_assessment_form($exercise, $assessment, $submission, $returnto) function exercise_print_teacher_table($course) { function exercise_print_time_to_deadline($time) { function exercise_print_upload_form($exercise) { @@ -74,7 +76,60 @@ function exercise_test_for_resubmission($exercise, $user) { function exercise_test_user_assessments($exercise, $user) { ***************************************/ +/////////////////////////////////////////////////////////////////////////////////////////////// +function exercise_add_custom_scales($exercise) { + global $EXERCISE_SCALES; + + if (! $course = get_record("course", "id", $exercise->course)) { + error("Course is misconfigured"); + } + + if ($scales = get_records("scale", "courseid", $course->id, "name ASC")) { + foreach ($scales as $scale) { + $labels = explode(",", $scale->scale); + $EXERCISE_SCALES[] = array('name' => $scale->name, 'type' => 'radio', 'size' => count($labels), + 'start' => trim($labels[0]), 'end' => trim($labels[count($labels) - 1])); + } + } + return; +} +/////////////////////////////////////////////////////////////////////////////////////////////// +function exercise_compare_assessments($exercise, $assessment1, $assessment2) { + global $EXERCISE_ASSESSMENT_COMPS, $EXERCISE_EWEIGHTS; + // first get the assignment elements for maxscores... + $elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC"); + foreach ($elementsraw as $element) { + $maxscore[] = $element->maxscore; // to renumber index 0,1,2... + $weight[] = $EXERCISE_EWEIGHTS[$element->weight]; // get real value and renumber index 0,1,2... + } + for ($i = 0; $i < 2; $i++) { + if ($i) { + $rawgrades = get_records("exercise_grades", "assessmentid", $assessment1->id, "elementno ASC"); + } else { + $rawgrades = get_records("exercise_grades", "assessmentid", $assessment2->id, "elementno ASC"); + } + foreach ($rawgrades as $grade) { + $grades[$i][] = $grade->grade; + } + } + $sumdiffs = 0; + $sumweights = 0; + for ($i=0; $i < $exercise->nelements; $i++) { + $diff = ($grades[0][$i] - $grades[1][$i]) * $weight[$i] / $maxscore[$i]; + $sumdiffs += $diff * $diff; // use squared distances + $sumweights += $weight[$i]; + } + // convert to a sensible grade (always out of 100) + $COMP = (object)$EXERCISE_ASSESSMENT_COMPS[$exercise->assessmentcomps]; + $factor = $COMP->value; + $gradinggrade = (($factor - ($sumdiffs / $sumweights)) / $factor) *100; + if ($gradinggrade < 0) { + $gradinggrade = 0; + } + return $gradinggrade; +} + /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_copy_assessment($assessment, $submission, $withfeedback = false) { // adds a copy of the given assessment for the submission specified to the exercise_assessemnts table. @@ -223,7 +278,9 @@ function exercise_count_unassessed_student_submissions($exercise) { } $timenow = time(); $n = 0; - if ($submissions = exercise_get_student_submissions($exercise)) { + // look at all the student submissions, exercise_get_student_submissions is group aware + $groupid = get_current_group($course->id); + if ($submissions = exercise_get_student_submissions($exercise, "time", $groupid)) { foreach ($submissions as $submission) { // only look at "cold" submissions if ($submission->timecreated < $timenow - $CFG->maxeditingtime) { @@ -248,10 +305,11 @@ function exercise_count_unassessed_student_submissions($exercise) { /////////////////////////////////////////////////////////////////////////////////////////////// -function exercise_count_ungraded_assessments_student($exercise) { +function exercise_count_ungraded_assessments_student($exercise, $groupid = 0) { // function returns the number of ungraded assessments by students of STUDENT submissions + $n = 0; - if ($submissions = exercise_get_student_submissions($exercise)) { + if ($submissions = exercise_get_student_submissions($exercise, $groupid)) { foreach ($submissions as $submission) { if ($assessments = exercise_get_assessments($submission)) { foreach ($assessments as $assessment) { @@ -404,7 +462,7 @@ function exercise_get_best_submission_grades($exercise) { // Returns the grades of students' best submissions global $CFG; - return get_records_sql("SELECT DISTINCT u.userid, MAX(a.grade) grade FROM + return get_records_sql("SELECT DISTINCT u.userid, MAX(a.grade) AS grade FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u WHERE u.course = $exercise->course @@ -421,7 +479,7 @@ function exercise_get_mean_grade($submission) { // Returns the mean grade of students' submission (may, very occassionally, be more than one assessment) global $CFG; - return get_record_sql("SELECT AVG(a.grade) grade FROM + return get_record_sql("SELECT AVG(a.grade) AS grade FROM {$CFG->prefix}exercise_assessments a WHERE a.submissionid = $submission->id GROUP BY a.submissionid"); @@ -442,45 +500,87 @@ function exercise_get_student_submission($exercise, $user) { /////////////////////////////////////////////////////////////////////////////////////////////// -function exercise_get_student_submissions($exercise, $order = "") { +function exercise_get_student_submissions($exercise, $order = "time", $groupid = 0) { // Return all ENROLLED student submissions // if order can grade|title|name|nothing, nothing is oldest first, youngest last global $CFG; - if ($order == "grade") { - // allow for multiple assessments of submissions (coming from different teachers) - return get_records_sql("SELECT s.*, AVG(a.grade) grade FROM {$CFG->prefix}exercise_submissions s, - {$CFG->prefix}user_students u, {$CFG->prefix}exercise_assessments a - WHERE u.course = $exercise->course - AND s.userid = u.userid - AND s.exerciseid = $exercise->id - AND a.submissionid = s.id - GROUP BY s.id - ORDER BY a.grade DESC"); - } - - if ($order == "title") { - $order = "s.title"; - } elseif ($order == "name") { - $order = "n.firstname, n.lastname, s.timecreated DESC"; - } else { - $order = "s.timecreated"; + if ($groupid) { + // just look at a single group + if ($order == "grade") { + // allow for multiple assessments of submissions (coming from different teachers) + return get_records_sql("SELECT s.*, AVG(a.grade) AS grade FROM {$CFG->prefix}user_students u, + {$CFG->prefix}groups_members g, {$CFG->prefix}exercise_submissions s, + {$CFG->prefix}exercise_assessments a + WHERE u.course = $exercise->course + AND g.groupid = $groupid + AND u.userid = g.userid + AND s.userid = u.userid + AND s.exerciseid = $exercise->id + AND a.submissionid = s.id + GROUP BY s.id + ORDER BY a.grade DESC"); + } + + if ($order == "title") { + $order = "s.title"; + } elseif ($order == "name") { + $order = "n.firstname, n.lastname, s.timecreated DESC"; + } elseif ($order == "time") { + $order = "s.timecreated"; + } + + return get_records_sql("SELECT s.* FROM {$CFG->prefix}user_students u, {$CFG->prefix}user n, + {$CFG->prefix}groups_members g, {$CFG->prefix}exercise_submissions s + WHERE u.course = $exercise->course + AND g.groupid = $groupid + AND u.userid = g.userid + AND s.userid = u.userid + AND n.id = u.userid + AND s.exerciseid = $exercise->id + ORDER BY $order"); + + } + else { // no group - all users + if ($order == "grade") { + // allow for multiple assessments of submissions (coming from different teachers) + return get_records_sql("SELECT s.*, AVG(a.grade) AS grade FROM {$CFG->prefix}exercise_submissions s, + {$CFG->prefix}user_students u, {$CFG->prefix}exercise_assessments a + WHERE u.course = $exercise->course + AND s.userid = u.userid + AND s.exerciseid = $exercise->id + AND a.submissionid = s.id + GROUP BY s.id + ORDER BY a.grade DESC"); + } + + if ($order == "title") { + $order = "s.title"; + } elseif ($order == "name") { + $order = "n.firstname, n.lastname, s.timecreated DESC"; + } elseif ($order == "time") { + $order = "s.timecreated"; + } + + return get_records_sql("SELECT s.* FROM {$CFG->prefix}exercise_submissions s, + {$CFG->prefix}user_students u, {$CFG->prefix}user n + WHERE u.course = $exercise->course + AND s.userid = u.userid + AND n.id = u.userid + AND s.exerciseid = $exercise->id + ORDER BY $order"); } - - return get_records_sql("SELECT s.* FROM {$CFG->prefix}exercise_submissions s, - {$CFG->prefix}user_students u, {$CFG->prefix}user n - WHERE u.course = $exercise->course - AND s.userid = u.userid - AND n.id = u.userid - AND s.exerciseid = $exercise->id - ORDER BY $order"); } /////////////////////////////////////////////////////////////////////////////////////////////// -function exercise_get_submission_assessment($submission, $user) { - // Return the user's assessment for this submission - return get_record("exercise_assessments", "submissionid", $submission->id, "userid", $user->id); +function exercise_get_submission_assessment($submission, $user = null) { + // Return a user's assessment for this submission + if ($user) { + return get_record("exercise_assessments", "submissionid", $submission->id, "userid", $user->id); + } else { // likely to be the teacher's assessment + return get_record("exercise_assessments", "submissionid", $submission->id); + } } @@ -543,6 +643,7 @@ function exercise_get_ungraded_assessments_teacher($exercise) { /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_get_user_assessments($exercise, $user) { // Return all the user's assessments, newest first, oldest last + // students will have only one, teachers will have more... return get_records_select("exercise_assessments", "exerciseid = $exercise->id AND userid = $user->id", "timecreated DESC"); } @@ -586,7 +687,7 @@ function exercise_list_all_ungraded_assessments($exercise) { /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_list_submissions_for_admin($exercise) { // list the teacher sublmissions first - global $CFG, $EXERCISE_FWEIGHTS, $THEME, $USER; + global $CFG, $THEME, $USER; if (! $course = get_record("course", "id", $exercise->course)) { error("Course is misconfigured"); @@ -594,7 +695,8 @@ function exercise_list_submissions_for_admin($exercise) { if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { error("Course Module ID was incorrect"); } - + $groupid = get_current_group($course->id); + exercise_print_assignment_info($exercise); print_heading_with_help(get_string("administration"), "administration", "exercise"); echo"

id\">". @@ -602,75 +704,9 @@ function exercise_list_submissions_for_admin($exercise) { if (isteacheredit($course->id)) { - ?> -

- - -
- id); - $gradingweight = get_field("exercise","gradingweight", "id", $exercise->id); - - // now show the weights used in the grades - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
cellheading2\" align=\"center\">". - get_string("weightsusedforoverallgrade", "exercise")."
".get_string("weightforgradingofassessments", "exercise").":"; - exercise_choose_from_menu($EXERCISE_FWEIGHTS, "gradingweight", $gradingweight, ""); - echo "
".get_string("weightforteacherassessments", "exercise", - $course->teacher).":"; - exercise_choose_from_menu($EXERCISE_FWEIGHTS, "teacherweight", $teacherweight, ""); - echo "
"; - echo "\n"; - echo "
\n"; - echo "

"; - echo "\n"; - - ?> -
- - -
- \n"; - echo "cellheading2\">". - get_string("leaguetable", "exercise")."\n"; - echo "".get_string("numberofentries", "exercise").":\n"; - echo ""; - $numbers[22] = 'All'; - $numbers[21] = 50; - for ($i=20; $i>=0; $i--) { - $numbers[$i] = $i; - } - $nentries = $exercise->showleaguetable; - if ($nentries == 99) { - $nentries = 'All'; - } - choose_from_menu($numbers, "nentries", "$nentries", ""); - echo "\n"; - echo "".get_string("hidenamesfromstudents", "exercise", - $course->students)."\n"; - $options[0] = get_string("no"); $options[1] = get_string("yes"); - choose_from_menu($options, "anonymous", $exercise->anonymous, ""); - echo "\n"; - echo ""; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
"; - echo "
\n"; - - // list any teacher submissions - $table->head = array (get_string("title", "exercise"), get_string("submitted", "exercise"), get_string("action", "exercise")); + $table->head = array (get_string("title", "exercise"), get_string("submitted", "exercise"), + get_string("action", "exercise")); $table->align = array ("left", "left", "left"); $table->size = array ("*", "*", "*"); $table->cellpadding = 2; @@ -703,6 +739,13 @@ function exercise_list_submissions_for_admin($exercise) { $table->cellspacing = 0; $nassessments = 0; foreach ($users as $user) { + // check group membership, if necessary + if ($groupid) { + // check user's group + if (!ismember($groupid, $user->id)) { + continue; // skip this user + } + } if ($assessments = exercise_get_user_assessments($exercise, $user)) { $title =''; foreach ($assessments as $assessment) { @@ -715,8 +758,7 @@ function exercise_list_submissions_for_admin($exercise) { // show only warm or cold assessments $title .= " {".number_format($assessment->grade * $exercise->grade / 100.0, 0); if ($assessment->timegraded) { - $title .= "/".number_format($assessment->gradinggrade * $exercise->grade / - COMMENTSCALE, 0); + $title .= "/".number_format($assessment->gradinggrade * $exercise->gradinggrade / 100.0, 0); } $title .= "} "; if ($realassessments = exercise_count_user_assessments_done($exercise, $user)) { @@ -736,7 +778,9 @@ function exercise_list_submissions_for_admin($exercise) { if (isset($table->data)) { print_heading(get_string("studentassessments", "exercise", $course->student)." [$nassessments]"); print_table($table); - echo "

".get_string("noteonstudentassessments", "exercise")."

\n"; + echo "

".get_string("noteonstudentassessments", "exercise"); + echo "
{".get_string("maximumgrade").": $exercise->grade / ". + get_string("maximumgrade").": $exercise->gradinggrade}

\n"; } } @@ -752,6 +796,13 @@ function exercise_list_submissions_for_admin($exercise) { $nsubmissions = 0; foreach ($users as $user) { + // check group membership, if necessary + if ($groupid) { + // check user's group + if (!ismember($groupid, $user->id)) { + continue; // skip this user + } + } if ($submissions = exercise_get_user_submissions($exercise, $user)) { foreach ($submissions as $submission) { $action = "
id&sid=$submission->id\">". @@ -802,10 +853,10 @@ function exercise_list_submissions_for_admin($exercise) { print_heading(get_string("studentsubmissions", "exercise", $course->student)." [$nsubmissions]", "center"); print_table($table); + echo "

[] - ".get_string("gradeforsubmission", "exercise"); + echo "
".get_string("maximumgrade").": $exercise->grade

\n"; echo "

".get_string("resubmitnote", "exercise", $course->student)."

\n"; } - echo "

".get_string("allgradeshaveamaximumof", "exercise", $exercise->grade). - "

\n"; } } @@ -876,7 +927,7 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false) // the user has not yet assessed this exercise, set up a hot assessment record for this user for one // of the teacher submissions, first count the number of assessments for each teacher submission... if ($submissions = exercise_get_teacher_submissions($exercise)) { - mt_srand ((float)microtime()*1000000); // initialise random number generator + // mt_srand ((float)microtime()*1000000); // initialise random number generator, assume php>=4.2.0 foreach ($submissions as $submission) { $n = count_records("exercise_assessments", "submissionid", $submission->id); // ...OK to have zero, we add a small random number to randomise things... @@ -896,6 +947,7 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false) $assessment->userid = $user->id; $assessment->grade = -1; // set impossible grade $assessment->timecreated = $yearfromnow; + $assessment->mailed = 1; // no need to email to the teacher! if (!$assessment->id = insert_record("exercise_assessments", $assessment)) { error("Could not insert exercise assessment!"); } @@ -927,6 +979,7 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false) // now list user's assessments (but only list those which come from teacher submissions) print_heading(get_string("yourassessment", "exercise")); + $assessed = false; if ($assessments = exercise_get_user_assessments($exercise, $user)) { $timenow = time(); foreach ($assessments as $assessment) { @@ -965,10 +1018,13 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false) // if user has submitted work, see if teacher has graded assessment if (exercise_count_user_submissions($exercise, $user) > 0) { if ($assessment->timegraded and (($timenow - $assessment->timegraded) > $CFG->maxeditingtime)) { - $comment .= get_string("thereisfeedbackfromthe", "exercise", $course->teacher); + $comment .= get_string("gradeforassessment", "exercise").": ". + number_format($assessment->gradinggrade * $exercise->gradinggrade / 100.0, 1). + " (".get_string("maximumgrade")." ".number_format($exercise->gradinggrade, 0).")"; + $assessed = true; } else { - $comment .= get_string("awaitingfeedbackfromthe", "exercise", $course->teacher); + $comment .= get_string("awaitingassessmentbythe", "exercise", $course->teacher); } } } @@ -976,6 +1032,9 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false) } } print_table($table); + if ($assessed) { + echo "

".get_string("noteongradinggrade", "exercise", $course->teacher)."

\n"; + } } } @@ -1003,7 +1062,9 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { $table->cellspacing = 0; // get all the submissions, oldest first, youngest last - if ($submissions = exercise_get_student_submissions($exercise)) { + // exercise_get_student_submissions is group aware + $groupid = get_current_group($course->id); + if ($submissions = exercise_get_student_submissions($exercise, "time", $groupid)) { foreach ($submissions as $submission) { // only consider "cold" submissions if ($submission->timecreated < $timenow - $CFG->maxeditingtime) { @@ -1256,7 +1317,7 @@ function exercise_list_user_submissions($exercise, $user) { $action = "
id&sid=$submission->id\">". get_string("delete", "exercise").""; } - // if this is a teacher's submission (an exercise descrription) ignore any assessments + // if this is a teacher's submission (an exercise description) ignore any assessments if (!$submission->isexercise) { // get the teacher assessments (could be more than one, if unlikely, when multiple teachers) if ($assessments = get_records_select("exercise_assessments", "exerciseid = $exercise->id AND @@ -1268,17 +1329,13 @@ function exercise_list_user_submissions($exercise, $user) { $action .= " | "; } $action .= "id&aid=$assessment->id\">". - get_string("viewassessment", "exercise").""; + get_string("viewteacherassessment", "exercise", $course->teacher).""; if ($comment) { - $action .= " | "; - } - $grade = number_format($assessment->grade * $exercise->grade / 100.0, 1); - if ($submission->late) { - $comment .= get_string("grade"). - ": ($grade)"; - } else { - $comment .= get_string("grade").": $grade"; + $comment .= " | "; } + $comment .= get_string("teacherassessment", "exercise", $course->teacher).": ". + number_format($assessment->grade * $exercise->grade / 100.0, 1). + " (".get_string("maximumgrade")." ".number_format($exercise->grade, 0).")"; } } } @@ -1806,39 +1863,13 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch echo "\n"; $timenow = time(); - // the teacher's comment on the assessment - // always allow the teacher to change their comment and grade if it's not their assessment! - if (isteacher($course->id) and ($assessment->userid != $USER->id)) { + + // always show the teacher the grading grade if it's not their assessment! + if (isteacher($course->id) and ($assessment->userid != $USER->id) and $exercise->gradinggrade) { echo "".get_string("gradeforstudentsassessment", "exercise", $course->student). "\n"; - // set up coment scale - for ($i=COMMENTSCALE; $i>=0; $i--) { - $num[$i] = $i; - } - choose_from_menu($num, "gradinggrade", $assessment->gradinggrade, ""); + echo number_format($exercise->gradinggrade * $assessment->gradinggrade / 100.0, 0); echo "\n"; - echo "\n"; - echo "

". get_string("teacherscomment", "exercise").":

\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - } - elseif ($assessment->timegraded and ($assessment->timegraded < ($timenow - $CFG->maxeditingtime))) { - // now show the teacher's comment (but not the grade) to the student if available... - echo "\n"; - echo "

". get_string("teacherscomment", "exercise").":

\n"; - echo " \n"; - echo text_to_html($assessment->teachercomment); - echo " \n"; - echo "\n"; - echo "\n"; - echo "cellheading2\"> \n"; - echo "\n"; } // ...and close the table, show buttons if needed... @@ -1895,7 +1926,7 @@ function exercise_print_assessments_for_admin($exercise, $submission) { error("Course Module ID was incorrect"); } - if ($assessments =exercise_get_assessments($submission)) { + if ($assessments = exercise_get_assessments($submission)) { foreach ($assessments as $assessment) { if (!$user = get_record("user", "id", $assessment->userid)) { error (" exercise_print_assessments_for_admin: unable to get user record"); @@ -1928,7 +1959,8 @@ function exercise_print_assignment_info($exercise) { print_heading($exercise->name, "center"); print_simple_box_start("center"); echo "".get_string("duedate", "exercise").": $strduedate
"; - echo "".get_string("maximumgrade").": $exercise->grade
"; + $maxgrade = $exercise->grade + $exercise->gradinggrade; + echo "".get_string("maximumgrade").": $maxgrade
"; echo "".get_string("handlingofmultiplesubmissions", "exercise").":"; if ($exercise->usemaximum) { echo get_string("usemaximum", "exercise")."
\n"; @@ -1958,9 +1990,99 @@ function exercise_print_difference($time) { /////////////////////////////////////////////////////////////////////////////////////////////// -function exercise_print_dual_assessment_form($exercise, $assessment, $submission, $returnto = '') { - // prints the user's assessment and a blank form for the user's submission (for teachers only) - global $CFG, $THEME, $USER, $EXERCISE_SCALES, $EXERCISE_EWEIGHTS; +function exercise_print_feedback($course, $submission) { + global $CFG, $THEME, $RATING; + + if (! $teacher = get_record("user", "id", $submission->teacher)) { + error("Weird exercise error"); + } + + echo "\n
"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo ""; + + echo "\n
body\" WIDTH=35 VALIGN=TOP>"; + print_user_picture($teacher->id, $course->id, $teacher->picture); + echo "cellheading\">$teacher->firstname $teacher->lastname"; + echo "  ".userdate($submission->timemarked).""; + echo "
cellcontent\">"; + + echo "

"; + if ($submission->grade) { + echo get_string("grade").": $submission->grade"; + } else { + echo get_string("nograde"); + } + echo "

"; + + echo text_to_html($submission->assessorcomment); + echo "
"; + echo "
"; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////// +function exercise_print_league_table($exercise) { + // print an order table of (student) submissions in grade order, only print the student's best submission when + // there are multiple submissions + if (! $course = get_record("course", "id", $exercise->course)) { + error("Print league table: Course is misconfigured"); + } + $groupid = get_current_group($course->id); + $nentries = $exercise->showleaguetable; + if ($nentries == 99) { + $nentries = 999999; // a large number + } + + if ($exercise->anonymous and isstudent($course->id)) { + $table->head = array (get_string("title", "exercise"), get_string("grade")); + $table->align = array ("left", "center"); + $table->size = array ("*", "*"); + } else { // show names + $table->head = array (get_string("title", "exercise"), get_string("name"), get_string("grade")); + $table->align = array ("left", "left", "center"); + $table->size = array ("*", "*", "*"); + } + $table->cellpadding = 2; + $table->cellspacing = 0; + + if ($submissions = exercise_get_student_submissions($exercise, "grade", $groupid)) { + $n = 1; + foreach ($submissions as $submission) { + if (empty($done[$submission->userid])) { + if ($submission->late) { + continue; + } + if (!$user = get_record("user", "id", $submission->userid)) { + error("Print league table: user not found"); + } + if ($exercise->anonymous and isstudent($course->id)) { + $table->data[] = array(exercise_print_submission_title($exercise, $submission), + number_format($submission->grade * $exercise->grade / 100.0, 1)); + } else { + $table->data[] = array(exercise_print_submission_title($exercise, $submission), + $user->firstname." ".$user->lastname, + number_format($submission->grade * $exercise->grade / 100.0, 1)); + } + $n++; + if ($n > $nentries) { + break; + } + $done[$submission->userid] = 'ok'; + } + } + print_heading(get_string("leaguetable", "exercise")); + print_table($table); + } + } + + +/////////////////////////////////////////////////////////////////////////////////////////////// +function exercise_print_submission_assessments($exercise, $submission) { + // Returns a list of grades for this submission if (! $course = get_record("course", "id", $exercise->course)) { error("Course is misconfigured"); @@ -1969,78 +2091,196 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission error("Course Module ID was incorrect"); } - $timenow = time(); - - if(!$submissionowner = get_record("user", "id", $submission->userid)) { - error("Print dual assessment form: User record not found"); + $str = ''; + if ($assessments = exercise_get_assessments($submission)) { + foreach ($assessments as $assessment) { + if (isteacher($exercise->course, $assessment->userid)) { + $str .= "[".number_format($assessment->grade * $exercise->grade / 100.0, 0)."] "; + } + else { // assessment by student - shouldn't happen! + $str .= "{".number_format($assessment->grade * $exercise->grade / 100.0, 0)."} "; + } + } } - - echo "
-
cellcontent\">\n"; - if (!$teachersubmission = get_record("exercise_submissions", "id", $assessment->submissionid)) { - error ("exercise_print_assessment_form: Submission record not found"); + if (!$str) { + $str = " "; // be kind to Mozilla browsers! } - echo exercise_print_submission_title($exercise, $teachersubmission); - echo "

\n"; - - print_heading_with_help(get_string("pleasegradetheassessment", "exercise", - "$submissionowner->firstname $submissionowner->lastname"), "gradinggrade", "exercise"); - - echo "
-
cellcontent\">\n"; - echo exercise_print_submission_title($exercise, $submission); - echo "

\n"; + return $str; +} - // only show the grade if grading strategy > 0 and the grade is positive - if ($exercise->gradingstrategy and $assessment->grade >= 0) { - echo "
".get_string("thegradeis", "exercise").": ". - number_format($assessment->grade * $exercise->grade / 100.0, 2)." (". - get_string("maximumgrade")." ".number_format($exercise->grade, 0).")

\n"; - } - - // now print the student's assessment form with the teacher's comments if any - // in this (first) form only allow teachers to change their comment and the grading grade - // the other "active" elements in thie form are suffixed with "_0" to stop conflicts with the teacher's - // assessment form - $allowchanges = false; - - // FORM is needed for Mozilla browsers, else radio bttons are not checked - ?> -
- - - - - - - userid)) { - error("Exercise_print_dual_assessment_form: could not find user record"); - } - echo "
\n"; - echo "\n"; - echo " \n"; - echo "\n"; - // get the assignment elements... - if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) { - print_string("noteonassignmentelements", "exercise"); - } - else { - foreach ($elementsraw as $element) { - $elements[] = $element; // to renumber index 0,1,2... +////////////////////////////////////////////////////////////////////////////////////// +function exercise_print_tabbed_heading($tabs) { +// Prints a tabbed heading where one of the tabs highlighted. +// $tabs is an object with several properties. +// $tabs->names is an array of tab names +// $tabs->urls is an array of links +// $tabs->align is an array of column alignments (defaults to "center") +// $tabs->size is an array of column sizes +// $tabs->wrap is an array of "nowrap"s or nothing +// $tabs->highlight is an index (zero based) of "active" heading . +// $tabs->width is an percentage of the page (defualts to 80%) +// $tabs->cellpadding padding on each cell (defaults to 5) + + global $CFG, $THEME; + + if (isset($tabs->names)) { + foreach ($tabs->names as $key => $name) { + if (!empty($tabs->urls[$key])) { + $url =$tabs->urls[$key]; + if ($tabs->highlight == $key) { + $tabcontents[$key] = "$name"; + } else { + $tabcontents[$key] = "$name"; + } + } else { + $tabcontents[$key] = "$name"; } } + } - // get any previous grades... - if ($gradesraw = get_records_select("exercise_grades", "assessmentid = $assessment->id", "elementno")) { - foreach ($gradesraw as $grade) { - $grades[] = $grade; // to renumber index 0,1,2... + if (empty($tabs->width)) { + $tabs->width = "80%"; + } + + if (empty($tabs->cellpadding)) { + $tabs->cellpadding = "5"; + } + + // print_simple_box_start("center", "$table->width", "#ffffff", 0); + echo "
cellheading2\">
".get_string("assessmentby", - "exercise", "$assessmentowner->firstname $assessmentowner->lastname")."
cellpadding\" cellspacing=\"0\" class=\"generaltable\">\n"; + + if (!empty($tabs->names)) { + echo ""; + echo "\n"; + foreach ($tabcontents as $key => $tab) { + if (isset($align[$key])) { + $alignment = "align=\"$align[$key]\""; + } else { + $alignment = "align=\"center\""; } - } - - // determine what sort of grading + if (isset($size[$key])) { + $width = "width=\"$size[$key]\""; + } else { + $width = ""; + } + if (isset($wrap[$key])) { + $wrapping = "no wrap"; + } else { + $wrapping = ""; + } + if ($key == $tabs->highlight) { + echo "\n"; + } else { + echo "\n"; + } + echo "\n"; + } + echo "\n"; + } else { + echo "\n"; + } + // bottom stripe + $ncells = count($tabs->names)*2 +1; + $height = 2; + echo "\n"; + echo "
". + "wwwroot/pix/spacer.gif\" alt=\"\">cellheading2\">$tabcellheading\">$tab". + "wwwroot/pix/spacer.gif\" alt=\"\">
No names specified
cellheading2\">". + "wwwroot/pix/spacer.gif\" alt=\"\">
\n"; + // print_simple_box_end(); + + return true; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////// +function exercise_print_teacher_assessment_form($exercise, $assessment, $submission, $returnto = '') { + // prints an assessment form based on the student's assessment + // if the teacher is re-assessing a submission they would use exercise_print_assessment_form() + // (for teachers only) + global $CFG, $THEME, $USER, $EXERCISE_SCALES, $EXERCISE_EWEIGHTS; + + if (! $course = get_record("course", "id", $exercise->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { + error("Course Module ID was incorrect"); + } + + $timenow = time(); + + if(!$submissionowner = get_record("user", "id", $submission->userid)) { + error("Print teacher assessment form: User record not found"); + } + + echo "
+
cellcontent\">\n"; + if (!$teachersubmission = get_record("exercise_submissions", "id", $assessment->submissionid)) { + error ("Print teacher assessment form: Submission record not found"); + } + echo exercise_print_submission_title($exercise, $teachersubmission); + echo "

\n"; + + echo "
+
cellcontent\">\n"; + echo exercise_print_submission_title($exercise, $submission); + echo "

\n"; + + ?> + + + + + + + + firstname $submissionowner->lastname"), "grading", "exercise"); + + // is there an existing assessment for the submission + if (!$assessment = exercise_get_submission_assessment($submission, $USER)) { + // copy student's assessment without the comments for the student's submission + $assessment = exercise_copy_assessment($studentassessment, $submission); + } + + // only show the grade if grading strategy > 0 and the grade is positive + if ($exercise->gradingstrategy and $assessment->grade >= 0) { + echo "
".get_string("thegradeis", "exercise").": ". + number_format($assessment->grade * $exercise->grade / 100.0, 2)." (". + get_string("maximumgrade")." ".number_format($exercise->grade, 0).")

\n"; + } + + echo "
\n"; + echo "\n"; + echo " \n"; + echo "\n"; + + // get the assignment elements... + if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) { + error("Teacher assessment form: Elements not found"); + } + foreach ($elementsraw as $element) { + $elements[] = $element; // to renumber index 0,1,2... + } + + // ...and get any previous grades... + if ($gradesraw = get_records_select("exercise_grades", "assessmentid = $assessment->id", "elementno")) { + foreach ($gradesraw as $grade) { + $grades[] = $grade; // to renumber index 0,1,2... + } + } + + // determine what sort of grading switch ($exercise->gradingstrategy) { case 0: // no grading // now print the form @@ -2057,18 +2297,18 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission echo " \n"; } + echo "\n"; + } else { echo text_to_html($grades[$i]->feedback); - } + } echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; - } + } break; case 1: // accumulative grading @@ -2097,38 +2337,38 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission 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; - } } + } if ($checked) { - echo "    \n"; - } + echo "    \n"; + } else { - echo "    \n"; - } + 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, "grade2_0[$i]", $grades[$i]->grade, ""); - } + choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, ""); + } else { - choose_from_menu($numbers, "grade2_0[$i]", 0, ""); - } + choose_from_menu($numbers, "grade[$i]", 0, ""); + } break; - + echo " \n"; echo "\n"; - } + } echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; - } + } break; case 2: // error banded grading @@ -2176,35 +2416,35 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission 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; - } } + } if ($checked) { - echo "    \n"; - } + echo "    \n"; + } else { - echo "    \n"; - } + 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_0[$i]", $grades[$i]->grade, ""); - } + choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, ""); + } else { - choose_from_menu($numbers, "grade_0[$i]", 0, ""); - } + choose_from_menu($numbers, "grade[$i]", 0, ""); + } break; - } + } echo " \n"; echo "\n"; @@ -2215,23 +2455,23 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission echo " \n"; } else { if (isset($grades[$i]->feedback)) { echo text_to_html($grades[$i]->feedback); - } } + } echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; if (empty($grades[$i]->grade)) { - $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; - } + $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; } + } // print the number of negative elements // echo "\n"; // echo "\n"; @@ -2245,24 +2485,24 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission for ($i=0; $i<=$exercise->nelements; $i++) { if ($i == intval($error + 0.5)) { echo "\n"; - } + } else { echo "\n"; - } } + } echo "
cellheading2\">
".get_string("yourassessment", "exercise"). + "
cellheading2\"> 

". get_string("feedback").":

\n"; @@ -2136,18 +2376,18 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission echo " \n"; } + echo "\n"; + } else { echo text_to_html($grades[$i]->feedback); - } + } echo "
cellheading2\"> 
cellheading2\"> 
".get_string("numberofnegativeitems", "exercise")."$negativecount
pixpath/t/right.gif\"> $i{$elements[$i]->maxscore}
$i{$elements[$i]->maxscore}
\n"; echo "

\n"; break; @@ -2275,36 +2515,36 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission // find which criteria has been selected (saved in the zero element), if any if (isset($grades[0]->grade)) { $selection = $grades[0]->grade; - } + } else { $selection = 0; - } + } // now run through the elements for ($i=0; $i < count($elements); $i++) { $iplus1 = $i+1; echo "\n"; echo " \n"; if ($selection == $i) { - echo " \n"; - } + echo " \n"; + } else { - echo " \n"; - } - echo "\n"; + echo " \n"; } + echo "\n"; + } echo "
". get_string("optionaladjustment", "exercise")."\n"; unset($numbers); for ($j = 20; $j >= -20; $j--) { $numbers[$j] = $j; - } + } if (isset($grades[$exercise->nelements]->grade)) { - choose_from_menu($numbers, "grade_0[$exercise->nelements]", $grades[$exercise->nelements]->grade, ""); - } + choose_from_menu($numbers, "grade[$exercise->nelements]", $grades[$exercise->nelements]->grade, ""); + } else { - choose_from_menu($numbers, "grade_0[$exercise->nelements]", 0, ""); - } + choose_from_menu($numbers, "grade[$exercise->nelements]", 0, ""); + } echo "
$iplus1".text_to_html($elements[$i]->description)."{$elements[$i]->maxscore}
{$elements[$i]->maxscore}
\n"; echo "

\n"; break; @@ -2322,28 +2562,28 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission echo " \n"; if (isset($grades[$i])) { $selection = $grades[$i]->grade; - } else { + } else { $selection = 0; - } + } // ...and the rubrics if ($rubricsraw = get_records_select("exercise_rubrics", "exerciseid = $exercise->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 "\n"; + echo " \n"; + } else { + echo " \n"; } + echo "\n"; + } echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; - } } + } break; } // end of outer switch @@ -2377,472 +2617,30 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission break; default : echo " \n"; - } + } echo " \n"; - echo "
". get_string("optionaladjustment", "exercise")."\n"; unset($numbers); for ($j = 20; $j >= -20; $j--) { $numbers[$j] = $j; - } + } if (isset($grades[1]->grade)) { - choose_from_menu($numbers, "grade_0[1]", $grades[1]->grade, ""); - } + choose_from_menu($numbers, "grade[1]", $grades[1]->grade, ""); + } else { choose_from_menu($numbers, "grade[1]", 0, ""); - } + } echo "
cellheading2\">". get_string("criterion","exercise")."
".text_to_html($rubrics[$j]->description)."".text_to_html($rubrics[$j]->description)."

". get_string("feedback").":

\n"; @@ -2351,19 +2591,19 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission echo " \n"; } + echo "\n"; + } else { echo text_to_html($grades[$i]->feedback); - } + } echo "
cellheading2\"> 

". get_string("reasonforadjustment", "exercise").":

\n"; if ($allowchanges) { echo " \n"; } + echo "\n"; + } else { if ($assessment) { if (isset($assessment->generalcomment)) { echo text_to_html($assessment->generalcomment); - } } + } else { print_string("yourfeedbackgoeshere", "exercise"); - } } + } echo " 
\n"; - - // the teacher's comment on the assessment - // always allow the teacher to change/add their comment and grade if it's not their assessment! - echo "

\n"; - if (isteacher($course->id) and ($assessment->userid != $USER->id)) { - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - } - elseif ($assessment->timegraded and (($timenow - $assessment->timegraded) > $CFG->maxeditingtime)) { - // now show the teacher's comment (but not the grade) to the student if available... - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - } - // ...and close the table - echo "
cellheading2\" align=\"center\">". - get_string("pleasegradetheassessment", "exercise", "$submissionowner->firstname $submissionowner->lastname"). - "
".get_string("gradeforstudentsassessment", "exercise", $course->student). - "\n"; - // set up coment scale - for ($i=COMMENTSCALE; $i>=0; $i--) { - $num[$i] = $i; - } - choose_from_menu($num, "gradinggrade", $assessment->gradinggrade, ""); - echo "

". get_string("teacherscomment", "exercise").":

\n"; - echo "\n"; - echo "
cellheading2\"> 

". get_string("teacherscomment", "exercise", $course->teacher).":

\n"; - echo text_to_html($assessment->teachercomment); - echo " 
cellheading2\"> 


\n"; - - // ****************************second form****************************************** - // now print a normal assessment form based on the student's assessment for this submission - // and allow the teacher to grade and add comments - $studentassessment = $assessment; - $allowchanges = true; - - print_heading_with_help(get_string("nowpleasemakeyourownassessment", "exercise", - "$submissionowner->firstname $submissionowner->lastname"), "grading", "exercise"); - - // is there an existing assessment for the submission - if (!$assessment = exercise_get_submission_assessment($submission, $USER)) { - // copy student's assessment without the comments for the student's submission - $assessment = exercise_copy_assessment($studentassessment, $submission); - } - - // only show the grade if grading strategy > 0 and the grade is positive - if ($exercise->gradingstrategy and $assessment->grade >= 0) { - echo "
".get_string("thegradeis", "exercise").": ". - number_format($assessment->grade * $exercise->grade / 100.0, 2)." (". - get_string("maximumgrade")." ".number_format($exercise->grade, 0).")

\n"; - } - - echo "
\n"; - echo "\n"; - echo " \n"; - echo "\n"; - - - unset($grades); - // get any previous grades... - if ($gradesraw = get_records_select("exercise_grades", "assessmentid = $assessment->id", "elementno")) { - foreach ($gradesraw as $grade) { - $grades[] = $grade; // to renumber index 0,1,2... - } - } - - // determine what sort of grading - switch ($exercise->gradingstrategy) { - case 0: // no grading - // now print the form - for ($i=0; $i < count($elements); $i++) { - $iplus1 = $i+1; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - } - break; - - case 1: // accumulative grading - // now print the form - for ($i=0; $i < count($elements); $i++) { - $iplus1 = $i+1; - echo "\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"; - echo "\n"; - } - break; - - case 2: // error banded grading - // now run through the elements - $error = 0; - for ($i=0; $i < count($elements) - 1; $i++) { - $iplus1 = $i+1; - echo "\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"; - echo "\n"; - if (empty($grades[$i]->grade)) { - $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; - } - } - // print the number of negative elements - // echo "\n"; - // echo "\n"; - // echo " \n"; - echo "
cellheading2\">
".get_string("yourassessment", "exercise"). - "

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

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

". get_string("feedback").":

\n"; - if ($allowchanges) { - echo " \n"; - } - else { - echo text_to_html($grades[$i]->feedback); - } - echo "
cellheading2\"> 

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

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

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

". get_string("grade"). ":

\n"; - - // get the appropriate scale - $scalenumber=$elements[$i]->scale; - $SCALE = (object)$EXERCISE_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; - } - } - if ($checked) { - echo "    \n"; - } - else { - 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 { - choose_from_menu($numbers, "grade[$i]", 0, ""); - } - break; - - echo "

". get_string("feedback").":

\n"; - if ($allowchanges) { - echo " \n"; - } - else { - echo text_to_html($grades[$i]->feedback); - } - echo "
cellheading2\"> 

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

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

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

". get_string("grade"). ":

\n"; - - // get the appropriate scale - yes/no scale (0) - $SCALE = (object) $EXERCISE_SCALES[0]; - 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; - } - } - if ($checked) { - echo "    \n"; - } - else { - 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 { - choose_from_menu($numbers, "grade[$i]", 0, ""); - } - break; - } - - echo "

". get_string("feedback").":

\n"; - if ($allowchanges) { - echo " \n"; - } - else { - if (isset($grades[$i]->feedback)) { - echo text_to_html($grades[$i]->feedback); - } - } - echo " 
cellheading2\"> 
".get_string("numberofnegativeitems", "exercise")."$negativecount
cellheading2\"> 
\n"; - // now print the grade table - echo "

".get_string("gradetable","exercise")."
\n"; - echo "
\n"; - for ($i=0; $i<=$exercise->nelements; $i++) { - if ($i == intval($error + 0.5)) { - echo "\n"; - } - else { - echo "\n"; - } - } - echo "
". - get_string("numberofnegativeresponses", "exercise"); - echo "". get_string("suggestedgrade", "exercise")."
pixpath/t/right.gif\"> $i{$elements[$i]->maxscore}
$i{$elements[$i]->maxscore}
\n"; - echo "

\n"; - break; - - case 3: // criteria grading - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - // find which criteria has been selected (saved in the zero element), if any - if (isset($grades[0]->grade)) { - $selection = $grades[0]->grade; - } - else { - $selection = 0; - } - // now run through the elements - for ($i=0; $i < count($elements); $i++) { - $iplus1 = $i+1; - echo "\n"; - echo " \n"; - if ($selection == $i) { - echo " \n"; - } - else { - echo " \n"; - } - echo "\n"; - } - echo "
". - get_string("optionaladjustment", "exercise")."\n"; - unset($numbers); - for ($j = 20; $j >= -20; $j--) { - $numbers[$j] = $j; - } - if (isset($grades[$exercise->nelements]->grade)) { - choose_from_menu($numbers, "grade[$exercise->nelements]", $grades[$exercise->nelements]->grade, ""); - } - else { - choose_from_menu($numbers, "grade[$exercise->nelements]", 0, ""); - } - echo "
cellheading2\"> cellheading2\">". get_string("criterion","exercise")."cellheading2\">".get_string("select", "exercise")."cellheading2\">".get_string("suggestedgrade", "exercise")."
$iplus1".text_to_html($elements[$i]->description)."{$elements[$i]->maxscore}
\n"; - 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 "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - if (isset($grades[$i])) { - $selection = $grades[$i]->grade; - } else { - $selection = 0; - } - // ...and the rubrics - if ($rubricsraw = get_records_select("exercise_rubrics", "exerciseid = $exercise->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 "\n"; - } - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - } - } - break; - } // end of outer switch - - // now get the general comment (present in all types) - echo "\n"; - switch ($exercise->gradingstrategy) { - case 0: - case 1: - case 4 : // no grading, accumulative and rubic - echo " \n"; - break; - default : - echo " \n"; - } - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; // ...and close the table and show two buttons...to resubmit or not to resubmit echo "
". - get_string("optionaladjustment", "exercise")."\n"; - unset($numbers); - for ($j = 20; $j >= -20; $j--) { - $numbers[$j] = $j; - } - if (isset($grades[1]->grade)) { - choose_from_menu($numbers, "grade[1]", $grades[1]->grade, ""); - } - else { - choose_from_menu($numbers, "grade[1]", 0, ""); - } - echo "
".get_string("element", "exercise")." $iplus1:".text_to_html($elements[$i]->description). - "

Weight: " - .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."

cellheading2\" align=\"center\">".get_string("select", "exercise")."cellheading2\">". get_string("criterion","exercise")."
".text_to_html($rubrics[$j]->description)."

". get_string("feedback").":

\n"; - if ($allowchanges) { - echo " \n"; - } - else { - echo text_to_html($grades[$i]->feedback); - } - echo "
cellheading2\"> 

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

". get_string("reasonforadjustment", "exercise").":

\n"; - if ($allowchanges) { - echo " \n"; - } - else { - if ($assessment) { - if (isset($assessment->generalcomment)) { - echo text_to_html($assessment->generalcomment); - } - } - else { - print_string("yourfeedbackgoeshere", "exercise"); - } - } - echo " 
cellheading2\"> 
cellheading2\"> 
\n"; @@ -2851,223 +2649,6 @@ function exercise_print_dual_assessment_form($exercise, $assessment, $submission echo "student)."\" onclick=\"document.assessmentform.resubmit.value='1';document.assessmentform.submit();\">\n"; echo "
\n"; - } - - -/////////////////////////////////////////////////////////////////////////////////////////////// -function exercise_print_feedback($course, $submission) { - global $CFG, $THEME, $RATING; - - if (! $teacher = get_record("user", "id", $submission->teacher)) { - error("Weird exercise error"); - } - - echo "\n
"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo ""; - - echo "\n
body\" WIDTH=35 VALIGN=TOP>"; - print_user_picture($teacher->id, $course->id, $teacher->picture); - echo "cellheading\">$teacher->firstname $teacher->lastname"; - echo "  ".userdate($submission->timemarked).""; - echo "
cellcontent\">"; - - echo "

"; - if ($submission->grade) { - echo get_string("grade").": $submission->grade"; - } else { - echo get_string("nograde"); - } - echo "

"; - - echo text_to_html($submission->assessorcomment); - echo "
"; - echo "
"; -} - - -/////////////////////////////////////////////////////////////////////////////////////////////// -function exercise_print_league_table($exercise) { - // print an order table of (student) submissions in grade order, only print the student's best submission when - // there are multiple submissions - if (! $course = get_record("course", "id", $exercise->course)) { - error("Print league table: Course is misconfigured"); - } - $nentries = $exercise->showleaguetable; - if ($nentries == 99) { - $nentries = 999999; // a large number - } - - if ($exercise->anonymous and isstudent($course->id)) { - $table->head = array (get_string("title", "exercise"), get_string("grade")); - $table->align = array ("left", "center"); - $table->size = array ("*", "*"); - } else { // show names - $table->head = array (get_string("title", "exercise"), get_string("name"), get_string("grade")); - $table->align = array ("left", "left", "center"); - $table->size = array ("*", "*", "*"); - } - $table->cellpadding = 2; - $table->cellspacing = 0; - - if ($submissions = exercise_get_student_submissions($exercise, "grade")) { - $n = 1; - foreach ($submissions as $submission) { - if (empty($done[$submission->userid])) { - if ($submission->late) { - continue; - } - if (!$user = get_record("user", "id", $submission->userid)) { - error("Print league table: user not found"); - } - if ($exercise->anonymous and isstudent($course->id)) { - $table->data[] = array(exercise_print_submission_title($exercise, $submission), - number_format($submission->grade * $exercise->grade / 100.0, 1)); - } else { - $table->data[] = array(exercise_print_submission_title($exercise, $submission), - $user->firstname." ".$user->lastname, - number_format($submission->grade * $exercise->grade / 100.0, 1)); - } - $n++; - if ($n > $nentries) { - break; - } - $done[$submission->userid] = 'ok'; - } - } - print_heading(get_string("leaguetable", "exercise")); - print_table($table); - } - } - - -/////////////////////////////////////////////////////////////////////////////////////////////// -function exercise_print_submission_assessments($exercise, $submission) { - // Returns a list of grades for this submission - - if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); - } - if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); - } - - $str = ''; - if ($assessments = exercise_get_assessments($submission)) { - foreach ($assessments as $assessment) { - if (isteacher($exercise->course, $assessment->userid)) { - $str .= "[".number_format($assessment->grade * $exercise->grade / 100.0, 0)."] "; - } - else { // assessment by student - shouldn't happen! - $str .= "{".number_format($assessment->grade * $exercise->grade / 100.0, 0)."} "; - } - } - } - if (!$str) { - $str = " "; // be kind to Mozilla browsers! - } - return $str; -} - - -////////////////////////////////////////////////////////////////////////////////////// -function exercise_print_tabbed_heading($tabs) { -// Prints a tabbed heading where one of the tabs highlighted. -// $tabs is an object with several properties. -// $tabs->names is an array of tab names -// $tabs->urls is an array of links -// $tabs->align is an array of column alignments (defaults to "center") -// $tabs->size is an array of column sizes -// $tabs->wrap is an array of "nowrap"s or nothing -// $tabs->highlight is an index (zero based) of "active" heading . -// $tabs->width is an percentage of the page (defualts to 80%) -// $tabs->cellpadding padding on each cell (defaults to 5) - - global $CFG, $THEME; - - if (isset($tabs->names)) { - foreach ($tabs->names as $key => $name) { - if (!empty($tabs->urls[$key])) { - $url =$tabs->urls[$key]; - if ($tabs->highlight == $key) { - $tabcontents[$key] = "$name"; - } else { - $tabcontents[$key] = "$name"; - } - } else { - $tabcontents[$key] = "$name"; - } - } - } - - if (empty($tabs->width)) { - $tabs->width = "80%"; - } - - if (empty($tabs->cellpadding)) { - $tabs->cellpadding = "5"; - } - - // print_simple_box_start("center", "$table->width", "#ffffff", 0); - echo "cellpadding\" cellspacing=\"0\" class=\"generaltable\">\n"; - - if (!empty($tabs->names)) { - echo ""; - echo "\n"; - foreach ($tabcontents as $key => $tab) { - if (isset($align[$key])) { - $alignment = "align=\"$align[$key]\""; - } else { - $alignment = "align=\"center\""; - } - if (isset($size[$key])) { - $width = "width=\"$size[$key]\""; - } else { - $width = ""; - } - if (isset($wrap[$key])) { - $wrapping = "no wrap"; - } else { - $wrapping = ""; - } - if ($key == $tabs->highlight) { - echo "\n"; - } else { - echo "\n"; - } - echo "\n"; - } - echo "\n"; - } else { - echo "\n"; - } - // bottom stripe - $ncells = count($tabs->names)*2 +1; - $height = 2; - echo "\n"; - echo "
". - "wwwroot/pix/spacer.gif\" alt=\"\">cellheading2\">$tabcellheading\">$tab". - "wwwroot/pix/spacer.gif\" alt=\"\">
No names specified
cellheading2\">". - "wwwroot/pix/spacer.gif\" alt=\"\">
\n"; - // print_simple_box_end(); - - return true; -} - - -/////////////////////////////////////////////////////////////////////////////////////////////// -function exercise_print_time_to_deadline($time) { - if ($time < 0) { - $timetext = get_string("afterdeadline", "exercise", format_time($time)); - return " ($timetext)"; - } else { - $timetext = get_string("beforedeadline", "exercise", format_time($time)); - return " ($timetext)"; - } } @@ -3123,6 +2704,18 @@ function exercise_print_teacher_table($course) { } +/////////////////////////////////////////////////////////////////////////////////////////////// +function exercise_print_time_to_deadline($time) { + if ($time < 0) { + $timetext = get_string("afterdeadline", "exercise", format_time($time)); + return " ($timetext)"; + } else { + $timetext = get_string("beforedeadline", "exercise", format_time($time)); + return " ($timetext)"; + } +} + + /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_print_upload_form($exercise) { @@ -3140,6 +2733,7 @@ function exercise_print_upload_form($exercise) { echo "".get_string("title", "exercise").":

\n"; echo " "; echo " "; + echo " (".get_string("maximumupload").": ".display_size($exercise->maxbytes).")\n"; echo ""; echo ""; } @@ -3154,7 +2748,7 @@ function exercise_print_user_assessments($exercise, $user) { $str = "$n ("; foreach ($assessments as $assessment) { if ($assessment->timegraded) { - $gradingscaled = intval($assessment->gradinggrade * $exercise->grade / COMMENTSCALE); + $gradingscaled = round($assessment->gradinggrade * $exercise->gradinggrade / 100.0); $str .= "id&aid=$assessment->id\">"; $str .= "$gradingscaled "; } diff --git a/mod/exercise/mod.html b/mod/exercise/mod.html index c0b7f21a20..52ab0987b0 100644 --- a/mod/exercise/mod.html +++ b/mod/exercise/mod.html @@ -4,15 +4,21 @@ if (empty($form->name)) { $form->name = ""; } - if (empty($form->gradingstrategy)) { + if (!isset($form->gradingstrategy)) { $form->gradingstrategy = 1; } if (empty($form->usemaximum)) { $form->usemaximum = 0; } + if (!isset($form->assessmentcomps)) { + $form->assessmentcomps = 2; + } if (!isset($form->grade)) { $form->grade = 100; } + if (!isset($form->gradinggrade)) { + $form->gradinggrade = 100; + } if (!isset($form->nelements)) { $form->nelements = 1; } @@ -22,6 +28,12 @@ if (empty($form->deadline)) { $form->deadline = ""; } + if (empty($form->showleaguetable)) { + $form->showleaguetable = ""; + } + if (empty($form->anonymous)) { + $form->anonymous = 0; + } $nohtmleditorneeded = true; ?> @@ -44,14 +56,24 @@ -

:

+

student) ?>:

=0; $i--) { $grades[$i] = $i; } + choose_from_menu($grades, "gradinggrade", "$form->gradinggrade", ""); + helpbutton("gradinggrade", get_string("gradinggrade", "exercise"), "exercise"); + ?> + + + + +

:

+ + grade", ""); - helpbutton("grade", get_string("maximumgrade", "exercise"), "exercise"); + helpbutton("grade", get_string("gradeforsubmission", "exercise"), "exercise"); ?> @@ -90,8 +112,22 @@ + +

:

+ + $COMPARISON) { + $COMPARISONS[] = $COMPARISON['name']; + } + choose_from_menu($COMPARISONS, "assessmentcomps", $form->assessmentcomps, ""); + helpbutton("comparisonofassessments", get_string("comparisonofassessments", "exercise"), "exercise"); + ?> + + + -

:

+

:

-

: +

:

deadline); echo " - "; @@ -125,9 +161,34 @@ ?> + +

:

+ =0; $i--) { + $numbers[$i] = $i; + } + choose_from_menu($numbers, "showleaguetable", "$form->showleaguetable", ""); + helpbutton("leaguetable", get_string("numberofentriesinleaguetable", "exercise"), "exercise"); + ?> + + + +> +

students) ?>:

+ anonymous, ""); + helpbutton("leaguetablenames", get_string("hidenamesfromstudents", "exercise", $course->students), "exercise"); + ?> + + + -
-
+
+
diff --git a/mod/exercise/submissions.php b/mod/exercise/submissions.php index fb26b2c6e4..0c23ba208e 100644 --- a/mod/exercise/submissions.php +++ b/mod/exercise/submissions.php @@ -111,7 +111,7 @@ add_to_log($course->id, "exercise", "late flag cleared", "view.php?id=$cm->id", "submission $submission->id"); - print_continue("submissions.php?id=$cm->id&action=adminlist"); + redirect("submissions.php?id=$cm->id&action=adminlist"); } @@ -132,6 +132,10 @@ if (!isteacheredit($course->id)) { error("Only teacher with editing permissions can delete teacher submissions."); } + if ($assessments = exercise_get_assessments($submission)) { + echo "

".get_string("deletesubmissionwarning", "exercise", count($assessments)). + "

\n"; + } } notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("submission", "exercise")), "submissions.php?action=admindelete&id=$cm->id&sid=$_GET[sid]", "submissions.php?id=$cm->id&action=adminlist"); @@ -218,12 +222,13 @@ if (set_field("exercise_submissions", "title", $_POST['title'], "id", $_POST['sid'])) { print_heading(get_string("amendtitle", "exercise")." ".get_string("ok")); } - print_continue("submissions.php?id=$cm->id&action=adminlist"); + redirect("submissions.php?id=$cm->id&action=adminlist"); } /*************** display final grades (by teacher) ***************************/ elseif ($action == 'displayfinalgrades') { + $groupid = get_current_group($course->id); // Get all the students if (!$users = get_course_students($course->id, "u.lastname, u.firstname")) { print_heading(get_string("nostudentsyet")); @@ -231,9 +236,6 @@ exit; } - // get the final weights from the database - $teacherweight = get_field("exercise","teacherweight", "id", $exercise->id); - $gradingweight = get_field("exercise","gradingweight", "id", $exercise->id); // show the final grades as stored in the tables... print_heading_with_help(get_string("displayoffinalgrades", "exercise"), "finalgrades", "exercise"); echo "
\n"; @@ -243,12 +245,19 @@ echo ""; echo "\n"; // now the weights - echo ""; + echo ""; echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; foreach ($users as $user) { + // check group membership, if necessary + if ($groupid) { + // check user's group + if (!ismember($groupid, $user->id)) { + continue; // skip this user + } + } // first get user's own assessment reord, it should contain their grading grade if ($ownassessments = exercise_get_user_assessments($exercise, $user)) { foreach ($ownassessments as $ownassessment) { @@ -262,19 +271,18 @@ foreach ($submissions as $submission) { if ($assessments = exercise_get_assessments($submission)) { foreach ($assessments as $assessment) { // (normally there should only be one + $gradinggrade = number_format($ownassessment->gradinggrade * $exercise->gradinggrade / + 100.0, 1); $grade = number_format($assessment->grade * $exercise->grade / 100.0, 1); - $overallgrade = number_format(((($assessment->grade * - $EXERCISE_FWEIGHTS[$teacherweight] / 100.0) + - ($ownassessment->gradinggrade * $EXERCISE_FWEIGHTS[$gradingweight]/ - COMMENTSCALE )) * $exercise->grade) / ($EXERCISE_FWEIGHTS[$teacherweight] + - $EXERCISE_FWEIGHTS[$gradingweight]), 1); + $overallgrade = number_format(($assessment->grade * $exercise->grade / 100.0) + + ($ownassessment->gradinggrade * $exercise->gradinggrade / 100.0), 1); if ($submission->late) { $grade = "(".$grade.")"; $overallgrade = "(".$overallgrade.")"; } echo "\n"; echo "\n"; - echo ""; + echo ""; echo ""; echo "\n"; } @@ -287,7 +295,7 @@ exercise_print_league_table($exercise); echo "
\n"; } - print_string("allgradeshaveamaximumof", "exercise", $exercise->grade)."\n"; + echo get_string("maximumgrade").": $exercise->grade\n"; print_continue("view.php?id=$cm->id"); } diff --git a/mod/exercise/version.php b/mod/exercise/version.php index a4c4a2b8bc..f1aa3b12e7 100644 --- a/mod/exercise/version.php +++ b/mod/exercise/version.php @@ -5,7 +5,7 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2004060400; +$module->version = 2004062300; $module->requires = 2004052501; // Requires this Moodle version $module->cron = 60; diff --git a/mod/exercise/view.php b/mod/exercise/view.php index 76a1c9113b..0efe73cae5 100644 --- a/mod/exercise/view.php +++ b/mod/exercise/view.php @@ -84,12 +84,8 @@ /****************** display final grade (for students) ************************************/ if ($action == 'displayfinalgrade' ) { - // get the final weights from the database - $teacherweight = get_field("exercise","teacherweight", "id", $exercise->id); - $gradingweight = get_field("exercise","gradingweight", "id", $exercise->id); - // show the final grades as stored in the tables... - print_heading_with_help(get_string("displayoffinalgrades", "exercise"), "finalgrades", "exercise"); + print_heading(get_string("displayoffinalgrades", "exercise")); if ($submissions = exercise_get_user_submissions($exercise, $USER)) { // any submissions from user? echo "
cellheading2\" align=\"center\">".get_string("gradeforsubmission", "exercise")."cellheading2\" align=\"center\">".get_string("overallgrade", "exercise")."
cellheading2\">".get_string("weights", "exercise")."
cellheading2\">".get_string("maximumgrade")."cellheading2\"> cellheading2\" align=\"center\">$EXERCISE_FWEIGHTS[$gradingweight]cellheading2\" align=\"center\">$EXERCISE_FWEIGHTS[$teacherweight]cellheading2\" align=\"center\">$exercise->gradinggradecellheading2\" align=\"center\">$exercise->gradecellheading2\"> 
$user->firstname $user->lastname".exercise_print_submission_title($exercise, $submission)."".number_format($ownassessment->gradinggrade * $exercise->grade / COMMENTSCALE, 1)."$gradinggrade$grade$overallgrade
"; echo ""; @@ -97,9 +93,9 @@ echo ""; echo "\n"; // now the weights - echo ""; - echo "\n"; - echo "\n"; + echo ""; + echo "\n"; + echo "\n"; echo "\n"; // first get user's own assessment reord, it should contain their grading grade if ($ownassessments = exercise_get_user_assessments($exercise, $USER)) { @@ -113,17 +109,17 @@ foreach ($submissions as $submission) { if ($assessments = exercise_get_assessments($submission)) { foreach ($assessments as $assessment) { // (normally there should only be one + $gradinggrade = number_format($ownassessment->gradinggrade * $exercise->gradinggrade / 100.0, + 1); $grade = number_format($assessment->grade * $exercise->grade / 100.0, 1); - $overallgrade = number_format(((($assessment->grade * - $EXERCISE_FWEIGHTS[$teacherweight] / 100.0) + ($ownassessment->gradinggrade * - $EXERCISE_FWEIGHTS[$gradingweight] / COMMENTSCALE )) * $exercise->grade) / - ($EXERCISE_FWEIGHTS[$teacherweight] + $EXERCISE_FWEIGHTS[$gradingweight]), 1); + $overallgrade = number_format(($assessment->grade * $exercise->grade / 100.0) + + ($ownassessment->gradinggrade * $exercise->gradinggrade / 100.0 ), 1); if ($submission->late) { $grade = "(".$grade.")"; $overallgrade = "(".$overallgrade.")"; } echo "\n"; - echo ""; + echo ""; echo ""; echo "\n"; } @@ -134,7 +130,7 @@ if ($exercise->showleaguetable) { exercise_print_league_table($exercise); } - echo "
".get_string("allgradeshaveamaximumof", "exercise", $exercise->grade)."
\n"; + echo "
".get_string("maximumgrade").": $exercise->grade
\n"; } @@ -238,7 +234,7 @@ } - /****************** student's view could be in 1 of 4 stages ***********************/ + /****************** student's view could be in 1 of 3 stages ***********************/ elseif ($action == 'studentsview') { exercise_print_assignment_info($exercise); // in Stage 1 - the student must make an assessment (linked to the teacher's exercise/submission @@ -302,8 +298,21 @@ error("Only teachers can look at this page"); } - print_heading_with_help(get_string("managingassignment", "exercise"), "managing", "exercise"); + /// Check to see if groups are being used in this exercise + /// and if so, set $currentgroup to reflect the current group + $changegroup = isset($_GET['group']) ? $_GET['group'] : -1; // Group change requested? + $groupmode = groupmode($course, $cm); // Groups are being used? + $currentgroup = get_and_set_current_group($course, $groupmode, $changegroup); + + /// Allow the teacher to change groups (for this session) + if ($groupmode) { + if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) { + print_group_menu($groups, $groupmode, $currentgroup, "view.php?id=$cm->id"); + } + } + print_heading_with_help(get_string("managingassignment", "exercise"), "managing", "exercise"); + exercise_print_assignment_info($exercise); $tabs->names = array("1. ".get_string("phase1", "exercise"), "2. ".get_string("phase2", "exercise", $course->student), -- 2.39.5
cellheading2\">".get_string("submissions", "exercise")."cellheading2\" align=\"center\">".get_string("gradeforsubmission", "exercise", $course->teacher)."cellheading2\" align=\"center\">".get_string("overallgrade", "exercise")."
cellheading2\">".get_string("weights", "exercise")."cellheading2\" align=\"center\">$EXERCISE_FWEIGHTS[$gradingweight]cellheading2\" align=\"center\">$EXERCISE_FWEIGHTS[$teacherweight]
cellheading2\">".get_string("maximumgrade")."cellheading2\" align=\"center\">$exercise->gradinggradecellheading2\" align=\"center\">$exercise->gradecellheading2\"> 
".exercise_print_submission_title($exercise, $submission)."".number_format($ownassessment->gradinggrade * $exercise->grade / COMMENTSCALE, 1)."$gradinggrade$grade$overallgrade