More changes to the user interface. See http://moodle.org/mod/forum/view.php?id=740.
authorgustav_delius <gustav_delius>
Sun, 12 Dec 2004 11:20:07 +0000 (11:20 +0000)
committergustav_delius <gustav_delius>
Sun, 12 Dec 2004 11:20:07 +0000 (11:20 +0000)
lang/en/workshop.php
mod/workshop/assess.php [new file with mode: 0644]
mod/workshop/assessment_grading_form.html
mod/workshop/assessments.php
mod/workshop/lib.php
mod/workshop/locallib.php
mod/workshop/submissions.php
mod/workshop/version.php
mod/workshop/view.php
mod/workshop/viewassessment.php [new file with mode: 0644]

index 6177113..dd46cc0 100644 (file)
@@ -9,9 +9,11 @@ $string['addacomment'] = 'Add a Comment';
 $string['addcomment'] = 'Add Comment';
 $string['afterdeadline'] = 'After Deadline: $a';
 $string['ago'] = "\$a ago";
+$string['agrade'] = 'Assmnt<br />Grade';
 $string['agreetothisassessment'] = 'Agree to this Assessment';
 $string['allgradeshaveamaximumof'] = 'All Grades have a Maximum of: $a';
 $string['allowresubmit'] = 'Allow Resubmissions';
+$string['allsubmissions'] = 'All submissions';
 $string['alreadyinphase'] = 'Already in Phase $a';
 $string['amendassessmentelements'] = 'Amend Assessment Elements';
 $string['amendtitle'] = 'Amend Title';
@@ -32,7 +34,7 @@ $string['assessmentofresubmission'] = 'This is an Assessment of a revised piece
 $string['assessmentofthissubmission'] = 'Assessment of this submission';
 $string['assessments'] = 'Assessments';
 $string['assessmentsareok'] = 'Assessments are OK';
-$string['assessmentsby'] = '$a Assessments';
+$string['assessmentsby'] = 'Assessments by $a';
 $string['assessmentsdone'] = 'Assessments Done';
 $string['assessmentsexcluded'] = 'Number of Assessments excluded for this $a';
 $string['assessmentsmustbeagreed'] = 'Assessments must be agreed';
@@ -43,6 +45,7 @@ $string['assessor'] = 'Assessor';
 $string['assessthissubmission'] = 'Assess this submission';
 $string['assessthisassessment'] = 'Grade this assessment';
 $string['assignmentnotinthecorrectphase'] = 'Assignment not in the Correct Phase';
+$string['assmnts'] = 'Assessments';
 $string['attachment'] = 'Attachment';
 $string['attachments'] = 'Attachments';
 $string['authorofsubmission'] = 'Author of Submission';
@@ -50,6 +53,7 @@ $string['automaticgradeforassessment'] = 'Automatic grade for assessment';
 $string['averageerror'] = 'Average Error';
 $string['awaitinggradingbyteacher'] = 'Awaiting Grading by $a';
 $string['beforedeadline'] = 'Before Deadline: $a';
+$string['by'] = 'submitted by';
 $string['calculationoffinalgrades'] = 'Calculation of Final Grades';
 $string['clearlateflag'] = "Clear Late Flag";
 $string['closeassignment'] = 'Close Assignment';
@@ -62,6 +66,8 @@ $string['correct'] = 'Correct';
 $string['count'] = 'Count';
 $string['criterion'] = 'Criterion';
 $string['currentphase'] = 'Current phase';
+$string['date'] = 'Date';
+$string['datestr'] = '%%d/%%m/%%y<br />%%H:%%M';
 $string['deadline'] = 'Deadline for submission';
 $string['deadlineis'] = 'The Deadline for submission is $a';
 $string['delete'] = 'Delete';
@@ -82,11 +88,13 @@ $string['elementweight'] = 'Element Weight';
 $string['enterpassword'] = "Enter Password";
 $string['errorbanded'] = 'Error Banded';
 $string['errortable'] = 'Error Table';
+$string['examplesubmissions'] = 'Example Submissions';
 $string['excellent'] = 'Excellent';
 $string['excludingdroppedassessments'] = 'excluding dropped Assessments';
 $string['expectederror'] = 'Expected Error Value if guessing: $a';
 $string['fair'] = "Fair";
 $string['feedbackgoeshere'] = 'Feedback goes here';
+$string['firstname'] = 'First name';
 $string['generalcomment'] = 'General comment';
 $string['good'] = 'Good';
 $string['grade'] = 'Grade';
@@ -100,6 +108,7 @@ $string['gradeforreliability'] = 'Grade for Reliability';
 $string['gradeforstudentsassessment'] = 'Grade for Student\'s Assessment';
 $string['gradeforsubmission'] = 'Grade for Submission';
 $string['gradeofsubmission'] = 'Grade of Submission: $a';
+$string['grades'] = 'Grades';
 $string['gradesforassessmentsare'] = 'Grades for Assessments are out of $a';
 $string['gradesforstudentsassessment'] = 'Grades for $a\'s Assessment';
 $string['gradesforsubmissionsare'] = 'Grades for Submissions are out of $a';
@@ -114,6 +123,7 @@ $string['incorrect'] = 'Incorrect';
 $string['info'] = 'Info';
 $string['invaliddates'] = 'The dates you have entered are not possible.<br />Use the browser\'s Back button to return to the form and correct the dates.';
 $string['iteration'] = 'Iteration $a completed';
+$string['lastname'] = 'Surname';
 $string['lax'] = "Lax";
 $string['leaguetable'] = 'League Table of Submitted Work';
 $string['listassessments'] = 'List Assessments';
@@ -130,7 +140,7 @@ $string['mail6'] = 'Your assessment of the assignment \'$a\' has by reviewed.';
 $string['mail7'] = 'The comments given by the $a can be seen in the Workshop Assignment '; //not used in 1.5
 $string['mail8'] = 'The assignment $a is a revised piece of work. ';
 $string['mail9'] = 'Please assess it in the workshop assignment \'$a\'.';
-$string['managingassignment'] = 'Managing the Assignment';
+$string['managingassignment'] = 'Managing the Workshop';
 $string['maximum'] = 'Maximum';
 $string['maximumsize'] = 'Maximum Size';
 $string['mean'] = 'Mean';
@@ -161,6 +171,7 @@ $string['noteonstudentassessments'] = '{Grade from Student / Grading Grade for A
 $string['notgraded'] = 'Not Graded';
 $string['notitle'] = 'No Title';
 $string['notitlegiven'] = 'No Title Given';
+$string['nowork'] = 'The submission period has now ended.<br />You have submitted no work.';
 $string['numberofassessmentelements'] = 'Number of Comments, Assessment Elements, Grade Bands, Criterion Statments or Categories in a Rubric';
 $string['numberofassessments'] = 'Number of Assessments';
 $string['numberofassessmentschanged'] = 'Number of Assessments Changed: $a';
@@ -172,6 +183,7 @@ $string['numberofattachments'] = 'Number of Attachments expected on Submissions'
 $string['numberofentries'] = 'Number of Entries';
 $string['numberofnegativeresponses'] = 'Number of Negative Responses';
 $string['numberofsubmissions'] = 'Number of Submissions: $a';
+$string['ograde'] = 'Total<br />Grade';
 $string['on'] = 'on $a';
 $string['openassignment'] = 'Open Assignment';
 $string['optionaladjustment'] = 'Optional Adjustment';
@@ -183,6 +195,7 @@ $string['overallpeergrade'] = 'Overall Peer Grade: $a';
 $string['overallteachergrade'] = 'Overall Teacher Grade: $a';
 $string['ownwork'] = 'Own Work';
 $string['passwordprotectedworkshop'] = "Password Protected Workshop";
+$string['passmnts'] = 'Peer<br />Assessments';
 $string['percentageofassessments'] = 'Percentage of Assessments to Drop';
 $string['phase'] = 'Phase';
 $string['phase0'] = 'Inactive';
@@ -231,6 +244,8 @@ $string['scalepresent'] = '2 point Present/Absent scale';
 $string['scaleyes'] = '2 point Yes/No scale';
 $string['select'] = 'Select';
 $string['selfassessment'] = 'Self Assessment';
+$string['sgrade'] = 'Sbmsn<br />Grade';
+$string['showdescription'] = 'Show Workshop Description';
 $string['showgrades'] = 'Show Grades';
 $string['showsubmission'] = 'Show Submission: $a';
 $string['specimenassessmentform'] = 'Specimen Assessment Form';
@@ -252,11 +267,13 @@ $string['submissionstartevent'] = 'Start of submissions for $a';
 $string['submissionsused'] = '$a Submissions used in this table';
 $string['submitassignment'] = 'Submit Assignment';
 $string['submitassignmentusingform'] = 'Submit your Assignment using this Form';
+$string['submitexample'] = 'Submit Example';
 $string['submitexampleassignment'] = 'Submit Example Assignment';
 $string['submitrevisedassignment'] = 'Submit your Revised Assignment using this Form';
 $string['submitted'] = 'Submitted';
 $string['submittedby'] = 'Submitted by';
 $string['suggestedgrade'] = 'Suggested Grade';
+$string['tassmnt'] = 'Teacher<br />Assessment';
 $string['teacherassessments'] = '$a Assessments';
 $string['teachergradeforassessment'] = '$a grade for assessment';
 $string['teacherscomment'] = 'Teacher\'s Comment';
@@ -267,7 +284,7 @@ $string['thegradeforthisassessmentis'] = 'The grade for this assessment is $a';
 $string['theseasessmentsaregradedbytheteacher'] = 'These Assessments are graded by the $a';
 $string['thisisadroppedassessment'] = 'This is a dropped Assessment.';
 $string['timeassessed'] = 'Time Assessed';
-$string['title'] = 'Title';
+$string['title'] = 'Submission Title';
 $string['typeofscale'] = 'Type of Scale';
 $string['unassessed'] = "\$a Unassessed";
 $string['ungradedassessments'] = '$a Ungraded Assessments';
@@ -279,6 +296,7 @@ $string['verylax'] = "Very Lax";
 $string['verypoor'] = "Very Poor";
 $string['verystrict'] = "Very Strict";
 $string['view'] = 'View';
+$string['viewassessment'] = 'View Assessment';
 $string['viewassessmentofteacher'] = 'View Assessment of $a';
 $string['viewotherassessments'] = 'View other Assessments';
 $string['warningonamendingelements'] = 'WARNING: There are submitted assessments. <br />Do NOT change the number
diff --git a/mod/workshop/assess.php b/mod/workshop/assess.php
new file mode 100644 (file)
index 0000000..81ac08d
--- /dev/null
@@ -0,0 +1,137 @@
+<?php  // $Id: assess.php
+
+    require("../../config.php");
+    require("lib.php"); 
+    require("locallib.php");
+
+    require_variable($sid);   // Submission ID
+    optional_variable($allowcomments, false);
+    optional_variable($redirect, '');
+
+    if (! $submission = get_record('workshop_submissions', 'id', $sid)) {
+        error("Incorrect submission id");
+    }
+    if (! $workshop = get_record("workshop", "id", $submission->workshopid)) {
+        error("Submission is incorrect");
+    }
+    if (! $course = get_record("course", "id", $workshop->course)) {
+        error("Workshop is misconfigured");
+    }
+    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
+        error("No coursemodule found");
+    }
+    
+    if (!$redirect) {
+        $redirect = urlencode($_SERVER["HTTP_REFERER"].'#sid='.$submission->id);
+    }
+    
+    require_login($course->id);
+
+    $strworkshops = get_string("modulenameplural", "workshop");
+    $strworkshop  = get_string("modulename", "workshop");
+    $strassess = get_string("assess", "workshop");
+    
+    /// Now check whether we need to display a frameset
+
+    if (empty($_GET['frameset'])) {
+        echo "<head><title>{$course->shortname}: {$workshop->name}</title></head>\n";
+        echo "<frameset rows=\"50%,*\" border=\"10\">";
+        echo "<frame src=\"assess.php?id=$id&amp;sid=$sid&amp;frameset=top&amp;redirect=$redirect\" border=\"10\">";
+        echo "<frame src=\"assess.php?id=$id&amp;sid=$sid&amp;frameset=bottom&amp;redirect=$redirect\">";
+        echo "</frameset>";
+        exit;
+    }
+
+    /// top frame with the navigation bar and the assessment form
+    
+    if (!empty($_GET['frameset']) and $_GET['frameset'] == "top") {
+    
+        print_header_simple("$workshop->name", "",
+                     "<a href=\"index.php?id=$course->id\">$strworkshops</a> -> 
+                      <a href=\"view.php?id=$cm->id\">$workshop->name</a> -> $strassess", 
+                      "", '<base target="_parent">', true);
+    
+        // there can be an assessment record (for teacher submissions), if there isn't...
+        if (!$assessment = get_record("workshop_assessments", "submissionid", $submission->id, "userid", 
+                    $USER->id)) {
+            // if it's the teacher see if the user has done a self assessment if so copy it
+            if (isteacher($course->id) and  ($assessment = get_record("workshop_assessments", "submissionid", 
+                            $submission->id, "userid", $submission->userid))) {
+                $assessment = workshop_copy_assessment($assessment, $submission, true);
+                // need to set owner of assessment
+                set_field("workshop_assessments", "userid", $USER->id, "id", $assessment->id);
+                $assessment->resubmission = 0; // not set by workshop_copy_assessment
+                $assessment->timegraded = 0; // not set by workshop_copy_assessment
+                $assessment->timeagreed = 0; // not set by workshop_copy_assessment
+            } else {
+                $yearfromnow = time() + 365 * 86400;
+                // ...create one and set timecreated way in the future, this is reset when record is updated
+                $assessment->workshopid = $workshop->id;
+                $assessment->submissionid = $submission->id;
+                $assessment->userid = $USER->id;
+                $assessment->timecreated = $yearfromnow;
+                $assessment->grade = -1; // set impossible grade
+                $assessment->timegraded = 0;
+                $assessment->timeagreed = 0;
+                $assessment->resubmission = 0;
+                if (!$assessment->id = insert_record("workshop_assessments", $assessment)) {
+                    error("Could not insert workshop assessment!");
+                }
+                // if it's the teacher and the workshop is error banded set all the elements to Yes
+                if (isteacher($course->id) and ($workshop->gradingstrategy == 2)) {
+                    for ($i =0; $i < $workshop->nelements; $i++) {
+                        unset($element);
+                        $element->workshopid = $workshop->id;
+                        $element->assessmentid = $assessment->id;
+                        $element->elementno = $i;
+                        $element->feedback = '';
+                        $element->grade = 1;
+                        if (!$element->id = insert_record("workshop_grades", $element)) {
+                            error("Could not insert workshop grade!");
+                        }
+                    }
+                    // now set the adjustment
+                    unset($element);
+                    $i = $workshop->nelements;
+                    $element->workshopid = $workshop->id;
+                    $element->assessmentid = $assessment->id;
+                    $element->elementno = $i;
+                    $element->grade = 0;
+                    if (!$element->id = insert_record("workshop_grades", $element)) {
+                        error("Could not insert workshop grade!");
+                    }
+                }
+            }
+        }
+        
+        print_heading_with_help(get_string("assessthissubmission", "workshop"), "grading", "workshop");
+        
+        // show assessment and allow changes
+        workshop_print_assessment($workshop, $assessment, true, $allowcomments, $redirect);
+        
+        print_heading("<a target=\"{$CFG->framename}\" href=\"$redirect\">".get_string("cancel")."</a>");
+        print_footer($course);
+        exit;
+    }
+    
+    /// print bottom frame with the submission
+    
+    print_header();
+    $title = '"'.$submission->title.'" ';
+    if (isteacher($course->id)) {
+        $title .= ' '.get_string('by', 'workshop').' '.workshop_fullname($submission->userid, $course->id);
+    }
+    print_heading($title);
+    workshop_print_submission($workshop, $submission);
+    
+    if (isteacher($course->id)) {
+        echo '<br /><center><b>'.get_string('assessments', 'workshop').': </b><br />';
+        echo workshop_print_submission_assessments($workshop, $submission, "all");
+        echo '</center>';
+    }
+            
+    
+    print_footer();
+?>
+
index a912aed..dc9546f 100644 (file)
@@ -6,8 +6,8 @@
 <form name="gradingform" action="assessments.php" method="post">
   <input type="hidden" name="action" value="updategrading" />
   <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-  <input type="hidden" name="stype" value="<?php echo $_GET['stype'] ?>" />
-  <input type="hidden" name="aid" value="<?php echo $_GET['aid'] ?>" />
+  <input type="hidden" name="redirect" value="<?php echo $redirect ?>" />
+  <input type="hidden" name="aid" value="<?php echo $aid ?>" />
   <center>
     <table cellpadding="5" border="1">
       <tr valign="top">
@@ -20,8 +20,7 @@
         <td align="right">
           <b><?php print_string("gradeforstudentsassessment", "workshop") ?></td>
         <td>
-          <input type="text" name="gradinggrade" size="3" value="<?php p($assessment->gradinggrade) ?>" />
-          /<?php echo $workshop->gradinggrade; ?>
+          <input type="text" name="gradinggrade" size="3" value="<?php p($assessment->gradinggrade) ?>" />%
         </td>
       </tr>
     </table>
index bcae007..c12f706 100644 (file)
@@ -5,11 +5,10 @@
 
     addcomment
     addstockcomment
-    adminconfirmdelete
-    admindelete
+    confirmdelete
+    delete
     adminlist
     agreeassessment
-    assesssubmission
     displaygradingform
     editcomment
     editelements (teachers only)
@@ -24,9 +23,6 @@
     updateassessment
     updatecomment
     updategrading
-    userconfirmdelete
-    userdelete
-    viewassessment
 
 ************************************************/
 
     require("lib.php"); 
     require("locallib.php");
 
-    require_variable($id);    // Course Module ID
+    optional_variable($id, '');    // Course Module ID
+    optional_variable($wid, '');    // Workshop ID
 
     // get some useful stuff...
-    if (! $cm = get_record("course_modules", "id", $id)) {
-        error("Course Module ID was incorrect");
+    if ($id) {
+        if (! $cm = get_record("course_modules", "id", $id)) {
+            error("Course Module ID was incorrect");
+        }
+        if (! $workshop = get_record("workshop", "id", $cm->instance)) {
+            error("Course module is incorrect");
+        }
+    } else if ($wid) {
+        if (! $workshop = get_record("workshop", "id", $wid)) {
+            error("Workshop id is incorrect");
+        }
+        if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
+            error("No coursemodule found");
+        }
+    } else {
+        error("No id given");
     }
     if (! $course = get_record("course", "id", $cm->course)) {
         error("Course is misconfigured");
     }
-    if (! $workshop = get_record("workshop", "id", $cm->instance)) {
-        error("Course module is incorrect");
-    }
 
     require_login($course->id);
     
         // get assessment record
         if (!$assessmentid = $_REQUEST['aid']) { // comes from link or hidden form variable
             error("Assessment id not given");
-            }
+        }
         $assessment = get_record("workshop_assessments", "id", $assessmentid);
         if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
             error("Submission not found");
-            }
+        }
         ?>
         <form name="commentform" action="assessments.php" method="post">
         <input type="hidden" name="action" value="insertcomment" />
         echo "</center></form>\n";
         echo "<center><b>".get_string("assessment", "workshop"). "</b></center>\n";
         workshop_print_assessment($workshop, $assessment);
-        }
-
+    }
 
 
     /*************** add stock comment (by teacher ) ***************************/
         // redisplay form, going back to original returnto address
         workshop_print_assessment($workshop, $assessment, true, true, $form->returnto);
         
-        // add_to_log($course->id, "workshop", "assess", "assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id", "$assessment->id", "$cm->id");
+        // add_to_log($course->id, "workshop", "assess", "viewassessment.php?id=$cm->id&amp;aid=$assessment->id", "$assessment->id", "$cm->id");
         
     }
 
 
-    /******************* admin confirm delete ************************************/
-    elseif ($action == 'adminconfirmdelete' ) {
+    /******************* confirm delete ************************************/
+    elseif ($action == 'confirmdelete' ) {
 
-        if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
-            }
         if (empty($_GET['aid'])) {
-            error("Admin confirm delete: assessment id missing");
+            error("Confirm delete: assessment id missing");
             }
             
         notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("assessment", "workshop")), 
-             "assessments.php?action=admindelete&amp;id=$cm->id&amp;aid=$_GET[aid]", "submissions.php?action=adminlist&amp;id=$cm->id");
+             "assessments.php?action=delete&amp;id=$cm->id&amp;aid=$_GET[aid]", "submissions.php?action=adminlist&amp;id=$cm->id");
         }
     
 
-    /******************* admin delete ************************************/
-    elseif ($action == 'admindelete' ) {
+    /******************* delete ************************************/
+    elseif ($action == 'delete' ) {
 
-        if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
-            }
         if (empty($_GET['aid'])) {
-            error("Admin delete: submission id missing");
+            error("Delete: submission id missing");
             }
             
         print_string("deleting", "workshop");
         // ...now delete the assessment...
         delete_records("workshop_assessments", "id", $_GET['aid']);
         
-        print_continue("submissions.php?id=$cm->id&amp;action=adminlist");
+        print_continue("view.php?id=$cm->id");
         }
     
 
         set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id);
         echo "<centre><b>".get_string("savedok", "workshop")."</b></center><br />\n";
             
-        add_to_log($course->id, "workshop", "agree", "assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id", "$assessment->id");
+        add_to_log($course->id, "workshop", "agree", "viewassessment.php?id=$cm->id&amp;aid=$assessment->id", "$assessment->id");
         print_continue("view.php?id=$cm->id");
         }
 
 
 
-    /*************** Assess submission (by teacher or student) ***************************/
-    elseif ($action == 'assesssubmission') {
-
-        require_variable($sid);
-        
-        optional_variable($allowcomments);
-        if (!isset($allowcomments)) {
-            $allowcomments = false;
-            }
-    
-        if (! $submission = get_record("workshop_submissions", "id", $sid)) {
-            error("Assess submission is misconfigured - no submission record!");
-            }
-        
-        // there can be an assessment record (for teacher submissions), if there isn't...
-        if (!$assessment = get_record("workshop_assessments", "submissionid", $submission->id, "userid", 
-                    $USER->id)) {
-            // if it's the teacher see if the user has done a self assessment if so copy it
-            if (isteacher($course->id) and  ($assessment = get_record("workshop_assessments", "submissionid", 
-                            $submission->id, "userid", $submission->userid))) {
-                $assessment = workshop_copy_assessment($assessment, $submission, true);
-                // need to set owner of assessment
-                set_field("workshop_assessments", "userid", $USER->id, "id", $assessment->id);
-                $assessment->resubmission = 0; // not set by workshop_copy_assessment
-                $assessment->timegraded = 0; // not set by workshop_copy_assessment
-                $assessment->timeagreed = 0; // not set by workshop_copy_assessment
-            } else {
-                $yearfromnow = time() + 365 * 86400;
-                // ...create one and set timecreated way in the future, this is reset when record is updated
-                $assessment->workshopid = $workshop->id;
-                $assessment->submissionid = $submission->id;
-                $assessment->userid = $USER->id;
-                $assessment->timecreated = $yearfromnow;
-                $assessment->grade = -1; // set impossible grade
-                $assessment->timegraded = 0;
-                $assessment->timeagreed = 0;
-                $assessment->resubmission = 0;
-                if (!$assessment->id = insert_record("workshop_assessments", $assessment)) {
-                    error("Could not insert workshop assessment!");
-                }
-                // if it's the teacher and the workshop is error banded set all the elements to Yes
-                if (isteacher($course->id) and ($workshop->gradingstrategy == 2)) {
-                    for ($i =0; $i < $workshop->nelements; $i++) {
-                        unset($element);
-                        $element->workshopid = $workshop->id;
-                        $element->assessmentid = $assessment->id;
-                        $element->elementno = $i;
-                        $element->feedback = '';
-                        $element->grade = 1;
-                        if (!$element->id = insert_record("workshop_grades", $element)) {
-                            error("Could not insert workshop grade!");
-                        }
-                    }
-                    // now set the adjustment
-                    unset($element);
-                    $i = $workshop->nelements;
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = $i;
-                    $element->grade = 0;
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
-                    }
-                }
-            }
-        }
-        
-        print_heading_with_help(get_string("assessthissubmission", "workshop"), "grading", "workshop");
-        
-        // show assessment and allow changes
-        workshop_print_assessment($workshop, $assessment, true, $allowcomments, $_SERVER["HTTP_REFERER"]);
-    }
-
-
     /*************** display grading form (viewed by student) *********************************/
     elseif ($action == 'displaygradingform') {
 
             
         add_to_log($course->id, "workshop", "comment", "view.php?id=$cm->id", "$comment->id");
 
-        print_continue("assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id");
+        print_continue("viewassessment.php?id=$cm->id&amp;aid=$assessment->id");
         }
 
 
         }
         echo "<pre>";
         workshop_grade_assessments($workshop);
+        echo '</pre>';
         print_continue("submissions.php?id=$cm->id&action=adminlist");
     }
     
         // redisplay form, going back to original returnto address
         workshop_print_assessment($workshop, $assessment, true, true, $form->returnto);
         
-        // add_to_log($course->id, "workshop", "assess", "assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id", "$assessment->id", "$cm->id");
+        // add_to_log($course->id, "workshop", "assess", "viewassessment.php?id=$cm->id&amp;aid=$assessment->id", "$assessment->id", "$cm->id");
         
     }
 
         
         // set grade...
         set_field("workshop_assessments", "grade", $grade, "id", $assessment->id);
-        // ...and clear the timegraded but set the graddinggrade to maximum, may to reduced subsequently...
+        // ...and clear the timegraded but set the graddinggrade to maximum, may be reduced subsequently...
         set_field("workshop_assessments", "timegraded", 0, "id", $assessment->id);
         set_field("workshop_assessments", "gradinggrade", 100, "id", $assessment->id);
         // ...and the resubmission flag
         set_field("workshop_assessments", "resubmission", 0, "id", $assessment->id);
 
         // if there's examples or peer assessments clear the counter in the submission so that
-        // the cron job will regrade this assessment (and the other assessments fo the submission)
+        // all assessments for this submission will be regraded
         if ($workshop->ntassessments or $workshop->nsassessments) {
             set_field("workshop_submissions", "nassessments", 0, "id", $submission->id);
+            workshop_grade_assessments($workshop);
         } else { // it could be self assessment....
             // now see if there's a corresponding assessment so that the gradinggrade can be set
             if (isteacher($course->id)) {
         }
             
         add_to_log($course->id, "workshop", "assess",
-                "assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id", "$assessment->id", "$cm->id");
+                "viewassessment.php?id=$cm->id&amp;aid=$assessment->id", "$assessment->id", "$cm->id");
         
         // set up return address
         if (!$returnto = $form->returnto) {
             echo "<centre><b>".get_string("savedok", "workshop")."</b></center><br />\n";
             
             add_to_log($course->id, "workshop", "comment", 
-                    "assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id", "$comment->id");
+                    "viewassessment.php?id=$cm->id&amp;aid=$assessment->id", "$comment->id");
         }
 
-        print_continue("assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id");
+        print_continue("viewassessment.php?id=$cm->id&amp;aid=$assessment->id");
     }
 
 
             echo "<centre><b>".get_string("savedok", "workshop")."</b></centre><br />\n";
             
             add_to_log($course->id, "workshop", "grade", 
-                 "assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id", "$assessment->id", "$cm->id");
+                 "viewassessment.php?id=$cm->id&amp;aid=$assessment->id", "$assessment->id", "$cm->id");
         }
-        switch ($form->stype) {
-            case "student" : 
-                redirect("assessments.php?action=listungradedstudentsubmissions&amp;id=$cm->id");
-                break;
-            case "teacher" : 
-                redirect("assessments.php?action=listungradedteachersubmissions&amp;id=$cm->id");
-                break;
-        }
-    }
-
-
-    /****************** user confirm delete ************************************/
-    elseif ($action == 'userconfirmdelete' ) {
-
-        if (empty($_GET['aid'])) {
-            error("User confirm delete: assessment id missing");
-        }
-            
-        notice_yesno(get_string("confirmdeletionofthisitem","workshop", 
-                get_string("assessment", "workshop")), 
-                "assessments.php?action=userdelete&amp;id=$cm->id&amp;aid=$_GET[aid]", "view.php?id=$cm->id");
-    }
-    
-
-    /****************** user delete ************************************/
-    elseif ($action == 'userdelete' ) {
-
-        if (empty($_GET['aid'])) {
-            error("User delete: assessment id missing");
-        }
-            
-        print_string("deleting", "workshop");
-        // first delete all the associated records...
-        delete_records("workshop_comments", "assessmentid", $_GET['aid']);
-        delete_records("workshop_grades", "assessmentid", $_GET['aid']);
-        // ...now delete the assessment...
-        delete_records("workshop_assessments", "id", $_GET['aid']);
-        
-        print_continue("view.php?id=$cm->id");
+        redirect($form->redirect);
     }
     
 
         print_continue("submissions.php?action=listallsubmissions&amp;id=$cm->id");
     }
 
-
-    /****************** view assessment *****************************/
-    elseif ($action == 'viewassessment') {
-
-        optional_variable($allowcomments);
-        if (!isset($allowcomments)) {
-            $allowcomments = false;
-        }
-    
-        // get the assessment record
-        if (!$assessment = get_record("workshop_assessments", "id", $_GET['aid'])) {
-            error("Assessment record not found");
-        }       
-
-        // show assessment but don't allow changes
-        workshop_print_assessment($workshop, $assessment, false, $allowcomments);
-        
-        if (isteacher($course->id) and !isteacher($course->id, $assessment->userid)) {
-            print_heading('<a href="assessments.php?action=gradeassessment&amp;id='.$cm->id.'&amp;stype=student&amp;aid='.$assessment->id.'">'.
-                get_string('assessthisassessment', 'workshop').'</a>');
-        }
-        
-        print_continue("view.php?id=$cm->id");
-    }
-
-
     /*************** no man's land **************************************/
     else {
         error("Fatal Error: Unknown Action: ".$action."\n");
index 8f478a0..5b5fb61 100644 (file)
@@ -894,6 +894,7 @@ function workshop_update_instance($workshop) {
 // Given an object containing all the necessary data, 
 // (defined by the form in mod.html) this function 
 // will update an existing instance with new data.
+    global $CFG;
 
     $workshop->timemodified = time();
 
@@ -971,6 +972,12 @@ function workshop_update_instance($workshop) {
         }
     }
 
+    if (time() > $workshop->assessmentstart) {
+        // regrade all the submissions...
+        set_field("workshop_submissions", "nassessments", 0, "workshopid", $workshop->id);
+        workshop_grade_assessments($workshop);
+    }
+
     return $returnid;
 }
 
@@ -1314,21 +1321,21 @@ function workshop_get_assess_logs($course, $timestart) {
 //////////////////////////////////////////////////////////////////////////////////////
 function workshop_get_assessments($submission, $all = '', $order = '') {
     // Return assessments for this submission ordered oldest first, newest last
-    // new assessments made within the editing time are NOT returned unless the
-    // second argument is set to ALL
-    global $CFG;
-    
+    // new assessments made within the editing time are NOT returned unless they
+    // belong to the user or the second argument is set to ALL
+    global $CFG, $USER;
 
+    $timenow = time();
     if (!$order) {
         $order = "timecreated DESC";
     }
     if ($all != 'ALL') {
-        $timenow = time();
         return get_records_select("workshop_assessments", "(submissionid = $submission->id) AND 
-            (timecreated < $timenow - $CFG->maxeditingtime)", $order);
+            ((timecreated < $timenow - $CFG->maxeditingtime) or 
+                ((timecreated < $timenow) AND (userid = $USER->id)))", $order);
     } else {
-        return get_records_select("workshop_assessments", "submissionid = $submission->id", 
-                $order);
+        return get_records_select("workshop_assessments", "submissionid = $submission->id AND 
+            (timecreated < $timenow)", $order);
     }
 }
 
@@ -1511,7 +1518,7 @@ function workshop_get_user_submissions($workshop, $user) {
 
 
 //////////////////////////////////////////////////////////////////////////////////////
-function workshop_grade_assessments($workshop) {
+function workshop_grade_assessments($workshop, $verbose=false) {
     global $WORKSHOP_EWEIGHTS;
     
     // timeout after 10 minutes
@@ -1598,8 +1605,10 @@ function workshop_grade_assessments($workshop) {
                     $total += $n; // weighted total
                 }
             }
-            echo "<p align=\"center\">".get_string("numberofsubmissions", "workshop", count($num))."<br />\n";
-            echo get_string("numberofassessmentsweighted", "workshop", $total)."</p>\n";
+            if ($verbose) {
+                echo "<p align=\"center\">".get_string("numberofsubmissions", "workshop", count($num))."<br />\n";
+                echo get_string("numberofassessmentsweighted", "workshop", $total)."</p>\n";
+            }
 
             // now get an estimate of the standard deviation of each element in the assessment
             // this is just a rough measure, all assessments are included and teacher's assesments are not weighted
@@ -1629,9 +1638,11 @@ function workshop_grade_assessments($workshop) {
                 set_field("workshop_elements", "stddev", $sd[$i], "workshopid", $workshop->id, "elementno", $i);
                 set_field("workshop_elements", "totalassessments", $totalassessments, "workshopid", $workshop->id,
                         "elementno", $i);
-                echo get_string("standarddeviationofelement", "workshop", $i+1)." $sd[$i]<br />";
-                if ($sd[$i] <= $minvar) {
-                    print_string("standarddeviationnote", "workshop")."<br />\n";
+                if ($verbose) {
+                    echo get_string("standarddeviationofelement", "workshop", $i+1)." $sd[$i]<br />";
+                    if ($sd[$i] <= $minvar) {
+                        print_string("standarddeviationnote", "workshop")."<br />\n";
+                    }
                 }
             }
         } 
@@ -1656,7 +1667,7 @@ function workshop_grade_assessments($workshop) {
                 // ...if there are three or more assessments calculate the variance of each assessment.
                 // Use the variance to find the "best" assessment. (When there is only one or two assessments they 
                 // are not altered by this routine.)
-                echo "Processing submission $submission->id ($nassessments asessments)...\n"; 
+                if ($verbose) echo "Processing submission $submission->id ($nassessments asessments)...\n"; 
                 if ($nassessments > 2) {
                     $num = 0; // weighted number of assessments
                     for ($i = 0; $i < $workshop->nelements; $i++) {
@@ -1694,7 +1705,7 @@ function workshop_grade_assessments($workshop) {
                         if ($num) { // could all the assessments be duff? 
                             for ($i = 0; $i < $workshop->nelements; $i++) {
                                 $mean[$i] = $sum[$i] / $num;
-                                echo "Submission: $submission->id; Element: $i; Mean: {$mean[$i]}\n";
+                                if ($verbose) echo "Submission: $submission->id; Element: $i; Mean: {$mean[$i]}\n";
                             }
                         } else {
                             continue; // move to the next submission
@@ -1729,7 +1740,7 @@ function workshop_grade_assessments($workshop) {
                         if (!$best = get_record("workshop_assessments", "id", $bestassessmentid)) {
                             error("Workshop grade assessments: cannot find best assessment");
                         }
-                        echo "Best assessment is $bestassessmentid;\n";
+                        if ($verbose) echo "Best assessment is $bestassessmentid;\n";
                         foreach ($assessments as $assessment) {
                             // don't overwrite teacher's grade
                             if ($assessment->teachergraded) {
@@ -1825,4 +1836,15 @@ function workshop_submission_grade($workshop, $submission) {
     return number_format($grade * $workshop->grade / 100, 1);
 }
 
+
+/////////////////////////////////////////////////////////////////////////////
+function workshop_fullname($userid, $courseid) {
+    global $CFG;
+    if (!$user = get_record('user', 'id', $userid)) {
+        return '';
+    }
+    return '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$courseid.'">'.
+        fullname($user).'</a>';
+}
+
 ?>
index 13a0d19..900c8ba 100644 (file)
@@ -751,7 +751,7 @@ function workshop_list_all_submissions($workshop, $user) {
                     AND userid = $user->id")) {
                 $curtime = time();
                 if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
-                    $action = "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id\">"
+                    $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id\">"
                         .get_string("view", "workshop")."</a>";
                     // has teacher graded user's assessment?
                     if ($assessment->timegraded) {
@@ -761,12 +761,12 @@ function workshop_list_all_submissions($workshop, $user) {
                         }
                     }
                 else { // there's still time left to edit...
-                    $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action = "<a href=\"assess.php?sid=$submission->id\">".
                         get_string("edit", "workshop")."</a>";
                     }
                 }
             else { // user has not graded this submission
-                $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                $action = "<a href=\"assess.php?sid=$submission->id\">".
                     get_string("assess", "workshop")."</a>";
                 }
             $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, 
@@ -798,7 +798,7 @@ function workshop_list_all_submissions($workshop, $user) {
                     AND userid = $user->id")) {
                 $curtime = time();
                 if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
-                    $action = "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id\">".
+                    $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id\">".
                         get_string("view", "workshop")."</a>";
                     // has teacher graded on user's assessment?
                     if ($assessment->timegraded) {
@@ -813,12 +813,12 @@ function workshop_list_all_submissions($workshop, $user) {
                         }
                     }
                 else { // there's still time left to edit...
-                    $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action = "<a href=\"assess.php?sid=$submission->id\">".
                         get_string("edit", "workshop")."</a>";
                     }
                 }
             else { // user has not assessed this submission
-                $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                $action = "<a href=\"assess.php?sid=$submission->id\">".
                     get_string("assess", "workshop")."</a>";
                 }
             $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, 
@@ -849,11 +849,11 @@ function workshop_list_all_ungraded_assessments($workshop) {
         foreach ($assessments as $assessment) {
             if (!isteacher($workshop->course, $assessment->userid)) {
                 if (($timenow - $assessment->timegraded) < $CFG->maxeditingtime) {
-                    $action = "<a href=\"assessments.php?action=gradeassessment&amp;id=$cm->id&amp;aid=$assessment->id\">".
+                    $action = "<a href=\"viewassessment.php?&amp;id=$cm->id&amp;aid=$assessment->id\">".
                         get_string("edit", "workshop")."</a>";
                     }
                 else {
-                    $action = "<a href=\"assessments.php?action=gradeassessment&amp;id=$cm->id&amp;aid=$assessment->id\">".
+                    $action = "<a href=\"viewassessment.php?&amp;id=$cm->id&amp;aid=$assessment->id\">".
                         get_string("gradeassessment", "workshop")."</a>";
                     }
                 $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
@@ -899,22 +899,22 @@ function workshop_list_assessed_submissions($workshop, $user) {
             if ($assessment->timecreated < ($timenow - $CFG->maxeditingtime)) { // it's cold
                 if ($workshop->agreeassessments) {
                     if (!$assessment->timeagreed) {
-                        $action = "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id&".
+                        $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id&".
                             "allowcomments=$workshop->agreeassessments\">".
                             get_string("view", "workshop")."</a>";
-                        $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                        $action .= " | <a href=\"assess.php?sid=$submission->id\">".
                             get_string("reassess", "workshop")."</a>";
                     } else {
-                        $action = "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id&".
+                        $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id&".
                             "allowcomments=false\">".get_string("view", "workshop")."</a>";
                     }
                 } else {
                     // if it been graded allow student to re-assess, except if it's a self assessment
                     if ($assessment->timegraded and !($USER->id == $assessment->userid)) {
-                        $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                        $action = "<a href=\"assess.php?sid=$submission->id\">".
                             get_string("reassess", "workshop")."</a>";
                     } else {
-                        $action = "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id\">".
+                        $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id\">".
                             get_string("view", "workshop")."</a>";
                     }
                 }          
@@ -988,7 +988,7 @@ function workshop_list_peer_assessments($workshop, $user) {
                             ($assessment->userid != $user->id)) { 
                         $timenow = time();
                         if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
-                            $action = "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id&".
+                            $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id&".
                                 "allowcomments=$workshop->agreeassessments\">".
                                 get_string("view", "workshop")."</a>";
                             $comment = get_string("assessedon", "workshop", userdate($assessment->timecreated));
@@ -1059,13 +1059,13 @@ function workshop_list_self_assessments($workshop, $user) {
             $comment = get_string("ownwork", "workshop"); // just in case they don't know!
             if (!$assessment = get_record_select("workshop_assessments", "submissionid = $submission->id AND
                     userid = $user->id")) {
-                $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                $action = "<a href=\"assess.php?sid=$submission->id\">".
                     get_string("assess", "workshop")."</a>";
                 $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
             } else {
                 // may still be warm
                 if (($assessment->timecreated + $CFG->maxeditingtime) > $timenow) {
-                    $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action = "<a href=\"assess.php?sid=$submission->id\">".
                         get_string("reassess", "workshop")."</a>";
                     $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
                 }
@@ -1187,12 +1187,12 @@ function workshop_list_student_submissions($workshop, $user) {
                 // just assessed but still editable [warm]; and "static" (may or may not have been graded by teacher, that
                 // is shown in the comment) [cold] 
                 if ($assessment->timecreated > $timenow) { // user needs to assess this submission
-                    $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action = "<a href=\"assess.php?sid=$submission->id\">".
                         get_string("assess", "workshop")."</a>";
                     $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
                     }
                 elseif ($assessment->timecreated > ($timenow - $CFG->maxeditingtime)) { // there's still time left to edit...
-                    $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action = "<a href=\"assess.php?sid=$submission->id\">".
                         get_string("edit", "workshop")."</a>";
                     $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
                     }
@@ -1251,20 +1251,20 @@ function workshop_list_submissions_for_admin($workshop, $order) {
                             AND userid = $USER->id")) {
                     $curtime = time();
                 if ($assessment->timecreated > $curtime) { // it's a "hanging" assessment 
-                    $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action .= " | <a href=\"assess.php?sid=$submission->id\">".
                         get_string("assess", "workshop")."</a>";
                 }
                 elseif (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
-                    $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">"
+                    $action .= " | <a href=\"assess.php?sid=$submission->id\">"
                         .get_string("reassess", "workshop")."</a>";
                 }
                 else { // there's still time left to edit...
-                    $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action .= " | <a href=\"assess.php?sid=$submission->id\">".
                         get_string("edit", "workshop")."</a>";
                 }
             }
                 else { // user has not graded this submission
-                    $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action .= " | <a href=\"assess.php?sid=$submission->id\">".
                         get_string("assess", "workshop")."</a>";
                 }
                 if ($assessments = workshop_get_assessments($submission)) {
@@ -1272,7 +1272,7 @@ function workshop_list_submissions_for_admin($workshop, $order) {
                         get_string("listassessments", "workshop")."</a>";
                 }
                 if (isteacheredit($course->id)) {
-                    $action .= " | <a href=\"submissions.php?action=adminconfirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action .= " | <a href=\"submissions.php?action=confirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
                         get_string("delete", "workshop")."</a>";
                 }
                 $table->data[] = array("<a href=\"submissions.php?action=editsubmission&amp;id=$cm->id&amp;sid=$submission->id\">$submission->title</a>", $course->teacher, $action);
@@ -1306,7 +1306,7 @@ function workshop_list_submissions_for_admin($workshop, $order) {
                 $title ='';
                 foreach ($assessments as $assessment) {
                     if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-                        error("Workshop_list_submissions_for_admin: Submission record not found!");
+                        error("Workshop_list_submissions_for_admin: Submission $assessment->submissionid not found!");
                     }
                     $title .= $submission->title;
                     if ($workshop->agreeassessments and !$assessment->timeagreed and 
@@ -1421,16 +1421,16 @@ function workshop_list_submissions_for_admin($workshop, $order) {
                     AND userid = $USER->id")) {
                 $curtime = time();
                 if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
-                    $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action .= " | <a href=\"assess.php?sid=$submission->id\">".
                         get_string("reassess", "workshop")."</a>";
                 }
                 else { // there's still time left to edit...
-                    $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action .= " | <a href=\"assess.php?sid=$submission->id\">".
                         get_string("edit", "workshop")."</a>";
                 }
             }
             else { // user has not assessed this submission
-                $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                $action .= " | <a href=\"assess.php?sid=$submission->id\">".
                     get_string("assess", "workshop")."</a>";
             }
             if ($nassessments = workshop_count_assessments($submission)) {
@@ -1441,7 +1441,7 @@ function workshop_list_submissions_for_admin($workshop, $order) {
                 $action .= " | <a href=\"submissions.php?action=adminlateflag&amp;id=$cm->id&amp;sid=$submission->id\">".
                     get_string("clearlateflag", "workshop")."</a>";
             }
-            $action .= " | <a href=\"submissions.php?action=adminconfirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
+            $action .= " | <a href=\"submissions.php?action=confirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
                 get_string("delete", "workshop")."</a>";
             $nsubmissions++;
             $table->data[] = array("$user->firstname $user->lastname", $submission->title.
@@ -1482,7 +1482,7 @@ function workshop_list_teacher_assessments_by_user($workshop, $user) {
             if ($assessments = workshop_get_assessments($submission)) {
                 foreach ($assessments as $assessment) {
                     if (isteacher($workshop->course, $assessment->userid)) { // assessments by teachers only
-                        $action = "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id\">".
+                        $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id\">".
                             get_string("view", "workshop")."</a>";
                         // has teacher commented on teacher's assessment? shouldn't happen but leave test in
                         if ($assessment->timegraded and ($timenow - $assessment->timegraded > $CFG->maxeditingtime)) {
@@ -1579,16 +1579,16 @@ function workshop_list_teacher_submissions($workshop, $user) {
                 // user assessment has two states: record created but not assessed (date created in the future); 
                 // assessed but always available for re-assessment 
                 if ($assessment->timecreated > $timenow) { // user needs to assess this submission
-                    $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action = "<a href=\"assess.php?sid=$submission->id\">".
                         get_string("assess", "workshop")."</a>";
                 }
                 elseif ($assessment->timegraded and ($assessment->gradinggrade < $reassessthreshold)) { 
                     // allow student to improve on their assessment once it's been graded and is below threshold
-                    $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action = "<a href=\"assess.php?sid=$submission->id\">".
                         get_string("reassess", "workshop")."</a>";
                 } else {
                     // allow student  just to see their assessment if it hasn't been graded (or above threshold)
-                    $action = "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id\">".
+                    $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id\">".
                         get_string("view", "workshop")."</a>";
                 }
                 // see if the assessment is graded
@@ -1657,7 +1657,7 @@ function workshop_list_unassessed_student_submissions($workshop, $user) {
                 if (($timenow - $assessment->timecreated < $CFG->maxeditingtime)) {
                     // last chance salon
                     $submissionowner = get_record("user", "id", $submission->userid);
-                    $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action = "<a href=\"assess.php?sid=$submission->id\">".
                         get_string("edit", "workshop")."</a>";
                     $table->data[] = array(workshop_print_submission_title($workshop, $submission), 
                         fullname($submissionowner), $timegap, $action, $comment);
@@ -1667,7 +1667,7 @@ function workshop_list_unassessed_student_submissions($workshop, $user) {
                 // no assessment by this user, if no other teacher has assessed submission then list it
                 if (!workshop_count_teacher_assessments($course->id, $submission)) {
                     $submissionowner = get_record("user", "id", $submission->userid);
-                    $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action = "<a href=\"assess.php?sid=$submission->id\">".
                         get_string("assess", "workshop")."</a>";
                     $table->data[] = array(workshop_print_submission_title($workshop, $submission), 
                         fullname($submissionowner), $timegap, $action, $comment);
@@ -1706,13 +1706,13 @@ function workshop_list_unassessed_teacher_submissions($workshop, $user) {
                 $timenow = time();
                 if (($timenow - $assessment->timecreated < $CFG->maxeditingtime)) {
                     // last chance salon
-                    $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    $action = "<a href=\"assess.php?sid=$submission->id\">".
                         get_string("edit", "workshop")."</a>";
                     $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
                     }
                 }
             else { // no assessment
-                $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                $action = "<a href=\"assess.php?sid=$submission->id\">".
                     get_string("assess", "workshop")."</a>";
                 $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
                 }
@@ -1753,11 +1753,11 @@ function workshop_list_ungraded_assessments($workshop, $stype) {
         foreach ($assessments as $assessment) {
             if (!isteacher($workshop->course, $assessment->userid)) { // don't let teacher grade their own assessments
                 if (($timenow - $assessment->timegraded) < $CFG->maxeditingtime) {
-                    $action = "<a href=\"assessments.php?action=gradeassessment&amp;id=$cm->id&amp;stype=$stype&amp;aid=$assessment->id\">".
+                    $action = "<a href=\"viewassessment.php?&amp;id=$cm->id&amp;stype=$stype&amp;aid=$assessment->id\">".
                         get_string("edit", "workshop")."</a>";
                     }
                 else {
-                    $action = "<a href=\"assessments.php?action=gradeassessment&amp;id=$cm->id&amp;stype=$stype&amp;aid=$assessment->id\">".
+                    $action = "<a href=\"viewassessment.php?&amp;id=$cm->id&amp;stype=$stype&amp;aid=$assessment->id\">".
                         get_string("grade", "workshop")."</a>";
                     }
                 $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
@@ -1796,7 +1796,7 @@ function workshop_list_user_submissions($workshop, $user) {
             if (($submission->timecreated > ($timenow - $CFG->maxeditingtime)) or ($workshop->assessmentstart > time())) {
                 $action = "<a href=\"submissions.php?action=editsubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
                     get_string("edit", "workshop")."</a> | ".
-                    "<a href=\"submissions.php?action=userconfirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
+                    "<a href=\"submissions.php?action=confirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
                     get_string("delete", "workshop")."</a>";
             }
             else {
@@ -1856,15 +1856,16 @@ function workshop_print_assessment($workshop, $assessment = false, $allowchanges
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
         error("Course Module ID was incorrect");
     }
-    
-    if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-        error ("Workshop_print_assessment: Submission record not found");
+    if ($assessment) {
+        if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
+            error ("Workshop_print_assessment: Submission record not found");
+        }
+        
+        print_heading(get_string('assessmentof', 'workshop', 
+            "<a href=\"submissions.php?id=$cm->id&action=showsubmission&sid=$submission->id\" target=\"submission\">".
+            $submission->title.'</a>'));
     }
     
-    print_heading(get_string('assessmentof', 'workshop', 
-        "<a href=\"submissions.php?id=$cm->id&action=showsubmission&sid=$submission->id\" target=\"submission\">".
-        $submission->title.'</a>'));
-    
     $timenow = time();
 
     // reset the internal flags
@@ -1966,7 +1967,7 @@ function workshop_print_assessment($workshop, $assessment = false, $allowchanges
     } else {
         print_string('assessment', 'workshop');
     }
-    echo "</b></center></td>\n";
+    echo '</b><br />'.userdate($assessment->timecreated)."</center></td>\n";
     echo "</tr>\n";
     
     // only show the grade if grading strategy > 0 and the grade is positive
@@ -2549,12 +2550,11 @@ function workshop_print_assessments_by_user_for_admin($workshop, $user) {
 
     if ($assessments = workshop_get_user_assessments_done($workshop, $user)) {
         foreach ($assessments as $assessment) {
-            echo "<p><center><b>".get_string("assessmentby", "workshop", fullname($user))."</b></center></p>\n";
             workshop_print_assessment($workshop, $assessment);
             echo "<p align=\"right\">".
-                '<a href="assessments.php?action=gradeassessment&amp;id='.$cm->id.'&amp;stype=student&amp;aid='.$assessment->id.'">'.
+                '<a href="viewassessment.php?&amp;id='.$cm->id.'&amp;stype=student&amp;aid='.$assessment->id.'">'.
                 get_string('assessthisassessment', 'workshop').'</a> | '.
-                "<a href=\"assessments.php?action=adminconfirmdelete&amp;id=$cm->id&amp;aid=$assessment->id\">".
+                "<a href=\"assessments.php?action=confirmdelete&amp;id=$cm->id&amp;aid=$assessment->id\">".
                 get_string("delete", "workshop")."</a></p><hr />\n";
             }
         }
@@ -2575,7 +2575,7 @@ function workshop_print_assessments_for_admin($workshop, $submission) {
                 }
             echo "<p><center><b>".get_string("assessmentby", "workshop", fullname($user))."</b></center></p>\n";
             workshop_print_assessment($workshop, $assessment);
-            echo "<p align=\"right\"><a href=\"assessments.php?action=adminconfirmdelete&amp;id=$cm->id&amp;aid=$assessment->id\">".
+            echo "<p align=\"right\"><a href=\"assessments.php?action=confirmdelete&amp;id=$cm->id&amp;aid=$assessment->id\">".
                 get_string("delete", "workshop")."</a></p><hr />\n";
             }
         }
@@ -2584,6 +2584,7 @@ function workshop_print_assessments_for_admin($workshop, $submission) {
 
 //////////////////////////////////////////////////////////////////////////////////////
 function workshop_print_assignment_info($workshop) {
+    global $CFG;
 
     if (! $course = get_record("course", "id", $workshop->course)) {
         error("Course is misconfigured");
@@ -2616,13 +2617,20 @@ function workshop_print_assignment_info($workshop) {
     echo $string;
 
     $grade = $workshop->gradinggrade + $workshop->grade;
-    echo "<br /><b>".get_string("maximumgrade")."</b>: $grade<br />";
-    echo "<b>".get_string("detailsofassessment", "workshop")."</b>: 
-        <a href=\"assessments.php?id=$cm->id&amp;action=displaygradingform\">".
-        get_string("specimenassessmentform", "workshop")."</a><br />";
+    echo "<br /><b>".get_string("maximumgrade")."</b>: $grade  ";
+    // print link to specimen assessment form
+    echo "(<a href=\"assessments.php?id=$cm->id&amp;action=displaygradingform\">".
+        get_string("specimenassessmentform", "workshop")."</a>";
+    // print edit icon
+    if (isteacheredit($course->id) and $workshop->nelements) {
+        echo " <a href=\"assessments.php?id=$cm->id&action=editelements\">".
+             "<img src=\"$CFG->pixpath/t/edit.gif\" ".
+             'height="11" width="11" border="0" alt="'.get_string('amendassessmentelements', 'workshop').'"></a>';
+    }
+    echo ")<br />";
     print_simple_box_end();
     echo "<br />";
-    echo format_text($workshop->description, $workshop->format);
+    echo format_text($workshop->summary, $workshop->format);
     print_simple_box_end();
     echo "<br />";  
     }
@@ -2811,58 +2819,67 @@ function workshop_print_submission($workshop, $submission) {
 
 //////////////////////////////////////////////////////////////////////////////////////
 function workshop_print_submission_assessments($workshop, $submission, $type) {
-    global $USER;
+    global $USER, $CFG;
     // Returns the teacher or peer grade and a hyperlinked list of grades for this submission
-
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-            error("Course Module ID was incorrect");
-    }
  
     $str = '';
-    // get the cold assessments in grade order, highest first
+    // get the assessments in grade order, highest first
     if ($assessments = workshop_get_assessments($submission, "", "grade DESC")) {
-        switch ($type) {
-            case "teacher" :
-                // students can see teacher assessments only if the release date has passed
-                $timenow = time();
-                if (isteacher($workshop->course, $USER->id) or ($timenow > $workshop->releasegrades)) {
-                    foreach ($assessments as $assessment) {
-                        if (isteacher($workshop->course, $assessment->userid)) {
-                            $str .= "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id\">"
-                                 . "[".number_format($assessment->grade *$workshop->grade / 100, 0)."]</a> ";
+        if ($type == 'teacher' or $type == 'all') {
+            // students can see teacher assessments only if the release date has passed
+            $timenow = time();
+            if (isteacher($workshop->course, $USER->id) or ($timenow > $workshop->releasegrades)) {
+                foreach ($assessments as $assessment) {
+                    if (isteacher($workshop->course, $assessment->userid)) {
+                        if ($type == 'all') {
+                            $str .= workshop_fullname($assessment->userid, $workshop->course).': ';
                         }
+                        $str .= "<a href=\"viewassessment.php?aid=$assessment->id\">"
+                             . "[".number_format($assessment->grade *$workshop->grade / 100, 0)."]</a>";
+                        if (isteacher($workshop->course, $USER->id)) {
+                            $str .= ' <a title="'.get_string('reassess', 'workshop').
+                                "\" href=\"assess.php?sid=$submission->id\"><img src=\"$CFG->pixpath/t/edit.gif\" ".
+                                ' height="11" width="11" border="0" alt="'.get_string('reassess', 'workshop').'"></a>';
+                            $str .= ' <a title="'.get_string('delete', 'workshop').
+                                "\" href=\"assessments.php?action=confirmdelete&amp;wid=$workshop->id&amp;aid=$assessment->id\"><img src=\"$CFG->pixpath/t/delete.gif\" ".
+                                ' height="11" width="11" border="0" alt="'.get_string('delete', 'workshop').'"></a><br />';
+                       }
                     }
                 }
-                break;
-            case "student" : 
-                foreach ($assessments as $assessment) {
-                    if (isstudent($workshop->course, $assessment->userid)) {
-                        $str .= "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id\">";
-                        if ($workshop->agreeassessments and !$assessment->timeagreed and 
-                                isstudent($workshop->course, $submission->userid)) { // agreement on student work only
-                            $str .= "&lt;&lt;".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
-                                number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
-                                ")&gt;&gt;</a> ";
-                        } elseif ($assessment->timegraded) {
-                            if ($assessment->gradinggrade) {
-                                $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0);
-                                if ($assessment->teachergraded) {
-                                    $str .= " [".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
-                                    "]}</a> ";
-                                } else {
-                                    $str .= " (".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
-                                    ")}</a> ";
-                                }
+            }
+        }
+        if ($type == 'student' or $type == 'all') {
+            foreach ($assessments as $assessment) {
+                if (isstudent($workshop->course, $assessment->userid)) {
+                    if ($type == 'all') {
+                        $str .= workshop_fullname($assessment->userid, $workshop->course).': ';
+                    }
+                    $str .= "<a href=\"viewassessment.php?aid=$assessment->id\">";
+                    if ($workshop->agreeassessments and !$assessment->timeagreed and 
+                            isstudent($workshop->course, $submission->userid)) { // agreement on student work only
+                        $str .= "&lt;&lt;".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
+                            number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
+                            ")&gt;&gt;</a> ";
+                    } elseif ($assessment->timegraded) {
+                        if ($assessment->gradinggrade) {
+                            $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0);
+                            if ($assessment->teachergraded) {
+                                $str .= " [".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
+                                "]}</a> ";
                             } else {
-                                $str .= "&lt;".number_format($assessment->grade * $workshop->grade / 100, 0).
-                                    " (0)&gt;</a> ";
+                                $str .= " (".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
+                                ")}</a> ";
                             }
                         } else {
-                            $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0)."}</a> ";
+                            $str .= "&lt;".number_format($assessment->grade * $workshop->grade / 100, 0).
+                                " (0)&gt;</a> ";
                         }
+                    } else {
+                        $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0)."}</a> ";
                     }
+                    $str .= '<br />';
                 }
-                break;
+            }
         }
     }
     if (!$str) {
@@ -2883,7 +2900,7 @@ function workshop_print_submission_title($workshop, $submission) {
     if (!$submission->timecreated) { // a "no submission"
         return $submission->title;
     }
-    return "<a href=\"submissions.php?id=$cm->id&action=showsubmission&sid=$submission->id\">$submission->title</a>";
+    return "<a name=\"sid=$submission->id\" href=\"submissions.php?id=$cm->id&action=showsubmission&sid=$submission->id\">$submission->title</a>";
 }
 
 
@@ -2939,18 +2956,20 @@ function workshop_print_upload_form($workshop) {
 
 
 //////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_user_assessments($workshop, $user) {
+function workshop_print_user_assessments($workshop, $user, &$gradinggrade) {
     // Returns the number of assessments and a hyperlinked list of grading grades for the assessments made by this user
 
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
             error("Course Module ID was incorrect");
     }
+    $gradinggrade = 0;
+    $n = 0;
+    $str = '';
     if ($assessments = workshop_get_user_assessments_done($workshop, $user)) {
-        $n = count($assessments);
-        $str = "$n : ";
         foreach ($assessments as $assessment) {
-            $str .= "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id\">";
+            $gradinggrade += $assessment->gradinggrade;
+            $n++;
+            $str .= "<a href=\"viewassessment.php?aid=$assessment->id\">";
             if ($assessment->timegraded) {
                 if ($assessment->gradinggrade) {
                     $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0);
@@ -2965,11 +2984,16 @@ function workshop_print_user_assessments($workshop, $user) {
             } else {
                 $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0)." (-)}</a> ";
             }
+            $str .= '<br />';
         }
     }
     else {
         $str ="0";
     }
+    if ($n = max($n, $workshop->ntassessments + $workshop->nsassessments)) {
+        $gradinggrade = number_format($gradinggrade/$n * $workshop->gradinggrade / 100, 1);
+    }
+    
     return $str;
 }
 
index 001bfe3..b754f38 100644 (file)
@@ -3,19 +3,16 @@
 /*************************************************
     ACTIONS handled are:
 
-    dminamendtitle
-    adminconfirmdelete
-    admindelete
+    adminamendtitle
+    confirmdelete
+    delete
     adminlist
-    displayfinalgrades (teachers only)
     editsubmission
     listallsubmissions
     listforassessmentstudent
     listforassessmentteacher
     showsubmission
     updatesubmission
-    userconfirmdelete
-    userdelete
     
 
 ************************************************/
@@ -55,7 +52,7 @@
     optional_variable($action);
     if (empty($action)) {
         $action = "listallsubmissions";
-        }
+    }
 
 
 /******************* admin amend title ************************************/
 
         if (!isteacher($course->id)) {
             error("Only teachers can look at this page");
-            }
+        }
         if (empty($_GET['sid'])) {
             error("Admin Amend Title: submission id missing");
-            }
+        }
         
         $submission = get_record("workshop_submissions", "id", $_GET['sid']);
         print_heading(get_string("amendtitle", "workshop"));
@@ -87,8 +84,9 @@
         echo "  </td></tr></table>\n";
         echo "<input type=\"submit\" value=\"".get_string("amendtitle", "workshop")."\" />\n";
         echo "</center></form>\n";
-
-        }
+        
+        print_heading("<a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id#sid=$submission->id\">".get_string("cancel")."</a>");
+    }
     
 
     /******************* admin clear late (flag) ************************************/
         
         add_to_log($course->id, "workshop", "late flag cleared", "view.php?id=$cm->id", "submission $submission->id");
         
-        redirect("submissions.php?id=$cm->id&amp;action=adminlist");
+        redirect("view.php?id=$cm->id");
     }
     
 
-    /******************* admin confirm delete ************************************/
-    elseif ($action == 'adminconfirmdelete' ) {
+    /******************* confirm delete ************************************/
+    elseif ($action == 'confirmdelete' ) {
 
-        if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
-            }
         if (empty($_GET['sid'])) {
-            error("Admin confirm delete: submission id missing");
+            error("Confirm delete: submission id missing");
             }
-            
+        $sid = $_GET['sid'];
         notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("submission", "workshop")), 
-             "submissions.php?action=admindelete&amp;id=$cm->id&amp;sid=$_GET[sid]", "submissions.php?id=$cm->id&amp;action=adminlist");
+             "submissions.php?action=delete&amp;id=$cm->id&amp;sid=$sid", "view.php?id=$cm->id#sid=$sid");
         }
     
 
-    /******************* admin delete ************************************/
-    elseif ($action == 'admindelete' ) {
+    /******************* delete ************************************/
+    elseif ($action == 'delete' ) {
 
-        if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
-            }
         if (empty($_GET['sid'])) {
-            error("Admin delete: submission id missing");
-            }
+            error("Delete: submission id missing");
+        }
     
         if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) {
             error("Admin delete: can not get submission record");
-            }
+        }
+        
+        // students are only allowed to delete their own submission and only up to the deadline
+        if (!(isteacher($course->id) or 
+               (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend)
+                   and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) {
+            error("You are not authorized to delete this submission");
+        }
+        
         print_string("deleting", "workshop");
         // first get any assessments...
         if ($assessments = workshop_get_assessments($submission, 'ALL')) {
                 delete_records("workshop_comments", "assessmentid", $assessment->id);
                 delete_records("workshop_grades", "assessmentid", $assessment->id);
                 echo ".";
-                }
+            }
             // ...now delete the assessments...
             delete_records("workshop_assessments", "submissionid", $submission->id);
-            }
+        }
         // ...and the submission record...
         delete_records("workshop_submissions", "id", $submission->id);
         // ..and finally the submitted file
         workshop_delete_submitted_files($workshop, $submission);
-        
-        print_continue("submissions.php?id=$cm->id&amp;action=adminlist");
-        }
+
+        redirect("view.php?id=$cm->id");
+    }
     
 
     /******************* admin (confirm) late flag ************************************/
 
         if (!isteacher($course->id)) {
             error("Only teachers can look at this page");
-            }
+        }
         if (empty($_GET['sid'])) {
             error("Admin confirm late flag: submission id missing");
-            }
+        }
         if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) {
             error("Admin confirm late flag: can not get submission record");
-            }
+        }
 
         notice_yesno(get_string("clearlateflag","workshop")."?", 
              "submissions.php?action=adminclearlate&amp;id=$cm->id&amp;sid=$_GET[sid]", 
-             "submissions.php?id=$cm->id&amp;action=adminlist");
-        }
+             "view.php?id=$cm->id");
+    }
     
 
     /******************* list all submissions ************************************/
 
         if (!isteacher($course->id)) {
             error("Only teachers can look at this page");
-            }
+        }
         if (empty($_GET['order'])) {
             $order = "name";
-            }
+        }
         else {
             $order = $_GET['order'];
-            }
+        }
             
         workshop_list_submissions_for_admin($workshop, $order);
         print_continue("view.php?id=$cm->id");
         
-        }
+    }
     
 
     /******************* admin update title ************************************/
 
         if (!isteacher($course->id)) {
             error("Only teachers can look at this page");
-            }
+        }
         if (empty($_POST['sid'])) {
             error("Admin Update Title: submission id missing");
-            }
+        }
     
         if (set_field("workshop_submissions", "title", $_POST['title'], "id", $_POST['sid'])) {
             print_heading(get_string("amendtitle", "workshop")." ".get_string("ok"));
-            }
-        print_continue("submissions.php?id=$cm->id&amp;action=adminlist");
         }
+        print_continue("view.php?id=$cm->id");
+    }
     
 
     /******************* confirm remove attachments ************************************/
 
         if (empty($_GET['sid'])) {
             error("Admin confirm delete: submission id missing");
-            }
+        }
         if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) {
             error("Admin delete: can not get submission record");
-            }
+        }
 
         notice_yesno(get_string("confirmremoveattachments","workshop"), 
              "submissions.php?action=removeattachments&amp;id=$cm->id&amp;sid=$_GET[sid]", 
              "view.php?id=$cm->id");
-        }
-    
-
-    /*************** display grades (by teacher) ***************************/
-    elseif ($action == 'displaygrades' or $action == 'displayfinalgrades' or $action == 'displaycurrentgrades') {
-
-        if (groupmode($course, $cm) == SEPARATEGROUPS) {
-            $groupid = get_current_group($course->id);
-        } else {
-            $groupid = 0;
-        }
-        
-        print_heading_with_help(get_string("displayofgrades", "workshop"), "finalgrades", "workshop");
-
-        if ($workshop->ntassessments) {
-            // display the teacher's submissions
-            echo "<center><table border=\"1\" width=\"90%\"><tr>\n";
-            echo "<td bgcolor=\"$THEME->cellheading2\"><b>$course->teacher ".get_string("submission", "workshop").
-                "</b></td>";
-            echo "<td bgcolor=\"$THEME->cellheading2\" align=\"center\"><b>".get_string("assessmentsby", "workshop",
-                    $course->teachers)."</b></td>";
-            echo "<td bgcolor=\"$THEME->cellheading2\" align=\"center\"><b>".get_string("assessmentsby", "workshop",
-                   $course->students)."</b></td></tr>";
-            if ($submissions = workshop_get_teacher_submissions($workshop)) {
-                foreach ($submissions as $submission) {
-                    echo "<tr><td>".workshop_print_submission_title($workshop, $submission)."</td>\n";
-                    echo "<td align=\"center\">".workshop_print_submission_assessments($workshop, $submission,
-                                "teacher")."</td>";
-                    echo "<td align=\"center\">".workshop_print_submission_assessments($workshop, $submission,
-                                "student")."</td></tr>";
-                }
-            }
-            echo "</table><br clear=\"all\" />\n";
-            workshop_print_key($workshop);
-        }
-
-        // Get all the students
-        if (!$users = get_course_students($course->id, "u.lastname, u.firstname")) {
-            print_heading(get_string("nostudentsyet"));
-            print_footer($course);
-            exit;
-        }
-        
-        // show the grades as stored in the tables...     
-        echo "<center><table border=\"1\" width=\"90%\"><tr>
-            <td bgcolor=\"$THEME->cellheading2\" width=\"120\"><b>".$course->student."</b></td>";
-        if ($workshop->wtype) {
-            echo "<td bgcolor=\"$THEME->cellheading2\" align=\"center\"><b>".get_string("assessmentsdone", "workshop").
-                "</b></td>";
-            echo "<td bgcolor=\"$THEME->cellheading2\" align=\"center\"><b>".get_string("gradeforassessments", 
-                "workshop")."</b></td>";
-        }
-        echo "<td bgcolor=\"$THEME->cellheading2\"><b>".get_string("submission", "workshop")."</b></td>";
-        echo "<td bgcolor=\"$THEME->cellheading2\" align=\"center\"><b>".get_string("assessmentsby", "workshop", 
-                $course->teachers)."</b></td>";
-        if ($workshop->wtype) {
-            echo "<td bgcolor=\"$THEME->cellheading2\" align=\"center\"><b>".get_string("assessmentsby", "workshop", 
-                $course->students)."</b></td>";
-        }
-        echo "<td bgcolor=\"$THEME->cellheading2\" align=\"center\"><b>".get_string("gradeforsubmission", 
-                "workshop")."</b></td>";
-        echo "<td bgcolor=\"$THEME->cellheading2\" align=\"center\"><b>".get_string("overallgrade", "workshop").
-                "</b></td></tr>\n";
-
-        foreach ($users as $user) {
-            // skip if student not in group
-            if ($groupid) {
-                if (!ismember($groupid, $user->id)) {
-                    continue;
-                }
-            }
-            if ($submissions = workshop_get_user_submissions($workshop, $user)) {
-                $gradinggrade = workshop_gradinggrade($workshop, $user);
-                foreach ($submissions as $submission) {
-                    $grade = workshop_submission_grade($workshop, $submission);
-                    echo "<tr><td><a href=\"{$CFG->wwwroot}/user/view.php?id=$user->id&amp;course=$course->id\">".
-                        fullname($user).'</a></td>';
-                    if ($workshop->wtype) {
-                        echo "<td align=\"center\">".workshop_print_user_assessments($workshop, $user)."</td>";
-                        echo "<td align=\"center\">$gradinggrade</td>";
-                    }
-                    echo "<td>".workshop_print_submission_title($workshop, $submission)."</td>\n";
-                    $strteachergrades = workshop_print_submission_assessments($workshop, $submission, "teacher");
-                    if ($strteachergrades == '&nbsp;') {
-                        $strteachergrades = '<a href="assessments.php?action=assesssubmission&id='.
-                            $cm->id.'&sid='.$submission->id.'">'.get_string('assess', 'workshop').'</a>';
-                    }
-                    echo "<td align=\"center\">$strteachergrades</td>";
-                    if ($workshop->wtype) {
-                        echo "<td align=\"center\">".workshop_print_submission_assessments($workshop, $submission, 
-                            "student")."</td>";
-                    }
-                    echo "<td align=\"center\">$grade</td>";
-                    echo "<td align=\"center\">".number_format($gradinggrade + $grade, 1)."</td></tr>\n";
-                }
-            }
-        }
-        echo "</table><br clear=\"all\" />\n";
-        workshop_print_key($workshop);
-        if ($workshop->showleaguetable and time() > $workshop->assessmentend) {
-            workshop_print_league_table($workshop);
-            if ($workshop->anonymous) {
-                echo "<p>".get_string("namesnotshowntostudents", "workshop", $course->students)."</p>\n";
-            }
-        }
-        print_continue("view.php?id=$cm->id");
     }
-
+    
 
     /******************* edit submission ************************************/
     elseif ($action == 'editsubmission' ) {
         echo "</table>\n";
         echo "<input type=\"submit\" value=\"".get_string("savemysubmission", "workshop")."\" />\n";
         echo "</center></form>\n";
-        }
+    }
     
 
     /******************* list all submissions ************************************/
             print_heading(get_string("nostudentsyet"));
             print_footer($course);
             exit;
-            }
+        }
         print_heading(get_string("listofallsubmissions", "workshop").":", "CENTER");
         workshop_list_all_submissions($workshop, $USER);
         print_continue("view.php?id=$cm->id");
         
-        }
+    }
     
 
     /******************* list for assessment student (submissions) ************************************/
             print_heading(get_string("nostudentsyet"));
             print_footer($course);
             exit;
-            }
+        }
         workshop_list_unassessed_student_submissions($workshop, $USER);
         print_continue("view.php?id=$cm->id");
         
-        }
+    }
     
 
     /******************* list for assessment teacher (submissions) ************************************/
    
         if (!isteacher($course->id)) {
             error("Only teachers can look at this page");
-            }
+        }
 
         workshop_list_unassessed_teacher_submissions($workshop, $USER);
         print_continue("view.php?id=$cm->id");
         
-        }
+    }
     
 
     /******************* remove (all) attachments ************************************/
     elseif ($action == 'removeattachments' ) {
-
+    
         $form = data_submitted();
         
         if (empty($form->sid)) {
             error("Update submission: submission id missing");
-            }
+        }
+        
         $submission = get_record("workshop_submissions", "id", $form->sid);
+        
+        // students are only allowed to remove their own attachments and only up to the deadline
+        if (!(isteacher($course->id) or 
+               (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend)
+                   and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) {
+            error("You are not authorized to delete these attachments");
+        }
+        
         // amend title... just in case they were modified
         // check existence of title
         if (empty($form->title)) {
         workshop_delete_submitted_files($workshop, $submission);
         add_to_log($course->id, "workshop", "removeattachments", "view.php?id=$cm->id", "submission $submission->id");
         
-        print_continue("view.php?id=$cm->id");
-        }
+        print_continue("view.php?id=$cm->id#sid=$submission->id");
+    }
     
 
     /******************* show submission ************************************/
     elseif ($action == 'showsubmission' ) {
 
         if (empty($_GET['sid'])) {
-            error("Edit submission: submission id missing");
-            }
+            error("Show submission: submission id missing");
+        }
         
         $submission = get_record("workshop_submissions", "id", $_GET['sid']);
-        workshop_print_submission($workshop, $submission);
-        print_continue("view.php?id=$cm->id");
+        $title = '"'.$submission->title.'" ';
+        if (isteacher($course->id)) {
+            $title .= get_string('by', 'workshop').' '.workshop_fullname($submission->userid, $course->id);
         }
+        print_heading($title);
+        echo '<center>'.get_string('submitted', 'workshop').': '.userdate($submission->timecreated).'</center><br />';
+        workshop_print_submission($workshop, $submission);
+        print_continue($_SERVER['HTTP_REFERER'].'#sid='.$submission->id);
+    }
     
 
     /*************** update (league table options teacher) ***************************/
         // save number of entries in showleaguetable option
         if ($form->nentries == 'All') {
             $form->nentries = 99;
-            }
+        }
         set_field("workshop", "showleaguetable", $form->nentries, "id", "$workshop->id");
         
         // save the anonymous option
         set_field("workshop", "anonymous", $form->anonymous, "id", "$workshop->id");
         add_to_log($course->id, "workshop", "league table", "view.php?id=$cm->id", $form->nentries, $cm->id);
 
-        redirect("submissions.php?action=adminlist&amp;id=$cm->id");
-        }
+        redirect("view.php?id=$cm->id");
+    }
 
 
     /*************** update submission ***************************/
         
         if (empty($form->sid)) {
             error("Update submission: submission id missing");
-            }
+        }
         $submission = get_record("workshop_submissions", "id", $form->sid);
+        
+        // students are only allowed to update their own submission and only up to the deadline
+        if (!(isteacher($course->id) or 
+               (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend)
+                   and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) {
+            error("You are not authorized to update your submission");
+        }
+        
         // check existence of title
         if (empty($form->title)) {
             $title = get_string("notitle", "workshop");
             } 
             print_continue("view.php?id=$cm->id");
         } else {
-            redirect("view.php?id=$cm->id");
+            redirect("view.php?id=$cm->id#sid=$submission->id");
         }
     }
-                
-     /******************* user confirm delete ************************************/
-    elseif ($action == 'userconfirmdelete' ) {
 
-        if (empty($_GET['sid'])) {
-            error("User Confirm Delete: submission id missing");
-            }
-            
-        notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("submission", "workshop")), 
-             "submissions.php?action=userdelete&amp;id=$cm->id&amp;sid=$_GET[sid]", "view.php?id=$cm->id");
-        }
-    
-
-    /******************* user delete ************************************/
-    elseif ($action == 'userdelete' ) {
-
-        if (empty($_GET['sid'])) {
-            error("User Delete: submission id missing");
-            }
-    
-        if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) {
-            error("User Delete: can not get submission record");
-            }
-        print_string("deleting", "workshop");
-        // first get any assessments...
-        if ($assessments = workshop_get_assessments($submission, 'ALL')) {
-            foreach($assessments as $assessment) {
-                // ...and all the associated records...
-                delete_records("workshop_comments", "assessmentid", $assessment->id);
-                delete_records("workshop_grades", "assessmentid", $assessment->id);
-                echo ".";
-                }
-            // ...now delete the assessments...
-            delete_records("workshop_assessments", "submissionid", $submission->id);
-            }
-        // ...and the submission record...
-        delete_records("workshop_submissions", "id", $submission->id);
-        // ..and finally the submitted file
-        workshop_delete_submitted_files($workshop, $submission);
-        
-        print_continue("view.php?id=$cm->id");
-        }
-    
 
     /*************** no man's land **************************************/
 
 
         error("Fatal Error: Unknown Action: ".$action."\n");
 
-        }
+    }
 
 
     print_footer($course);
index fef985e..f51ae1a 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2004120900;
+$module->version  = 2004120902;
 $module->requires = 2004052505;  // Requires this Moodle version
 $module->cron     = 60;
 
index 1454b51..b46d6e3 100644 (file)
@@ -8,6 +8,8 @@
     studentsview
     submitexample 
     teachersview
+    showdescription
+    showallsubmissions
     
 ************************************************/
 
     require("locallib.php");
     
     require_variable($id);    // Course Module ID
-    
+    optional_variable($action, '');
+    optional_variable($sort, "lastname");
+    optional_variable($dir, "ASC");
+
     $timenow = time();
 
     // get some useful stuff...
 
     $strworkshops = get_string("modulenameplural", "workshop");
     $strworkshop  = get_string("modulename", "workshop");
+    $straction = ($action) ? '-> '.get_string($action, 'workshop') : '';
 
     // ...display header...
     print_header_simple("$workshop->name", "",
-                 "<a href=\"index.php?id=$course->id\">$strworkshops</a> -> $workshop->name", 
+                 "<a href=\"index.php?id=$course->id\">$strworkshops</a> -> 
+                  <a href=\"view.php?id=$cm->id\">$workshop->name</a> $straction", 
                   "", "", true, update_module_button($cm->id, $course->id, $strworkshop), navmenu($course, $cm));
 
     // ...and if necessary set default action 
     
-    optional_variable($action);
     if (isteacher($course->id)) {
         if (empty($action)) { // no action specified, either go straight to elements page else the admin page
             // has the assignment any elements
         }
         if ($timenow < $workshop->submissionstart) { 
             $action = 'notavailable'; 
-        } else if ($timenow < $workshop->assessmentend) {
-            $action = 'studentsview';
-        } else {
-            $action = 'displayfinalgrade';
+        } else if (!$action) {
+            if ($timenow < $workshop->assessmentend) {
+                $action = 'studentsview';
+            } else {
+                $action = 'displayfinalgrade';
+            }
         }
     }
     else { // it's a guest, oh no!
     /****************** display final grade (for students) ************************************/
     if ($action == 'displayfinalgrade' ) {
 
+        print_heading("<b><a href=\"view.php?id=$cm->id&amp;action=showdescription\">".
+                get_string("showdescription", 'workshop')."</a></b>");
         // show the final grades as stored in the tables...
-        print_heading(get_string("displayoffinalgrades", "workshop"));
         if ($submissions = workshop_get_user_submissions($workshop, $USER)) { // any submissions from user?
+            print_heading(get_string("displayoffinalgrades", "workshop"));
             echo "<center><table border=\"1\" width=\"90%\"><tr>";
             echo "<td><b>".get_string("submissions", "workshop")."</b></td>";
             if ($workshop->wtype) {
             }
             echo "<td align=\"center\"><b>".get_string("gradeforsubmission", "workshop")."</b></td>";
             echo "<td align=\"center\"><b>".get_string("overallgrade", "workshop")."</b></td></tr>\n";
-            $gradinggrade = workshop_gradinggrade($workshop, $USER);
             foreach ($submissions as $submission) {
                 $grade = workshop_submission_grade($workshop, $submission);
                 echo "<tr><td>".workshop_print_submission_title($workshop, $submission)."</td>\n";
                 if ($workshop->wtype) {
-                    echo "<td align=\"center\">".workshop_print_user_assessments($workshop, $USER)."</td>";
+                    echo "<td align=\"center\">".workshop_print_user_assessments($workshop, $USER, $gradinggrade)."</td>";
                     echo "<td align=\"center\">$gradinggrade</td>";
                 }
                 echo "<td align=\"center\">".workshop_print_submission_assessments($workshop, 
                 echo "<td align=\"center\">$grade</td>";
                 echo "<td align=\"center\">".number_format($gradinggrade + $grade, 1)."</td></tr>\n";
             }
+            echo "</table><br clear=\"all\" />\n";
+            workshop_print_key($workshop);
+        } else {
+            print_heading(get_string('nowork', 'workshop'));
         }
-        echo "</table><br clear=\"all\" />\n";
-        workshop_print_key($workshop);
         if ($workshop->showleaguetable) {
             workshop_print_league_table($workshop);
         }
             }
         }
         workshop_print_assignment_info($workshop);
+        
+        // if the student has not yet submitted show the full description
+        if (!record_exists('workshop_submissions', 'workshopid', $workshop->id, 'userid', $USER->id)) {
+            print_simple_box(format_text($workshop->description, $workshop->format), 'center');
+        } else {
+            print_heading("<b><a href=\"view.php?id=$cm->id&amp;action=showdescription\">".
+                get_string("showdescription", 'workshop')."</a></b>");
+        }
+        
         // in Stage 1? - are there any teacher's submissions? and...
         // ...has student assessed the required number of the teacher's submissions 
         if ($workshop->ntassessments and (!workshop_test_user_assessments($workshop, $USER))) {
         // in stage 2? - submit own first attempt
         else {
             if ($workshop->ntassessments) { 
-                // show assessment the teacher's examples, there may be feedback from teacher
+                // show assessment of the teacher's examples, there may be feedback from teacher
                 print_heading(get_string("yourassessmentsofexamplesfromtheteacher", "workshop", 
                             $course->teacher));
                 workshop_list_teacher_submissions($workshop, $USER);
                 // list previous submissions
                 print_heading(get_string("yoursubmissions", "workshop"));
                 workshop_list_user_submissions($workshop, $USER);
+                
                 // are resubmissions allowed and the workshop is in submission/assessment phase?
                 if ($workshop->resubmit and ($timenow > $workshop->assessmentstart and $timenow < $workshop->submissionend)) {
                     // see if there are any cold assessments of the last submission
         if (!isteacher($course->id)) {
             error("Only teachers can look at this page");
         }
-    
-        workshop_print_assignment_info($workshop);
         
         // list previous submissions from teacher 
         workshop_list_user_submissions($workshop, $USER);
         // print upload form
         print_heading(get_string("submitexampleassignment", "workshop").":");
         workshop_print_upload_form($workshop);
+        
+        print_heading("<a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">".get_string("cancel")."</a>");
     }
 
 
         if (!isteacher($course->id)) {
             error("Only teachers can look at this page");
         }
+        
+        // automatically grade assessments if workshop has examples and/or peer assessments
+        if ($workshop->gradingstrategy and ($workshop->ntassessments or $workshop->nsassessments)) {
+            workshop_grade_assessments($workshop);
+        }
 
         /// Check to see if groups are being used in this workshop
         /// and if so, set $currentgroup to reflect the current group
         $groupmode = groupmode($course, $cm);   // Groups are being used?
         $currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
         
+        /// Print settings and things in a table across the top
+        echo '<table width="100%" border="0" cellpadding="3" cellspacing="0"><tr valign="top">';
+        
         /// Allow the teacher to change groups (for this session)
-        if ($groupmode) {
+        if ($groupmode and isteacheredit($course->id)) {
             if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) {
+                echo '<td>';
                 print_group_menu($groups, $groupmode, $currentgroup, "view.php?id=$cm->id");
+                echo '</td>';
             }
         }
+        /// Print admin links
+        echo "<td align=\"right\"><b><a href=\"view.php?id=$cm->id&amp;action=showdescription\">".
+            get_string("showdescription", 'workshop')."</a></b> \n";
+        echo "<br /><b><a href=\"submissions.php?id=$cm->id&amp;action=adminlist\">".
+            get_string("administration")."</a></b> \n";
         
-        print_heading_with_help(get_string("managingassignment", "workshop"), "managing2", "workshop");
+        echo '</td></tr>';
         
         workshop_print_assignment_info($workshop);
         
-        echo "<center>\n";
+        /// Print grade tables /////////////////////////////////////////////////
         
-        // if there are assessment elements show link to edit them
-        if ($workshop->nelements) {
-            echo "<br /><b><a href=\"assessments.php?id=$cm->id&amp;action=editelements\">".
-                get_string("amendassessmentelements", "workshop")."</a></b> \n";
-            helpbutton("elements", get_string("amendassessmentelements", "workshop"), "workshop");
+        // display the teacher's submissions
+        if ($workshop->ntassessments) {
+            $table->head = array(get_string("examplesubmissions", "workshop"),
+                get_string("assessmentsby", "workshop", $course->teachers),
+                get_string("assessmentsby", "workshop", $course->students));
+            $table->data = array();
+            if ($submissions = workshop_get_teacher_submissions($workshop)) {
+                foreach ($submissions as $submission) {
+                    $teacherassessments = workshop_print_submission_assessments($workshop, $submission, "teacher");
+                    // If not yet assessed, show assess link
+                    if ($teacherassessments == '&nbsp;') {
+                        $teacherassessments = '<a href="assess.php?id='.
+                            $cm->id.'&sid='.$submission->id.'">'.get_string('assess', 'workshop').'</a>';
+                    }
+                    $title = workshop_print_submission_title($workshop, $submission).
+                        " <a href=\"submissions.php?action=editsubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
+                        "<img src=\"$CFG->pixpath/t/edit.gif\" ".
+                        'height="11" width="11" border="0" alt="'.get_string('edit').'"></a>'.
+                        " <a href=\"submissions.php?action=confirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
+                        "<img src=\"$CFG->pixpath/t/delete.gif\" ".
+                        'height="11" width="11" border="0" alt="'.get_string('delete', 'workshop').'"></a>';
+                    $table->data[] = array($title, $teacherassessments,
+                        workshop_print_submission_assessments($workshop, $submission, "student"));
+                }
+            }
+            // Put in a submission link
+            $table->data[] = array("<b><a href=\"view.php?id=$cm->id&amp;action=submitexample\">".
+                get_string("submitexampleassignment", "workshop")."</a></b>".
+                helpbutton("submissionofexamples", get_string("submitexampleassignment", "workshop"), "workshop", true, false, '', true), 
+                '&nbsp;', '&nbsp;');
+            
+            print_table($table);
+            workshop_print_key($workshop);
+        }
+    
+        // Get all the students
+        if (!$users = get_course_students($course->id, "u.lastname, u.firstname")) {
+            print_heading(get_string("nostudentsyet"));
+            print_footer($course);
+            exit;
         }
         
-        // if teacher examples show submission and assessment links
-        if ($workshop->ntassessments) { 
-            // submission link for teacher examples
-            echo "<br /><b><a href=\"view.php?id=$cm->id&amp;action=submitexample\">".
-                get_string("submitexampleassignment", "workshop")."</a></b> \n";
-            helpbutton("submissionofexamples", get_string("submitexampleassignment", "workshop"),
-                    "workshop");
-            // show assessment link for teachers examples only once there are such examples
-            if ($n = workshop_count_teacher_submissions_for_assessment($workshop, $USER)) {
-                echo "<br /><b><a href=\"submissions.php?id=$cm->id&amp;action=listforassessmentteacher\">".
-                    get_string("teachersubmissionsforassessment", "workshop", $n)."</a></b> \n";
-                helpbutton("assessmentofexamples", get_string("teachersubmissionsforassessment", 
-                            "workshop"), "workshop");
+        /// Now prepare table with student assessments and submissions
+        $tablesort->data = array();
+        $tablesort->sortdata = array();
+        foreach ($users as $user) {
+            // skip if student not in group
+            if ($currentgroup) {
+                if (!ismember($currentgroup, $user->id)) {
+                    continue;
+                }
             }
-        }
+            if ($submissions = workshop_get_user_submissions($workshop, $user)) {
+                foreach ($submissions as $submission) {
+                    $data = array();
+                    $sortdata = array();
+                    
+                    $data[] = "<a name=\"userid$user->id\" href=\"{$CFG->wwwroot}/user/view.php?id=$user->id&amp;course=$course->id\">".
+                        fullname($user).'</a>';
+                    $sortdata['firstname'] = $user->firstname;
+                    $sortdata['lastname'] = $user->lastname;
+                    
+                    if ($workshop->wtype) {
+                        $data[] = workshop_print_user_assessments($workshop, $user, $gradinggrade);
+                        
+                        $data[] = $gradinggrade;
+                        $sortdata['agrade'] = $gradinggrade;
+                    }
+                    
+                    $data[] = workshop_print_submission_title($workshop, $submission).
+                        " <a href=\"submissions.php?action=adminamendtitle&amp;id=$cm->id&amp;sid=$submission->id\">".
+                        "<img src=\"$CFG->pixpath/t/edit.gif\" ".
+                        'height="11" width="11" border="0" alt="'.get_string('amendtitle', 'workshop').'"></a>'.
+                        " <a href=\"submissions.php?action=confirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
+                        "<img src=\"$CFG->pixpath/t/delete.gif\" ".
+                        'height="11" width="11" border="0" alt="'.get_string('delete', 'workshop').'"></a>';
+                    $sortdata['title'] = $submission->title;
+                    
+                    $data[] = userdate($submission->timecreated, get_string('datestr', 'workshop'));
+                    $sortdata['date'] = $submission->timecreated;
+                    
+                    if (($tmp = workshop_print_submission_assessments($workshop, $submission, "teacher")) == '&nbsp;') {
+                        $data[] = '<a href="assess.php?id='.
+                            $cm->id.'&sid='.$submission->id.'">'.get_string('assess', 'workshop').'</a>';
+                        $sortdata['tassmnt'] = -1;
+                    } else {
+                        $data[] = $tmp;
+                        $sortdata['tassmnt'] = 1; // GWD still have to fix this
+                    }
+                    
+                    if ($workshop->wtype) {
+                        $data[] = workshop_print_submission_assessments($workshop, $submission, "student");
+                    }
+                    
+                    $grade = workshop_submission_grade($workshop, $submission);
+                    $data[] = $grade;
+                    $sortdata['sgrade'] = $grade;
 
-        if ($workshop->wtype) {
-            // only show grading assessments if there are grading grades involved
-            if ($numberofassessments = workshop_count_ungraded_assessments($workshop)) {
-                echo "<br /><b><a href=\"assessments.php?id=$cm->id&amp;action=gradeallassessments\">".
-                    get_string("ungradedassessments", "workshop", 
-                    $numberofassessments)."</a></b> \n";
-                helpbutton("ungradedassessments", 
-                    get_string("ungradedassessments", "workshop"), "workshop");
-            }
-        }
+                    if ($workshop->wtype) {
+                        $data[] = number_format($gradinggrade + $grade, 1);
+                        $sortdata['ograde'] = $gradinggrade + $grade;
+                    }
 
-        // Show link to student submissions for assessment only if assessment has started
-        if ($timenow > $workshop->assessmentstart) {
-            if ($numberofsubmissions = workshop_count_student_submissions_for_assessment($workshop, $USER)) {
-                echo "<br /><b><a href=\"submissions.php?id=$cm->id&amp;action=listforassessmentstudent\">".
-                    get_string("studentsubmissionsforassessment", "workshop", 
-                    $numberofsubmissions)."</a></b> \n";
-                helpbutton("gradingsubmissions", 
-                    get_string("studentsubmissionsforassessment", "workshop"), "workshop");
+                    $tablesort->data[] = $data;
+                    $tablesort->sortdata[] = $sortdata;
+                }
             }
         }
         
-        // Show link to current grades
-        if ($timenow > $workshop->assessmentstart) {
-            if ($timenow < $workshop->assessmentend) {
-                echo "<br /><b><a href=\"submissions.php?id=$cm->id&amp;action=displaycurrentgrades\">".
-                        get_string("displayofcurrentgrades", "workshop")."</a></b> \n";
+        function workshop_sortfunction($a, $b) {
+           global $sort, $dir;
+           if ($dir == 'ASC') {
+               return ($a[$sort] > $b[$sort]);
+           } else {
+               return ($a[$sort] < $b[$sort]);
+           }
+        }
+        uasort($tablesort->sortdata, 'workshop_sortfunction');
+        $table->data = array();
+        foreach($tablesort->sortdata as $key => $row) {
+            $table->data[] = $tablesort->data[$key];
+        }
+        
+        if ($workshop->wtype) {
+            $table->align = array ('left', 'center', 'center', 'left', 'center', 'center', 'center', 'center', 'center', 'center');
+            $columns = array('firstname', 'lastname', 'agrade', 'title', 'date', 'tassmnt', 'sgrade', 'ograde');
+        } else {
+            $table->align = array ('left', 'left', 'center', 'center', 'center', 'center');
+            $columns = array('firstname', 'lastname', 'title', 'date', 'tassmnt', 'ograde');
+        }
+        $table->width = "95%";  
+    
+        foreach ($columns as $column) {
+            $string[$column] = get_string("$column", 'workshop');
+            if ($sort != $column) {
+                $columnicon = '';
+                $columndir = 'ASC';
             } else {
-                echo "<br /><b><a href=\"submissions.php?id=$cm->id&amp;action=displayfinalgrades\">".
-                        get_string("displayoffinalgrades", "workshop")."</a></b> \n";
+                $columndir = $dir == 'ASC' ? 'DESC':'ASC';
+                if ($column == 'lastaccess') {
+                    $columnicon = $dir == 'ASC' ? 'up':'down';
+                } else {
+                    $columnicon = $dir == 'ASC' ? 'down':'up';
+                }
+                $columnicon = " <img src=\"$CFG->pixpath/t/$columnicon.gif\" />";
+    
             }
+            $$column = "<a href=\"view.php?id=$id&amp;sort=$column&amp;dir=$columndir\">".$string[$column]."</a>$columnicon";
         }
-
-        echo "<br /><b><a href=\"submissions.php?id=$cm->id&amp;action=adminlist\">".
-            get_string("administration")."</a></b> \n";
+    
+        if ($workshop->wtype) {
+            $table->head = array ("$firstname / $lastname", get_string("assmnts", "workshop"), $agrade,
+                $title, $date, $tassmnt, get_string('passmnts', 'workshop'), $sgrade, $ograde);
+        } else {
+            $table->head = array ("$firstname / $lastname", $title, $date, $tassmnt, $ograde);
+        }
+        
+        print_table($table);
+        workshop_print_key($workshop);
         
-        echo '</center><br />';
+        // grading grade analysis
+        unset($table);
+        $table->head = array (get_string("count", "workshop"), get_string("mean", "workshop"),
+            get_string("standarddeviation", "workshop"), get_string("maximum", "workshop"), 
+            get_string("minimum", "workshop"));
+        $table->align = array ("center", "center", "center", "center", "center");
+        $table->size = array ("*", "*", "*", "*", "*");
+        $table->cellpadding = 2;
+        $table->cellspacing = 0;
+        if ($currentgroup) {
+            $stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean, 
+                    STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max 
+                    FROM {$CFG->prefix}groups_members g, {$CFG->prefix}workshop_assessments a 
+                    WHERE g.groupid = $currentgroup AND a.userid = g.userid AND a.timegraded > 0 
+                    AND a.workshopid = $workshop->id");
+        } else { // no group/all participants
+            $stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean, 
+                    STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max 
+                    FROM {$CFG->prefix}workshop_assessments a 
+                    WHERE a.timegraded > 0 AND a.workshopid = $workshop->id");
+        }   
+        $table->data[] = array($stats->count, number_format($stats->mean * $workshop->gradinggrade / 100, 1), 
+                number_format($stats->stddev * $workshop->gradinggrade /100, 1), 
+                number_format($stats->max * $workshop->gradinggrade / 100, 1), 
+                number_format($stats->min* $workshop->gradinggrade / 100, 1));
+        print_heading(get_string("gradinggrade", "workshop")." ".get_string("analysis", "workshop"));
+        print_table($table);
+        
+        if ($workshop->showleaguetable and time() > $workshop->assessmentend) {
+            workshop_print_league_table($workshop);
+            if ($workshop->anonymous) {
+                echo "<p>".get_string("namesnotshowntostudents", "workshop", $course->students)."</p>\n";
+            }
+        } 
     }
-    
-    
+
+
+    /****************** show description  ************/
+    elseif ($action == 'showdescription') {
+
+        workshop_print_assignment_info($workshop);
+        print_simple_box(format_text($workshop->description, $workshop->format));
+        print_continue($_SERVER["HTTP_REFERER"]);
+    }
+
+
+    /****************** teacher's view - list all submissions  ************/
+    elseif ($action == 'allsubmissions') {
+
+        if ($submissions = get_records('workshop_submissions', 'workshopid', $workshop->id)) {
+            foreach($submissions as $submission) {
+                $user = get_record('user', 'id', $submission->userid);
+                print_heading('"'.$submission->title.'" '.get_string('by', 'workshop').' '.fullname($user));
+                workshop_print_submission($workshop, $submission);
+            }
+        }
+    }
+
+
     /*************** no man's land **************************************/
     else {
         error("Fatal Error: Unknown Action: ".$action."\n");
diff --git a/mod/workshop/viewassessment.php b/mod/workshop/viewassessment.php
new file mode 100644 (file)
index 0000000..1a756bc
--- /dev/null
@@ -0,0 +1,81 @@
+<?php  // $Id: viewassessment.php
+
+    require("../../config.php");
+    require("lib.php"); 
+    require("locallib.php");
+
+    require_variable($aid);   // Assessment ID
+    optional_variable($allowcomments, false);
+    optional_variable($redirect, '');
+    
+    if (! $assessment = get_record("workshop_assessments", "id", $aid)) {
+        error("Assessment id is incorrect");
+    }
+    if (! $submission = get_record('workshop_submissions', 'id', $assessment->submissionid)) {
+        error("Incorrect submission id");
+    }
+    if (! $workshop = get_record("workshop", "id", $submission->workshopid)) {
+        error("Submission is incorrect");
+    }
+    if (! $course = get_record("course", "id", $workshop->course)) {
+        error("Workshop is misconfigured");
+    }
+    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
+        error("No coursemodule found");
+    }
+
+    if (!$redirect) {
+        $redirect = urlencode($_SERVER["HTTP_REFERER"].'#sid='.$submission->id);
+    }
+
+    require_login($course->id);
+
+    $strworkshops = get_string("modulenameplural", "workshop");
+    $strworkshop  = get_string("modulename", "workshop");
+    $strassess = get_string("viewassessment", "workshop");
+    
+    /// Now check whether we need to display a frameset
+
+    if (empty($_GET['frameset'])) {
+        echo "<head><title>{$course->shortname}: {$workshop->name}</title></head>\n";
+        echo "<frameset rows=\"90%,*\" border=\"10\">";
+        echo "<frame src=\"viewassessment.php?id=$id&amp;aid=$aid&amp;frameset=top&amp;redirect=$redirect\" border=\"10\">";
+        echo "<frame src=\"viewassessment.php?id=$id&amp;aid=$aid&amp;frameset=bottom&amp;redirect=$redirect\">";
+        echo "</frameset>";
+        exit;
+    }
+
+    /// top frame with the navigation bar and the assessment form
+    
+    if (!empty($_GET['frameset']) and $_GET['frameset'] == "top") {
+    
+        print_header_simple("$workshop->name", "",
+                     "<a href=\"index.php?id=$course->id\">$strworkshops</a> -> 
+                      <a href=\"view.php?id=$cm->id\">$workshop->name</a> -> $strassess", 
+                      "", '<base target="_parent">', true);
+    
+        // show assessment but don't allow changes
+        workshop_print_assessment($workshop, $assessment, false, $allowcomments);
+        
+        if (isteacher($course->id) and !isteacher($course->id, $assessment->userid)) {
+            print_heading_with_help(get_string("gradeassessment", "workshop"), "gradingassessments", "workshop");
+            include('assessment_grading_form.html');
+        }
+        print_continue($redirect);
+        print_footer($course);
+        exit;
+    }
+    
+    /// print bottom frame with the submission
+    
+    print_header();
+    $title = '"'.$submission->title.'" ';
+    if (isteacher($course->id)) {
+        $title .= ' '.get_string('by', 'workshop').' '.workshop_fullname($submission->userid, $course->id);
+    }
+    print_heading($title);
+    workshop_print_submission($workshop, $submission);
+    print_footer();
+?>
+