--- /dev/null
+<P ALIGN=CENTER><B>Anonymous Grading</B></P>
+
+<P>A peer graded assignment can be graded anonymously. In this
+ case the names (and any photos) of the students doing the grading
+ are not shown. Only the (file) names of the submissions are used to identify
+ the peices of work being graded.
+
+<P>When the peer graded assignment is not graded anonymously, the
+ pieces of work are shown with the names (and any photos) of the
+ students who submitted the work. This may lead to bias in the gradings.
+
+<P>Note that if the teacher's grades are shown to the students these are
+ never shown anonymously.
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Peer Graded Assignment Type</B></P>
+
+<P>A peer graded assignment can have one of two types:
+
+<OL>
+<LI>Only feedback on the assessment elements and the general comment
+ is entered. The grading of assessment elements is not seen in the
+ grading pages. Assignments themselves are not given an overall grade.
+ However, the grading performance of the students is measured and
+ this, and only this measure contributes towards the final grades given
+ to the students.
+
+<LI>Here the teacher and peers are asked to provide both feedback and
+ grades. The assignments are given an overall quantative grade as well
+ as the qualative data. The final grade for a student will be calculated
+ from the (weighted) contributions of the teacher's grade, the mean
+ peers' grade and the student's grading performance.
+
+</OL>
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>The Breakdown of the Final Grade</B></P>
+
+<P>The table on this screen shows your final grade and how it was calculated.
+ The final grade is made up from three possible components.
+
+<OL>
+<LI>The teacher's grade for your submitted work.
+<LI>The average of the peer grades for your submitted work.
+<LI>A grade for your performance in the peer grading phase. This
+ performance was based by (a) whether your grades were too high or too low
+ when compared with the average grade of the other students (this is called bias),
+ (b) whether your grades follow, again on average, the grades given by
+ the other students (this is called reliability)
+ and (c) on the quality of your comments on the other pieces of work you graded.
+ This was graded by the teacher. These three performance grades were weighted
+ by the factors 1:2:3 respectively to give an overall "grading"
+ grade. In other words the teacher's grading of the comments is given the
+ same weight as the Bias and Reliability factors combined.
+</OL>
+
+<P>These three components can be weighted as deemed appropriate for the
+ assignment. These weights are shown in the smaller table.
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>The Calculation of the Final Grade</B></P>
+
+<P>The table on this screen shows how the the final grades for the students
+ are calculated. The final grades are a weighted sum of up to five components.
+
+<OL>
+<LI>The teacher's grade for their submitted work. This is optional and will be
+ used if the teacher actually assesses the student's work. If the student submits
+ more than one peice of work the "best" grade is used. Here, best
+ means the piece of work with the highest weighted combination of teacher's
+ grade and peer grade...
+<LI>The average of the peer grades for their submitted work. Again if the student
+ submits more than one peice of work the "best" grade is used. The
+ peer grade can optionally
+ include the teacher's grade. This grade would be included if the number of
+ peer gradings is very low or it is thought that the peer gradings are suspect
+ either because of bias (usually on the high side) or for not being reliable.
+ If included the teacher's grade is treated in the same way as a peer grade in
+ the calculation of the average.
+<LI>The student's bias in grading peer work. This is measure of whether the
+ student grades work either too high or too low. It is not an absolute measure
+ as it is based on the difference between the student's grade and the peer
+ averages for each of the submissions they assessed. In general this component
+ should NOT be given a high weighting.
+<LI>The student's reliability in grading peer work. This is a measure on how well
+ a students grades follow the peer average for the peices of work they
+ assessed. The measure discounts the student bias and averages the absolute
+ differences between their grades and the peer average grades. In theory if
+ the students gives high marks for good peices of work and low marks for poor
+ pieces of work their reliability will be high. If it is suspected that the students in
+ general are poor assessors then the teacher's grades should be included into
+ the ppeer averages, this should make the reliability values more meaningful.
+<LI>The average grade given by the teacher for the student's assessments.
+ This includes both the preliminary assessments made by the student on the
+ example pieces of work and any grading the teacher makes on the asessments
+ produced during the peer assessement phase of the assignment. In general this
+ component is probably more important than both the Bias and Reliability
+ components and thus, if available, should be weighted higher.
+</OL>
+
+<P>These five components can be weighted as deemed appropriate for the
+ assignment. For example the teacher's grade might be weighted strongly
+ if the peer grading part of the assignment is only considered a minor part
+ of the assignment as a whole. Alternatively, if the teacher only grades a few
+ of the submissions these grades can be ignored by giving them a zero weighting.
+ If the assignment is all about the students as judges and the providing of feedback
+ then first two components may be set to zero (or low) and the students'
+ grading abilities will determine the final grades.
+
+<P>Note that this screen is used iteratively and the final grades are not normally
+ made available to the students until the final phase of the assignment. Once the
+ the teacher is happy with the final grades and their weightings then they can
+ be made available to the students.
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Assignment Elements</B></P>
+
+<P>For ease of grading, a Workshop Assignment should have a reasonable
+ number of "Assessment Elements". Each element should cover
+ a particular aspect of the assignment. Typically an assignment will have
+ something between 5 to 15 elements for comments and grading, the
+ actual number depending on the size and complexity of the assignment. A peer
+ assignment with only one element is allowed and has a similar assessment
+ strategy to the standard Moodle Assignment.
+
+<P>The type of elements dependent of the assignment's grading strategy.
+
+<P><B>Not Graded.</B> The elements are descriptions of aspects of the assignment.
+ The assessor is asked to comment on each of these aspects. As with all the grading
+ strategies, there is also an area for general comments.
+
+
+<P><B>Accumulative Grading.</B> The elements have the following three features:
+<OL>
+<LI>The DESCRIPTION of the assessment element. This should clearly state what
+ aspect of the assignment is being assessed. If the assessment is qualatative
+ it is helpful to give details of what is considered excellent, average
+ and poor.
+
+<LI>The SCALE of the assessment element. There are a number of prefined
+ scales. These range from simple Yes/No scales, through multipoint scales to
+ a full percentage scale. Each element has its own scale which should be choosen
+ to fit the number of possible variations for that element. Note that the scale
+ does NOT determine the element's importance when calculating the overall
+ grade, a two point scale has the same "influence" as a 100 point
+ scale if the respective elements have the same weight...
+
+<LI>The WEIGHT of the assessment element. By default the elements are given the same
+ importance when calculating the overall grade of the assignment. This can be
+ changed by giving the more importance elements a weight greater than one, and
+ the less important elements a weight below one. Changing the weights does NOT
+ effect the maximum grade, that value is fixed by the Maximum Grade parameter
+ of the peer assignment. Weights can be assigned negative values, this is an
+ experimental feature.
+</OL>
+<P><B>Error Banded Grading.</B> The elements will normally describe certain items
+ or aspects which must be present in the assignment. The assessment is made on the
+ present or absence of these items or aspects. The teacher must all set of grade table which
+ give the suggested grades when all the items are present, when one is absent, when two are
+ absent, etc. If certain items are more important than others then those items can be given
+ a weighting greater than one. Minor items can be given a weighting less than one. The
+ overall "error count" is a weighted sum of the missing items. The assessor
+ can always make a minor adjustment to these suggested grades.
+
+<P><B>Criteria Grading.</B> The elements will give a set of "level" statements
+which can be used to rank the assignment. The statements may be cumulative or they may
+each be self contained. The assessor must decide which statement best fits each piece of
+work. The teacher must also relate each criterion statement with a suggested grade. These
+should normally be in order. The assessor can make a minor adjustment to these
+suggested grades.
+</P>
\ No newline at end of file
--- /dev/null
+<P ALIGN=CENTER><B>The Final Grades</B></P>
+
+<P>The table on this screen lists the final grades and their breakdown as shown to
+ the students. If there are missing values in the table then it is possible to "go back"
+ and add these. In fact, there are two adjustments which can be made to the Final Grades.
+
+<OL>
+<LI>If a teacher's grade needs to be added then the piece of work can be
+ graded by going
+ to the teacher's Management screen for assignment and clicking on the link "Student
+ Submissions for Assessment". Any otherstanding submissions can be graded. Once this has
+ been done then move the assignment back to Phase 3 and re-calculate the Final grades. In a
+ similar way any assessments which have not been graded can be graded from the Management
+ screen.
+<LI>If it is desired to use a different weighting scheme then the assignment should be moved
+ back to Phase 3 and link "Calculate Final Grades" can be clicked and the new
+ weights entered. After the grades have been re-calcualted the assignment should be moved
+ to Phase 4 to make the new grades available.
+</OL>
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>A Graded Peer Assignment</B></P>
+
+<P>This shows the grades and comments made on the submitted piece of
+ work. You can if you wish reply to this assessment and choose not to
+ accept it (at this stage). If that is the case, please enter your reply in the
+ box at the foot of the page giving the reason why you are not happy with
+ the assessment. Then click on the button at the foot of the page and
+ choose NO when asked whether you are happy with this assessment.
+
+<P>If, on the other hand. you are happy with the assessment simply
+ click on the button at the foot of the page and then click on YES when
+ asked whether you are happy with this assessment.
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Grading of Peer Assignments</B></P>
+
+<P>For ease of grading a Peer Assignment is divided into a number of
+ assessment "elements". Each element covers
+ a particular aspect of the assignment. Depending on the type of assessment,
+ for each element you should
+<OL>
+<LI>Enter a Grade by clicking in the appropriate button or selecting an appropriate
+ number from the drop down menu.
+
+<LI>Enter an explaination of why you gave that grade in the Feedback box. If
+ you feel that the reason is obvious then leave the box empty. Note, however,
+ that the teacher may look at your assessment and may well query a grade
+ if there is no explaination.
+</OL>
+
+<P>In other type of asessments, you are asked to determine if various items
+ are present or absent, in others you are asked to choose which statement best
+ fits the peice of work. In both of these assignments you can adjust the grade
+ somewhat as you see fit.
+
+<P>The last box on this form allows you to make a general comment on the
+ work. This should justify your assessment. It should be polite and as far as
+ possible constructive. Your assessment will be shown to the student who
+ produced the piece of work.
+
+<P>You have a limited period of time, typically half an hour, in which to
+ change your mind and alter your grades or comments. Once that period
+ is over the person whose work you are assessing is notified about the assessment.
+ At that stage you can view your assessment but you cannot change it.
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Grading the Student Assessments</B></P>
+
+<P>This screen is used to enter the teacher's grade for the assessment made
+ by the student during the submission and assessment phase of the assignment. A relatively
+ simple grading is used, the score out of 20. The treacher can decide what is
+ being graded and the relative scores from the instructions given to the students
+ before the assignment started. For example, at a higher level the students may be
+ required to give critical comments, at an intermediate level the students may be
+ required to point out strengths and weaknesses, and at a lower level the students
+ may be simply pointing out errors and inaccuracies.
+
+<P>If available the Teacher's own assessment is shown before that of the
+ student so an easy comparison can be made. The teacher's own
+ comments can act as a kind of benchmark.
+
+<P>The grades of assessment is
+ saved by clicking on the apprpriate button at the foot of the page. There is a
+ chance to repeat the grading within the "editing" period. Once that
+ time has elapsed the grade is made available to the student.
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Grading Strategy</B></P>
+
+<P>A workshop assignment is quite flexible in the type of grading scheme used. This can be:
+
+<OL>
+<LI><B>No grading:</B> In this type of assignment the teacher is not
+ interested in quantative assessment from the students at all. The students
+ make comments of the pieces of works but not not grade them. The teacher,
+ however, can, if desired, grade the student comments. These
+ "grading grades" form the basis of the students' final grades.
+ If the teacher does not grade the student assessments then the assignment
+ does not have any final grades.
+
+<LI><B>Accumulative grading:</B> This is the default type of grading.
+ In this type of assignment the grade of each
+ assessment is made up of a number of "assessment elements".
+ Each element should cover
+ a particular aspect of the assignment. Typically an assignment will have
+ something between 5 to 15 elements for comments and grading, the
+ actual number depending on the size and complexity of the assignment. A peer
+ assignment with only one element is allowed and has a similar assessment
+ strategy to the standard Moodle Assignment.
+
+<P>Elements have the following three features:
+<OL>
+<LI>The DESCRIPTION of the assessment element. This should clearly state what
+ aspect of the assignment is being assessed. If the assessment is qualatative
+ it is helpful to give details of what is considered excellent, average
+ and poor.
+
+<LI>The SCALE of the assessment element. There are a number of prefined
+ scales. These range from simple Yes/No scales, through multipoint scales to
+ a full percentage scale. Each element has its own scale which should be choosen
+ to fit the number of possible variations for that element. Note that the scale
+ does NOT determine the element's importance when calculating the overall
+ grade, a two point scale has the same "influence" as a 100 point
+ scale if the respective elements have the same weight...
+
+<LI>The WEIGHT of the assessment element. By default the elements are given the same
+ importance when calculating the overall grade of the assignment. This can be
+ changed by giving the more importance elements a weight greater than one, and
+ the less important elements a weight below one. Changing the weights does NOT
+ effect the maximum grade, that value is fixed by the Maximum Grade parameter
+ of the peer assignment. Weights can be assigned negative values, this is an
+ experimental feature.
+</OL>
+
+<LI><B>Error Banded Grading:</B> In this type of assignment the submissions are
+ graded on a set of Yes/No scales. The grade is determined by the "Grade
+ Table " which gives the relationship between the number of
+ "errors" and the suggested grade. For example an assignment may have six
+ significant items which should be present, the Grade Table will give suggested
+ grades if all are present, one is absent, if two are absent, etc. The individual
+ items can, if desired, be given weighting factors if some items are more important
+ than others. The number of "errors" is a weighted sum of the items not
+ present. By default each item is given a weight of one. The grading table is likely
+ to be non-linear, for example
+ the sugested grades may be 90%, 70%, 50%, 40%, 30%, 20%, 10%, 0%, 0%, 0% for
+ an assignment with 10 items.The assessor can adjust the suggested grade by up
+ to 20% either way to give the submission's final grade.
+
+<LI><B>Criteria Grading:</B> This is simpliest type of assessment to grade (although
+ not necessarily the most straightforward to set up). The submissions are
+ graded against a set of criteria statments. The assessor choses which statement
+ best fits the piece of work. The grade is determined by a "Criteria
+ Table" which gives the suggested grade for each criterion. For example
+ an assignment may be set up with, say, five criteria statements and the assessors
+ must then choose one of the five statements for each of their assessments. As with
+ the Banded assignment the assessor can adjust the suggested grade by up to
+ 20% to give the final grade.
+</OL>
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Including Self in the Assignment</B></P>
+
+<P>A peer graded assignment can optionally include the student's own work
+ in the set of pieces each student is asked to grade. This will mean that if, say, the
+ number of peer assessors is 5, then each student will be asked to grade 6
+ pieces of work, one of them being their own work.
+
+<P>If the number of peer assessors is set to zero and the include self option
+ is turned on then the assignment becomes a self-graded assignment. This
+ may or may not include the teacher's grading depending on whether that
+ option is set or not.
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Managing a Workshop Assignment</B></P>
+
+<P>A Workshop Assignment is more complex than an ordinary assignment.
+ It involves a number of steps or phases. These are
+<OL>
+<LI>The assessment of the assignment should be broken into a number
+ of assessment ELEMENTS. This makes the grading of an assignment less
+ arbitary and gives the students a framework on which to make assessments.
+ The teacher has the role of setting up the assessment elements thus making a
+ grading sheet. (See that page for more details.)
+
+ <P>With the assessment elements set up the teacher will normally submit a
+ small number of example pieces of work. These are practice pieces for the
+ students to assess before preparing their own pieces of work. However,
+ before the assignment is made available to students, these example
+ pieces should be assessed by the teacher. This provides the students
+ with not only examples for the assignment but also specimen assessments
+ on those examples.
+ <P>The submission of example pieces of work by the teacher is optional
+ and for certain assignments may not be appropriate.
+
+<LI>The assignment is now opened to the students. If the teacher has set up
+ example pieces of work the students can be asked to assess a number of these.
+ In this case, the teacher must grade these assessments and the students must
+ reach a satisfactory standard before they are allowed submit their own work.
+ Here, a "satisfactory standard" has been set at 40%. Once a student
+ has "passed" the required number of assessments they are free to
+ submit their own work.
+ <P>When a student submits a piece of work the teacher can, if desired assess that
+ work. This assessment can be incorporated into the student final grade. These
+ assessments, if they are required, can take place either during the submission
+ phase of the assignment or after the submission deadline.
+ <P>If the assignment incorporates peer assessment, students who have submitted
+ work are shown other students' work to assess. When they have made an assessment
+ their peer can see that assessment (but the other student cannot comment on it.)
+ The teacher, however, can, if desired, grade the assessment and that score is taken
+ forward towards the student's final grade.
+
+<LI>After the deadline has passed, the teacher moves the assignment to the next phase
+ where further submissions and assessments by students are not allowed. The teacher
+ can, if wished, grade the peer assessments made by the students. This is not really
+ necessary as provided a reason number of assessments have been made on each
+ submission the "grading performance" of each student can be
+ determined from the relative scores. The teacher now calculates the final grades
+ of the students. These final grades are normally made up of three components,
+ teacher's grade of the student's work, mean peer grade of the student's work
+ and the student's grading performance. The last can include the mean "grading
+ grade" entered by the teacher against a student's comments. These three
+ components are given weights by the teacher before the calculation of the final
+ grades takes place.
+
+<LI>The final phase of the assignment is entered to allow the students to see their
+ final grades. The teacher can, be desired, backtrack the assignment to allow some
+ adjustment of, say, the weights used in the final grade calculation, the revised
+ grades can then be shown to the students.
+</OL>
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Number of Assessments of Student submissions</B></P>
+
+<P>This number determines whether the students are asked to peer assess
+ other students' work. If it is
+ not zero then each student is offered that number of peices
+ of work from other students. After assessment the originator of the work
+ can view the comments and grade given by their peer. The teacher can also,
+ if desired, grade these assessments and those grades can be used in the calculation of
+ the final marks. The student is show the teacher's comments and grade
+ for each of their assessments if available.
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Number of Assessments of Teacher's Examples</B></P>
+
+<P>This number determines whether the students are asked to assess
+ any example peices of work before submitting their own work. If it is
+ not zero then each student must assess that number of example pieces
+ of work to a satisfactory level. This means that the teacher must grade
+ these assessments before the student can submit work. The student is
+ shown the teacher's comments and grade for each of their
+ assessments.
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Number of Comments, Elements, Bands or Criteria</B></P>
+
+<P>The number entered here determines how many items will be used in
+ the assessments. Depending on the type of grading strategy, this number
+ gives the number of comments, assessments elements, bands or criteria
+ to be used in the assessments. Typically an assignment will have
+ something between 5 to 15 assessment items, the
+ actual number depending on the size and complexity of the assignment.
+
+<P>All assessments have a General Comments field. For a "No
+ Grading" assignment the value given here determines the
+ number of additional comment areas. It can be specified as zero and results
+ in the assessment having only a single General Comments area.
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Number of Peer Assessors</B></P>
+
+<P>A peer graded assignment will normally have around 3 to 8 peer
+ assessors. That is, in the peer grading phase, each student will be
+ asked to grade this number of pieces of work from the other students
+ in the class. The larger the assignment is, in terms of content, the
+ smaller this number should be, else the grading burden on the
+ students becomes onerous. However, each student should see sufficient
+ examples to gain an insight into what constitutes a good piece of work
+ and a poor piece of work. Further for the grading performance of a
+ student to be assessed meaningfully the greater the number of peer
+ gradings the better. This performance is unlikely to be valid if only three
+ or four gradings are done by each student.
+
+<P>Provided there is enough pieces of work submitted (actually 10 or
+ more), the system will allocate each student at least one "good" and
+ at least one "poor" piece of work. However, this can only be done if the
+ teacher has graded the pieces of work BEORE the allocation of (peer) grading
+ work is done. The teacher does NOT, however, have to grade all the
+ pieces of work, a sample is sufficient. Further, the teacher's gradings need
+ NOT be the final gradings, a preliminary grading is good enough. Note,
+ however, that if the option to show teacher's gradings is turned on,
+ these gradings will be shown to the students at the end of the submission
+ phase.
+
+<P>The number of peer assesors can be zero. In which case the assignment
+ becomes either a self-graded assignment if that option is turned on, or
+ a normal teacher-graded assignment.
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Resubmitting assignments</B></P>
+
+<P>By default, students cannot resubmit assignments, they are allowed only one submission.</P>
+
+<P>If you turn this option on, then students will be allowed to submit more than one piece of work
+ to this assignment. This may be useful if the teacher wants to encourage students to do better
+ work by an iterative process.</P>
+
+<P>The assessment of submissions is allocated on the basis of the number of assessments a piece
+ of work has had. Thus new submissions from a student are likely to be candidates for peer
+ assessment. However, if a student resubmits a number of pieces of work in quick succession then
+ they are all equally likely to be assessed. The assignment does NOT give priority to the newest
+ submission.
+
+<P>When the student's final grade is calculated the submission with the highest grade is used. Here
+ highest grade means the weighted combination of the teacher's grade and the peer grade if
+ both are available.
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Self Assessment</B></P>
+
+<P>A workshop assignment can optionally include the student's own work
+ in the set of pieces each student is asked to assess. This will mean that if, say, the
+ number of student pieces of work each student has to assess is set at 5, then
+ each student will be asked to assess 6 pieces of work, one of them being their own work.
+
+<P>If the number of student pieces of work is set to zero and the self assessment option
+ is turned on then the assignment becomes a self-graded assignment. This
+ may or may not include the teacher's grading depending on the teacher's decision.
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>When to display Grades</B></P>
+
+<P>A peer graded assignment can have either of these characteristics:
+
+<OL>
+<LI>In the peer grading phase the students see the feedback on the
+ assessment elements, the general comment and the grades given
+ by the other students. The students are shown both the individual
+ assessment element grades and their overall grade. This may lead
+ into more disputes than the second type of peer graded assignment...
+
+<LI>In the peer grading phase the students see only the feadback on the
+ assessment elements and the general comment made by
+ the other students. The grades for the individual assessment elements are
+ not revealed (although they are held in the system). Further, the students
+ do not see their overall grades as given by their peers. Only when the
+ comments have been agreed are the grades (and the overall grade)
+ shown. This type of peer graded assignment is likely to be less
+ contentious than the first type.
+</OL>
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Specimen Grading Form</B></P>
+
+<P>This page shows shows the details of the actual form used to grade
+ your assignment. It will be used by the teacher to grade your work. Further,
+ in a peer graded asignment, the same form will be used by yourself and
+ your fellow students to grade the submitted pieces of work.
+
+<P>Please note that although you can change the grades and add text on
+ this form these changes are NOT saved. This is simply a specimen form,
+ but a very similar form will be used by the teacher and by you during this
+ assignment.
+
+
+</P>
--- /dev/null
+<P ALIGN=CENTER><B>Display of Teacher's Grades</B></P>
+
+<P>A peer graded assignment can optionally make the teacher's comments
+ and grades available to the student's. If desired, these are shown after the
+ submission deadline, or later if the grades are not available then. The teacher's
+ comments and grades may well help the students when making their own
+ (peer) assessments on other student's work.
+
+<P>Note that even when the peer grading is done anonymously, the
+ teacher's grades are always shown to the students with the teacher's
+ name and, if available, their photo.
+
+</P>
--- /dev/null
+<?PHP // $Id$
+
+$string['accumulative'] = "Accumulative";
+$string['action'] = "Action";
+$string['afterdeadline'] = "After Deadline: \$a";
+$string['allgradeshaveamaximumof'] = "All Grades have a Maximum of: \$a";
+$string['allowresubmit'] = "Allow Resubmissions";
+$string['alreadyinphase'] = "Already in Phase \$a";
+$string['amendassessmentelements'] = "Amend Assessment Elements";
+$string['assess'] = "Assess";
+$string['assessmentgrade'] = "Assessment Grade: \$a";
+$string['assessmentsby'] = "Assessments by \$a";
+$string['assessments'] = "Assessments";
+$string['assessmentsareok'] = "Assessments are OK";
+$string['assessmentsdone'] = "Assessments Done";
+$string['assessthissubmission'] = "Assess this submission";
+$string['assessmentofthissubmission'] = "Assessment of this submission";
+$string['assignmentnotinthecorrectphase'] = "Assignment not in the Correct Phase";
+$string['awaitinggradingbyteacher'] = "Awaiting Grading by \$a";
+$string['beforedeadline'] = "Before Deadline: \$a";
+$string['calculationoffinalgrades'] = "Calculation of Final Grades";
+$string['closeassignment'] = "Close Assignment";
+$string['comment'] = "Comment";
+$string['criteria'] = "Criteria";
+$string['deadline'] = "Deadline";
+$string['deadlineis'] = "The Deadline is \$a";
+$string['description'] = "Description";
+$string['detailsofassessment'] = "Details of Assessment";
+$string['displayoffinalgrades'] = "Display of Final Grades";
+$string['dontshowgrades'] = "Don't Show Grades";
+$string['edit'] = "Edit";
+$string['editingassessmentelements'] = "Editing Assessment Elements";
+$string['element'] = "Element";
+$string['elementweight'] = "Element Weight";
+$string['errorbanded'] = "Error Banded";
+$string['feedbackgoeshere'] = "Feedback goes here";
+$string['generalcomment'] = "General comment";
+$string['grade'] = "Grade";
+$string['gradeassessment'] = "Grade Assessment";
+$string['graded'] = "Graded";
+$string['gradedbyteacher'] = "Graded by \$a";
+$string['gradeforassessments'] = "Grade for Assessments";
+$string['gradeforbias'] = "Grade for Bias";
+$string['gradeforreliability'] = "Grade for Reliability";
+$string['gradeforstudentsassessment'] = "Grade for Student's Assessment";
+$string['gradeofsubmission'] = "Grade of Submission: \$a";
+$string['gradingstrategy'] = "Grading Strategy";
+$string['includeteachersgrade'] = "Include Teacher's Grade";
+$string['listofallsubmissions'] = "List of all Submissions";
+$string['managingassignment'] = "Managing Assignment";
+$string['maximumsize'] = "Maximum Size";
+$string['modulename'] = "Workshop";
+$string['modulenameplural'] = "Workshops";
+$string['movedtophase'] = "Moved to Phase \$a";
+$string['moveonto'] = "Move on to";
+$string['noassessmentsdone'] = "No Assessments Done";
+$string['nosubmissionsavailableforassessment'] = "No Submissions available for assessment";
+$string['notavailable'] = "Not Available";
+$string['noteonassessmentelements'] =
+ "Note that grading is broken down into a number of 'Assessment Elements'.<BR>
+ This makes the grading easier and more consistent. As teacher you must add these <BR>
+ Elements before making the assignment available to students. This is done by<BR>
+ clicking on the assignment in the course, if no elements are present you will be asked<BR>
+ to add them. You can change the number of elements using the Edit Assignment screen,<BR>
+ the elements themselves can be amended from the "Managing Assessment" screen. ";
+$string['notitlegiven'] = "No Title Given";
+$string['notgraded'] = "Not Graded";
+$string['numberofassessments'] = "Number of Assessments";
+$string['numberofassessmentelements'] = "Number of Comments, Assessment Elements, Grade Bands or Criteria Statments";
+$string['numberofassessmentsofstudentsubmissions'] = "Number of Assessments of Student Submissions";
+$string['numberofassessmentsofteachersexamples'] = "Number of Assessments of Examples from Teacher";
+$string['openassignment'] = "Open Assignment";
+$string['optionforpeergrade'] = "Option for Peer Grade";
+$string['overallgrade'] = "Overall Grade";
+$string['overallpeergrade'] = "Overall Peer Grade: \$a";
+$string['overallteachergrade'] = "Overall Teacher Grade: \$a";
+$string['ownwork'] = "Own Work";
+$string['phase'] = "Phase";
+$string['phase1'] = "Set Up Assignment";
+$string['phase2'] = "\$a Submissions and Assessments";
+$string['phase3'] = "Calculation of Final Grades";
+$string['phase4'] = "Show Final Grades";
+$string['pleaseassesstheseexamplesfromtheteacher'] = "Please assess these Examples from the \$a";
+$string['pleaseassessthesestudentsubmissions'] = "Please assess these \$a Submissions";
+$string['returntosubmissionpage'] = "Return to Submission Page";
+$string['savemyassessment'] = "Save my Assessment";
+$string['savedok'] = "Saved OK";
+$string['savemygrading'] = "Save my Grading";
+$string['scaleyes'] = "2 point Yes/No scale";
+$string['scalepresent'] = "2 point Present/Absent scale";
+$string['scalecorrect'] = "2 point Correct/Incorrect scale";
+$string['scalegood3'] = "3 point Good/Poor scale";
+$string['scaleexcellent4'] = "4 point Excellent/Very Poor scale";
+$string['scaleexcellent5'] = "5 point Excellent/Very Poor scale";
+$string['scaleexcellent7'] = "7 point Excellent/Very Poor scale";
+$string['scale10'] = "Score out of 10";
+$string['scale20'] = "Score out of 20";
+$string['scale100'] = "Score out of 100";
+$string['selfassessment'] = "Self Assessment";
+$string['showgrades'] = "Show Grades";
+$string['specimenassessmentform'] = "Specimen Assessment Form";
+$string['studentsassessment'] = "Student's Assessment";
+$string['studentgrades'] = "\$a Grades";
+$string['studentsubmissionsforassessment'] = "\$a Student Submissions for Assessment";
+$string['studentsubmissions'] = "\$a Submissions";
+$string['submitassignment'] = "Submit Assignment";
+$string['submitexampleassignment'] = "Submit Example Assignment";
+$string['submitted'] = "Submitted";
+$string['submissions'] = "Submissions";
+$string['returnto'] = "Return to";
+$string['teachersassessment'] = "Teacher's Assessment";
+$string['teacherscomment'] = "Teacher's Comment";
+$string['teachersgrade'] = "Teacher's Grade";
+$string['teachersubmissionsforassessment'] = "\$a Teacher Submissions for Assessment";
+$string['thegradeis'] = "The Grade is \$a";
+$string['theseasessmentsaregradedbytheteacher'] = "These Assessments are graded by the \$a";
+$string['timeassessed'] = "Time Assessed";
+$string['title'] = "Title";
+$string['typeofscale'] = "Type of Scale";
+$string['ungradedassessmentsofstudentsubmissions'] = "\$a Ungraded Assessments of Student Submissions";
+$string['ungradedassessmentsofteachersubmissions'] = "\$a Ungraded Assessments of Teacher Submissions";
+$string['view'] = "View";
+$string['viewassessmentofteacher'] = "View Assessment of \$a";
+$string['viewotherassessments'] = "View other Assessments";
+$string['warningonamendingelements'] = "WARNING: There are submitted assessments. <BR>Do NOT change the number
+ of elements, the scale types or the element weights.";
+$string['weightederrorcount'] = "Weighted Error Count: \$a";
+$string['weightforbias'] = "Weight for Bias";
+$string['weightforgradingofassessments'] = "Weight for Grading of Assessments";
+$string['weightforpeerassessments'] = "Weight for Peer Assessments";
+$string['weightforreliability'] = "Weight for Reliability";
+$string['weightforteachersassessment'] = "Weight for Teacher's Assessment";
+$string['weights'] = "Weights";
+$string['weightsusedforfinalgrade'] = "Weights used for Final Grade";
+$string['weightsusedforsubmissions'] = "Weights used for Submissions";
+$string['yourassessments'] = "Your Assessments";
+
+?>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="content-type"
+ content="text/html; charset=ISO-8859-1">
+ <title>Another Assignment Overview</title>
+</head>
+<body>
+<h2> Another Assignment Module</h2>
+<br>
+<div style="margin-left: 40px;"> "Assessment is the most powerful lever
+teachers have to influence the way students respond to courses and
+behave as learners"<br>
+</div>
+<br>
+<div style="text-align: right; margin-left: 80px;"><small> from Graham
+Gibbs, "Using Assessment Strategically to Change the Way Students Learn"
+in "Asessment Matter in Higher Education, edited by Sally Brown and
+Angela Glasner, OU Press, 1999</small><br>
+</div>
+<br>
+<h3>Overview</h3>
+This new module enables the teacher to set up a controlled assignment
+which encourages students to become more critical of both their own work
+and that of others. In its standard form, the module usually begins with
+a preparatory phase where the teacher sets up the assessment criteria.
+These will depend on which assessment strategy the teacher decides to
+use for the assignment. There are four separate strategies:<br>
+<ol>
+ <li><b>No grading:</b> In this type of assignment the teacher is not
+ interested in quantative assessment from the students at all. The
+students make comments of the pieces of works but not not grade them.
+The teacher, however, can, if desired, grade the student comments.
+These "grading grades" form the basis of the students' final grades.
+ If the teacher does not grade the student assessments then the
+assignment does not have any final grades. </li>
+ <li><b>Accumulative grading:</b> This is the default type of grading.
+ In this type of assignment the grade of each assessment is made up of
+a number of "assessment elements". Each element should cover a
+particular aspect of the assignment. Typically an assignment will have
+ something between 5 to 15 elements for comments and grading, the
+ actual number depending on the size and complexity of the assignment. A
+peer assignment with only one element is allowed and has a similar
+assessment strategy to the standard Moodle Assignment.</li>
+ <li><b>Error Banded Grading:</b> In this type of assignment the
+submissions are graded on a set of Yes/No scales. The grade is
+determined by the "Grade Table " which gives the relationship between
+the number of "errors" and the suggested grade. For example an
+assignment may have six significant items which should be present, the
+Grade Table will give suggested grades if all are present, one is
+absent, if two are absent, etc.</li>
+ <li><b>Criteria Grading:</b> This is simpliest type of assessment to
+grade (although not necessarily the most straightforward to set up).
+The submissions are graded against a set of criterion statments. The
+assessor choses which statement best fits the piece of work. The grade
+is determined by a "Criteria Table" which gives the suggested grade
+for each criterion. </li>
+</ol>
+Next the teacher submits a small number (probably between 5 and 10)
+example pieces of work. These most likely have been gleaned from
+previous cohorts and should probably include both good and poor attempts
+at the assignment.<br>
+<br>
+Lastly the teacher assesses these examples using the "grading form" set
+up for the asssignment. The teacher's assessments are there to guide the
+students when they start the assignment.<br>
+<br>
+With these three sets of items in place, the assessment elements (and
+possibly the associated grade table), the example assignments and the
+specimen assessments, the assignment can be opened up to the students.
+The students' first task is usually to assess a selection of the
+example assignments. As these assessments are produced the teacher
+reviews them and, if satisfactory, the individual students are allowed
+to progress to the next stage. The teacher may ask a student to
+re-assess one or more of the example assessments. This should be easy to
+do as once an example assignment is assessed the student is able to view
+the teacher's "specimen" assessments. This loop is basically there to
+check that the weaker students are aware of the specimen assessments and
+have looked at them.<br>
+<br>
+At the end of this initial stage the students should have a fair idea
+of what the assignment is about and how it is being assessed. They are
+now allowed to submit their own work. This is not a fixed milestone,
+each student will reach this second stage independently. With all the
+inital assessments graded the teacher can sit back and let the module
+run until the deadline date.<br>
+<br>
+The module can be set up to allow single submission or multiple
+submissions. Depending on this setting, the student' first submission is
+either their first draft or their only attempt.When the students have
+submitted work they are asked to assess work from the other students.
+They are also shown the assessments of their own work by the other
+students. However, they must do at least one assessment before they are
+shown the peer assessments. When the assignment allows resubmission the
+student may, in the light of the feedback, revise their work and submit
+a new copy for peer assessment. The peer assessment of student
+submissions continues until the deadline date is reached.<br>
+<br>
+The teacher now has several choices. The module allows a flexible
+approach to calculating the final grade for the students. In fact, the
+final grade can be a teacher-defined combination of:<br>
+<ol>
+ <li>The teacher's grade of the (final) submission</li>
+ <li>The average peer grade of the (final) submission</li>
+ <li>The student's grading performance</li>
+</ol>
+Obviously if (1) is to be included then the teacher has to assess the
+student submissions after the deadline. There is no real need for the
+students' assessments produced during the peer asessment phase to be
+graded by the teacher. The module can assess the quality of these
+assignments by internal comparison. This is probably just as well as the
+number of assessments generated at that phase could be quite large even
+for reasonably sized classes. The final phase of the module is the
+release of the final grades to the students.<br>
+<br>
+Thus the module normally runs through four phases:<br>
+<ol>
+ <li>Set up</li>
+ <li>Student assessment of the example assignments, submission of work
+and peer assessment</li>
+ <li>Calculation of final grades</li>
+ <li>Release of final grades</li>
+</ol>
+And there's a single deadline occurring between phases 2 and 3.<br>
+<br>
+<h3>Variants</h3>
+That describes the "standard" assignment which this module supports.
+The module also lends itself to a few other types of assignment. For
+example, a "case study" assignment can be handled where the teacher
+sets up a number of scenarios for the students to comment on. Here there
+are no student submissions the teacher simply grades the students
+responses to each scenario and uses those to calculate the final grades.<br>
+<br>
+A second example using the module in an abbrieviated way is as a simple
+peer assessment assignment. Here the teacher sets up the assessment
+elements but does not submit any example assignments and the students go
+straight in to the peer assessment phase, possibly going where no class
+has boldly gone before!<br>
+<br>
+For certain assignments the teacher may decide that the example
+assignments would simply lead the students into doing a cut-and-paste
+exercise to produce their assignments. Here the initial assessment phase
+would be better performed on a set of examples from a related subject
+rather than those directly pertaining to the particular assignment. In
+this way the students are shown what is expected of them and how it is
+being assessed but "the cat is still in the bag" so to speak. Careful
+monitoring of the assignment would be necessary else many students, not
+reading the instructions, would reproduce the examples rather then the
+required assignment.<br>
+<br>
+The module can also be set up to ask the students to asssess their own
+work. That is instead of peer assessment the assignment becomes one
+involving self assessment. Here it is likely that the teacher would
+grade the (self) assessments make in the second half of phase 2 and
+include these grades in the final grades.<br>
+<br>
+<h3>Conclusion</h3>
+Thus the module is quite flexible while still being relatively easy to
+set up and run. The module has been keep purposely simple. For example
+it does not allow the students to enter into an assessment - reply -
+assessment cycle during the peer assessment phase. If that
+sophistication is required then the Peer Graded Assignment module should
+be used. Other technical restrictions are that the submitted assignments
+are limited to a single file, that is although multiple submissions are
+allowed each submission can only be just one file. The files themselves
+are limited to a prediefined size and the module does not support links
+to external pieces of work.<br>
+ <br>
+Ray Kingdon <br>
+April 2003<br>
+<br>
+</body>
+</html>
--- /dev/null
+<?PHP
+/* assessments.php: version 1.0 30th April 2003 */
+
+/*************************************************
+ ACTIONS handled are:
+
+ assesssubmission
+ displayelements
+ editelements (teachers only)
+ gradeassessment (teachers only)
+ insertelements (for teachers)
+ listungradedstudentsubmissions (for teachers)
+ listungradedteachersubmissions (for teachers)
+ listteachersubmissions
+ updateassessment
+ updategrading
+ viewassessment
+
+************************************************/
+
+ require("../../config.php");
+ require("lib.php");
+
+ error_reporting(15);
+
+ optional_variable($id); // Course Module ID
+ optional_variable($a); // workshop ID
+
+ // get some useful stuff...
+ if ($id) {
+ if (! $cm = get_record("course_modules", "id", $id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ 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");
+ }
+
+ } else {
+ if (! $workshop = get_record("workshop", "id", $a)) {
+ error("Course module is incorrect");
+ }
+ if (! $course = get_record("course", "id", $workshop->course)) {
+ error("Course is misconfigured");
+ }
+ if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
+ error("Course Module ID was incorrect");
+ }
+ }
+
+ require_login($course->id);
+
+ if ($course->category) {
+ $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
+ }
+
+ $strworkshops = get_string("modulenameplural", "workshop");
+ $strworkshop = get_string("modulename", "workshop");
+ $strassessments = get_string("assessments", "workshop");
+
+ // ... print the header and...
+ print_header("$course->shortname: $workshop->name", "$course->fullname",
+ "$navigation <A HREF=index.php?id=$course->id>$strworkshops</A> ->
+ <A HREF=\"view.php?a=$workshop->id\">$workshop->name</A> -> $strassessments",
+ "", "", true);
+
+ //...get the action
+ require_variable($action);
+
+
+/*************** Assess submission (by teacher or student) ***************************/
+ if ($action == 'assesssubmission') {
+
+ require_variable($sid);
+
+ if (! $submission = get_record("workshop_submissions", "id", $sid)) {
+ error("assess submission is misconfigured");
+ }
+
+ $yearfromnow = time() + 365 * 86400;
+ // is there an assessment record, create one and set timecreated way in the future, this is reset when record is updated
+ if (!$assessment = workshop_get_submission_assessment($submission, $USER)) {
+ $assessment->workshopid = $workshop->id;
+ $assessment->submissionid = $submission->id;
+ $assessment->userid = $USER->id;
+ $assessment->grade = -1; // set impossible grade
+ $assessment->timecreated = $yearfromnow;
+ $assessment->timegraded = 0;
+ if (!$assessment->id = insert_record("workshop_assessments", $assessment)) {
+ error("Could not insert workshop assessment!");
+ }
+ }
+
+ print_heading_with_help(get_string("assessthissubmission", "workshop"), "grading", "workshop");
+
+ echo "<CENTER><TABLE BORDER=1 WIDTH=\"30%\"><TR><TD ALIGN=CENTER BGCOLOR=\"$THEME->cellcontent\">";
+ echo workshop_print_submission_title($workshop, $submission);
+ echo "</TD></TR></TABLE><BR CLEAR=ALL>\n";
+ workshop_print_assessment($workshop, $assessment, TRUE);
+ }\r
+
+
+ /*************** display elements (viewed by student) *********************************/
+ elseif ($action == 'displaygradingform') {
+
+ print_heading_with_help(get_string("specimengradingform", "workshop"), "specimen", "workshop");
+ $assessment = ''; // needed?
+ workshop_print_assessment($workshop, $assessment);
+ }\r
+
+
+ /*********************** edit assessment elements (for teachers) ***********************/
+ elseif ($action == 'editelements') {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ $count = count_records("workshop_grades", "workshop", $workshop->id);
+ if ($workshop->phase > 1 and $count) {
+ notify(get_string("warningonamendingelements", "workshop"));
+ }
+ // set up heading, form and table
+ print_heading_with_help(get_string("editingassessmentelements", "workshop"), "elements", "workshop");
+ ?>
+ <form name="form" method="post" action="assessments.php">
+ <input type="hidden" name="id" value="<?PHP echo $cm->id ?>">
+ <input type="hidden" name="action" value="insertelements">
+ <CENTER><TABLE cellpadding=5 border=1>
+ <?PHP
+
+ // get existing elements, if none set up appropriate default ones
+ if ($elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC" )) {
+ foreach ($elementsraw as $element) {
+ $elements[] = $element; // to renumber index 0,1,2...
+ }
+ }
+ // check for missing elements (this happens either the first time round or when the number of elements is icreased)
+ for ($i=0; $i<$workshop->nelements; $i++) {
+ if (!isset($elements[$i])) {
+ $elements[$i]->description = '';
+ $elements[$i]->scale =0;
+ $elements[$i]->weight = 11;
+ }
+ }
+ switch ($workshop->gradingstrategy) {
+ case 0: // no grading
+ for ($i=0; $i<$workshop->nelements; $i++) {
+ $iplus1 = $i+1;
+ echo "<TR valign=top>\n";\r
+ echo " <TD ALIGN=RIGHT><P><B>". get_string("element","workshop")." $iplus1:</B></TD>\n";\r
+ echo "<TD><textarea name=\"description[]\" rows=3 cols=75 wrap=\"virtual\">".$elements[$i]->description."</textarea>\n";\r
+ echo " </TD></TR>\n";
+ echo "<TR valign=top>\n";\r
+ echo " <TD colspan=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ echo "</TR>\n";
+ }
+ break;
+
+ case 1: // accumulative grading
+ // set up scales name
+ foreach ($WORKSHOP_SCALES as $KEY => $SCALE) {
+ $SCALES[] = $SCALE['name'];
+ }
+ for ($i=0; $i<$workshop->nelements; $i++) {
+ $iplus1 = $i+1;
+ echo "<TR valign=top>\n";\r
+ echo " <TD ALIGN=RIGHT><P><B>". get_string("element","workshop")." $iplus1:</B></TD>\n";\r
+ echo "<TD><textarea name=\"description[]\" rows=3 cols=75 wrap=\"virtual\">".$elements[$i]->description."</textarea>\n";\r
+ echo " </TD></TR>\n";
+ echo "<TR valign=top>\n";
+ echo " <TD align=right><P><B>". get_string("typeofscale", "workshop"). ":</B></P></TD>\n";
+ echo "<TD valign=\"top\">\n";
+ choose_from_menu($SCALES, "scale[]", $elements[$i]->scale, "");
+ if ($elements[$i]->weight == '') { // not set
+ $elements[$i]->weight = 11; // unity
+ }
+ echo "</TR>\n";
+ echo "<TR valign=top><TD ALIGN=RIGHT><B>".get_string("elementweight", "workshop").":</B></TD><TD>\n";
+ workshop_choose_from_menu($WORKSHOP_EWEIGHTS, "weight[]", $elements[$i]->weight, "");
+ echo " </TD>\n";
+ echo "</TR>\n";
+ echo "<TR valign=top>\n";\r
+ echo " <TD colspan=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ echo "</TR>\n";
+ }
+ break;
+
+ case 2: // error banded grading
+ if ($elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC" )) {
+ foreach ($elementsraw as $element) {
+ $elements[] = $element; // to renumber index 0,1,2...
+ }
+ }
+ else { // set up the elements array with default values
+ for ($i=0; $i<=$workshop->nelements; $i++) {
+ $elements[$i]->description = '';
+ $elements[$i]->maxscore =0;
+ }
+ }
+ for ($i=0; $i<$workshop->nelements; $i++) {
+ $iplus1 = $i+1;
+ echo "<TR valign=top>\n";\r
+ echo " <TD ALIGN=RIGHT><P><B>". get_string("element","workshop")." $iplus1:</B></TD>\n";\r
+ echo "<TD><textarea name=\"description[$i]\" rows=3 cols=75 wrap=\"virtual\">".$elements[$i]->description."</textarea>\n";\r
+ echo " </TD></TR>\n";
+ if ($elements[$i]->weight == '') { // not set
+ $elements[$i]->weight = 11; // unity
+ }
+ echo "</TR>\n";
+ echo "<TR valign=top><TD ALIGN=RIGHT><B>".get_string("elementweight", "workshop").":</B></TD><TD>\n";
+ workshop_choose_from_menu($WORKSHOP_EWEIGHTS, "weight[]", $elements[$i]->weight, "");
+ echo " </TD>\n";
+ echo "</TR>\n";
+ echo "<TR valign=top>\n";\r
+ echo " <TD colspan=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ echo "</TR>\n";
+ }
+ echo "</CENTER></TABLE><BR>\n";
+ echo "<P><CENTER><B>".get_string("gradetable","workshop")."</B></CENTER>\n";
+ echo "<CENTER><TABLE cellpadding=5 border=1><TR><TD ALIGN=\"CENTER\">".
+ get_string("numberofnegativeresponses", "workshop");
+ echo "</TD><TD>". get_string("suggestedgrade", "workshop")."</TD></TR>\n";
+ for ($j = 100; $j >= 0; $j--) {
+ $numbers[$j] = $j;
+ }
+ for ($i=0; $i<=$workshop->nelements; $i++) {
+ echo "<TR><TD ALIGN=\"CENTER\">$i</TD><TD ALIGN=\"CENTER\">";
+ choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, "");
+ echo "</TD></TR>\n";
+ }
+ echo "</TABLE></CENTER>\n";
+ break;
+
+ case 3: // criteria grading
+ if ($elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC" )) {
+ foreach ($elementsraw as $element) {
+ $elements[] = $element; // to renumber index 0,1,2...
+ }
+ }
+ else { // set up the elements array with default values
+ for ($i=0; $i<=$workshop->nelements; $i++) {
+ $elements[$i]->description = '';
+ $elements[$i]->maxscore =0;
+ }
+ }
+ for ($j = 100; $j >= 0; $j--) {
+ $numbers[$j] = $j;
+ }
+ for ($i=0; $i<$workshop->nelements; $i++) {
+ $iplus1 = $i+1;
+ echo "<TR valign=top>\n";\r
+ echo " <TD ALIGN=RIGHT><P><B>". get_string("criterion","workshop")." $iplus1:</B></TD>\n";\r
+ echo "<TD><textarea name=\"description[$i]\" rows=3 cols=75 wrap=\"virtual\">".$elements[$i]->description."</textarea>\n";\r
+ echo " </TD></TR>\n";
+ echo "<TR><TD><B>". get_string("suggestedgrade", "workshop").":</B></TD><TD>\n";
+ choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, "");
+ echo "</TD></TR>\n";
+ echo "<TR valign=top>\n";\r
+ echo " <TD colspan=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ echo "</TR>\n";
+ }
+ break;
+ }
+ // close table and form\r
+ ?>
+ </TABLE>
+ <input type="submit" value="<? print_string("savechanges") ?>">
+ <input type="submit" name=cancel value="<? print_string("cancel") ?>">
+ </CENTER>\r
+ </FORM>
+ <?PHP
+ }
+
+
+ /*************** grade (student's) assessment (by teacher) ***************************/
+ elseif ($action == 'gradeassessment') {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ // set up coment scale
+ for ($i=COMMENTSCALE; $i>=0; $i--) {
+ $num[$i] = $i;
+ }
+
+ print_heading_with_help(get_string("gradeassessment", "workshop"), "gradingassessments", "workshop");
+ // get assessment record
+ if (!$assessmentid = $_GET['aid']) {
+ 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");
+ }
+ echo "<BR><P><B>".workshop_print_submission_title($workshop, $submission)."</B><BR><BR>\n";
+ // get the teacher's assessment first
+ if ($teachersassessment = workshop_get_submission_assessment($submission, $USER)) {
+ echo "<P><B>".get_string("teachersassessment", "workshop")."</B>\n";
+ workshop_print_assessment($workshop, $teachersassessment);
+ }
+ // now the student's assessment
+ echo "<P><B>".get_string("studentsassessment", "workshop")."</B>\n";
+ workshop_print_assessment($workshop, $assessment);
+
+ ?>
+ <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'] ?>">
+ <CENTER>
+ <TABLE CELLPADDING=5 BORDER=1>
+ <?PHP
+
+ // now get the teacher's comment
+ echo "<TR valign=top>\n";\r
+ echo " <TD align=right><P><B>". get_string("teacherscomment", "workshop").":</B></P></TD>\n";\r
+ echo " <TD>\n";\r
+ echo " <textarea name=\"teachercomment\" rows=5 cols=75 wrap=\"virtual\">\n";
+ if (isset($assessment->teachercomment)) {
+ echo $assessment->teachercomment;
+ }
+ echo "</textarea>\n";\r
+ echo " </TD>\n";\r
+ echo "</TR>\n";\r
+ echo "<TR><TD ALIGN=RIGHT><B>".get_string("gradeforstudentsassessment", "workshop")."</TD><TD>\n";
+ choose_from_menu($num, "gradinggrade", $assessment->gradinggrade, "");
+ echo "</TD></TR></TABLE>\n";
+ echo "<INPUT TYPE=submit VALUE=\"".get_string("savemygrading", "workshop")."\">\n";
+ echo "</CENTER></FORM>\n";
+ }\r
+
+
+ /*********************** insert/update assignment elements (for teachers)***********************/
+ elseif ($action == 'insertelements') {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ $form = (object)$HTTP_POST_VARS;
+
+ // let's not fool around here, dump the junk!
+ delete_records("workshop_elements", "workshopid", $workshop->id);
+
+ // determine wich type of grading
+ switch ($workshop->gradingstrategy) {
+ case 0: // no grading
+ // Insert all the elements that contain something
+ foreach ($form->description as $key => $description) {
+ if ($description) {
+ unset($element);
+ $element->description = $description;
+ $element->workshopid = $workshop->id;
+ $element->elementno = $key;
+ if (!$element->id = insert_record("workshop_elements", $element)) {
+ error("Could not insert workshop element!");
+ }
+ }
+ }
+ break;
+
+ case 1: // accumulative grading
+ // Insert all the elements that contain something
+ foreach ($form->description as $key => $description) {
+ if ($description) {
+ unset($element);
+ $element->description = $description;
+ $element->workshopid = $workshop->id;
+ $element->elementno = $key;
+ if (isset($form->scale[$key])) {
+ $element->scale = $form->scale[$key];
+ switch ($WORKSHOP_SCALES[$form->scale[$key]]['type']) {
+ case 'radio' : $element->maxscore = $WORKSHOP_SCALES[$form->scale[$key]]['size'] - 1;
+ break;
+ case 'selection' : $element->maxscore = $WORKSHOP_SCALES[$form->scale[$key]]['size'];
+ break;
+ }
+ }
+ if (isset($form->weight[$key])) {
+ $element->weight = $form->weight[$key];
+ }
+ if (!$element->id = insert_record("workshop_elements", $element)) {
+ error("Could not insert workshop element!");
+ }
+ }
+ }
+ break;
+
+ case 2: // error banded grading...
+ case 3: // ...and criteria grading
+ // Insert all the elements that contain something, the number of descriptions is one less than the number of grades
+ foreach ($form->maxscore as $key => $themaxscore) {
+ unset($element);
+ $element->workshopid = $workshop->id;
+ $element->elementno = $key;
+ $element->maxscore = $themaxscore;
+ if (isset($form->description[$key])) {
+ $element->description = $form->description[$key];
+ }
+ if (isset($form->weight[$key])) {
+ $element->weight = $form->weight[$key];
+ }
+ if (!$element->id = insert_record("workshop_elements", $element)) {
+ error("Could not insert workshop element!");
+ }
+ }
+ break;
+ } // end of switch
+
+ echo "<P>\n";
+ notice_yesno(get_string("amendassessmentelements","workshop")." ".get_string("again"),
+ "assessments.php?id=$cm->id&action=editelements", "view.php?id=$cm->id");
+ }
+
+
+ /*********************** list assessments for grading (Student submissions)(by teachers)***********************/
+ elseif ($action == 'listungradedstudentsubmissions') {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+ workshop_list_ungraded_assessments($workshop, "student");
+ print_continue("view.php?a=$workshop->id");
+ }
+
+
+ /*********************** list assessments for grading (Teacher submissions) (by teachers)***********************/
+ elseif ($action == 'listungradedteachersubmissions') {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+ workshop_list_ungraded_assessments($workshop, "teacher");
+ print_continue("view.php?a=$workshop->id");
+ }
+
+
+ /*********************** list teacher submissions ***********************/
+ elseif ($action == 'listteachersubmissions') {
+
+ workshop_list_teacher_submissions($workshop, $USER);
+ print_continue("view.php?a=$workshop->id");
+ }
+
+
+ /*************** update assessment (by teacher or student) ***************************/
+ elseif ($action == 'updateassessment') {
+
+ require_variable($aid);
+ if (! $assessment = get_record("workshop_assessments", "id", $aid)) {
+ error("workshop assessment is misconfigured");
+ }
+
+ // first get the assignment elements for maxscores and weights...
+ if (!$elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC")) {
+ print_string("noteonassignmentelements", "workshop");
+ }
+ else {
+ foreach ($elementsraw as $element) {
+ $elements[] = $element; // to renumber index 0,1,2...
+ }
+ }
+
+ $timenow = time();
+ // don't fiddle about, delete all the old and add the new!
+ delete_records("workshop_grades", "assessmentid", $assessment->id);
+
+ $form = (object)$HTTP_POST_VARS;
+
+ //determine what kind of grading we have
+ switch ($workshop->gradingstrategy) {
+ case 0: // no grading
+ // Insert all the elements that contain something
+ foreach ($form->feedback as $key => $thefeedback) {
+ unset($element);
+ $element->workshopid = $workshop->id;
+ $element->assessmentid = $assessment->id;
+ $element->elementno = $key;
+ $element->feedback = $thefeedback;
+ if (!$element->id = insert_record("workshop_grades", $element)) {
+ error("Could not insert workshop element!");
+ }
+ }
+ $grade = 0; // set to satisfy save to db
+ break;
+
+ case 1: // accumulative grading
+ // Insert all the elements that contain something
+ foreach ($form->grade as $key => $thegrade) {
+ unset($element);
+ $element->workshopid = $workshop->id;
+ $element->assessmentid = $assessment->id;
+ $element->elementno = $key;
+ $element->feedback = $form->feedback[$key];
+ $element->grade = $thegrade;
+ if (!$element->id = insert_record("workshop_grades", $element)) {
+ error("Could not insert workshop element!");
+ }
+ }
+ // now work out the grade...
+ $rawgrade=0;
+ $totalweight=0;
+ foreach ($form->grade as $key => $grade) {
+ $maxscore = $elements[$key]->maxscore;
+ $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight];
+ if ($weight > 0) {
+ $totalweight += $weight;
+ }
+ $rawgrade += ($grade / $maxscore) * $weight;
+ // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade<BR>";
+ }
+ $grade = $workshop->grade * ($rawgrade / $totalweight);
+ break;
+
+ case 2: // error banded graded
+ // Insert all the elements that contain something
+ $error = 0.0;
+ for ($i =0; $i < $workshop->nelements; $i++) {
+ unset($element);
+ $element->workshopid = $workshop->id;
+ $element->assessmentid = $assessment->id;
+ $element->elementno = $i;
+ $element->feedback = $form->feedback[$i];
+ $element->grade = $form->grade[$i];
+ if (!$element->id = insert_record("workshop_grades", $element)) {
+ error("Could not insert workshop element!");
+ }
+ if (empty($form->grade[$i])){
+ $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight];
+ }
+ }
+ // now save the adjustment
+ unset($element);
+ $i = $workshop->nelements;
+ $element->workshopid = $workshop->id;
+ $element->assessmentid = $assessment->id;
+ $element->elementno = $i;
+ $element->grade = $form->grade[$i];
+ if (!$element->id = insert_record("workshop_grades", $element)) {
+ error("Could not insert workshop element!");
+ }
+ $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * $workshop->grade / 100;
+ echo "<P><B>".get_string("weightederrorcount", "workshop", intval($error + 0.5))."</B>\n";
+ break;
+
+ case 3: // criteria grading
+ // save in the selected criteria value in element zero,
+ unset($element);
+ $element->workshopid = $workshop->id;
+ $element->assessmentid = $assessment->id;
+ $element->elementno = 0;
+ $element->grade = $form->grade[0];
+ if (!$element->id = insert_record("workshop_grades", $element)) {
+ error("Could not insert workshop element!");
+ }
+ // now save the adjustment in element one
+ unset($element);
+ $element->workshopid = $workshop->id;
+ $element->assessmentid = $assessment->id;
+ $element->elementno = 1;
+ $element->grade = $form->grade[1];
+ if (!$element->id = insert_record("workshop_grades", $element)) {
+ error("Could not insert workshop element!");
+ }
+ $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * $workshop->grade / 100;
+ } // end of switch
+
+ // update the time of the assessment record (may be re-edited)...
+ set_field("workshop_assessments", "timecreated", $timenow, "id", $assessment->id);
+ set_field("workshop_assessments", "grade", $grade, "id", $assessment->id);
+ // ...and clear any grading of this assessment
+ set_field("workshop_assessments", "timegraded", 0, "id", $assessment->id);
+ set_field("workshop_assessments", "gradinggrade", 0, "id", $assessment->id);
+
+ // any comment?
+ if (!empty($form->generalcomment)) {
+ set_field("workshop_assessments", "generalcomment", $form->generalcomment, "id", $assessment->id);
+ }
+
+ // show grade if grading strategy is not zero
+ if ($workshop->gradingstrategy) {
+ echo "<B>".get_string("thegradeis", "workshop").": ".number_format($grade, 2)."% (".get_string("maximumgrade").
+ " ".number_format($workshop->grade)."%)</B>\n";
+ }
+
+ print_continue("view.php?id=$cm->id");
+
+ add_to_log($course->id, "workshop", "assess", "view.php?a=$workshop->id", "$workshop->id");
+ }
+
+
+ /*************** update grading (by teacher) ***************************/
+ elseif ($action == 'updategrading') {
+ $timenow = time();
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ $form = (object)$_POST;
+
+ if (!$assessment = get_record("workshop_assessments", "id", $_POST['aid'])) {
+ error("Update Grading failed");
+ }
+ //save the comment and grade for the assessment
+ if (isset($form->teachercomment)) {
+ set_field("workshop_assessments", "teachercomment", $form->teachercomment, "id", $assessment->id);
+ set_field("workshop_assessments", "gradinggrade", $form->gradinggrade, "id", $assessment->id);
+ set_field("workshop_assessments", "timegraded", $timenow, "id", $assessment->id);
+ set_field("workshop_assessments", "mailed", 0, "id", $assessment->id);
+ echo "<CENTRE><B>".get_string("savedok", "workshop")."</B></CENTER><BR>\n";
+
+ add_to_log($course->id, "workshop", "grade", "view.php?id=$cm->id", "$workshop->id");
+ }
+ switch ($form->stype) {
+ case "student" :
+ print_continue("assessments.php?action=listungradedstudentsubmissions&id=$cm->id");
+ break;
+ case "teacher" :
+ print_continue("assessments.php?action=listungradedteachersubmissions&id=$cm->id");
+ break;
+ }
+ }\r
+
+
+ /*********************** view all assessments ***********************/
+ elseif ($action == 'viewallassessments') {
+
+ if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) {
+ error("View All Assessments: submission record not found");
+ }
+
+ if ($assessments = workshop_get_assessments($submission)) {
+ echo "<CENTER><TABLE BORDER=1 WIDTH=\"30%\"><TR><TD ALIGN=CENTER BGCOLOR=\"$THEME->cellcontent\">";
+ echo workshop_print_submission_title($workshop, $submission);
+ echo "</TD></TR></TABLE><BR CLEAR=ALL>\n";
+ foreach ($assessments as $assessment) {
+ workshop_print_assessment($workshop, $assessment);
+ }
+ }
+ // only called from list all submissions
+ print_continue("submissions.php?action=listallsubmissions&id=$cm->id");
+ }
+
+
+ /*********************** view assessment ***********************/
+ elseif ($action == 'viewassessment') {
+ // get the assessment record
+ if (!$assessment = get_record("workshop_assessments", "id", $_GET['aid'])) {
+ error("Assessment record not found");
+ }
+
+ echo "<CENTER><TABLE BORDER=1 WIDTH=\"30%\"><TR><TD ALIGN=CENTER BGCOLOR=\"$THEME->cellcontent\">";
+ $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
+ echo workshop_print_submission_title($workshop, $submission);
+ echo "</TD></TR></TABLE><BR CLEAR=ALL>\n";
+
+ workshop_print_assessment($workshop, $assessment);
+ print_continue("view.php?a=$workshop->id");
+ }
+
+
+ /*************** no man's land **************************************/\r
+ else {\r
+ error("Fatal Error: Unknown Action: ".$action."\n");\r
+ }\r
+
+ print_footer($course);
+
+?>
+
--- /dev/null
+<?PHP // $Id$
+
+function gallery_upgrade($oldversion) {
+// This function does anything necessary to upgrade
+// older versions to match current functionality
+
+ global $CFG;
+
+ if ($oldversion < 2003043000) {
+
+ }
+ return true;
+}
+
+
+?>
+
--- /dev/null
+#
+# Table structure for table `workshop`
+#
+
+CREATE TABLE `prefix_workshop` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `course` int(10) unsigned NOT NULL default '0',
+ `name` varchar(255) NOT NULL default '',
+ `description` text NOT NULL,
+ `nelements` tinyint(3) unsigned NOT NULL default '10',
+ `phase` tinyint(2) unsigned NOT NULL default '0',
+ `format` tinyint(2) unsigned NOT NULL default '0',
+ `gradingstrategy` tinyint(2) unsigned NOT NULL default '1',
+ `resubmit` tinyint(2) unsigned NOT NULL default '0',
+ `graded` tinyint(2) unsigned NOT NULL default '1',
+ `showgrades` tinyint(2) unsigned NOT NULL default '0',
+ `anonymous` tinyint(2) unsigned NOT NULL default '0',
+ `includeself` tinyint(2) unsigned NOT NULL default '0',
+ `maxbytes` int(10) unsigned NOT NULL default '100000',
+ `deadline` int(10) unsigned NOT NULL default '0',
+ `grade` int(10) NOT NULL default '0',
+ `ntassessments` tinyint(3) unsigned NOT NULL default '0',
+ `nsassessments` tinyint(3) unsigned NOT NULL default '0',
+ `timemodified` int(10) unsigned NOT NULL default '0',
+ `mergegrades` tinyint(3) unsigned NOT NULL default '0',
+ `teacherweight` tinyint(3) unsigned NOT NULL default '5',
+ `peerweight` tinyint(3) unsigned NOT NULL default '5',
+ `includeteachersgrade` tinyint(3) unsigned NOT NULL default '0',
+ `biasweight` tinyint(3) unsigned NOT NULL default '5',
+ `reliabilityweight` tinyint(3) unsigned NOT NULL default '5',
+ `gradingweight` tinyint(3) unsigned NOT NULL default '5',
+ PRIMARY KEY (`id`)
+) COMMENT='Defines workshop';
+# --------------------------------------------------------
+
+#
+# Table structure for table `workshop_submissions`
+#
+
+CREATE TABLE `prefix_workshop_submissions` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `workshopid` int(10) unsigned NOT NULL default '0',
+ `userid` int(10) unsigned NOT NULL default '0',
+ `title` varchar(100) NOT NULL default '',
+ `timecreated` int(10) unsigned NOT NULL default '0',
+ `mailed` tinyint(2) unsigned NOT NULL default '0',
+ `teachergrade` int(3) unsigned NOT NULL default '0',
+ `peergrade` int(3) unsigned NOT NULL default '0',
+ `biasgrade` int(3) unsigned NOT NULL default '0',
+ `reliabilitygrade` int(3) unsigned NOT NULL default '0',
+ `gradinggrade` int(3) unsigned NOT NULL default '0',
+ `finalgrade` int(3) unsigned NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ INDEX `title` (`title`)
+) COMMENT='Info about submitted work from teacher and students';
+# --------------------------------------------------------
+
+#
+# Table structure for table `workshop_assessments`
+#
+
+CREATE TABLE `prefix_workshop_assessments` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `workshopid` int(10) unsigned NOT NULL default '0',
+ `submissionid` int(10) unsigned NOT NULL default '0',
+ `userid` int(10) unsigned NOT NULL default '0',
+ `timecreated` int(10) unsigned NOT NULL default '0',
+ `timegraded` int(10) unsigned NOT NULL default '0',
+ `grade` float NOT NULL default '0',
+ `gradinggrade` int(3) NOT NULL default '0',
+ `mailed` tinyint(2) unsigned NOT NULL default '0',
+ `generalcomment` text NOT NULL,
+ `teachercomment` text NOT NULL,
+ PRIMARY KEY (`id`)
+ ) COMMENT='Info about assessments by teacher and students';
+# --------------------------------------------------------
+
+#
+# Table structure for table `workshop_elements`
+#
+
+CREATE TABLE `prefix_workshop_elements` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `workshopid` int(10) unsigned NOT NULL default '0',
+ `elementno` tinyint(3) unsigned NOT NULL default '0',
+ `description` text NOT NULL,
+ `scale` tinyint(3) unsigned NOT NULL default '0',
+ `maxscore` tinyint(3) unsigned NOT NULL default '1',
+ `weight` float NOT NULL default '1.0',
+ PRIMARY KEY (`id`)
+) COMMENT='Info about marking scheme of assignment';
+# --------------------------------------------------------
+
+#
+# Table structure for table `workshop_grades`
+#
+
+CREATE TABLE `prefix_workshop_grades` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+# workshop not necessary just makes deleting instance easier
+ `workshopid` int(10) unsigned NOT NULL default '0',
+ `assessmentid` int(10) unsigned NOT NULL default '0',
+ `elementno` int(10) unsigned NOT NULL default '0',
+ `feedback` text NOT NULL default '',
+ `grade` tinyint(3) NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) COMMENT='Info about individual grades given to each element';
+# --------------------------------------------------------
+
+INSERT INTO `prefix_log_display` VALUES ('workshop', 'assess', 'workshop', 'name');
+INSERT INTO `prefix_log_display` VALUES ('workshop', 'close', 'workshop', 'name');
+INSERT INTO `prefix_log_display` VALUES ('workshop', 'display grades', 'workshop', 'name');
+INSERT INTO `prefix_log_display` VALUES ('workshop', 'grade', 'workshop', 'name');
+INSERT INTO `prefix_log_display` VALUES ('workshop', 'hide grades', 'workshop', 'name');
+INSERT INTO `prefix_log_display` VALUES ('workshop', 'open', 'workshop', 'name');
+INSERT INTO `prefix_log_display` VALUES ('workshop', 'submit', 'workshop', 'name');
+INSERT INTO `prefix_log_display` VALUES ('workshop', 'view', 'workshop', 'name');
+INSERT INTO `prefix_log_display` VALUES ('workshop', 'update', 'workshop', 'name');
+
--- /dev/null
+<?PHP // $Id$
+
+ require("../../config.php");
+ require("lib.php");
+
+ require_variable($id); // course
+
+ if (! $course = get_record("course", "id", $id)) {
+ error("Course ID is incorrect");
+ }
+
+ require_login($course->id);
+ add_to_log($course->id, "workshop", "view all", "index.php?id=$course->id", "");
+
+ if ($course->category) {
+ $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
+ }
+
+ $strworkshops = get_string("modulenameplural", "workshop");
+ $strworkshop = get_string("modulename", "workshop");
+ $strweek = get_string("week");
+ $strtopic = get_string("topic");
+ $strname = get_string("name");
+ $strdeadline = get_string("deadline", "workshop");
+ $strsubmitted = get_string("submitted", "assignment");
+
+ print_header("$course->shortname: $strworkshops", "$course->fullname", "$navigation $strworkshops", "", "", true, "", navmenu($course));
+
+ if (! $workshops = get_all_instances_in_course("workshop", $course->id, "cw.section ASC")) {
+ notice("There are no workshops", "../../course/view.php?id=$course->id");
+ die;
+ }
+
+ $timenow = time();
+
+ if ($course->format == "weeks") {
+ $table->head = array ($strweek, $strname, $strdeadline, $strsubmitted);
+ $table->align = array ("CENTER", "LEFT", "LEFT", "LEFT");
+ } else if ($course->format == "topics") {
+ $table->head = array ($strtopic, $strname, $strdeadline, $strsubmitted);
+ $table->align = array ("CENTER", "LEFT", "LEFT", "LEFT");
+ } else {
+ $table->head = array ($strname, $strdeadline, $strsubmitted);
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ }
+
+ foreach ($workshops as $workshop) {
+ if ($submissions = workshop_get_user_submissions($workshop, $USER)) {
+ foreach ($submissions as $submission) {
+ if ($submission->timecreated <= $workshop->deadline) {
+ $submitted = userdate($submission->timecreated);
+ }
+ else {
+ $submitted = "<FONT COLOR=red>".userdate($submission->timecreated)."</FONT>";
+ }
+ $due = userdate($workshop->deadline);
+ $link = "<A HREF=\"view.php?id=$workshop->coursemodule\">$workshop->name</A><BR>".
+ "($submission->title)";
+ if ($course->format == "weeks" or $course->format == "topics") {
+ $table->data[] = array ($workshop->section, $link, $due, $submitted);
+ }
+ else {
+ $table->data[] = array ($link, $due, $submitted);
+ }
+ }
+ }
+ else {
+ $submitted = get_string("no");
+ $due = userdate($workshop->deadline);
+ $link = "<A HREF=\"view.php?id=$workshop->coursemodule\">$workshop->name</A>";
+ if ($course->format == "weeks" or $course->format == "topics") {
+ $table->data[] = array ($workshop->section, $link, $due, $submitted);
+ }
+ else {
+ $table->data[] = array ($link, $due, $submitted);
+ }
+ }
+ }
+ echo "<BR>";
+
+ print_table($table);
+
+ print_footer($course);
+?>
--- /dev/null
+<?PHP // $Id: lib.php,v 1.0 30th April 2003
+
+include_once("$CFG->dirroot/files/mimetypes.php");
+
+/*** Constants **********************************/
+
+$WORKSHOP_TYPE = array (0 => get_string("notgraded", "workshop"),
+ 1 => get_string("accumulative", "workshop"),
+ 2 => get_string("errorbanded", "workshop"),
+ 3 => get_string("criteria", "workshop") );
+
+$WORKSHOP_SHOWGRADES = array (0 => get_string("dontshowgrades", "workshop"),
+ 1 => get_string("showgrades", "workshop") );
+
+$WORKSHOP_SCALES = array(
+ 0 => array( 'name' => get_string("scaleyes", "workshop"), 'type' => 'radio', 'size' => 2, 'start' => 'yes', 'end' => 'no'),
+ 1 => array( 'name' => get_string("scalepresent", "workshop"), 'type' => 'radio', 'size' => 2, 'start' => 'present', 'end' => 'absent'),
+ 2 => array( 'name' => get_string("scalecorrect", "workshop"), 'type' => 'radio', 'size' => 2, 'start' => 'correct', 'end' => 'incorrect'),
+ 3 => array( 'name' => get_string("scalegood3", "workshop"), 'type' => 'radio', 'size' => 3, 'start' => 'good', 'end' => 'poor'),
+ 4 => array( 'name' => get_string("scaleexcellent4", "workshop"), 'type' => 'radio', 'size' => 4, 'start' => 'excellent', 'end' => 'very poor'),
+ 5 => array( 'name' => get_string("scaleexcellent5", "workshop"), 'type' => 'radio', 'size' => 5, 'start' => 'excellent', 'end' => 'very poor'),
+ 6 => array( 'name' => get_string("scaleexcellent7", "workshop"), 'type' => 'radio', 'size' => 7, 'start' => 'excellent', 'end' => 'very poor'),
+ 7 => array( 'name' => get_string("scale10", "workshop"), 'type' => 'selection', 'size' => 10),
+ 8 => array( 'name' => get_string("scale20", "workshop"), 'type' => 'selection', 'size' => 20),
+ 9 => array( 'name' => get_string("scale100", "workshop"), 'type' => 'selection', 'size' => 100));
+
+$WORKSHOP_EWEIGHTS = array( 0 => -4.0, 1 => -2.0, 2 => -1.5, 3 => -1.0, 4 => -0.75, 5 => -0.5, 6 => -0.25,
+ 7 => 0.0, 8 => 0.25, 9 => 0.5, 10 => 0.75, 11=> 1.0, 12 => 1.5, 13=> 2.0, 14 => 4.0);
+
+$WORKSHOP_FWEIGHTS = array( 0 => 0, 1 => 0.1, 2 => 0.25, 3 => 0.5, 4 => 0.75, 5 => 1, 6 => 1.5,
+ 7 => 2.0, 8 => 3.0, 9 => 5.0, 10 => 7.5, 11=> 10.0);
+
+define("COMMENTSCALE", 20);
+
+/*** Standard Moodle functions ******************
+function workshop_add_instance($workshop)
+function workshop_update_instance($workshop)
+function workshop_delete_instance($id)
+function workshop_user_outline($course, $user, $mod, $workshop)
+function workshop_user_complete($course, $user, $mod, $workshop)
+function workshop_cron ()
+function workshop_print_recent_activity(&$logs, $isteacher=false)
+function workshop_grades($workshopid)
+**********************************************/
+
+function workshop_add_instance($workshop) {
+// Given an object containing all the necessary data,
+// (defined by the form in mod.html) this function
+// will create a new instance and return the id number
+// of the new instance.
+
+ $workshop->timemodified = time();
+
+ $workshop->deadline = make_timestamp($workshop->deadlineyear,
+ $workshop->deadlinemonth, $workshop->deadlineday, $workshop->deadlinehour,
+ $workshop->deadlineminute);
+
+ return insert_record("workshop", $workshop);
+}
+
+
+function workshop_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) {
+/// Given an array of value, creates a popup menu to be part of a form
+/// $options["value"]["label"]
+
+ if ($nothing == "choose") {
+ $nothing = get_string("choose")."...";
+ }
+
+ if ($script) {
+ $javascript = "onChange=\"$script\"";
+ } else {
+ $javascript = "";
+ }
+
+ $output = "<SELECT NAME=$name $javascript>\n";
+ if ($nothing) {
+ $output .= " <OPTION VALUE=\"$nothingvalue\"\n";
+ if ($nothingvalue == $selected) {
+ $output .= " SELECTED";
+ }
+ $output .= ">$nothing</OPTION>\n";
+ }
+ if (!empty($options)) {
+ foreach ($options as $value => $label) {
+ $output .= " <OPTION VALUE=\"$value\"";
+ if ($value == $selected) {
+ $output .= " SELECTED";
+ }
+ // stop zero label being replaced by array index value
+ // if ($label) {
+ // $output .= ">$label</OPTION>\n";
+ // } else {
+ // $output .= ">$value</OPTION>\n";
+ // }
+ $output .= ">$label</OPTION>\n";
+
+ }
+ }
+ $output .= "</SELECT>\n";
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
+}
+
+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.
+
+ $workshop->timemodified = time();
+
+ $workshop->deadline = make_timestamp($workshop->deadlineyear,
+ $workshop->deadlinemonth, $workshop->deadlineday, $workshop->deadlinehour,
+ $workshop->deadlineminute);
+
+ $workshop->id = $workshop->instance;
+
+ return update_record("workshop", $workshop);
+}
+
+
+function workshop_delete_instance($id) {
+// Given an ID of an instance of this module,
+// this function will permanently delete the instance
+// and any data that depends on it.
+
+ if (! $workshop = get_record("workshop", "id", "$id")) {
+ return false;
+ }
+
+ // delete all the associated records in the workshop tables, start positive...
+ $result = true;
+
+ if (! delete_records("workshop_grades", "workshopid", "$workshop->id")) {
+ $result = false;
+ }
+
+ if (! delete_records("workshop_elements", "workshopid", "$workshop->id")) {
+ $result = false;
+ }
+
+ if (! delete_records("workshop_assessments", "workshopid", "$workshop->id")) {
+ $result = false;
+ }
+
+ if (! delete_records("workshop_submissions", "workshopid", "$workshop->id")) {
+ $result = false;
+ }
+
+ if (! delete_records("workshop", "id", "$workshop->id")) {
+ $result = false;
+ }
+
+ return $result;
+}
+
+function workshop_user_outline($course, $user, $mod, $workshop) {
+ if ($submission = workshop_get_submission($workshop, $user)) {
+
+ if ($submission->grade) {
+ $result->info = get_string("grade").": $submission->grade";
+ }
+ $result->time = $submission->timemodified;
+ return $result;
+ }
+ return NULL;
+}
+
+function workshop_user_complete($course, $user, $mod, $workshop) {
+ if ($submission = workshop_get_submission($workshop, $user)) {
+ if ($basedir = workshop_file_area($workshop, $user)) {
+ if ($files = get_directory_list($basedir)) {
+ $countfiles = count($files)." ".get_string("submissions", "workshop");
+ foreach ($files as $file) {
+ $countfiles .= "; $file";
+ }
+ }
+ }
+
+ print_simple_box_start();
+ echo "<P><FONT SIZE=1>";
+ echo get_string("lastmodified").": ";
+ echo userdate($submission->timemodified);
+ echo workshop_print_difference($workshop->timedue - $submission->timemodified);
+ echo "</FONT></P>";
+
+ workshop_print_user_files($workshop, $user);
+
+ echo "<BR>";
+
+ workshop_print_feedback($course, $submission);
+
+ print_simple_box_end();
+
+ } else {
+ print_string("notsubmittedyet", "workshop");
+ }
+}
+
+
+function workshop_cron () {
+// Function to be run periodically according to the moodle cron
+// Finds all workshop notifications that have yet to be mailed out, and mails them
+
+ global $CFG, $USER;
+
+ $cutofftime = time() - $CFG->maxeditingtime;
+
+ // look for new assessments
+ if ($assessments = workshop_get_unmailed_assessments($cutofftime)) {
+ $timenow = time();
+
+ foreach ($assessments as $assessment) {
+
+ echo "Processing workshop assessment $assessment->id\n";
+
+ if (! $submission = get_record("workshop_submissions", "id", "$assessment->submissionid")) {
+ echo "Could not find submission $assessment->submissionid\n";
+ continue;
+ }
+
+ if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
+ echo "Could not find user $submission->userid\n";
+ continue;
+ }
+
+ if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) {
+ echo "Could not find user $assessment->userid\n";
+ continue;
+ }
+
+ if (! $course = get_record("course", "id", "$assessment->course")) {
+ echo "Could not find course $assessment->course\n";
+ continue;
+ }
+
+ if (! isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) {
+ continue; // Not an active participant
+ }
+
+ if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) {
+ continue; // Not an active participant
+ }
+
+ if (! $workshop = get_coursemodule_from_instance("workshop", $assessment->workshopid, $course->id)) {
+ echo "Could not find course module for workshop id $submission->workshop\n";
+ continue;
+ }
+
+ $strworkshops = get_string("modulenameplural", "workshop");
+ $strworkshop = get_string("modulename", "workshop");
+
+ // it's an assessment, tell the submission owner
+ $USER->lang = $submissionowner->lang;
+ $sendto = $submissionowner;
+ $msg = "Your assignment \"$submission->title\" has been assessed.\n".
+ "The comments and grade can be seen in ".
+ "the workshop assignment '$workshop->name'\n\n";
+
+ $postsubject = "$course->shortname: $strworkshops: $workshop->name";
+ $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n";
+ $posttext .= "---------------------------------------------------------------------\n";
+ $posttext .= $msg;
+ $posttext .= "You can see it in your workshop assignment:\n";
+ $posttext .= " $CFG->wwwroot/mod/workshop/view.php?a=$workshop->id\n";
+ $posttext .= "---------------------------------------------------------------------\n";
+ if ($user->mailformat == 1) { // HTML
+ $posthtml = "<P><FONT FACE=sans-serif>".
+ "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->".
+ "<A HREF=\"$CFG->wwwroot/mod/workshop/index.php?id=$course->id\">$strworkshops</A> ->".
+ "<A HREF=\"$CFG->wwwroot/mod/workshop/view.php?a=$pgassessment->id\">$workshop->name</A></FONT></P>";
+ $posthtml .= "<HR><FONT FACE=sans-serif>";
+ $posthtml .= "<P>$msg</P>";
+ $posthtml .= "<P>You can see it <A HREF=\"$CFG->wwwroot/mod/workshop/view.php?a=$workshop->id\">";
+ $posthtml .= "in to your peer graded assignment</A>.</P></FONT><HR>";
+ } else {
+ $posthtml = "";
+ }
+
+ if (!$teacher = get_teacher($course->id)) {
+ echo "Error: can not find teacher for course $course->id!\n";
+ }
+
+ if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
+ echo "Error: workshop cron: Could not send out mail for id $submission->id to user $sendto->id ($sendto->email)\n";
+ }
+ if (! set_field("workshop_assessments", "mailed", "1", "id", "$assessment->id")) {
+ echo "Could not update the mailed field for id $assessment->id\n";
+ }
+ }
+
+ // look for new gradings
+ if ($assessments = workshop_get_unmailed_graded_assessments($cutofftime)) {
+ $timenow = time();
+
+ foreach ($assessments as $assessment) {
+
+ echo "Processing workshop assessment $assessment->id (graded)\n";
+
+ if (! $submission = get_record("workshop_submissions", "id", "$assessment->submissionid")) {
+ echo "Could not find submission $assessment->submissionid\n";
+ continue;
+ }
+
+ if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
+ echo "Could not find user $submission->userid\n";
+ continue;
+ }
+
+ if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) {
+ echo "Could not find user $assessment->userid\n";
+ continue;
+ }
+
+ if (! $course = get_record("course", "id", "$assessment->course")) {
+ echo "Could not find course $assessment->course\n";
+ continue;
+ }
+
+ if (! isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) {
+ continue; // Not an active participant
+ }
+
+ if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) {
+ continue; // Not an active participant
+ }
+
+ if (! $workshop = get_coursemodule_from_instance("workshop", $assessment->workshopid, $course->id)) {
+ echo "Could not find course module for workshop id $submission->workshop\n";
+ continue;
+ }
+
+ $strworkshops = get_string("modulenameplural", "workshop");
+ $strworkshop = get_string("modulename", "workshop");
+
+ // it's a grading tell the assessment owner
+ $USER->lang = $assessmentowner->lang;
+ $sendto = $assessmentowner;
+ $msg = "Your assessment of the assignment \"$submission->title\" has by graded.\n".
+ "The comments and grade given by the $course->teacher can be seen in ".
+ "the workshop assignment '$workshop->name'\n\n";
+ }
+
+
+ $postsubject = "$course->shortname: $strworkshops: $workshop->name";
+ $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n";
+ $posttext .= "---------------------------------------------------------------------\n";
+ $posttext .= $msg;
+ $posttext .= "You can see it in your workshop assignment:\n";
+ $posttext .= " $CFG->wwwroot/mod/workshop/view.php?a=$workshop->id\n";
+ $posttext .= "---------------------------------------------------------------------\n";
+ if ($user->mailformat == 1) { // HTML
+ $posthtml = "<P><FONT FACE=sans-serif>".
+ "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->".
+ "<A HREF=\"$CFG->wwwroot/mod/workshop/index.php?id=$course->id\">$strworkshops</A> ->".
+ "<A HREF=\"$CFG->wwwroot/mod/workshop/view.php?a=$pgassessment->id\">$workshop->name</A></FONT></P>";
+ $posthtml .= "<HR><FONT FACE=sans-serif>";
+ $posthtml .= "<P>$msg</P>";
+ $posthtml .= "<P>You can see it <A HREF=\"$CFG->wwwroot/mod/workshop/view.php?a=$workshop->id\">";
+ $posthtml .= "in to your peer graded assignment</A>.</P></FONT><HR>";
+ } else {
+ $posthtml = "";
+ }
+
+ if (!$teacher = get_teacher($course->id)) {
+ echo "Error: can not find teacher for course $course->id!\n";
+ }
+
+ if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
+ echo "Error: workshop cron: Could not send out mail for id $submission->id to user $sendto->id ($sendto->email)\n";
+ }
+ if (! set_field("workshop_assessments", "mailed", "1", "id", "$assessment->id")) {
+ echo "Could not update the mailed field for id $assessment->id\n";
+ }
+ }
+ }
+
+ return true;
+}
+
+
+function workshop_print_recent_activity(&$logs, $isteacher=false) {
+ global $CFG, $COURSE_TEACHER_COLOR;
+
+ $content = false;
+ $workshops = NULL;
+ $timenow = time();
+
+ foreach ($logs as $log) {
+ if ($log->module == "workshop" and $log->action == "submit") {
+ $workshops[$log->info] = get_record_sql("SELECT a.name, u.firstname, u.lastname
+ FROM {$CFG->prefix}workshop a, {$CFG->prefix}user u
+ WHERE a.id = '$log->info' AND u.id = '$log->userid'");
+ $workshops[$log->info]->time = $log->time;
+ $workshops[$log->info]->url = $log->url;
+ }
+ }
+
+ if ($workshops) {
+ $content = true;
+ print_headline(get_string("submissions", "workshop").":");
+ foreach ($workshops as $workshop) {
+ $date = userdate($workshop->time, "%d %b, %H:%M");
+ echo "<P><FONT SIZE=1>$date - $workshop->firstname $workshop->lastname<BR>";
+ echo "\"<A HREF=\"$CFG->wwwroot/mod/workshop/$workshop->url\">";
+ echo "$workshop->name";
+ echo "</A>\"</FONT></P>";
+ }
+ }
+
+ $workshops = NULL;
+
+ foreach ($logs as $log) {
+ if ($log->module == "workshop" and $log->action == "assess") {
+ if ($workshops[$log->userid] = get_record_sql("SELECT a.name, u.firstname, u.lastname
+ FROM {$CFG->prefix}workshop a, {$CFG->prefix}user u
+ WHERE a.id = '$log->info' AND u.id = '$log->userid'")) {
+ $workshops[$log->userid]->time = $log->time;
+ $workshops[$log->userid]->url = $log->url;
+ }
+ }
+ }
+
+ if ($workshops) {
+ $content = true;
+ print_headline(get_string("assessments", "workshop").":");
+ foreach ($workshops as $workshop) {
+ $date = userdate($workshop->time, "%d %b, %H:%M");
+ echo "<P><FONT SIZE=1>$date - $workshop->firstname $workshop->lastname<BR>";
+ echo "\"<A HREF=\"$CFG->wwwroot/mod/workshop/$workshop->url\">";
+ echo "$workshop->name";
+ echo "</A>\"</FONT></P>";
+ }
+ }
+
+ $workshops = NULL;
+
+ foreach ($logs as $log) {
+ if ($log->module == "workshop" and $log->action == "grade") {
+ $workshops[$log->userid] = get_record_sql("SELECT a.name, u.firstname, u.lastname
+ FROM {$CFG->prefix}workshop a, {$CFG->prefix}user u
+ WHERE a.id = '$log->info' AND u.id = '$log->userid'");
+ $workshops[$log->userid]->time = $log->time;
+ $workshops[$log->userid]->url = $log->url;
+ }
+ }
+
+ if ($workshops) {
+ $content = true;
+ print_headline(get_string("graded", "workshop").":");
+ foreach ($workshops as $workshop) {
+ $date = userdate($workshop->time, "%d %b, %H:%M");
+ echo "<P><FONT SIZE=1>$date - $workshop->firstname $workshop->lastname<BR>";
+ echo "\"<A HREF=\"$CFG->wwwroot/mod/workshop/$workshop->url\">";
+ echo "$workshop->name";
+ echo "</A>\"</FONT></P>";
+ }
+ }
+
+ $workshops = NULL;
+
+ foreach ($logs as $log) {
+ if ($log->module == "workshop" and $log->action == "close") {
+ $workshops[$log->userid] = get_record_sql("SELECT a.name, u.firstname, u.lastname
+ FROM {$CFG->prefix}workshop a, {$CFG->prefix}user u
+ WHERE a.id = '$log->info' AND u.id = '$log->userid'");
+ $workshops[$log->userid]->time = $log->time;
+ $workshops[$log->userid]->url = $log->url;
+ }
+ }
+
+ if ($workshops) {
+ $content = true;
+ print_headline(get_string("closeassignment", "workshop").":");
+ foreach ($workshops as $workshop) {
+ $date = userdate($workshop->time, "%d %b, %H:%M");
+ echo "<P><FONT SIZE=1>$date - $workshop->firstname $workshop->lastname<BR>";
+ echo "\"<A HREF=\"$CFG->wwwroot/mod/workshop/$workshop->url\">";
+ echo "$workshop->name";
+ echo "</A>\"</FONT></P>";
+ }
+ }
+
+ foreach ($logs as $log) {
+ if ($log->module == "workshop" and $log->action == "open") {
+ $workshops[$log->userid] = get_record_sql("SELECT a.name, u.firstname, u.lastname
+ FROM {$CFG->prefix}workshop a, {$CFG->prefix}user u
+ WHERE a.id = '$log->info' AND u.id = '$log->userid'");
+ $workshops[$log->userid]->time = $log->time;
+ $workshops[$log->userid]->url = $log->url;
+ }
+ }
+
+ if ($workshops) {
+ $content = true;
+ print_headline(get_string("openassignment", "workshop").":");
+ foreach ($workshops as $workshop) {
+ $date = userdate($workshop->time, "%d %b, %H:%M");
+ echo "<P><FONT SIZE=1>$date - $workshop->firstname $workshop->lastname<BR>";
+ echo "\"<A HREF=\"$CFG->wwwroot/mod/workshop/$workshop->url\">";
+ echo "$workshop->name";
+ echo "</A>\"</FONT></P>";
+ }
+ }
+
+ return $content;
+}
+
+function workshop_grades($workshopid) {
+/// Must return an array of grades, indexed by user, and a max grade.
+
+ $return->grades = get_records_select_menu("workshop_submissions",
+ "workshopid = $workshopid", "", "userid, finalgrade");
+ $return->maxgrade = get_field("workshop", "grade", "id", "$workshopid");
+ return $return;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+/*** Functions for the workshop module ******
+
+function workshop_count_all_assessments($workshop, $user) {
+function workshop_count_all_submissions_for_assessment($workshop, $user) {
+function workshop_count_peer_assessments($workshop, $user) {
+function workshop_count_student_submissions($workshop) {
+function workshop_count_student_submissions_for_assessment($workshop, $user) {
+function workshop_count_teacher_assessments($workshop, $user) {
+function workshop_count_teacher_submissions($workshop) {
+function workshop_count_teacher_submissions_for_assessment($workshop, $user) {
+function workshop_count_ungraded_assessments_student($workshop) {
+function workshop_count_ungraded_assessments_teacher($workshop) {
+
+function workshop_delete_user_files($workshop, $user, $exception) {
+
+function workshop_file_area($workshop, $submission) {
+function workshop_file_area_name($workshop, $submission) {
+
+function workshop_get_assessments($submission) {
+function workshop_get_student_assessments($workshop, $user) {
+function workshop_get_student_submission_assessments($workshop) {
+function workshop_get_student_submissions($workshop) {
+function workshop_get_submission_assessment($submission, $user) {
+function workshop_get_teacher_submission_assessments($workshop) {
+function workshop_get_teacher_submissions($workshop) {
+function workshop_get_ungraded_assessments($workshop) {
+function workshop_get_unmailed_assessments($cutofftime) {
+function workshop_get_unmailed_marked_assessments($cutofftime) {
+function workshop_get_user_assessments($workshop, $user) {
+function workshop_get_user_submissions($workshop, $user) {
+function workshop_get_users_done($workshop) {
+
+function workshop_list_all_submissions($workshop) {
+function workshop_list_all_ungraded_assessments($workshop) {
+function workshop_list_assessed_submissions($workshop, $user) {
+function workshop_list_peer_assessments($workshop, $user) {
+function workshop_list_student_submissions($workshop, $user) {
+function workshop_list_teacher_assessments($workshop, $user) {
+function workshop_list_teacher_submissions($workshop) {
+function workshop_list_unassessed_student_submissions($workshop, $user) {
+function workshop_list_unassessed_teacher_submissions($workshop, $user) {
+function workshop_list_ungraded_assessments($workshop, $stype) {
+function workshop_list_user_submissions($workshop, $user) {
+
+
+function workshop_print_assessment($workshop, $assessment, $allowchanges)
+function workshop_print_difference($time) {
+function workshop_print_feedback($course, $submission) {
+function workshop_print_submission_assessments($workshop, $submission, $type) {
+function workshop_print_submission_title($workshop, $user) {
+function workshop_print_time_to_deadline($time) {
+function workshop_print_upload_form($workshop) {
+function workshop_print_user_assessments($workshop, $user) {
+
+function workshop_test_user_assessments($workshop, $user) {
+***************************************/
+
+function workshop_count_all_assessments($workshop, $user) {
+ return count_records("workshop_assessments", "workshopid", $workshop->id, "userid", $user->id);
+ }
+
+
+function workshop_count_all_submissions_for_assessment($workshop, $user) {
+ // looks at all submissions and deducts the number which has been assessed by this user
+ $n = 0;
+ if ($submissions = get_records_select("workshop_submissions", "workshopid = $workshop->id AND timecreated > 0")) {
+ $n =count($submissions);
+ foreach ($submissions as $submission) {
+ $n -= count_records("workshop_assessments", "submissionid", $submission->id, "userid", $user->id);
+ }
+ }
+ return $n;
+ }
+
+
+function workshop_count_assessments($workshop, $stype, $user) {
+ // returns the number of assessments made by a user on either the student or teacher submissions
+ // the maxeditingtime is NOT taken into account here
+
+ switch ($stype) {
+ case "student" :
+ $submissions = workshop_get_student_submissions($workshop);
+ break;
+ case "teacher" :
+ $submissions = workshop_get_teacher_submissions($workshop);
+ break;
+ }
+ $n = 0;
+ if ($submissions) {
+ foreach ($submissions as $submission) {
+ $n += count_records_select("workshop_assessments", "(submissionid = $submission->id) AND
+ (userid = $user->id)");
+ }
+ }
+ return $n;
+ }
+
+
+function workshop_count_peer_assessments($workshop, $user) {
+ // returns the number of assessments made by students on user's submissions
+
+ $n = 0;
+ if ($submissions = workshop_get_user_submissions($workshop, $user)) {
+ foreach ($submissions as $submission) {
+ if ($assessments = workshop_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ // ignore teacher assessments
+ if (!isteacher($workshop->course, $assessment->userid)) {
+ $n++;
+ }
+ }
+ }
+ }
+ }
+ return $n;
+ }
+
+
+function workshop_count_student_submissions($workshop) {
+ global $CFG;
+
+ return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_students u
+ WHERE u.course = $workshop->course
+ AND s.userid = u.userid
+ AND s.workshopid = $workshop->id
+ AND timecreated > 0");
+ }
+
+
+function workshop_count_student_submissions_for_assessment($workshop, $user) {
+ global $CFG;
+
+ $timenow = time();
+ $n = 0;
+ if ($submissions = workshop_get_student_submissions($workshop)) {
+ $n =count($submissions);
+ foreach ($submissions as $submission) {
+ $n -= count_records_select("workshop_assessments", "submissionid = $submission->id AND
+ userid = $user->id AND timecreated < $timenow - $CFG->maxeditingtime");
+ }
+ }
+ return $n;
+ }
+
+
+function workshop_count_teacher_assessments($workshop, $user) {
+ // returns the number of assessments made by teachers on user's submissions
+
+ $n = 0;
+ if ($submissions = workshop_get_user_submissions($workshop, $user)) {
+ foreach ($submissions as $submission) {
+ if ($assessments = workshop_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ // count only teacher assessments
+ if (isteacher($workshop->course, $assessment->userid)) {
+ $n++;
+ }
+ }
+ }
+ }
+ }
+ return $n;
+ }
+
+
+function workshop_count_teacher_submissions($workshop) {
+ global $CFG;
+
+ return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_submissions s,
+ {$CFG->prefix}user_teachers u
+ WHERE u.course = $workshop->course
+ AND s.userid = u.userid
+ AND s.workshopid = $workshop->id");
+ }
+
+
+function workshop_count_teacher_submissions_for_assessment($workshop, $user) {
+
+ $n = 0;
+ if ($submissions = workshop_get_teacher_submissions($workshop)) {
+ $n =count($submissions);
+ foreach ($submissions as $submission) {
+ $n -= count_records("workshop_assessments", "submissionid", $submission->id, "userid", $user->id);
+ }
+ }
+ return $n;
+ }
+
+
+function workshop_count_ungraded_assessments_student($workshop) {
+ // function returns the number of ungraded assessments by students of STUDENT submissions
+ $n = 0;
+ if ($submissions = workshop_get_student_submissions($workshop)) {
+ foreach ($submissions as $submission) {
+ if ($assessments = workshop_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ if ($assessment->timegraded == 0) {
+ // ignore teacher assessments
+ if (!isteacher($workshop->course, $assessment->userid)) {
+ $n++;
+ }
+ }
+ }
+ }
+ }
+ }
+ return $n;
+ }
+
+
+function workshop_count_ungraded_assessments_teacher($workshop) {
+ // function returns the number of ungraded assessments by students of TEACHER submissions
+ global $CFG;
+
+ $timenow = time();
+ $n = 0;
+ if ($submissions = workshop_get_teacher_submissions($workshop)) {
+ foreach ($submissions as $submission) {
+ if ($assessments = workshop_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ if ($assessment->timegraded == 0) {
+ // ignore teacher assessments
+ if (!isteacher($workshop->course, $assessment->userid)) {
+ // must have created a little time ago
+ if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
+ $n++;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return $n;
+ }
+
+
+function workshop_delete_user_files($workshop, $user, $exception) {
+// Deletes all the user files in the workshop area for a user
+// EXCEPT for any file named $exception
+
+ if (!$submissions = workshop_get_submissions($workshop, $user)) {
+ notify("No submissions!");
+ return;
+ }
+ foreach ($submissions as $submission) {
+ if ($basedir = workshop_file_area($workshop, $submission)) {
+ if ($files = get_directory_list($basedir)) {
+ foreach ($files as $file) {
+ if ($file != $exception) {
+ unlink("$basedir/$file");
+ notify("Existing file '$file' has been deleted!");
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+function workshop_file_area($workshop, $submission) {
+ return make_upload_directory( workshop_file_area_name($workshop, $submission) );
+}
+
+
+function workshop_file_area_name($workshop, $submission) {
+// Creates a directory file name, suitable for make_upload_directory()
+ global $CFG;
+
+ return "$workshop->course/$CFG->moddata/workshop/$submission->id";
+}
+
+
+function workshop_get_assessments($submission) {
+ // Return all assessments for this submission provided they are after the editing time, oredered oldest first, newest last
+ global $CFG;
+
+ $timenow = time();
+ return get_records_select("workshop_assessments", "(submissionid = $submission->id) AND
+ (timecreated < $timenow - $CFG->maxeditingtime)", "timecreated DESC");
+}
+
+
+function workshop_get_student_assessments($workshop, $user) {
+// Return all assessments on the student submissions by a user, order by youngest first, oldest last
+ global $CFG;
+
+ return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_students u,
+ {$CFG->prefix}workshop_assessments a
+ WHERE u.course = $workshop->course
+ AND s.userid = u.userid
+ AND s.workshopid = $workshop->id
+ AND a.submissionid = s.id
+ AND a.userid = $user->id
+ ORDER BY a.timecreated DESC");
+}
+
+
+function workshop_get_student_submission_assessments($workshop) {
+// Return all assessments on the student submissions, order by youngest first, oldest last
+ global $CFG;
+
+ return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_students u,
+ {$CFG->prefix}workshop_assessments a
+ WHERE u.course = $workshop->course
+ AND s.userid = u.userid
+ AND s.workshopid = $workshop->id
+ AND a.submissionid = s.id
+ ORDER BY a.timecreated DESC");
+}
+
+
+function workshop_get_student_submissions($workshop) {
+// Return all ENROLLED student submissions
+ global $CFG;
+
+ return get_records_sql("SELECT s.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_students u
+ WHERE u.course = $workshop->course
+ AND s.userid = u.userid
+ AND s.workshopid = $workshop->id
+ AND s.timecreated > 0
+ ORDER BY s.title");
+}
+
+
+function workshop_get_submission_assessment($submission, $user) {
+ // Return the user's assessment for this submission
+ return get_record("workshop_assessments", "submissionid", $submission->id, "userid", $user->id);
+}
+
+
+function workshop_get_teacher_submission_assessments($workshop) {
+// Return all assessments on the teacher submissions, order by youngest first, oldest last
+ global $CFG;
+
+ return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_teachers u,
+ {$CFG->prefix}workshop_assessments a
+ WHERE u.course = $workshop->course
+ AND s.userid = u.userid
+ AND s.workshopid = $workshop->id
+ AND a.submissionid = s.id
+ ORDER BY a.timecreated DESC");
+}
+
+
+function workshop_get_teacher_submissions($workshop) {
+// Return all teacher submissions, ordered by title
+ global $CFG;
+
+ return get_records_sql("SELECT s.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_teachers u
+ WHERE u.course = $workshop->course
+ AND s.userid = u.userid
+ AND s.workshopid = $workshop->id
+ ORDER BY s.title");
+}
+
+
+function workshop_get_ungraded_assessments($workshop) {
+ global $CFG;
+ // Return all assessments which have not been graded or just graded
+ $cutofftime =time() - $CFG->maxeditingtime;
+ return get_records_select("workshop_assessments", "workshopid = $workshop->id AND (timegraded = 0 OR
+ timegraded > $cutofftime)", "timecreated");
+ }
+
+
+function workshop_get_ungraded_assessments_student($workshop) {
+ global $CFG;
+ // Return all assessments which have not been graded or just graded of student's submissions
+
+ $cutofftime =time() - $CFG->maxeditingtime;
+ return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_students u,
+ {$CFG->prefix}workshop_assessments a
+ WHERE u.course = $workshop->course
+ AND s.userid = u.userid
+ AND s.workshopid = $workshop->id
+ AND a.submissionid = s.id
+ AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
+ AND a.timecreated < $cutofftime
+ ORDER BY a.timecreated DESC");
+ }
+
+
+function workshop_get_ungraded_assessments_teacher($workshop) {
+ global $CFG;
+ // Return all assessments which have not been graded or just graded of teacher's submissions
+
+ $cutofftime =time() - $CFG->maxeditingtime;
+ return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_teachers u,
+ {$CFG->prefix}workshop_assessments a
+ WHERE u.course = $workshop->course
+ AND s.userid = u.userid
+ AND s.workshopid = $workshop->id
+ AND a.submissionid = s.id
+ AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
+ AND a.timecreated < $cutofftime
+ ORDER BY a.timecreated DESC");
+ }
+
+
+function workshop_get_unmailed_assessments($cutofftime) {
+ /// Return list of (ungraded) assessments that have not been mailed out
+ global $CFG;
+ return get_records_sql("SELECT a.*, g.course, g.name
+ FROM {$CFG->prefix}workshop_assessments a, {$CFG->prefix}workshop g
+ WHERE a.mailed = 0
+ AND a.timegraded = 0
+ AND a.timecreated < $cutofftime
+ AND g.id = a.workshopid");
+}
+
+
+function workshop_get_unmailed_graded_assessments($cutofftime) {
+ /// Return list of graded assessments that have not been mailed out
+ global $CFG;
+ return get_records_sql("SELECT a.*, g.course, g.name
+ FROM {$CFG->prefix}workshop_assessments a, {$CFG->prefix}workshop g
+ WHERE a.mailed = 0
+ AND a.timegraded < $cutofftime
+ AND a.timegraded > 0
+ AND g.id = a.workshopid");
+}
+
+
+function workshop_get_user_assessments($workshop, $user) {
+ // Return all the user's assessments, newest first, oldest last
+ return get_records_select("workshop_assessments", "workshopid = $workshop->id AND userid = $user->id",
+ "timecreated DESC");
+}
+
+
+function workshop_get_user_submissions($workshop, $user) {
+ // return submission of user newest first, oldest last
+ return get_records_select("workshop_submissions ",
+ "workshopid = $workshop->id AND userid = $user->id", "timecreated DESC" );
+}
+
+
+function workshop_get_users_done($workshop) {
+ global $CFG;
+ return get_records_sql("SELECT u.*
+ FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s, {$CFG->prefix}workshop_submissions a
+ WHERE s.course = '$workshop->course' AND s.user = u.id
+ AND u.id = a.user AND a.workshop = '$workshop->id'
+ ORDER BY a.timemodified DESC");
+}
+
+
+function workshop_list_all_submissions($workshop, $user) {
+ // list the teacher sublmissions first
+ global $CFG;
+
+ if (! $course = get_record("course", "id", $workshop->course)) {
+ error("Course is misconfigured");
+ }
+ $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ if ($submissions = workshop_get_teacher_submissions($workshop)) {
+ foreach ($submissions as $submission) {
+ if ($submission->userid == $user->id) {
+ $comment = get_string("ownwork", "workshop")."; ";
+ }
+ else {
+ $comment = "";
+ }
+ // has user already assessed this submission
+ if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
+ AND userid = $user->id")) {
+ $curtime = time();
+ if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
+ $action = "<A HREF=\"assessments.php?action=viewassessment&a=$workshop->id&aid=$assessment->id\">"
+ .get_string("view", "workshop")."</A>";
+ // has teacher graded user's assessment?
+ if ($assessment->timegraded) {
+ if (($curtime - $assessment->timegraded) > $CFG->maxeditingtime) {
+ $comment .= get_string("gradedbyteacher", "workshop", $course->teacher);
+ }
+ }
+ }
+ else { // there's still time left to edit...
+ $action = "<A HREF=\"assessments.php?action=assesssubmission&a=$workshop->id&sid=$submission->id\">".
+ get_string("edit", "workshop")."</A>";
+ }
+ }
+ else { // user has not graded this submission
+ $action = "<A HREF=\"assessments.php?action=assesssubmission&a=$workshop->id&sid=$submission->id\">".
+ get_string("assess", "workshop")."</A>";
+ }
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
+ }
+ print_table($table);
+ }
+
+ echo "<CENTER><P><B>".get_string("studentsubmissions", "workshop", $course->student)."</B></CENTER><BR>\n";
+ unset($table);
+ $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ if ($submissions = workshop_get_student_submissions($workshop)) {
+ foreach ($submissions as $submission) {
+ if ($submission->userid == $user->id) {
+ $comment = get_string("ownwork", "workshop")."; ";
+ }
+ else {
+ $comment = "";
+ }
+ // has user already assessed this submission
+ if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
+ AND userid = $user->id")) {
+ $curtime = time();
+ if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
+ $action = "<A HREF=\"assessments.php?action=viewassessment&a=$workshop->id&aid=$assessment->id\">".
+ get_string("view", "workshop")."</A>";
+ // has teacher graded on user's assessment?
+ if ($assessment->timegraded) {
+ if (($curtime - $assessment->timegraded) > $CFG->maxeditingtime) {
+ $comment .= get_string("gradedbyteacher", "workshop", $course->teacher)."; ";
+ }
+ }
+ $otherassessments = workshop_get_assessments($submission);
+ if (count($otherassessments) > 1) {
+ $comment .= "<A HREF=\"assessments.php?action=viewallassessments&a=$workshop->id&sid=$submission->id\">".
+ get_string("viewotherassessments", "workshop")."</A>";
+ }
+ }
+ else { // there's still time left to edit...
+ $action = "<A HREF=\"assessments.php?action=assesssubmission&a=$workshop->id&sid=$submission->id\">".
+ get_string("edit", "workshop")."</A>";
+ }
+ }
+ else { // user has not assessed this submission
+ $action = "<A HREF=\"assessments.php?action=assesssubmission&a=$workshop->id&sid=$submission->id\">".
+ get_string("assess", "workshop")."</A>";
+ }
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
+ }
+ print_table($table);
+ }
+ }
+
+
+function workshop_list_all_ungraded_assessments($workshop) {
+ // lists all the assessments for comment by teacher
+ global $CFG;
+
+ $table->head = array (get_string("title", "workshop"), get_string("timeassessed", "workshop"), get_string("action", "workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+ $timenow = time();
+
+ if ($assessments = workshop_get_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&a=$workshop->id&aid=$assessment->id\">".
+ get_string("edit", "workshop")."</A>";
+ }
+ else {
+ $action = "<A HREF=\"assessments.php?action=gradeassessment&a=$workshop->id&aid=$assessment->id\">".
+ get_string("gradeassessment", "workshop")."</A>";
+ }
+ $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission),
+ userdate($assessment->timecreated), $action);
+ }
+ }
+ if (isset($table->data)) {
+ print_table($table);
+ }
+ }
+ }
+
+
+function workshop_list_assessed_submissions($workshop, $user) {
+ // list the submissions that have been assessed by this user
+ global $CFG;
+
+ if (! $course = get_record("course", "id", $workshop->course)) {
+ error("Course is misconfigured");
+ }
+ $table->head = array (get_string("title","workshop"), get_string("action","workshop"), get_string("comment","workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ if ($assessments = workshop_get_student_assessments($workshop, $user)) {
+ $timenow = time();
+ foreach ($assessments as $assessment) {
+ $comment = "";
+ $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
+ if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
+ $action = "<A HREF=\"assessments.php?action=viewassessment&a=$workshop->id&aid=$assessment->id\">".
+ get_string("view", "workshop")."</A>";
+ // has teacher graded user's assessment?
+ if ($assessment->timegraded) {
+ if (($timenow - $assessment->timegraded) > $CFG->maxeditingtime) {
+ $comment = get_string("gradedbyteacher", "workshop", $course->teacher);
+ }
+ }
+ }
+ else { // there's still time left to edit...
+ $action = "<A HREF=\"assessments.php?action=assesssubmission&a=$workshop->id&sid=$submission->id\">".
+ get_string("edit", "workshop")."</A>";
+ }
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
+ }
+ }
+ if (isset($table->data)) {
+ print_table($table);
+ }
+ else {
+ echo "<CENTER>".get_string("noassessmentsdone", "workshop")."</CENTER>\n";
+ }
+ }
+
+
+function workshop_list_peer_assessments($workshop, $user) {
+ global $CFG;
+
+ if (! $course = get_record("course", "id", $workshop->course)) {
+ error("Course is misconfigured");
+ }
+ $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ // get user's submissions
+ if ($submissions = workshop_get_user_submissions($workshop, $user)) {
+ foreach ($submissions as $submission) {
+ // get the assessments
+ if ($assessments = workshop_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ if (isstudent($workshop->course, $assessment->userid)) { // assessments by students only
+ $timenow = time();
+ if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
+ $action = "<A HREF=\"assessments.php?action=viewassessment&a=$workshop->id&aid=$assessment->id\">".
+ get_string("view", "workshop")."</A>";
+ // has teacher commented on user's assessment?
+ if ($assessment->timegraded and ($timenow - $assessment->timegraded > $CFG->maxeditingtime)) {
+ $comment = get_string("gradedbyteacher", "workshop", $course->teacher);
+ }
+ else {
+ $comment = userdate($assessment->timecreated);
+ }
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (isset($table->data)) {
+ print_table($table);
+ }
+ else {
+ echo "<CENTER>".get_string("noassessmentsdone", "workshop")."</CENTER>\n";
+ }
+ }
+
+
+
+function workshop_list_student_submissions($workshop, $user) {
+ // list available submissions for this user to assess, submissions with the least number
+ // of assessments are show first
+ global $CFG;
+
+ if (! $course = get_record("course", "id", $workshop->course)) {
+ error("Course is misconfigured");
+ }
+ $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ // get the number of assessments this user has done
+ $nassessed = workshop_count_assessments($workshop, "student", $user);
+
+ // count the number of assessments for each student submission
+ if ($submissions = workshop_get_student_submissions($workshop)) {
+ foreach ($submissions as $submission) {
+ $n = count_records("workshop_assessments", "submissionid", $submission->id);
+ // OK to have zero
+ $nassessments[$submission->id] = $n;
+ }
+
+ // put the submissions with the lowest number of assessments first
+ asort($nassessments);
+ reset($nassessments);
+ $comment = "";
+ foreach ($nassessments as $submissionid =>$n) {
+ $submission = get_record("workshop_submissions", "id", $submissionid);
+ if (($submission->userid != $user->id) or $workshop->includeself) {
+ // add if user has NOT already assessed this submission
+ if (!$assessment = get_record_select("workshop_assessments", "submissionid = $submissionid
+ AND userid = $user->id")) {
+ if ($nassessed < $workshop->nsassessments) {
+ $action = "<A HREF=\"assessments.php?action=assesssubmission&a=$workshop->id&sid=$submission->id\">".
+ get_string("assess", "workshop")."</A>";
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
+ $nassessed++;
+ }
+ else {
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (isset($table->data)) {
+ echo "<P><CENTER><B>".get_string("pleaseassessthesestudentsubmissions", "workshop", $course->student).
+ "</B></CENTER><BR>\n";
+ print_table($table);
+ }
+ else {
+ echo "<P><CENTER><B>".get_string("nosubmissionsavailableforassessment", "workshop")."</B></CENTER><BR>\n";
+ }
+ }
+
+
+function workshop_list_teacher_assessments($workshop, $user) {
+ global $CFG;
+
+ if (! $course = get_record("course", "id", $workshop->course)) {
+ error("Course is misconfigured");
+ }
+ $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ // get user's submissions
+ if ($submissions = workshop_get_user_submissions($workshop, $user)) {
+ foreach ($submissions as $submission) {
+ // get the assessments
+ 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&a=$workshop->id&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)) {
+ $comment = get_string("gradedbyteacher", "workshop", $course->teacher);
+ }
+ else {
+ $comment = userdate($assessment->timecreated);
+ }
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
+ }
+ }
+ }
+ }
+ }
+ if (isset($table->data)) {
+ print_table($table);
+ }
+ else {
+ echo "<CENTER>".get_string("noassessmentsdone", "workshop")."</CENTER>\n";
+ }
+ }
+
+
+
+function workshop_list_teacher_submissions($workshop, $user) {
+ global $CFG;
+
+ if (! $course = get_record("course", "id", $workshop->course)) {
+ error("Course is misconfigured");
+ }
+ $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ // get the number of assessments this user has done
+ $nassessed = count_records_select("workshop_assessments", "workshopid = $workshop->id
+ AND userid = $user->id");
+
+ if ($submissions = workshop_get_teacher_submissions($workshop)) {
+ foreach ($submissions as $submission) {
+ $comment = '';
+ // has user already assessed this submission
+ if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
+ AND userid = $user->id AND timecreated > 0")) {
+ $timenow = time();
+ if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
+ $action = "<A HREF=\"assessments.php?action=viewassessment&a=$workshop->id&aid=$assessment->id\">".
+ get_string("view", "workshop")."</A>";
+ // has teacher graded user's assessment and is it cooked?
+ if ($assessment->timegraded and ($timenow - $assessment->timegraded > $CFG->maxeditingtime)) {
+ // add teacher's comment to action string
+ $action = "<A HREF=\"assessments.php?action=viewassessment&a=$workshop->id&aid=$assessment->id\">".
+ get_string("view", "workshop")." ".get_string("teacherscomment", "workshop")."</A>";
+ // show user the teacher's assessment and if they failed allow them to resubmit assessment
+ $percentage = number_format($assessment->gradinggrade*100/COMMENTSCALE, 0);
+ $comment = get_string("assessmentgrade", "workshop", $percentage )."%" ;
+ // is there a teacher's assessment, if so show a link to it
+ $otherassessments = workshop_get_assessments($submission);
+ foreach ($otherassessments as $otherassessment) {
+ if (isteacher($workshop->course, $otherassessment->userid) ) {
+ $comment .= " <A HREF=\"assessments.php?action=viewassessment&a=$workshop->id&aid=$otherassessment->id\">".
+ get_string("viewassessmentofteacher", "workshop", $course->teacher)."</A>";
+ }
+ }
+ // has user failed?
+ if ($assessment->gradinggrade < COMMENTSCALE*0.4) {
+ $action = "<A HREF=\"assessments.php?action=assesssubmission&a=$workshop->id&sid=$submission->id\">".
+ get_string("edit", "workshop")."</A>";
+ }
+ }
+ else { // teacher has not graded this assessment yet
+ $comment = get_string("awaitinggradingbyteacher", "workshop", $course->teacher);
+ }
+ }
+ else { // there's still time left to edit...
+ $action = "<A HREF=\"assessments.php?action=assesssubmission&a=$workshop->id&sid=$submission->id\">".
+ get_string("edit", "workshop")."</A>";
+ }
+ }
+ else { // user has not graded this submission
+ if ($nassessed < $workshop->ntassessments) {
+ $action = "<A HREF=\"assessments.php?action=assesssubmission&a=$workshop->id&sid=$submission->id\">".
+ get_string("assess", "workshop")."</A>";
+ }
+ else {
+ $action = "<A HREF=\"assessments.php?action=viewassessment&a=$workshop->id&aid=$assessment->id\">".
+ get_string("view", "workshop")."</A>";
+ }
+ }
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
+ }
+ print_table($table);
+ }
+ }
+
+
+function workshop_list_unassessed_student_submissions($workshop, $user) {
+ // list the student submissions not assessed by this user
+ global $CFG;
+
+ $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ if ($submissions = workshop_get_student_submissions($workshop)) {
+ foreach ($submissions as $submission) {
+ $comment = "";
+ // see if user already graded this assessment
+ if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
+ AND userid = $user->id")) {
+ $timenow = time();
+ if (($timenow - $assessment->timecreated < $CFG->maxeditingtime)) {
+ // last chance salon
+ $action = "<A HREF=\"assessments.php?action=assesssubmission&a=$workshop->id&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&a=$workshop->id&sid=$submission->id\">".
+ get_string("assess", "workshop")."</A>";
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
+ }
+ }
+ if (isset($table->data)) {
+ print_table($table);
+ }
+ }
+ }
+
+
+function workshop_list_unassessed_teacher_submissions($workshop, $user) {
+ // list the teacher submissions not assessed by this user
+ global $CFG;
+
+ $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ if ($submissions = workshop_get_teacher_submissions($workshop)) {
+ foreach ($submissions as $submission) {
+ $comment = "";
+ // see if user already graded this assessment
+ if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
+ AND userid = $user->id")) {
+ $timenow = time();
+ if (($timenow - $assessment->timecreated < $CFG->maxeditingtime)) {
+ // last chance salon
+ $action = "<A HREF=\"assessments.php?action=assesssubmission&a=$workshop->id&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&a=$workshop->id&sid=$submission->id\">".
+ get_string("assess", "workshop")."</A>";
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
+ }
+ }
+ if (isset($table->data)) {
+ print_table($table);
+ }
+ }
+ }
+
+
+function workshop_list_ungraded_assessments($workshop, $stype) {
+ global $CFG;
+
+ // lists all the assessments of student submissions for grading by teacher
+ $table->head = array (get_string("title", "workshop"), get_string("timeassessed", "workshop"), get_string("action", "workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+ $timenow = time();
+
+ switch ($stype) {
+ case "student" :
+ $assessments = workshop_get_ungraded_assessments_student($workshop);
+ break;
+ case "teacher" :
+ $assessments = workshop_get_ungraded_assessments_teacher($workshop);
+ break;
+ }
+ if ($assessments) {
+ 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&a=$workshop->id&stype=$stype&aid=$assessment->id\">".
+ get_string("edit", "workshop")."</A>";
+ }
+ else {
+ $action = "<A HREF=\"assessments.php?action=gradeassessment&a=$workshop->id&stype=$stype&aid=$assessment->id\">".
+ get_string("grade", "workshop")."</A>";
+ }
+ $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission),
+ userdate($assessment->timecreated), $action);
+ }
+ }
+ if (isset($table->data)) {
+ print_table($table);
+ }
+ }
+ }
+
+
+function workshop_list_user_submissions($workshop, $user) {
+ $table->head = array (get_string("title", "workshop"), get_string("submitted", "assignment"), get_string("assessments", "workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ if ($submissions = workshop_get_user_submissions($workshop, $user)) {
+ foreach ($submissions as $submission) {
+ $n = count_records("workshop_assessments", "submissionid", $submission->id);
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), userdate($submission->timecreated), $n);
+ }
+ print_table($table);
+ }
+ }
+
+
+function workshop_print_assessment($workshop, $assessment, $allowchanges = FALSE) {
+ global $CFG, $WORKSHOP_SCALES, $WORKSHOP_EWEIGHTS, $THEME;
+ if (! $course = get_record("course", "id", $workshop->course)) {
+ error("Course is misconfigured");
+ }
+ if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ // only show the grade if grading strategy > 0 and the grade is positive
+ if ($workshop->gradingstrategy and $assessment->grade >= 0) { \r
+ echo "<CENTER><B>".get_string("thegradeis", "workshop").": ".number_format($assessment->grade, 2)."% (".
+ get_string("maximumgrade")." ".number_format($workshop->grade)."%)</B></CENTER><BR CLEAR=ALL>\n";
+ }
+
+ // now print the grading form with the teacher's comments if any
+ // FORM is needed for Mozilla browsers, else radio bttons are not checked
+ ?>
+ <form name="form" method="post" action="assessments.php">
+ <INPUT TYPE="hidden" NAME="id" VALUE="<?PHP echo $cm->id ?>">
+ <input type="hidden" name="aid" value="<?PHP echo $assessment->id ?>">
+ <input type="hidden" name="action" value="updateassessment">
+ <CENTER>
+ <TABLE CELLPADDING=5 BORDER=1>
+ <?PHP
+
+ // get the assignment elements...
+ if (!$elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC")) {
+ print_string("noteonassignmentelements", "workshop");
+ }
+ else {
+ foreach ($elementsraw as $element) {
+ $elements[] = $element; // to renumber index 0,1,2...
+ }
+ }
+
+ // get any previous grades...
+ if ($gradesraw = get_records_select("workshop_grades", "assessmentid = $assessment->id", "elementno")) {
+ foreach ($gradesraw as $grade) {
+ $grades[] = $grade; // to renumber index 0,1,2...
+ }
+ }
+
+ // determine what sort of grading
+ switch ($workshop->gradingstrategy) {
+ case 0: // no grading
+ // now print the form
+ for ($i=0; $i < count($elements); $i++) {
+ $iplus1 = $i+1;
+ echo "<TR valign=top>\n";\r
+ echo " <TD align=right><P><B>". get_string("element","workshop")." $iplus1:</B></P></TD>\n";\r
+ echo " <TD>".text_to_html($elements[$i]->description);
+ echo "</TD></TR>\n";
+ echo "<TR valign=top>\n";\r
+ echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";\r
+ echo " <TD>\n";
+ if ($allowchanges) {\r
+ echo " <textarea name=\"feedback[]\" rows=3 cols=75 wrap=\"virtual\">\n";
+ if (isset($grades[$i]->feedback)) {
+ echo $grades[$i]->feedback;
+ }
+ echo "</textarea>\n";
+ }
+ else {
+ echo text_to_html($grades[$i]->feedback);
+ }\r
+ echo " </TD>\n";\r
+ echo "</TR>\n";\r
+ echo "<TR valign=top>\n";\r
+ echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ echo "</TR>\n";
+ }
+ break;
+
+ case 1: // accumulative grading
+ // now print the form
+ for ($i=0; $i < count($elements); $i++) {
+ $iplus1 = $i+1;
+ echo "<TR valign=top>\n";\r
+ echo " <TD align=right><P><B>". get_string("element","workshop")." $iplus1:</B></P></TD>\n";\r
+ echo " <TD>".text_to_html($elements[$i]->description);
+ echo "<P align=right><FONT size=1>Weight: "
+ .number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight],2)."</FONT>\n";
+ echo "</TD></TR>\n";
+ echo "<TR valign=top>\n";
+ echo " <TD align=right><P><B>". get_string("grade"). ":</B></P></TD>\n";
+ echo " <TD valign=\"top\">\n";
+
+ // get the appropriate scale
+ $scalenumber=$elements[$i]->scale;
+ $SCALE = (object)$WORKSHOP_SCALES[$scalenumber];
+ switch ($SCALE->type) {
+ case 'radio' :
+ // show selections highest first
+ echo "<CENTER><B>$SCALE->start</B> ";
+ for ($j = $SCALE->size - 1; $j >= 0 ; $j--) {
+ $checked = false;
+ if (isset($grades[$i]->grade)) {
+ if ($j == $grades[$i]->grade) {
+ $checked = true;
+ }
+ }
+ else { // there's no previous grade so check the lowest option
+ if ($j == 0) {
+ $checked = true;
+ }
+ }
+ if ($checked) {
+ echo " <INPUT TYPE=\"RADIO\" NAME=\"grade[$i]\" VALUE=\"$j\" CHECKED> \n";
+ }
+ else {
+ echo " <INPUT TYPE=\"RADIO\" NAME=\"grade[$i]\" VALUE=\"$j\"> \n";
+ }
+ }
+ echo " <B>$SCALE->end</B></CENTER>\n";
+ break;
+ case 'selection' :
+ unset($numbers);
+ for ($j = $SCALE->size; $j >= 0; $j--) {
+ $numbers[$j] = $j;
+ }
+ if (isset($grades[$i]->grade)) {
+ choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, "");
+ }
+ else {
+ choose_from_menu($numbers, "grade[$i]", 0, "");
+ }
+ break;
+ }
+
+ echo " </TD>\n";
+ echo "</TR>\n";
+ echo "<TR valign=top>\n";\r
+ echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";\r
+ echo " <TD>\n";
+ if ($allowchanges) {\r
+ echo " <textarea name=\"feedback[]\" rows=3 cols=75 wrap=\"virtual\">\n";
+ if (isset($grades[$i]->feedback)) {
+ echo $grades[$i]->feedback;
+ }
+ echo "</textarea>\n";
+ }
+ else {
+ echo text_to_html($grades[$i]->feedback);
+ }\r
+ echo " </TD>\n";\r
+ echo "</TR>\n";\r
+ echo "<TR valign=top>\n";\r
+ echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ echo "</TR>\n";
+ }
+ break;
+
+ case 2: // error banded grading
+ // now run through the elements
+ $negativecount = 0;
+ for ($i=0; $i < count($elements) - 1; $i++) {
+ $iplus1 = $i+1;
+ echo "<TR valign=top>\n";\r
+ echo " <TD align=right><P><B>". get_string("element","workshop")." $iplus1:</B></P></TD>\n";\r
+ echo " <TD>".text_to_html($elements[$i]->description);
+ echo "<P align=right><FONT size=1>Weight: "
+ .number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight],2)."</FONT>\n";
+ echo "</TD></TR>\n";
+ echo "<TR valign=top>\n";
+ echo " <TD align=right><P><B>". get_string("grade"). ":</B></P></TD>\n";
+ echo " <TD valign=\"top\">\n";
+
+ // get the appropriate scale - yes/no scale (0)
+ $SCALE = (object) $WORKSHOP_SCALES[0];
+ switch ($SCALE->type) {
+ case 'radio' :
+ // show selections highest first
+ echo "<CENTER><B>$SCALE->start</B> ";
+ for ($j = $SCALE->size - 1; $j >= 0 ; $j--) {
+ $checked = false;
+ if (isset($grades[$i]->grade)) {
+ if ($j == $grades[$i]->grade) {
+ $checked = true;
+ }
+ }
+ else { // there's no previous grade so check the lowest option
+ if ($j == 0) {
+ $checked = true;
+ }
+ }
+ if ($checked) {
+ echo " <INPUT TYPE=\"RADIO\" NAME=\"grade[$i]\" VALUE=\"$j\" CHECKED> \n";
+ }
+ else {
+ echo " <INPUT TYPE=\"RADIO\" NAME=\"grade[$i]\" VALUE=\"$j\"> \n";
+ }
+ }
+ echo " <B>$SCALE->end</B></CENTER>\n";
+ break;
+ case 'selection' :
+ unset($numbers);
+ for ($j = $SCALE->size; $j >= 0; $j--) {
+ $numbers[$j] = $j;
+ }
+ if (isset($grades[$i]->grade)) {
+ choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, "");
+ }
+ else {
+ choose_from_menu($numbers, "grade[$i]", 0, "");
+ }
+ break;
+ }
+
+ echo " </TD>\n";
+ echo "</TR>\n";
+ echo "<TR valign=top>\n";\r
+ echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";\r
+ echo " <TD>\n";
+ if ($allowchanges) {\r
+ echo " <textarea name=\"feedback[$i]\" rows=3 cols=75 wrap=\"virtual\">\n";
+ if (isset($grades[$i]->feedback)) {
+ echo $grades[$i]->feedback;
+ }
+ echo "</textarea>\n";
+ }
+ else {
+ if (isset($grades[$i]->feedback)) {
+ echo text_to_html($grades[$i]->feedback);
+ }
+ }\r
+ echo " </TD>\n";\r
+ echo "</TR>\n";\r
+ echo "<TR valign=top>\n";\r
+ echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ echo "</TR>\n";
+ if (empty($grades[$i]->grade)) {
+ $negativecount++;
+ }
+ }
+ // print the number of negative elements
+ // echo "<TR><TD>".get_string("numberofnegativeitems", "workshop")."</TD><TD>$negativecount</TD></TR>\n";\r
+ // echo "<TR valign=top>\n";\r
+ // echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ echo "</TABLE></CENTER>\n";
+ // now print the grade table
+ echo "<P><CENTER><B>".get_string("gradetable","workshop")."</B></CENTER>\n";
+ echo "<CENTER><TABLE cellpadding=5 border=1><TR><TD ALIGN=\"CENTER\">".
+ get_string("numberofnegativeresponses", "workshop");
+ echo "</TD><TD>". get_string("suggestedgrade", "workshop")."</TD></TR>\n";
+ for ($j = 100; $j >= 0; $j--) {
+ $numbers[$j] = $j;
+ }
+ for ($i=0; $i<=$workshop->nelements; $i++) {
+ if ($i == $negativecount) {
+ echo "<TR><TD ALIGN=\"CENTER\"><IMG SRC=\"../../pix/t/right.gif\"> $i</TD><TD ALIGN=\"CENTER\">{$elements[$i]->maxscore}</TD></TR>\n";
+ }
+ else {
+ echo "<TR><TD ALIGN=\"CENTER\">$i</TD><TD ALIGN=\"CENTER\">{$elements[$i]->maxscore}</TD></TR>\n";
+ }
+ }
+ echo "</TABLE></CENTER>\n";
+ echo "<P><CENTER><TABLE cellpadding=5 border=1><TR><TD>".get_string("adjustment", "workshop")."</TD><TD>\n";
+ unset($numbers);
+ for ($j = 20; $j >= -20; $j--) {
+ $numbers[$j] = $j;
+ }
+ if (isset($grades[$workshop->nelements]->grade)) {
+ choose_from_menu($numbers, "grade[$workshop->nelements]", $grades[$workshop->nelements]->grade, "");
+ }
+ else {
+ choose_from_menu($numbers, "grade[$workshop->nelements]", 0, "");
+ }
+ echo "</TD></TR>\n";
+ break;
+
+ case 3: // criteria grading
+ echo "<TR valign=top>\n";\r
+ echo " <TD BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ echo " <TD BGCOLOR=\"$THEME->cellheading2\"><B>". get_string("criterion","workshop")."</B></TD>\n";\r
+ echo " <TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("select", "workshop")."</B></TD>\n";
+ echo " <TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("suggestedgrade", "workshop")."</B></TD>\n";
+ // find which criteria has been selected (saved in the zero element), if any
+ if (isset($grades[0]->grade)) {
+ $selection = $grades[0]->grade;
+ }
+ else {
+ $selection = 0;
+ }
+ // now run through the elements
+ for ($i=0; $i < count($elements); $i++) {
+ $iplus1 = $i+1;
+ echo "<TR valign=top>\n";\r
+ echo " <TD>$iplus1</TD><TD>".text_to_html($elements[$i]->description)."</TD>\n";
+ if ($selection == $i) {
+ echo " <TD align=center><INPUT TYPE=\"RADIO\" NAME=\"grade[0]\" VALUE=\"$i\" CHECKED></TD>\n";
+ }
+ else {
+ echo " <TD align=center><INPUT TYPE=\"RADIO\" NAME=\"grade[0]\" VALUE=\"$i\"></TD>\n";
+ }
+ echo "<TD align=center>{$elements[$i]->maxscore}</TD></TR>\n";
+ }
+ echo "</TABLE></CENTER>\n";
+ echo "<P><CENTER><TABLE cellpadding=5 border=1><TR><TD>".get_string("adjustment", "workshop")."</TD><TD>\n";
+ unset($numbers);
+ for ($j = 20; $j >= -20; $j--) {
+ $numbers[$j] = $j;
+ }
+ if (isset($grades[1]->grade)) {
+ choose_from_menu($numbers, "grade[1]", $grades[1]->grade, "");
+ }
+ else {
+ choose_from_menu($numbers, "grade[1]", 0, "");
+ }
+ echo "</TD></TR>\n";
+ } // end of outer switch
+
+ // now get the general comment (present in all types)
+ echo "<TR valign=top>\n";\r
+ echo " <TD align=right><P><B>". get_string("generalcomment", "workshop").":</B></P></TD>\n";\r
+ echo " <TD>\n";\r
+ if ($allowchanges) {
+ echo " <textarea name=\"generalcomment\" rows=5 cols=75 wrap=\"virtual\">\n";
+ if (isset($assessment->generalcomment)) {
+ echo $assessment->generalcomment;
+ }
+ echo "</textarea>\n";
+ }
+ else {
+ if (isset($assessment->generalcomment)) {
+ echo text_to_html($assessment->generalcomment);
+ }
+ }\r
+ echo " </TD>\n";\r
+ echo "</TR>\n";\r
+ echo "<TR valign=top>\n";\r
+ echo " <TD colspan=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ echo "</TR>\n";
+
+ $timenow = time();
+ // now show the teacher's comment if available...
+ if ($assessment->timegraded and (($timenow - $assessment->timegraded) > $CFG->maxeditingtime)) {
+ echo "<TR valign=top>\n";\r
+ echo " <TD align=right><P><B>". get_string("teacherscomment", "workshop").":</B></P></TD>\n";\r
+ echo " <TD>\n";\r
+ echo text_to_html($assessment->teachercomment);
+ echo " </TD>\n";\r
+ echo "</TR>\n";
+ echo "<TR valign=top>\n";\r
+ echo " <TD align=right><P><B>". get_string("teachersgrade", "workshop").":</B></P></TD>\n";\r
+ echo " <TD>\n";\r
+ echo number_format($assessment->gradinggrade*100/COMMENTSCALE,0)."%";
+ echo " </TD>\n";\r
+ echo "</TR>\n";
+ echo "<TR valign=top>\n";\r
+ echo " <TD colspan=2 BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";\r
+ echo "</TR>\n";
+ }
+
+ // ...and close the table, show submit button if needed and close the form
+ echo "</TABLE>\n";
+ if ($allowchanges) {
+ echo "<INPUT TYPE=submit VALUE=\"".get_string("savemyassessment", "workshop")."\">\n";
+ }
+ echo "</CENTER>";
+ echo "</FORM>\n";
+ }\r
+
+
+function workshop_print_difference($time) {
+ if ($time < 0) {
+ $timetext = get_string("late", "assignment", format_time($time));
+ return " (<FONT COLOR=RED>$timetext</FONT>)";
+ } else {
+ $timetext = get_string("early", "assignment", format_time($time));
+ return " ($timetext)";
+ }
+}
+
+function workshop_print_feedback($course, $submission) {
+ global $CFG, $THEME, $RATING;
+
+ if (! $teacher = get_record("user", "id", $submission->teacher)) {
+ error("Weird workshop error");
+ }
+
+ echo "\n<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=1 ALIGN=CENTER><TR><TD BGCOLOR=#888888>";
+ echo "\n<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 VALIGN=TOP>";
+
+ echo "\n<TR>";
+ echo "\n<TD ROWSPAN=3 BGCOLOR=\"$THEME->body\" WIDTH=35 VALIGN=TOP>";
+ print_user_picture($teacher->id, $course->id, $teacher->picture);
+ echo "</TD>";
+ echo "<TD NOWRAP WIDTH=100% BGCOLOR=\"$THEME->cellheading\">$teacher->firstname $teacher->lastname";
+ echo " <FONT SIZE=2><I>".userdate($submission->timemarked)."</I>";
+ echo "</TR>";
+
+ echo "\n<TR><TD WIDTH=100% BGCOLOR=\"$THEME->cellcontent\">";
+
+ echo "<P ALIGN=RIGHT><FONT SIZE=-1><I>";
+ if ($submission->grade) {
+ echo get_string("grade").": $submission->grade";
+ } else {
+ echo get_string("nograde");
+ }
+ echo "</I></FONT></P>";
+
+ echo text_to_html($submission->assessorcomment);
+ echo "</TD></TR></TABLE>";
+ echo "</TD></TR></TABLE>";
+}
+
+
+function workshop_print_submission_assessments($workshop, $submission, $type) {
+ // Returns the teacher or peer grade and a hyperlinked list of grades for this submission
+
+ if ($assessments = workshop_get_assessments($submission)) {
+ switch ($type) {
+ case "teacher" :
+ $str = "$submission->teachergrade (";
+ foreach ($assessments as $assessment) {
+ if (isteacher($workshop->course, $assessment->userid)) {
+ $str .= "<A HREF=\"assessments.php?action=viewassessment&a=$workshop->id&aid=$assessment->id\">";
+ $str .= number_format($assessment->grade, 1)."</A> ";
+ }
+ }
+ break;
+ case "student" :
+ $str = "$submission->peergrade (";
+ foreach ($assessments as $assessment) {
+ if (isstudent($workshop->course, $assessment->userid)) {
+ $str .= "<A HREF=\"assessments.php?action=viewassessment&a=$workshop->id&aid=$assessment->id\">";
+ $str .= number_format($assessment->grade, 1)."</A> ";
+ }
+ }
+ break;
+ }
+ $str .= ")";
+ }
+ else {
+ $str ="0";
+ }
+ return $str;
+}
+
+
+function workshop_print_submission_title($workshop, $submission) {
+// Arguments are objects
+
+ global $CFG;
+
+ if (!$submission->timecreated) { // a "no submission"
+ return $submission->title;
+ }
+
+ $filearea = workshop_file_area_name($workshop, $submission);
+ if ($basedir = workshop_file_area($workshop, $submission)) {
+ if (list($file) = get_directory_list($basedir)) {
+ $icon = mimeinfo("icon", $file);
+ if ($CFG->slasharguments) {
+ $ffurl = "file.php/$filearea/$file";
+ } else {
+ $ffurl = "file.php?file=/$filearea/$file";
+ }
+ return "<IMG SRC=\"$CFG->wwwroot/files/pix/$icon\" HEIGHT=16 WIDTH=16 BORDER=0 ALT=\"File\">".
+ " <A TARGET=\"uploadedfile\" HREF=\"$CFG->wwwroot/$ffurl\">$submission->title</A>";
+ }
+ }
+}
+
+
+function workshop_print_user_assessments($workshop, $user) {
+ // Returns the number of assessments and a hyperlinked list of grading grades for the assessments made by this user
+
+ if ($assessments = workshop_get_user_assessments($workshop, $user)) {
+ $n = count($assessments);
+ $str = "$n (";
+ foreach ($assessments as $assessment) {
+ if ($assessment->timegraded) {
+ $gradingscaled = intval($assessment->gradinggrade * $workshop->grade / COMMENTSCALE);
+ $str .= "<A HREF=\"assessments.php?action=viewassessment&a=$workshop->id&aid=$assessment->id\">";
+ $str .= "$gradingscaled</A> ";
+ }
+ else {
+ $str .= "<A HREF=\"assessments.php?action=viewassessment&a=$workshop->id&aid=$assessment->id\">";
+ $str .= "-</A> ";
+ }
+ }
+ $str .= ")";
+ }
+ else {
+ $str ="0";
+ }
+ return $str;
+ }
+
+
+function workshop_print_time_to_deadline($time) {
+ if ($time < 0) {
+ $timetext = get_string("afterdeadline", "workshop", format_time($time));
+ return " (<FONT COLOR=RED>$timetext</FONT>)";
+ } else {
+ $timetext = get_string("beforedeadline", "workshop", format_time($time));
+ return " ($timetext)";
+ }
+}
+
+
+function workshop_print_upload_form($workshop) {
+// Arguments are objects, needs title coming in
+
+ echo "<DIV ALIGN=CENTER>";
+ echo "<FORM ENCTYPE=\"multipart/form-data\" METHOD=\"POST\" ACTION=upload.php>";
+ echo " <INPUT TYPE=hidden NAME=MAX_FILE_SIZE value=\"$workshop->maxbytes\">";
+ echo " <INPUT TYPE=hidden NAME=a VALUE=\"$workshop->id\">";
+ echo get_string("title", "workshop")." <INPUT NAME=\"title\" TYPE=\"text\" SIZE=\"60\" MAXSIZE=\"100\"><BR><BR>\n";
+ echo " <INPUT NAME=\"newfile\" TYPE=\"file\" size=\"50\">";
+ echo " <INPUT TYPE=submit NAME=save VALUE=\"".get_string("uploadthisfile")."\">";
+ echo "</FORM>";
+ echo "</DIV>";
+}
+
+function workshop_test_user_assessments($workshop, $user) {
+ // see if user has passed the required number of assessments of teachers submissions
+ global $CFG;
+
+ $result = TRUE;
+ $n = 0;
+ $timenow =time();
+ if ($workshop->ntassessments) { // they have to pass some!
+ if ($submissions = workshop_get_teacher_submissions($workshop)) {
+ foreach ($submissions as $submission) {
+ if ($assessment = workshop_get_submission_assessment($submission, $user)) {
+ if (($assessment->gradinggrade >= COMMENTSCALE*0.4) and
+ (($timenow - $assessment->timegraded) > $CFG->maxeditingtime)) {
+ $n++;
+ }
+ }
+ }
+ }
+ if ($n < min($workshop->ntassessments, workshop_count_teacher_submissions($workshop))) {
+ $result = FALSE;
+ }
+ }
+ return $result;
+ }
+
+?>
--- /dev/null
+<?
+ if ($usehtmleditor = can_use_richtext_editor()) {
+ $defaultformat = FORMAT_HTML;
+ $onsubmit = "onsubmit=\"copyrichtext(document.form.description);\"";
+ } else {
+ $defaultformat = FORMAT_MOODLE;
+ $onsubmit = "";
+ }
+?>
+
+<form name="form" method="post" <?=$onsubmit ?> action="<?=$ME ?>">
+<table cellpadding=5>
+<tr valign=top>
+ <td align=right><P><B><? print_string("title", "workshop") ?>:</B></P></TD>
+ <td>
+ <input type="text" name="name" size=60 value="<? p($form->name) ?>">
+ </td>
+</tr>
+<tr valign=top>
+ <td align=right><P><B><? print_string("description", "workshop") ?>:</B></P></TD>
+ <td>
+ <?
+ print_textarea($usehtmleditor, 20, 60, 595, 400, "description", $form->description);
+
+ if ($usehtmleditor) {
+ helpbutton("richtext", get_string("helprichtext"));
+ } else {
+ helpbutton("text", get_string("helptext"));
+ }
+ echo "<P align=right>";
+ print_string("formattexttype");
+ echo ": ";
+ if (!$form->format) {
+ $form->format = $defaultformat;
+ }
+ choose_from_menu(format_text_menu(), "format", $form->format, "");
+ helpbutton("textformat", get_string("formattexttype"));
+ echo "</P>";
+ ?>
+ </td>
+</tr>
+
+<tr valign=top>
+ <td align=right><P><B><? print_string("maximumgrade") ?>:</B></P></TD>
+ <td>
+ <?
+ for ($i=100; $i>=0; $i--) {
+ $grades[$i] = $i;
+ }
+ choose_from_menu($grades, "grade", "$form->grade", "");
+ ?>
+ </td>
+</tr>
+
+<tr valign=top>
+ <td align=right><P><B><? print_string("gradingstrategy", "workshop") ?>:</B></P></TD>
+ <td>
+ <?PHP
+ require("$CFG->dirroot/mod/workshop/lib.php");
+ if (!isset($form->gradingstrategy)) {
+ $form->gradingstrategy = 1; // default
+ }
+ choose_from_menu($WORKSHOP_TYPE, "gradingstrategy", $form->gradingstrategy, "");
+ helpbutton("gradingstrategy", get_string("gradingstrategy", "workshop"), "workshop");
+ ?>
+ </td>
+</tr>
+
+<tr valign=top>
+ <td align=right><P><B><? print_string("numberofassessmentelements", "workshop") ?>:</B></P></TD>
+ <td>
+ <?
+ for ($i=20; $i>=0; $i--) {
+ $numbers[$i] = $i;
+ }
+ choose_from_menu($numbers, "nelements", "$form->nelements", "");
+ helpbutton("nelements", get_string("numberofassessmentelements", "workshop"), "workshop");
+ ?>
+ </td>
+</tr>
+
+<tr>
+ <td align=right><P><B><? print_string("allowresubmit", "workshop") ?>:</B></P></TD>
+ <td>
+ <?PHP
+ $options[0] = get_string("no"); $options[1] = get_string("yes");
+ choose_from_menu($options, "resubmit", $form->resubmit, "");
+ helpbutton("resubmit", get_string("allowresubmit", "workshop"), "workshop");
+ ?>
+ </td>
+</tr>
+
+<tr valign=top>
+ <td align=right><P><B><? print_string("numberofassessmentsofteachersexamples", "workshop") ?>:</B></P></TD>
+ <td>
+ <?PHP
+ for ($i=20; $i>=0; $i--) {
+ $numbers[$i] = $i;
+ }
+ choose_from_menu($numbers, "ntassessments", $form->ntassessments, "");
+ helpbutton("nassessmentsofteachersexamples", get_string("numberofassessmentsofteachersexamples", "workshop"), "workshop");
+ ?>
+ </td>
+</tr>
+
+<tr valign=top>
+ <td align=right><P><B><? print_string("numberofassessmentsofstudentsubmissions", "workshop") ?>:</B></P></TD>
+ <td>
+ <?PHP
+ for ($i=20; $i>=0; $i--) {
+ $numbers[$i] = $i;
+ }
+ choose_from_menu($numbers, "nsassessments", $form->nsassessments, "");
+ helpbutton("nassessmentsofstudentsubmissions", get_string("numberofassessmentsofstudentsubmissions", "workshop"), "workshop");
+ ?>
+ </td>
+</tr>
+
+<tr>
+ <td align=right><P><B><? print_string("selfassessment", "workshop") ?>:</B></P></TD>
+ <td>
+ <?PHP
+ $options[0] = get_string("no"); $options[1] = get_string("yes");
+ choose_from_menu($options, "includeself", $form->includeself, "");
+ helpbutton("selfassessment", get_string("selfassessment", "workshop"), "workshop");
+ ?>
+ </td>
+</tr>
+
+<tr valign=top>
+ <td align=right><P><B><? print_string("maximumsize", "workshop") ?>:</B></P></TD>
+ <td>
+ <?
+ $sizelist = array("10Kb", "50Kb", "100Kb", "500Kb", "1Mb", "2Mb", "5Mb", "10Mb", "20Mb", "50Mb");
+ $maxsize = get_max_upload_file_size();
+ $sizeinlist = false;
+ foreach ($sizelist as $size) {
+ $sizebytes = get_real_size($size);
+ if ($sizebytes < $maxsize) {
+ $filesize[$sizebytes] = $size;
+ }
+ if ($form->maxbytes == $sizebytes) {
+ $sizeinlist = true;
+ }
+ }
+ $filesize[$maxsize] = display_size($maxsize);
+ if (!$sizeinlist) {
+ $form->maxbytes = get_real_size("500K");
+ }
+ ksort($filesize, SORT_NUMERIC);
+ choose_from_menu($filesize, "maxbytes", "$form->maxbytes", "");
+ ?>
+ </td>
+</tr>
+
+<tr valign=top>
+ <td align=right><P><B><? print_string("deadline", "workshop") ?>:</B></td>
+ <td><?
+ print_date_selector("deadlineday", "deadlinemonth", "deadlineyear", $form->deadline);
+ echo " - ";
+ print_time_selector("deadlinehour", "deadlineminute", $form->deadline);
+ formerr($err["deadline"]);
+ ?></td>
+</tr>
+
+</table>
+<BR>
+<CENTER>
+<input type="hidden" name=course value="<? p($form->course) ?>">
+<input type="hidden" name=coursemodule value="<? p($form->coursemodule) ?>">
+<input type="hidden" name=section value="<? p($form->section) ?>">
+<input type="hidden" name=module value="<? p($form->module) ?>">
+<input type="hidden" name=modulename value="<? p($form->modulename) ?>">
+<input type="hidden" name=instance value="<? p($form->instance) ?>">
+<input type="hidden" name=mode value="<? p($form->mode) ?>">
+<input type="submit" value="<? print_string("savechanges") ?>">
+<input type="submit" name=cancel value="<? print_string("cancel") ?>">
+<p>
+<p><?PHP notify(get_string("noteonassessmentelements", "workshop")); ?>
+
+</CENTER>
+</FORM>
+
+<?
+ if ($usehtmleditor) {
+ print_richedit_javascript("form", "description", "no");
+ }
+?>
+
--- /dev/null
+<?PHP
+/* submissions.php: version 1.0 30th April 2003 */
+
+/*************************************************
+ ACTIONS handled are:
+
+ calculatefinalgrades
+ displayfinalgrades (teachers only)
+ displayfinalweights
+ listallsubmissions
+ listforassessmentstudent
+ listforassessmentteacher
+
+
+************************************************/
+
+ require("../../config.php");
+ require("lib.php");
+
+ error_reporting(15);
+
+ optional_variable($id); // Course Module ID
+ optional_variable($a); // workshop ID
+
+ // get some useful stuff...
+ if ($id) {
+ if (! $cm = get_record("course_modules", "id", $id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ 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");
+ }
+
+ } else {
+ if (! $workshop = get_record("workshop", "id", $a)) {
+ error("Course module is incorrect");
+ }
+ if (! $course = get_record("course", "id", $workshop->course)) {
+ error("Course is misconfigured");
+ }
+ if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
+ error("Course Module ID was incorrect");
+ }
+ }
+
+ require_login($course->id);
+
+ if ($course->category) {
+ $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
+ }
+
+ $strworkshops = get_string("modulenameplural", "workshop");
+ $strworkshop = get_string("modulename", "workshop");
+ $strsubmissions = get_string("submissions", "workshop");
+
+ // ... print the header and...
+ print_header("$course->shortname: $workshop->name", "$course->fullname",
+ "$navigation <A HREF=index.php?id=$course->id>$strworkshops</A> ->
+ <A HREF=\"view.php?a=$workshop->id\">$workshop->name</A> -> $strsubmissions",
+ "", "", true);
+
+ //...get the action or set up an suitable default
+ optional_variable($action);
+ if (empty($action)) {
+ $action = "listallsubmissions";
+ }
+
+
+ /*************** calculate final grades (by teacher) ***************************/
+ if ($action == 'calculatefinalgrades') {
+
+ $form = (object)$_POST;
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ // Get all the students in surname order
+ if (!$users = get_course_students($course->id, "u.firstname, u.lastname")) {
+ print_heading(get_string("nostudentsyet"));
+ print_footer($course);
+ exit;
+ }
+
+ // set up the weights from the calculate final grades form...
+ if (isset($form->teacherweight)) {
+ $teacherweight = $form->teacherweight;
+ // ...and save them
+ set_field("workshop", "teacherweight", $teacherweight, "id", "$workshop->id");
+ }
+
+ if (isset($form->peerweight)) {
+ $peerweight = $form->peerweight;
+ // ...and save them
+ set_field("workshop", "peerweight", $peerweight, "id", "$workshop->id");
+ }
+
+ // get the include teachers grade flag
+ if (isset($form->includeteachersgrade)) {
+ $includeteachersgrade = $form->includeteachersgrade;
+ set_field("workshop", "includeteachersgrade", $includeteachersgrade, "id", "$workshop->id");
+ }
+
+ if (isset($form->biasweight)) {
+ $biasweight = $form->biasweight;
+ // ...and save them
+ set_field("workshop", "biasweight", $biasweight, "id", "$workshop->id");
+ }
+
+ if (isset($form->reliabilityweight)) {
+ $reliabilityweight = $form->reliabilityweight;
+ // ...and save them
+ set_field("workshop", "reliabilityweight", $reliabilityweight, "id", "$workshop->id");
+ }
+
+ if (isset($form->gradingweight)) {
+ $gradingweight = $form->gradingweight;
+ // ...and save them
+ set_field("workshop", "gradingweight", $gradingweight, "id", "$workshop->id");
+ }
+
+ // work out what to show in the final grades tables and what to include in the calculation of the final grade
+ // teacher grades?
+ if ($workshop->gradingstrategy and $teacherweight) {
+ $useteachersgrades = 1;
+ }
+ else {
+ $useteachersgrades = 0;
+ }
+ // peergrades?
+ if ($workshop->gradingstrategy and $workshop->nsassessments and $peerweight) {
+ $usepeergrades = 1;
+ }
+ else {
+ $usepeergrades = 0;
+ }
+ // bias grades?
+ if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and ($useteachersgrades or $usepeergrades)
+ and $biasweight ) {
+ $usebiasgrades = 1;
+ }
+ else {
+ $usebiasgrades = 0;
+ }
+ // reliability grades?
+ if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and ($useteachersgrades or $usepeergrades)
+ and $reliabilityweight ) {
+ $usereliabilitygrades = 1;
+ }
+ else {
+ $usereliabilitygrades = 0;
+ }
+ // grading grades?
+ if (($workshop->ntassessments or $workshop->nsassessments) and $gradingweight ) {
+ $usegradinggrades = 1;
+ }
+ else {
+ $usegradinggrades = 0;
+ }
+
+ // start to calculate the grand means
+ $sumallteachergrades = 0.0;
+ $nallteachergrades = 0;
+ $sumallpeergrades = 0.0;
+ $nallpeergrades = 0;
+ // get the grades of each student's submission...
+ // the method used allowed a submission to be graded by more than one teacher
+ if (workshop_count_student_submissions($workshop)) {
+ echo "<CENTER><B>".get_string("studentsubmissions", "workshop", $course->student);
+ echo "<BR><TABLE BORDER=1 WIDTH=\"90%\"><TR>\n";
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>$course->student</B></TD>\n";
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("submissions","workshop")."</B></TD>\n";
+ if ($useteachersgrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("assessmentsby", "workshop", $course->teachers)."</B></TD>\n";
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("numberofassessments", "workshop")."</B></TD>\n";
+ }
+ if ($usepeergrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("assessmentsby", "workshop", $course->students)."</B></TD>\n";
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("numberofassessments", "workshop")."</B></TD>\n";
+ }
+ if ($useteachersgrades or $usepeergrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("gradeofsubmission", "workshop")."</B></TD></TR>\n";
+ }
+ // display weights
+ echo "<TR><TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("weights","workshop")."</B></TD>\n";
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";
+ if ($useteachersgrades) {
+ echo "<TD COLSPAN=\"2\" BGCOLOR=\"$THEME->cellheading2\"><CENTER><B>$WORKSHOP_FWEIGHTS[$teacherweight]</B></CENTER></TD>\n";
+ }
+ if ($usepeergrades) {
+ echo "<TD COLSPAN=\"2\" BGCOLOR=\"$THEME->cellheading2\"><CENTER><B>$WORKSHOP_FWEIGHTS[$peerweight]</B></CENTER></TD>\n";
+ }
+ if ($useteachersgrades or $usepeergrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"> </TD>\n";
+ }
+ echo "<TR>\n";
+ // go through the submissions in "user" order, makes comparing the two tables easier
+ foreach ($users as $user) {
+ if ($submissions = workshop_get_user_submissions($workshop, $user)) {
+ foreach ($submissions as $submission) {
+ $sumteachergrades = 0.0;
+ $nteachergrades = 0;
+ $sumpeergrades = 0.0;
+ $npeergrades = 0;
+ // have a look at each assessment and add to arrays
+ if ($assessments = workshop_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ if (isteacher($workshop->course, $assessment->userid)) {
+ // it's a teacher's
+ $sumteachergrades += $assessment->grade;
+ $nteachergrades++;
+ if ($includeteachersgrade) { // add it to the student grades
+ $sumpeergrades += $assessment->grade;
+ $npeergrades++;
+ }
+ }
+ else {
+ // its' a student's
+ $sumpeergrades += $assessment->grade;
+ $npeergrades++;
+ }
+ }
+ }
+ if ($nteachergrades) {
+ $teachergrade = intval($sumteachergrades / $nteachergrades + 0.5);
+ $sumallteachergrades += $teachergrade;
+ $nallteachergrades++;
+ }
+ else {
+ $teachergrade = 0;
+ }
+ if ($npeergrades) {
+ $peergrade = intval($sumpeergrades / $npeergrades + 0.5);
+ $sumallpeergrades += $peergrade;
+ $nallpeergrades++;
+ }
+ else {
+ $peergrade = 0;
+ }
+ if ($teacherweight + $peerweight > 0) {
+ $grade = intval((($useteachersgrades * $teachergrade * $WORKSHOP_FWEIGHTS[$teacherweight] +
+ $usepeergrades * $peergrade * $WORKSHOP_FWEIGHTS[$peerweight]) /
+ ($useteachersgrades * $WORKSHOP_FWEIGHTS[$teacherweight] +
+ $usepeergrades * $WORKSHOP_FWEIGHTS[$peerweight])) + 0.5);
+ }
+ else {
+ $grade = 0;
+ }
+ // display the grades...
+ echo "<TR><TD>$user->firstname $user->lastname</TD>\n";
+ echo "<TD>".workshop_print_submission_title($workshop, $submission)."</TD>\n";
+ if ($useteachersgrades) {
+ echo "<TD>$teachergrade</TD>\n";
+ echo "<TD>[$nteachergrades]</TD>\n";
+ }
+ if ($usepeergrades) {
+ echo "<TD>$peergrade</TD>\n";
+ echo "<TD>[$npeergrades]</TD>\n";
+ }
+ if ($useteachersgrades or $usepeergrades) {
+ echo "<TD>$grade</TD></TR>\n";
+ }
+ // ...and save in the database
+ set_field("workshop_submissions", "teachergrade", $teachergrade, "id", $submission->id);
+ set_field("workshop_submissions", "peergrade", $peergrade, "id", $submission->id);
+ }
+ }
+ }
+ echo "</TABLE></CENTER>\n";
+ }
+ // now display the overall teacher and peer means
+ if ($nallteachergrades) {
+ $grandteachergrade = $sumallteachergrades / $nallteachergrades;
+ }
+ else {
+ $grandteachergrade = 0;
+ }
+ if ($nallpeergrades) {
+ $grandpeergrade = $sumallpeergrades / $nallpeergrades;
+ }
+ else {
+ $grandpeergrade = 0;
+ }
+ if ($useteachersgrades) {
+ echo "<P><B>".get_string("overallteachergrade", "workshop", number_format($grandteachergrade, 2))." [$nallteachergrades]</B>\n";
+ }
+ if ($usepeergrades) {
+ echo "<P><B>".get_string("overallpeergrade", "workshop", number_format($grandpeergrade, 2))." [$nallpeergrades]</B><BR>\n";
+ }
+ // run thru each users and see how their assessments faired, we may junk the grading stats but what the heck!
+ foreach ($users as $user) {
+ // we need to calculate a user bias before we can calculate their reliability
+ $sumbias = 0.0;
+ // nbias is used later to show how many peer assessments the user has done
+ $nbias[$user->id] = 0;
+ if ($workshop->nsassessments) { // peer assessments?
+ // run thru this user's assessments on the STUDENT submissions
+ if ($assessments = workshop_get_student_assessments($workshop, $user)) {
+ foreach ($assessments as $assessment) {
+ $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
+ // calculate the sum of "validity" values, the bias in a user's grading...
+ $sumbias += $submission->peergrade - $assessment->grade;
+ $nbias[$user->id]++;
+ }
+ }
+ }
+ if ($nbias[$user->id] > 1) {
+ // we could divide by n-1 to remove own score from calculation of mean but we don't because we re-use bias
+ // values in the calculation of reliability, and it's all relative anyway
+ $bias[$user->id] = $sumbias / $nbias[$user->id];
+ }
+ else {
+ $bias[$user->id] = 0.0;
+ }
+ // now look at all the user's assessments of both the TEACHER's submissions and the STUDENT submissions
+ // to calculate their overall grading grade
+ $sumgradinggrade = 0.0;
+ $ngradinggrades = 0;
+ if ($workshop->ntassessments or $workshop->nsassessments) { // worth looking?
+ if ($assessments = workshop_get_user_assessments($workshop, $user)) {
+ foreach ($assessments as $assessment) {
+ if ($assessment->timegraded > 0) {
+ $sumgradinggrade += $assessment->gradinggrade;
+ $ngradinggrades++;
+ }
+ }
+ }
+ }
+ if ($ngradinggrades) {
+ $gradinggrade[$user->id] = $sumgradinggrade / $ngradinggrades;
+ }
+ else {
+ $gradinggrade[$user->id] = 0.0;
+ }
+ }
+
+ // calculate the mean value of "reliability", the accuracy of a user's grading (disregarding bias)
+ // use a linear function rather than a squared function for reliability
+ // at the same time calculate a reliability of a "dumb user" whose grades everything at the grand mean value
+ $sumdumbreliability = 0.0;
+ $ndumbreliability =0;
+ foreach ($users as $user) {
+ $sumreliability = 0.0;
+ $nreliability = 0;
+ if ($workshop->nsassessments) { // worth a look?
+ // look only at the user's assessment of STUDENT submissions
+ if ($assessments = workshop_get_student_assessments($workshop, $user)) {
+ foreach ($assessments as $assessment) {
+ $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
+ $sumreliability += abs($submission->peergrade - $assessment->grade - $bias[$user->id]);
+ $nreliability++;
+ $sumdumbreliability += abs($submission->peergrade - $grandpeergrade);
+ $ndumbreliability++;
+ }
+ }
+ }
+ // calculate the mean reliability values
+ if ($nreliability) {
+ $reliability[$user->id] = $sumreliability / $nreliability;
+ }
+ else {
+ $reliability[$user->id] = 999999; // big number
+ }
+ }
+ if ($ndumbreliability) {
+ $dumbreliability = $sumdumbreliability / $ndumbreliability;
+ }
+ else {
+ $dumbreliability = 999999; // big number
+ }
+
+ // convert bias and reliability values into scales where 1 is prefect, 0 is no grading done...
+ // ...but first find the largest (absolute) value of the bias measures
+ if (max($bias) > abs(min($bias))) {
+ $maxbias = max($bias);
+ }
+ else {
+ $maxbias = abs(min($bias));
+ }
+
+ echo "<P><CENTER>".get_string("studentgrades", "workshop", $course->student)."<BR>\n";
+ echo "<CENTER><TABLE BORDER=1 WIDTH=\"90%\"><TR>
+ <TD BGCOLOR=\"$THEME->cellheading2\"><B>$course->student</B></TD>\n";
+ if ($useteachersgrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("assessmentsby", "workshop", $course->teachers)."</B></TD>\n";
+ }
+ if ($usepeergrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("assessmentsby", "workshop", $course->students)."</B></TD>\n";
+ }
+ if ($usebiasgrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("gradeforbias", "workshop")."</B></TD>\n";
+ }
+ if ($usereliabilitygrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("gradeforreliability", "workshop")."</B></TD>\n";
+ }
+ if ($usegradinggrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("gradeforassessments", "workshop")."</B></TD>\n";
+ }
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("overallgrade", "workshop")."</B></TD></TR>\n";
+ // now display the weights
+ echo "<TR><TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("weights","workshop")."</B></TD>\n";
+ if ($useteachersgrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>$WORKSHOP_FWEIGHTS[$teacherweight]</B></TD>\n";
+ }
+ if ($usepeergrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>$WORKSHOP_FWEIGHTS[$peerweight]</B></TD>\n";
+ }
+ if ($usebiasgrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>$WORKSHOP_FWEIGHTS[$biasweight]</B></TD>\n";
+ }
+ if ($usereliabilitygrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>$WORKSHOP_FWEIGHTS[$reliabilityweight]</B></TD>\n";
+ }
+ if ($usegradinggrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>$WORKSHOP_FWEIGHTS[$gradingweight]</B></TD>\n";
+ }
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B> </B></TD></TR>\n";
+ foreach ($users as $user) {
+ // get user's best submission
+ $bestgrade = -1;
+ $teachergrade = 0;
+ $peergrade = 0;
+ if ($submissions = workshop_get_user_submissions($workshop, $user)) {
+ foreach ($submissions as $submission) {
+ $grade = ($submission->teachergrade * $WORKSHOP_FWEIGHTS[$teacherweight] +
+ $submission->peergrade * $WORKSHOP_FWEIGHTS[$peerweight]) /
+ ($WORKSHOP_FWEIGHTS[$teacherweight] + $WORKSHOP_FWEIGHTS[$peerweight]);
+ if ($grade > $bestgrade) {
+ $bestgrade = $grade;
+ $teachergrade = $submission->teachergrade;
+ $peergrade = $submission->peergrade;
+ $bestsubmission = $submission;
+ }
+ }
+ }
+ else { // funny this user did not submit - create a dummy submission to hold any grades they might have
+ $bestsubmission->workshopid = $workshop->id;
+ $bestsubmission->userid = $user->id;
+ $bestsubmission->title = "No Submission";
+ $bestsubmission->timecreated = 0;
+ if (!$bestsubmission->id = insert_record("workshop_submissions", $bestsubmission)) {
+ error("Unable to create dummy submission record");
+ }
+ }
+ // biasgrade is scaled between zero and one NEED TO ADD TEST FOR NO PEER ASSESSMENTS OF SUBMITTED WORK
+ if ($maxbias) {
+ $biasgrade = max(($nbias[$user->id] / $workshop->nsassessments) - (abs($bias[$user->id]) / $maxbias),
+ 0.0);
+ }
+ else {
+ $biasgrade = 0;
+ }
+ // reliabilitygrade is scaled between zero and one
+
+ if ($dumbreliability and $workshop->nsassessments) {
+ // nbias used here as it contains the number of assessments the user has done
+ $reliabilitygrade = max(($nbias[$user->id] / $workshop->nsassessments) -
+ ($reliability[$user->id] / $dumbreliability), 0.0);
+ }
+ else {
+ $reliabilitygrade = 0;
+ }
+ $biasscaled = intval($biasgrade * $workshop->grade + 0.5);
+ $reliabilityscaled = intval($reliabilitygrade * $workshop->grade + 0.5);
+ $gradingscaled = intval($gradinggrade[$user->id] * $workshop->grade / COMMENTSCALE + 0.5);
+ $finalgrade = intval((($teachergrade * $WORKSHOP_FWEIGHTS[$teacherweight] * $useteachersgrades) +
+ ($peergrade * $WORKSHOP_FWEIGHTS[$peerweight] * $usepeergrades) +
+ ($biasscaled * $WORKSHOP_FWEIGHTS[$biasweight] * $usebiasgrades) +
+ ($reliabilityscaled * $WORKSHOP_FWEIGHTS[$reliabilityweight] * $usereliabilitygrades) +
+ ($gradingscaled * $WORKSHOP_FWEIGHTS[$gradingweight] * $usegradinggrades) + 0.5) /
+ (($WORKSHOP_FWEIGHTS[$teacherweight] * $useteachersgrades) +
+ ($WORKSHOP_FWEIGHTS[$peerweight] * $usepeergrades) +
+ ($WORKSHOP_FWEIGHTS[$biasweight] * $usebiasgrades) +
+ ($WORKSHOP_FWEIGHTS[$reliabilityweight] * $usereliabilitygrades) +
+ ($WORKSHOP_FWEIGHTS[$gradingweight] * $usegradinggrades)));
+ echo "<TR><TD>$user->firstname $user->lastname</TD>";
+ if ($useteachersgrades) {
+ echo "<TD>$teachergrade</TD>";
+ }
+ if ($usepeergrades) {
+ echo "<TD>$peergrade</TD>";
+ }
+ if ($usebiasgrades) {
+ echo "<TD>$biasscaled</TD>";
+ }
+ if ($usereliabilitygrades) {
+ echo "<TD>$reliabilityscaled</TD>";
+ }
+ if ($usegradinggrades) {
+ echo "<TD>$gradingscaled</TD>";
+ }
+ echo "<TD>$finalgrade</TD></TR>\n";
+
+ // save the grades
+ set_field("workshop_submissions", "biasgrade", $biasscaled, "id", $bestsubmission->id);
+ set_field("workshop_submissions", "reliabilitygrade", $reliabilityscaled, "id", $bestsubmission->id);
+ set_field("workshop_submissions", "gradinggrade", $gradingscaled, "id", $bestsubmission->id);
+ set_field("workshop_submissions", "finalgrade", $finalgrade, "id", $bestsubmission->id);
+ }
+ echo "</TABLE><BR CLEAR=ALL>\n";
+ print_string("allgradeshaveamaximumof", "workshop", $workshop->grade);
+ echo "</CENTER><BR>\n";
+
+ print_continue("view.php?a=$workshop->id");
+ }
+
+
+ /*************** display final grades (by teacher) ***************************/
+ elseif ($action == 'displayfinalgrades') {
+ // Get all the students
+ if (!$users = get_course_students($course->id, "u.firstname, u.lastname")) {
+ print_heading(get_string("nostudentsyet"));
+ print_footer($course);
+ exit;
+ }
+
+ // get the final weights from the database
+ $teacherweight = get_field("workshop","teacherweight", "id", $workshop->id);
+ $peerweight = get_field("workshop","peerweight", "id", $workshop->id);
+ $includeteachersgrade = get_field("workshop","includeteachersgrade", "id", $workshop->id);
+ $biasweight = get_field("workshop","biasweight", "id", $workshop->id);
+ $reliabilityweight = get_field("workshop","reliabilityweight", "id", $workshop->id);
+ $gradingweight = get_field("workshop","gradingweight", "id", $workshop->id);
+ // work out what to show in the final grades tables and what to include in the calculation of the final grade
+ // teacher grades?
+ if ($workshop->gradingstrategy and $teacherweight) {
+ $useteachersgrades = 1;
+ }
+ else {
+ $useteachersgrades = 0;
+ }
+ // peergrades?
+ if ($workshop->gradingstrategy and $workshop->nsassessments and $peerweight) {
+ $usepeergrades = 1;
+ }
+ else {
+ $usepeergrades = 0;
+ }
+ // bias grades?
+ if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and ($useteachersgrades or $usepeergrades)
+ and $biasweight ) {
+ $usebiasgrades = 1;
+ }
+ else {
+ $usebiasgrades = 0;
+ }
+ // reliability grades?
+ if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and ($useteachersgrades or $usepeergrades)
+ and $reliabilityweight ) {
+ $usereliabilitygrades = 1;
+ }
+ else {
+ $usereliabilitygrades = 0;
+ }
+ // grading grades?
+ if (($workshop->ntassessments or $workshop->nsassessments) and $gradingweight ) {
+ $usegradinggrades = 1;
+ }
+ else {
+ $usegradinggrades = 0;
+ }
+
+ // show the final grades as stored in the tables...
+ print_heading_with_help(get_string("displayoffinalgrades", "workshop"), "finalgrades", "workshop");
+ echo "<CENTER><TABLE BORDER=1 WIDTH=\"90%\"><TR>
+ <TD BGCOLOR=\"$THEME->cellheading2\"><B>".$course->student."</B></TD>";
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("submissions", "workshop")."</B></TD>";
+ if ($useteachersgrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("assessmentsby", "workshop", $course->teachers)."</B></TD>";
+ }
+ if ($usepeergrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("assessmentsby", "workshop", $course->students)."</B></TD>";
+ }
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("assessmentsdone", "workshop")."</B></TD>";
+ if ($usebiasgrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("gradeforbias", "workshop")."</B></TD>";
+ }
+ if ($usereliabilitygrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("gradeforreliability", "workshop")."</B></TD>";
+ }
+ if ($usegradinggrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("gradeforassessments", "workshop")."</B></TD>";
+ }
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("overallgrade", "workshop")."</B></TD></TR>\n";
+ // now the weights
+ echo "<TR><TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("weights", "workshop")."</B></TD>";
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B> </B></TD>\n";
+ if ($useteachersgrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>$WORKSHOP_FWEIGHTS[$teacherweight]</B></TD>\n";
+ }
+ if ($usepeergrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>$WORKSHOP_FWEIGHTS[$peerweight]</B></TD>\n";
+ }
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B> </B></TD>\n";
+ if ($usebiasgrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>$WORKSHOP_FWEIGHTS[$biasweight]</B></TD>\n";
+ }
+ if ($usereliabilitygrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>$WORKSHOP_FWEIGHTS[$reliabilityweight]</B></TD>\n";
+ }
+ if ($usegradinggrades) {
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B>$WORKSHOP_FWEIGHTS[$gradingweight]</B></TD>\n";
+ }
+ echo "<TD BGCOLOR=\"$THEME->cellheading2\"><B> </B></TD></TR>\n";
+ foreach ($users as $user) {
+ if ($submissions = workshop_get_user_submissions($workshop, $user)) {
+ foreach ($submissions as $submission) {
+ echo "<TR><TD>$user->firstname $user->lastname</TD>";
+ echo "<TD>".workshop_print_submission_title($workshop, $submission)."</TD>\n";
+ if ($useteachersgrades) {
+ echo "<TD>".workshop_print_submission_assessments($workshop, $submission, "teacher")."</TD>";
+ }
+ if ($usepeergrades) {
+ echo "<TD>".workshop_print_submission_assessments($workshop, $submission, "student")."</TD>";
+ }
+ echo "<TD>".workshop_print_user_assessments($workshop, $user)."</TD>";
+ if ($usebiasgrades) {
+ echo "<TD>$submission->biasgrade</TD>";
+ }
+ if ($usereliabilitygrades) {
+ echo "<TD>$submission->reliabilitygrade</TD>";
+ }
+ if ($usegradinggrades) {
+ echo "<TD>$submission->gradinggrade</TD>";
+ }
+ echo "<TD>$submission->finalgrade</TD></TR>\n";
+ }
+ }
+ }
+ echo "</TABLE><BR CLEAR=ALL>\n";
+ print_string("allgradeshaveamaximumof", "workshop", $workshop->grade);
+ print_continue("view.php?a=$workshop->id");
+ }\r
+
+
+ /*************** display final weights (by teacher) ***************************/
+ elseif ($action == 'displayfinalweights') {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ if ($workshop->phase != 3) { // is this at the expected phase?
+ echo "<CENTER><B>".get_string("assignmentnotinthecorrectphase", "workshop")."</B></CENTER>\n";
+ print_continue("view.php?a=$workshop->id");
+ }
+ else {
+
+ ?>
+ <form name="weightsform" method="post" action="submissions.php">
+ <INPUT TYPE="hidden" NAME="id" VALUE="<?PHP echo $cm->id ?>">
+ <input type="hidden" name="action" value="calculatefinalgrades">
+ <CENTER>
+ <?PHP
+
+ // get the final weights from the database
+ $teacherweight = get_field("workshop","teacherweight", "id", $workshop->id);
+ $peerweight = get_field("workshop","peerweight", "id", $workshop->id);
+ $includeteachersgrade = get_field("workshop","includeteachersgrade", "id", $workshop->id);
+ $biasweight = get_field("workshop","biasweight", "id", $workshop->id);
+ $reliabilityweight = get_field("workshop","reliabilityweight", "id", $workshop->id);
+ $gradingweight = get_field("workshop","gradingweight", "id", $workshop->id);
+
+ // now show the weights used in the final grades
+ print_heading_with_help(get_string("calculationoffinalgrades", "workshop"), "calculatingfinalgrade", "workshop");
+ echo "<TABLE WIDTH=\"50%\" BORDER=\"1\">\n";
+ echo "<TR><TD COLSPAN=\"2\" BGCOLOR=\"$THEME->cellheading2\"><CENTER><B>".
+ get_string("weightsusedforfinalgrade", "workshop")."</B></CENTER></TD></TR>\n";
+ echo "<TR><TD ALIGN=\"right\">".get_string("weightforteachersassessment", "workshop").":</TD>\n";
+ echo "<TD>";
+ workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "teacherweight", $teacherweight, "");
+ echo "</TD></TR>\n";
+ echo "<TR><TD ALIGN=\"right\">".get_string("weightforpeerassessments", "workshop").":</TD>\n";
+ echo "<TD>";
+ workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "peerweight", $peerweight, "");
+ echo "</TD></TR>\n";
+ echo "<TR><TD ALIGN=\"right\">".get_string("weightforbias", "workshop").":</TD>\n";
+ echo "<TD>";
+ workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "biasweight", $biasweight, "");
+ echo "</TD></TR>\n";
+ echo "<TR><TD ALIGN=\"right\">".get_string("weightforreliability", "workshop").":</TD>\n";
+ echo "<TD>";
+ workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "reliabilityweight", $reliabilityweight, "");
+ echo "</TD></TR>\n";
+ echo "<TR><TD ALIGN=\"right\">".get_string("weightforgradingofassessments", "workshop").":</TD>\n";
+ echo "<TD>";
+ workshop_choose_from_menu($WORKSHOP_FWEIGHTS, "gradingweight", $gradingweight, "");
+ echo "</TD></TR>\n";
+ echo "<TR><TD COLSPAN=\"2\" BGCOLOR=\"$THEME->cellheading2\"><CENTER><B>".
+ get_string("optionforpeergrade", "workshop")."</B></CENTER></TD></TR>\n";
+ echo "<TR><TD ALIGN=\"right\">".get_string("includeteachersgrade", "workshop").":</TD>\n";
+ echo "<TD>";
+ $options[0] = get_string("no"); $options[1] = get_string("yes");
+ choose_from_menu($options, "includeteachersgrade", $includeteachersgrade, "");
+ helpbutton("includeteachersgrade", get_string("includeteachersgrade", "workshop"), "workshop");
+ echo "</TD></TR>\n";
+ echo "</TABLE>\n";
+ echo "<INPUT TYPE=submit VALUE=\"".get_string("calculationoffinalgrades", "workshop")."\">\n";
+ echo "</CENTER>";
+ echo "</FORM>\n";
+ }
+ }
+
+
+ /******************* list all submissions ************************************/
+ elseif ($action == 'listallsubmissions' ) {
+ if (!$users = get_course_students($course->id)) {
+ 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) ************************************/
+ elseif ($action == 'listforassessmentstudent' ) {
+ if (!$users = get_course_students($course->id)) {
+ 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) ************************************/
+ elseif ($action == 'listforassessmentteacher' ) {
+ if (!$users = get_course_students($course->id)) {
+ print_heading(get_string("nostudentsyet"));
+ print_footer($course);
+ exit;
+ }
+ workshop_list_unassessed_teacher_submissions($workshop, $USER);
+ print_continue("view.php?id=$cm->id");
+
+ }
+
+
+ /*************** no man's land **************************************/\r
+ else {\r
+ error("Fatal Error: Unknown Action: ".$action."\n");\r
+ }\r
+
+ print_footer($course);
+
+?>
+
--- /dev/null
+To Do
+=====
+
+Use a better method to measure bias in peer grades, probably based on the
+ percentage difference rather the relative difference used at present.
+
+When there are many peer gradings the grade comments page needs to be
+ broken into manageable chunks. **DONE**
+
+Allow teacher to add a set of submissions (from say a previous cohort) for the
+ students to grade. **Probably better as a separate module**
+
+Add option to allow the teacher's grade and mean peer grade to be merged in
+ the final grades table (to avoid disputes!).
+
+Add alternative grading strategies: Simple Grading (= assignment style grading);
+ Accumulative Grading (current strategy); Criteria Grading; and Error Banding.
+
+
+Ray Kingdon
+06 Feb 2003
+
+
--- /dev/null
+<?PHP // $Id: upload.php, v1.0 30th April 2003
+
+ require("../../config.php");
+ require("lib.php");
+
+ require_variable($a); // workshop ID
+
+ $newfile = $HTTP_POST_FILES["newfile"];
+
+ if (! $workshop = get_record("workshop", "id", $a)) {
+ error("Not a valid workshop ID");
+ }
+
+ if (! $course = get_record("course", "id", $workshop->course)) {
+ error("Course is misconfigured");
+ }
+
+ require_login($course->id);
+
+ add_to_log($course->id, "workshop", "submit", "view.php?a=$workshop->id", "$workshop->id");
+
+ if ($course->category) {
+ $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
+ }
+ $strworkshops = get_string("modulenameplural", "workshop");
+ $strworkshop = get_string("modulename", "workshop");
+ $strupload = get_string("upload");
+
+ print_header("$course->shortname: $workshop->name : $strupload", "$course->fullname",
+ "$navigation <A HREF=index.php?id=$course->id>$strworkshops</A> ->
+ <A HREF=\"view.php?a=$workshop->id\">$workshop->name</A> -> $strupload",
+ "", "", true);
+ /****
+ if ($submissions = workshop_get_submissions($workshop, $USER)) {
+ if ($submission->grade and !$workshop->resubmit) {
+ error("You've already been graded - there's no point in uploading anything");
+ }
+ }
+****/
+ if (!$title = $_POST['title']) {
+ notify(get_string("notitlegiven", "workshop") );
+ }
+ else {
+ if (is_uploaded_file($newfile['tmp_name']) and $newfile['size'] > 0) {
+ if ($newfile['size'] > $workshop->maxbytes) {
+ notify(get_string("uploadfiletoobig", "assignment", $workshop->maxbytes));
+ }
+ else {
+ $newfile_name = clean_filename($newfile['name']);
+ if ($newfile_name) {
+ $newsubmission->workshopid = $workshop->id;
+ $newsubmission->userid = $USER->id;
+ $newsubmission->title = $title;
+ $newsubmission->timecreated = time();
+ if (!$newsubmission->id = insert_record("workshop_submissions", $newsubmission)) {
+ error("Failure to create new submission record!");
+ }
+ if (! $dir = workshop_file_area($workshop, $newsubmission)) {
+ error("Sorry, an error in the system prevents you from uploading files: contact your teacher or system administrator");
+ }
+ if (move_uploaded_file($newfile['tmp_name'], "$dir/$newfile_name")) {
+ print_heading(get_string("uploadsuccess", "assignment", $newfile_name) );
+ }
+ else {
+ notify(get_string("uploaderror", "assignment") );
+ }
+ }
+ else {
+ notify(get_string("uploadbadname", "assignment") );
+ }
+ }
+ }
+ else {
+ notify(get_string("uploadnofilefound", "assignment") );
+ }
+ }
+ print_continue("view.php?a=$workshop->id");
+
+ print_footer($course);
+
+?>
--- /dev/null
+<?PHP // $Id$
+
+////////////////////////////////////////////////////////////////////////////////
+// Code fragment to define the module version etc.
+// This fragment is called by /admin/index.php
+////////////////////////////////////////////////////////////////////////////////
+
+$module->version = 2003043000;
+$module->cron = 60;
+
+?>
--- /dev/null
+<?PHP // $Id: view.php, v1.0 30th April 2003
+
+/*************************************************
+ ACTIONS handled are:
+
+ close workshop( for teachers)
+ displayfinalgrade (for students)
+ makefinalgradesunavailable (for teachers)
+ notavailable (for students)
+ open workshop (for teachers)
+ setupassignment (for teachers)
+ studentsview
+ submitassignment
+ teachersview
+
+************************************************/
+
+ require("../../config.php");
+ require("lib.php");
+
+ error_reporting(15);
+
+ optional_variable($id); // Course Module ID
+ optional_variable($a); // workshop ID
+
+ // get some useful stuff...
+ if ($id) {
+ if (! $cm = get_record("course_modules", "id", $id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ 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");
+ }
+
+ } else {
+ if (! $workshop = get_record("workshop", "id", $a)) {
+ error("Course module is incorrect");
+ }
+ if (! $course = get_record("course", "id", $workshop->course)) {
+ error("Course is misconfigured");
+ }
+ if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
+ error("Course Module ID was incorrect");
+ }
+ }
+
+ require_login($course->id);
+
+ // ...log activity...
+ add_to_log($course->id, "workshop", "view", "view.php?id=$cm->id", "$workshop->id");
+
+ if ($course->category) {
+ $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
+ }
+
+ $strworkshops = get_string("modulenameplural", "workshop");
+ $strworkshop = get_string("modulename", "workshop");
+
+ // ...display header...
+ print_header("$course->shortname: $workshop->name", "$course->fullname",
+ "$navigation <A HREF=index.php?id=$course->id>$strworkshops</A> -> $workshop->name",
+ "", "", 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 (count_records("workshop_elements", "workshopid", $workshop->id)) {
+ $action = "teachersview";
+ }
+ else {
+ redirect("assessments.php?action=editelements&id=$cm->id");
+ }
+ }
+ }
+ elseif (!isguest()) { // it's a student then
+ switch ($workshop->phase) {
+ case 0 :
+ case 1 : $action = 'notavailable'; break;
+ case 2 : $action = 'studentsview'; break;
+ case 3 : $action = 'notavailable'; break;
+ case 4 : $action = 'displayfinalgrade';
+ }
+ }
+ else { // it's a guest, oh no!
+ $action = 'notavailable';
+ }
+
+
+ /*********************** close workshop for student assessments and submissions (move to phase 3) (for teachers)**/
+ if ($action == 'closeworkshop') {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ // move phase along
+ if ($workshop->phase == 2) { // force phase to open workshop
+ set_field("workshop", "phase", 3, "id", "$workshop->id");
+ echo "<CENTER><B>".get_string("movedtophase", "workshop", 3)."</B></CENTER>\n";
+ add_to_log($course->id, "workshop", "close", "view.php?a=$workshop->id", "$workshop->id");
+ }
+
+ print_continue("view.php?a=$workshop->id");
+
+ }
+
+
+ /******************* display final grade (for students) ************************************/
+ elseif ($action == 'displayfinalgrade' ) {
+
+ // get the final weights from the database
+ $teacherweight = get_field("workshop","teacherweight", "id", $workshop->id);
+ $peerweight = get_field("workshop","peerweight", "id", $workshop->id);
+ $includeteachersgrade = get_field("workshop","includeteachersgrade", "id", $workshop->id);
+ $biasweight = get_field("workshop","biasweight", "id", $workshop->id);
+ $reliabilityweight = get_field("workshop","reliabilityweight", "id", $workshop->id);
+ $gradingweight = get_field("workshop","gradingweight", "id", $workshop->id);
+ // work out what to show in the final grades tables and what to include in the calculation of the final grade
+ // teacher grades?
+ if ($workshop->graded and $teacherweight) {
+ $useteachersgrades = 1;
+ }
+ else {
+ $useteachersgrades = 0;
+ }
+ // peergrades?
+ if ($workshop->graded and $workshop->nsassessments and $peerweight) {
+ $usepeergrades = 1;
+ }
+ else {
+ $usepeergrades = 0;
+ }
+ // bias grades?
+ if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and $biasweight ) {
+ $usebiasgrades = 1;
+ }
+ else {
+ $usebiasgrades = 0;
+ }
+ // reliability grades?
+ if ((($workshop->ntassessments >= 3) or ($workshop->nsassessments >= 3)) and $reliabilityweight ) {
+ $usereliabilitygrades = 1;
+ }
+ else {
+ $usereliabilitygrades = 0;
+ }
+ // grading grades?
+ if (($workshop->ntassessments or $workshop->nsassessments) and $gradingweight ) {
+ $usegradinggrades = 1;
+ }
+ else {
+ $usegradinggrades = 0;
+ }
+
+ // show the final grades as stored in the tables...
+ print_heading_with_help(get_string("displayoffinalgrades", "workshop"), "finalgrades", "workshop");
+ if ($submissions = workshop_get_user_submissions($workshop, $USER)) { // any submissions from user?
+ echo "<CENTER><TABLE BORDER=1 WIDTH=\"90%\"><TR>";
+ echo "<TD><B>".get_string("submissions", "workshop")."</B></TD>";
+ if ($useteachersgrades) {
+ echo "<TD><B>".get_string("teachersassessment", "workshop")."</B></TD>";
+ }
+ if ($usepeergrades) {
+ echo "<TD><B>".get_string("studentsassessment", "workshop")."</B></TD>";
+ }
+ echo "<TD><B>".get_string("assessmentsdone", "workshop")."</B></TD>";
+ if ($usebiasgrades) {
+ echo "<TD><B>".get_string("gradeforbias", "workshop")."</B></TD>";
+ }
+ if ($usereliabilitygrades) {
+ echo "<TD><B>".get_string("gradeforreliability", "workshop")."</B></TD>";
+ }
+ if ($usegradinggrades) {
+ echo "<TD><B>".get_string("gradeforassessments", "workshop")."</B></TD>";
+ }
+ echo "<TD><B>".get_string("overallgrade", "workshop")."</B></TD></TR>\n";
+ // now the weights
+ echo "<TR><TD><B>".get_string("weights", "workshop")."</B></TD>";
+ if ($useteachersgrades) {
+ echo "<TD><B>$workshop_FWEIGHTS[$teacherweight]</B></TD>\n";
+ }
+ if ($usepeergrades) {
+ echo "<TD><B>$workshop_FWEIGHTS[$peerweight]</B></TD>\n";
+ }
+ echo "<TD><B> </B></TD>\n";
+ if ($usebiasgrades) {
+ echo "<TD><B>$workshop_FWEIGHTS[$biasweight]</B></TD>\n";
+ }
+ if ($usereliabilitygrades) {
+ echo "<TD><B>$workshop_FWEIGHTS[$reliabilityweight]</B></TD>\n";
+ }
+ if ($usegradinggrades) {
+ echo "<TD><B>$workshop_FWEIGHTS[$gradingweight]</B></TD>\n";
+ }
+ echo "<TD><B> </B></TD></TR>\n";
+ foreach ($submissions as $submission) {
+ echo "<TR><TD>".workshop_print_submission_title($workshop, $submission)."</TD>\n";
+ if ($useteachersgrades) {
+ echo "<TD>".workshop_print_submission_assessments($workshop, $submission, "teacher")."</TD>";
+ }
+ if ($usepeergrades) {
+ echo "<TD>".workshop_print_submission_assessments($workshop, $submission, "student")."</TD>";
+ }
+ echo "<TD>".workshop_print_user_assessments($workshop, $USER)."</TD>";
+ if ($usebiasgrades) {
+ echo "<TD>$submission->biasgrade</TD>";
+ }
+ if ($usereliabilitygrades) {
+ echo "<TD>$submission->reliabilitygrade</TD>";
+ }
+ if ($usegradinggrades) {
+ echo "<TD>$submission->gradinggrade</TD>";
+ }
+ echo "<TD>$submission->finalgrade</TD></TR>\n";
+ }
+ }
+ echo "</TABLE><BR CLEAR=ALL>\n";
+ print_string("allgradeshaveamaximumof", "workshop", $workshop->grade);
+ print_continue("view.php?a=$workshop->id");
+ }\r
+
+
+ /*********************** make final grades available (for teachers only)**************/
+ elseif ($action == 'makefinalgradesavailable') {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ if ($workshop->phase == 3) { // is this at the expected phase?
+ set_field("workshop", "phase", 4, "id", "$workshop->id");
+ echo "<CENTER><B>".get_string("movedtophase", "workshop", 4)."</B></CENTER>\n";
+ }
+ else {
+ echo "<CENTER><B>".get_string("assignmentnotinthecorrectphase", "workshop")."</B></CENTER>\n";
+ }
+ print_continue("view.php?a=$workshop->id");
+ add_to_log($course->id, "workshop", "display grades", "view.php?a=$workshop->id", "$workshop->id");
+ }
+
+
+ /*********************** make final grades unavailable (for teachers only)**************/
+ elseif ($action == 'makefinalgradesunavailable') {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ if ($workshop->phase == 4) { // is this at the expected phase?
+ set_field("workshop", "phase", 3, "id", "$workshop->id");
+ echo "<CENTER><B>".get_string("movedtophase", "workshop", 3)."</B></CENTER>\n";
+ }
+ else {
+ echo "<CENTER><B>".get_string("assignmentnotinthecorrectphase", "workshop")."</B></CENTER>\n";
+ }
+ print_continue("view.php?a=$workshop->id");
+ add_to_log($course->id, "workshop", "hide grades", "view.php?a=$workshop->id", "$workshop->id");
+ }
+
+
+ /*********************** assignment not available (for students)***********************/
+ elseif ($action == 'notavailable') {
+ echo "<p><center>".get_string("notavailable", "workshop")."</center>\n";
+ }
+
+
+ /*********************** open workshop for student assessments and submissions (move to phase 2) (for teachers)**/
+ elseif ($action == 'openworkshop') {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ // move phase along
+ if (!($workshop->phase == 2)) { // force phase to open workshop
+ set_field("workshop", "phase", 2, "id", "$workshop->id");
+ echo "<CENTER><B>".get_string("movedtophase", "workshop", 2)."</B></CENTER>\n";
+ }
+
+ print_continue("view.php?id=$cm->id");
+
+ add_to_log($course->id, "workshop", "open", "view.php?a=$workshop->id", "$workshop->id");
+ }
+
+
+ /*********************** set up assignemnt (move back to phase 1) (for teachers)***********************/
+ elseif ($action == 'setupassignment') {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ if ($workshop->phase == 2) { // phase must be correct
+ set_field("workshop", "phase", 1, "id", "$workshop->id");
+ echo "<CENTER><B>".get_string("movedtophase", "workshop", 1)."</B></CENTER>\n";
+ }
+ else {
+ echo "<CENTER><B>".get_string("assignmentnotinthecorrectphase", "workshop")."</B></CENTER>\n";
+ }
+ print_continue("view.php?a=$workshop->id");
+ }
+
+
+ /*********************** student's view could be in 1 of 4 stages ***********************/
+ elseif ($action == 'studentsview') {
+ // print standard assignment heading
+ $strdifference = format_time($workshop->deadline - time());
+ if (($workshop->deadline - time()) < 0) {
+ $strdifference = "<FONT COLOR=RED>$strdifference</FONT>";
+ }
+ $strduedate = userdate($workshop->deadline)." ($strdifference)";
+ print_simple_box_start("CENTER");
+ print_heading($workshop->name, "CENTER");
+ print_simple_box_start("CENTER");
+ echo "<B>".get_string("duedate", "assignment")."</B>: $strduedate<BR>";
+ echo "<B>".get_string("maximumgrade")."</B>: $workshop->grade<BR>";
+ echo "<B>".get_string("detailsofassessment", "workshop")."</B>:
+ <A HREF=\"assessments.php?id=$cm->id&action=displayelements\">".
+ get_string("specimenassessmentform", "workshop")."</A><BR>";
+ print_simple_box_end();
+ echo "<BR>";
+ echo format_text($workshop->description, $workshop->format);
+ print_simple_box_end();
+ echo "<BR>";
+ // in Stage 1? - assess teacher's submissions to a satisfactory level
+ if (!workshop_test_user_assessments($workshop, $USER)) {
+ echo "<CENTER><B>".get_string("pleaseassesstheseexamplesfromtheteacher", "workshop", $course->teacher)."</B></CENTER><BR>\n";
+ workshop_list_teacher_submissions($workshop, $USER);
+ echo "<CENTER><B>".get_string("theseasessmentsaregradedbytheteacher", "workshop", $course->teacher)."</B></CENTER><BR>\n";
+ }
+ // in stage 2? - submit own first attempt
+ else {
+ if ($workshop->ntassessments) { // display message if student had to assess the teacher's examples
+ echo "<P><CENTER><B><A HREF=\"assessments.php?action=listteachersubmissions&id=$cm->id\">".
+ get_string("assessmentsareok", "workshop")."</A></B></CENTER>\n";
+ }
+ if (!workshop_get_user_submissions($workshop, $USER)) {
+ // print upload form
+ print_heading(get_string("submitassignment", "assignment").":", "CENTER");
+ workshop_print_upload_form($workshop);
+ }
+ // in stage 3? - grade other student's submissions, resubmit and list all submissions
+ else {
+ // list any assessments by teachers
+ if (workshop_count_teacher_assessments($workshop, $USER)) {
+ echo "<P><CENTER><B>".get_string("assessmentsby", "workshop", $course->teachers)."</B></CENTER><BR>\n";
+ workshop_list_teacher_assessments($workshop, $USER);
+ }
+ // if student assessments show any to assess...
+ if ($workshop->nsassessments) { // if there are student assessment display them...
+ workshop_list_student_submissions($workshop, $USER);
+ echo "<P><CENTER><B>".get_string("yourassessments", "workshop")."</B></CENTER><BR>\n";
+ workshop_list_assessed_submissions($workshop, $USER);
+ // ... and show peer assessments
+ if (workshop_count_peer_assessments($workshop, $USER)) {
+ echo "<P><CENTER><B>".get_string("assessmentsby", "workshop", $course->students)."</B></CENTER><BR>\n";
+ workshop_list_peer_assessments($workshop, $USER);
+ }
+ }
+ // list previous submissions
+ echo "<P><CENTER><B>".get_string("submissions", "workshop")."</B></CENTER><BR>\n";
+ workshop_list_user_submissions($workshop, $USER);
+ echo "<HR SIZE=1 NOSHADE>";
+ if ($workshop->resubmit) {
+ // if resubmissions allowed print upload form
+ print_heading(get_string("submitassignment", "assignment").":", "CENTER");
+ workshop_print_upload_form($workshop);
+ echo "<HR SIZE=1 NOSHADE>";
+ }
+ echo "<CENTER><B><A HREF=\"submissions.php?action=listallsubmissions&id=$cm->id\">".
+ get_string("listofallsubmissions", "workshop")."</A></B></CENTER>\n";
+ }
+ }
+ }
+
+
+ /*********************** submission of assignment by a student/teacher ***********************/
+ elseif ($action == 'submitassignment') {
+ $strdifference = format_time($workshop->deadline - time());
+ if (($workshop->deadline - time()) < 0) {
+ $strdifference = "<FONT COLOR=RED>$strdifference</FONT>";
+ }
+ $strduedate = userdate($workshop->deadline)." ($strdifference)";
+
+ print_simple_box_start("CENTER");
+ print_heading($workshop->name, "CENTER");
+ print_simple_box_start("CENTER");
+ echo "<B>".get_string("duedate", "assignment")."</B>: $strduedate<BR>";
+ echo "<B>".get_string("maximumgrade")."</B>: $workshop->grade<BR>";
+ echo "<B>".get_string("detailsofassessment", "workshop")."</B>:
+ <A HREF=\"assessments.php?id=$cm->id&action=displayelements\">".
+ get_string("specimenassessmentform", "workshop")."</A><BR>";
+ print_simple_box_end();
+ echo "<BR>";
+ echo format_text($workshop->description, $workshop->format);
+ print_simple_box_end();
+ echo "<BR>";
+
+ workshop_list_teacher_submissions($workshop, $USER);
+ echo "<HR SIZE=1 NOSHADE>";
+ echo "<BR>";
+
+ workshop_list_student_submissions($workshop, $USER);
+ echo "<HR SIZE=1 NOSHADE>";
+ echo "<BR>";
+
+ // list previous submissions
+ workshop_list_user_submissions($workshop, $USER);
+
+ echo "<HR SIZE=1 NOSHADE>";
+
+ // print upload form
+ print_heading(get_string("submitassignment", "assignment").":", "CENTER");
+ workshop_print_upload_form($workshop);
+ }
+
+
+ /*********************** teacher's view - display admin page (current phase options) ************/
+ elseif ($action == 'teachersview') {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ print_heading_with_help(get_string("managingassignment", "workshop"), "managing", "workshop");
+ echo "<CENTER><P>\n";
+ switch ($workshop->phase) {
+ case 0:
+ case 1: // set up assignment
+ echo "<B><U>".get_string("phase1", "workshop")."</U></B>";
+ echo "<P><B><A HREF=\"assessments.php?id=$cm->id&action=editelements\">".
+ get_string("amendassessmentelements", "workshop")."</A></B></P>";
+ echo "<P><B><A HREF=\"view.php?id=$cm->id&action=submitassignment\">".
+ get_string("submitexampleassignment", "workshop")."</A></B>";
+ echo "<P><B><A HREF=\"submissions.php?id=$cm->id&action=listforassessmentteacher\">".
+ get_string("teachersubmissionsforassessment", "workshop",
+ workshop_count_teacher_submissions_for_assessment($workshop, $USER)).
+ "</A></B></P>\n";
+ echo "<P><B><A HREF=\"view.php?id=$cm->id&action=openworkshop\">".
+ get_string("moveonto", "workshop")." ".get_string("phase2", "workshop", $course->student)."</A></B></P>";
+ break;
+
+ case 2: // submissions and assessments
+ echo "<B><U>".get_string("phase2", "workshop", $course->student)."</U></B>";
+ echo "<P><B><A HREF=\"assessments.php?id=$cm->id&action=listungradedteachersubmissions\">".
+ get_string("ungradedassessmentsofteachersubmissions", "workshop", workshop_count_ungraded_assessments_teacher($workshop))."</A></B>\n";
+ echo "<P><B><A HREF=\"assessments.php?id=$cm->id&action=listungradedstudentsubmissions\">".
+ get_string("ungradedassessmentsofstudentsubmissions", "workshop", workshop_count_ungraded_assessments_student($workshop))."</A></B>\n";
+ echo "<P><B><A HREF=\"submissions.php?id=$cm->id&action=listforassessmentstudent\">".
+ get_string("studentsubmissionsforassessment", "workshop", workshop_count_student_submissions_for_assessment($workshop, $USER)).
+ "</A></B>\n";
+ echo "<P><B><A HREF=\"view.php?id=$cm->id&action=closeworkshop\">".
+ get_string("moveonto", "workshop")." ".get_string("phase3", "workshop")."</A></B></P>";
+ echo "<P><FONT SIZE=1>[".get_string("deadlineis", "workshop", userdate($workshop->deadline))."]</FONT></P>\n";
+ echo "<P><B><A HREF=\"view.php?id=$cm->id&action=setupassignment\">(".
+ get_string("returnto", "workshop")." ".get_string("phase1", "workshop").")</A></B></P>";
+ break;
+
+ case 3: // calculate final grades
+ echo "<B><U>".get_string("phase3", "workshop")."</U></B>";
+ echo "<P><B><A HREF=\"assessments.php?id=$cm->id&action=listungradedstudentsubmissions\">".
+ get_string("ungradedassessmentsofstudentsubmissions", "workshop", workshop_count_ungraded_assessments_student($workshop))."</A></B>\n";
+ echo "<P><B><A HREF=\"submissions.php?id=$cm->id&action=listforassessmentstudent\">".
+ get_string("studentsubmissionsforassessment", "workshop", workshop_count_student_submissions_for_assessment($workshop, $USER)).
+ "</A></B>\n";
+ echo "<P><B><A HREF=\"submissions.php?id=$cm->id&action=displayfinalweights\">".
+ get_string("calculationoffinalgrades", "workshop")."</A></B></P>";
+ echo "<P><B><A HREF=\"view.php?id=$cm->id&action=makefinalgradesavailable\">".
+ get_string("moveonto", "workshop")." ".get_string("phase4", "workshop")."</A></B></P>";
+ echo "<P><B><A HREF=\"view.php?id=$cm->id&action=openworkshop\">(".
+ get_string("returnto", "workshop")." ".get_string("phase2", "workshop", $course->student).")</A></B></P>";
+ break;
+
+ case 4: // show final grades
+ echo "<B><U>".get_string("phase4", "workshop")."</U></B>";
+ echo "<P><B><A HREF=\"submissions.php?id=$cm->id&action=displayfinalgrades\">".
+ get_string("displayoffinalgrades", "workshop")."</A></B></P>";
+ echo "<P><B><A HREF=\"view.php?id=$cm->id&action=makefinalgradesunavailable\">(".
+ get_string("returnto", "workshop")." ".get_string("phase3", "workshop").")</A></B></P>";
+ }
+ echo "<P><B><A HREF=\"submissions.php?id=$cm->id&action=listallsubmissions\">".
+ get_string("listofallsubmissions", "workshop")."</A></B></P>\n";
+ }
+
+
+ /*************** no man's land **************************************/\r
+ else {\r
+ error("Fatal Error: Unknown Action: ".$action."\n");\r
+ }\r
+
+ print_footer($course);
+
+?>