]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17827 workshop: initial check in of the files
authorDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 17:34:08 +0000 (17:34 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 17:34:08 +0000 (17:34 +0000)
Exported from David's git repository

13 files changed:
mod/workshop/db/install.xml [new file with mode: 0644]
mod/workshop/editgradingform.php [new file with mode: 0644]
mod/workshop/grading/accumulative/edit_accumulative_strategy_form.php [new file with mode: 0644]
mod/workshop/grading/edit_strategy_form.php [new file with mode: 0644]
mod/workshop/icon.gif [new file with mode: 0644]
mod/workshop/index.php [new file with mode: 0644]
mod/workshop/lang/en_utf8/workshop.php [new file with mode: 0644]
mod/workshop/lib.php [new file with mode: 0644]
mod/workshop/mod_form.php [new file with mode: 0644]
mod/workshop/settings.php [new file with mode: 0644]
mod/workshop/simpletest/testlib.php [new file with mode: 0644]
mod/workshop/version.php [new file with mode: 0644]
mod/workshop/view.php [new file with mode: 0644]

diff --git a/mod/workshop/db/install.xml b/mod/workshop/db/install.xml
new file mode 100644 (file)
index 0000000..1600009
--- /dev/null
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<XMLDB PATH="mod/workshop/db" VERSION="20090526" COMMENT="XMLDB file for Moodle mod/workshop"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
+>
+  <TABLES>
+    <TABLE NAME="workshop" COMMENT="This table keeps information about the module instances and their settings" NEXT="workshop_submissions">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="course"/>
+        <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="ID of the parent course" PREVIOUS="id" NEXT="name"/>
+        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="Name of the activity" PREVIOUS="course" NEXT="intro"/>
+        <FIELD NAME="intro" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="The introduction or description of the activity" PREVIOUS="name" NEXT="introformat"/>
+        <FIELD NAME="introformat" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the intro field" PREVIOUS="intro" NEXT="timemodified"/>
+        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The timestamp when the module was modified" PREVIOUS="introformat" NEXT="phase"/>
+        <FIELD NAME="phase" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The current phase of workshop (0 = not available, 1 = submission, 2 = assessment, 3 = closed)" PREVIOUS="timemodified" NEXT="useexamples"/>
+        <FIELD NAME="useexamples" TYPE="int" LENGTH="2" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="optional feature: students practise evaluating on example submissions from teacher" PREVIOUS="phase" NEXT="usepeerassessment"/>
+        <FIELD NAME="usepeerassessment" TYPE="int" LENGTH="2" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="optional feature: students perform peer assessment of others' work" PREVIOUS="useexamples" NEXT="useselfassessment"/>
+        <FIELD NAME="useselfassessment" TYPE="int" LENGTH="2" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="optional feature: students perform self assessment of their own work" PREVIOUS="usepeerassessment" NEXT="grade"/>
+        <FIELD NAME="grade" TYPE="int" LENGTH="5" NOTNULL="false" UNSIGNED="true" DEFAULT="80" SEQUENCE="false" COMMENT="The maximum grade for submission" PREVIOUS="useselfassessment" NEXT="gradinggrade"/>
+        <FIELD NAME="gradinggrade" TYPE="int" LENGTH="5" NOTNULL="false" UNSIGNED="true" DEFAULT="20" SEQUENCE="false" COMMENT="The maximum grade for assessment" PREVIOUS="grade" NEXT="strategy"/>
+        <FIELD NAME="strategy" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" COMMENT="The type of the current grading strategy used in this workshop" PREVIOUS="gradinggrade" NEXT="nattachments"/>
+        <FIELD NAME="nattachments" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Number of required submission attachments" PREVIOUS="strategy" NEXT="latesubmissions"/>
+        <FIELD NAME="latesubmissions" TYPE="int" LENGTH="2" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Allow submitting the work after the deadline" PREVIOUS="nattachments" NEXT="maxbytes"/>
+        <FIELD NAME="maxbytes" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="100000" SEQUENCE="false" COMMENT="Maximum size of the one attached file" PREVIOUS="latesubmissions" NEXT="anonymity"/>
+        <FIELD NAME="anonymity" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The anonymity mode (0 = not anonymous, 1 = authors hidden to reviewers, 2 = reviewers hidden to authors, 3 = fully anonymous)" PREVIOUS="maxbytes" NEXT="assesswosubmission"/>
+        <FIELD NAME="assesswosubmission" TYPE="int" LENGTH="2" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="If a student should participate in peer assessment phase even if she has not managed to submit her own work" PREVIOUS="anonymity" NEXT="nsassessments"/>
+        <FIELD NAME="nsassessments" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Number of required assessments of other students' work" PREVIOUS="assesswosubmission" NEXT="nexassessments"/>
+        <FIELD NAME="nexassessments" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="If useexamples == 1: the number of required assessments of teacher examples (0 = all, greater than 0: the number)" PREVIOUS="nsassessments" NEXT="examplesmode"/>
+        <FIELD NAME="examplesmode" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="0 = example assessments are voluntary, 1 = examples must be assessed before submission, 2 = examples are available after own submission and must be assessed before peer/self assessment phase" PREVIOUS="nexassessments" NEXT="teacherweight"/>
+        <FIELD NAME="teacherweight" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" COMMENT="The weight of the teacher's assessments" PREVIOUS="examplesmode" NEXT="agreeassessments"/>
+        <FIELD NAME="agreeassessments" TYPE="int" LENGTH="2" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Boolean - determines if author may comment assessments and agree/disagree with it" PREVIOUS="teacherweight" NEXT="hidegrades"/>
+        <FIELD NAME="hidegrades" TYPE="int" LENGTH="2" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Boolean - if agreeassessments==1, should the grades be hidden for author? If hidden, only comments are visible" PREVIOUS="agreeassessments" NEXT="assessmentcomps"/>
+        <FIELD NAME="assessmentcomps" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="2" SEQUENCE="false" COMMENT="Comparison of assessments = required level of assessment similarity (0 = very lax, 1 = lax, 2 = fair, 3 = strict, 4 = very strict)" PREVIOUS="hidegrades" NEXT="submissionstart"/>
+        <FIELD NAME="submissionstart" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="0 = will be started manually, greater than 0 the timestamp of the start of the submission phase" PREVIOUS="assessmentcomps" NEXT="submissionend"/>
+        <FIELD NAME="submissionend" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="0 = will be closed manually, greater than 0 the timestamp of the end of the submission phase" PREVIOUS="submissionstart" NEXT="assessmentstart"/>
+        <FIELD NAME="assessmentstart" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="0 = will be started manually, greater than 0 the timestamp of the start of the assessment phase" PREVIOUS="submissionend" NEXT="assessmentend"/>
+        <FIELD NAME="assessmentend" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="0 = will be closed manually, greater than 0 the timestamp of the end of the assessment phase" PREVIOUS="assessmentstart" NEXT="releasegrades"/>
+        <FIELD NAME="releasegrades" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="0 = will be released manually, greater than 0 the timestamp when final grades are published" PREVIOUS="assessmentend" NEXT="password"/>
+        <FIELD NAME="password" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="The access password" PREVIOUS="releasegrades"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="course_fk"/>
+        <KEY NAME="course_fk" TYPE="foreign" FIELDS="course" REFTABLE="course" REFFIELDS="id" PREVIOUS="primary"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="workshop_submissions" COMMENT="Info about the submission and the aggregation of the grade for submission, grade for assessment and final grade. Both grade for submission and grade for assessment can be overridden by teacher. Final grade is always the sum of them. All grades are stored as of 0-100." PREVIOUS="workshop" NEXT="workshop_assessments">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="workshopid"/>
+        <FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="the id of the workshop instance" PREVIOUS="id" NEXT="example"/>
+        <FIELD NAME="example" TYPE="int" LENGTH="2" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Is this submission an example from teacher" PREVIOUS="workshopid" NEXT="userid"/>
+        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The author of the submission" PREVIOUS="example" NEXT="timecreated"/>
+        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Timestamp when the work was submitted for the first time" PREVIOUS="userid" NEXT="timemodified"/>
+        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Timestamp when the submission has been updated" PREVIOUS="timecreated" NEXT="grade"/>
+        <FIELD NAME="grade" TYPE="number" LENGTH="10" NOTNULL="false" UNSIGNED="false" DEFAULT="-1" SEQUENCE="false" DECIMALS="5" COMMENT="Grade for the submission calculated as average of the peer-assessments. The grade is a number from interval 0..100. If grade == -1 then the grade for submission has not been aggregated yet." PREVIOUS="timemodified" NEXT="gradeover"/>
+        <FIELD NAME="gradeover" TYPE="number" LENGTH="10" NOTNULL="false" UNSIGNED="false" DEFAULT="-1" SEQUENCE="false" DECIMALS="5" COMMENT="Grade for the submission manually overridden by a teacher. Grade is always from interval 0..100. If gradeover == -1 then the grade is not overriden." PREVIOUS="grade" NEXT="gradeoverby"/>
+        <FIELD NAME="gradeoverby" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the user who has overridden the grade for submission." PREVIOUS="gradeover" NEXT="gradinggrade"/>
+        <FIELD NAME="gradinggrade" TYPE="number" LENGTH="10" NOTNULL="false" UNSIGNED="false" DEFAULT="-1" SEQUENCE="false" DECIMALS="5" COMMENT="Grade for the assessment calculated by the module. The grade is a number from interval 0..100. If grade == -1 then the grade for assessment has not been aggregated yet." PREVIOUS="gradeoverby" NEXT="teachercomment"/>
+        <FIELD NAME="teachercomment" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="Teacher comment for the submission, for example describing the reasons for the overriding" PREVIOUS="gradinggrade" NEXT="teachercommentformat"/>
+        <FIELD NAME="teachercommentformat" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the teachercomment field" PREVIOUS="teachercomment"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="workshop_fk"/>
+        <KEY NAME="workshop_fk" TYPE="foreign" FIELDS="workshopid" REFTABLE="workshop" REFFIELDS="id" COMMENT="Workshop foreign key" PREVIOUS="primary" NEXT="author_fk"/>
+        <KEY NAME="author_fk" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="workshop_fk" NEXT="overriddenby_fk"/>
+        <KEY NAME="overriddenby_fk" TYPE="foreign" FIELDS="gradeoverby" REFTABLE="user" REFFIELDS="id" PREVIOUS="author_fk"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="workshop_assessments" COMMENT="Info about the made assessment and automatically calculated grade for it. The proposed grade can be overridden by teacher." PREVIOUS="workshop_submissions" NEXT="workshop_grades">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="submissionid"/>
+        <FIELD NAME="submissionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the assessed submission" PREVIOUS="id" NEXT="userid"/>
+        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the reviewer who created this assessment" PREVIOUS="submissionid" NEXT="timecreated"/>
+        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="If 0 then the assessment was allocated but the reviewer has not assessed yet. If greater than 0 then the timestamp of when the reviewer assessed for the first time" PREVIOUS="userid" NEXT="timemodified"/>
+        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="If 0 then the assessment was allocated but the reviewer has not assessed yet. If greater than 0 then the timestamp of when the reviewer assessed for the last time" PREVIOUS="timecreated" NEXT="timeagreed"/>
+        <FIELD NAME="timeagreed" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="If 0 then the assessment was not agreed by the author. If greater than 0 then the timestamp of when the assessment was agreed by the author" PREVIOUS="timemodified" NEXT="grade"/>
+        <FIELD NAME="grade" TYPE="number" LENGTH="10" NOTNULL="false" UNSIGNED="false" DEFAULT="-1" SEQUENCE="false" DECIMALS="5" COMMENT="The aggregated grade for submission suggested by the reviewer. The grade is computed from the values assigned to the assessment dimensions fields. If grade == -1 then it has not been aggregated yet." PREVIOUS="timeagreed" NEXT="gradinggrade"/>
+        <FIELD NAME="gradinggrade" TYPE="number" LENGTH="10" NOTNULL="false" UNSIGNED="false" DEFAULT="-1" SEQUENCE="false" DECIMALS="5" COMMENT="The computed grade for this assessment. If gradinggrade == -1 then it has not been computed yet." PREVIOUS="grade" NEXT="gradinggradeover"/>
+        <FIELD NAME="gradinggradeover" TYPE="number" LENGTH="10" NOTNULL="false" UNSIGNED="false" DEFAULT="-1" SEQUENCE="false" DECIMALS="5" COMMENT="Grade for the assessment manually overridden by a teacher. Grade is always from interval 0..100. If gradinggradeover == -1 then the grade is not overriden." PREVIOUS="gradinggrade" NEXT="gradinggradeoverby"/>
+        <FIELD NAME="gradinggradeoverby" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the user who has overridden the grade for submission." PREVIOUS="gradinggradeover" NEXT="generalcomment"/>
+        <FIELD NAME="generalcomment" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="Comment from the reviewer" PREVIOUS="gradinggradeoverby" NEXT="generalcommentformat"/>
+        <FIELD NAME="generalcommentformat" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of generalcomment field" PREVIOUS="generalcomment" NEXT="teachercomment"/>
+        <FIELD NAME="teachercomment" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="The comment from the teacher. For example the reason why the grade for assessment was overridden" PREVIOUS="generalcommentformat" NEXT="teachercommentformat"/>
+        <FIELD NAME="teachercommentformat" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of teachercomment field" PREVIOUS="teachercomment"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="submission_fk"/>
+        <KEY NAME="submission_fk" TYPE="foreign" FIELDS="submissionid" REFTABLE="workshop_submissions" REFFIELDS="id" PREVIOUS="primary" NEXT="reviewer_fk"/>
+        <KEY NAME="reviewer_fk" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="submission_fk" NEXT="overriddenby_fk"/>
+        <KEY NAME="overriddenby_fk" TYPE="foreign" FIELDS="gradinggradeoverby" REFTABLE="user" REFFIELDS="id" PREVIOUS="reviewer_fk"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="workshop_grades" COMMENT="How the reviewers filled-up the grading forms, given grades and comments" PREVIOUS="workshop_assessments" NEXT="workshop_forms_nograding">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="assessmentid"/>
+        <FIELD NAME="assessmentid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Part of which assessment this grade is of" PREVIOUS="id" NEXT="strategy"/>
+        <FIELD NAME="strategy" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" COMMENT="The type of the grading strategy used for this grade" PREVIOUS="assessmentid" NEXT="dimensionid"/>
+        <FIELD NAME="dimensionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Foreign key. References dimension id in one of the grading strategy tables." PREVIOUS="strategy" NEXT="grade"/>
+        <FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Given grade in the referenced assessment dimension." PREVIOUS="dimensionid" NEXT="peercomment"/>
+        <FIELD NAME="peercomment" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="Reviewer's comment to the grade value." PREVIOUS="grade" NEXT="peercommentformat"/>
+        <FIELD NAME="peercommentformat" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="The format of peercomment field" PREVIOUS="peercomment"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="assessment_fk"/>
+        <KEY NAME="assessment_fk" TYPE="foreign" FIELDS="assessmentid" REFTABLE="workshop_assessments" REFFIELDS="id" PREVIOUS="primary"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="workshop_forms_nograding" COMMENT="The assessment dimensions definitions of No grading strategy forms" PREVIOUS="workshop_grades" NEXT="workshop_forms_errorbanded">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="workshopid"/>
+        <FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the Workshop instance where this dimension is used as a part of evaluation form." PREVIOUS="id" NEXT="sort"/>
+        <FIELD NAME="sort" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The order of the dimension in the form" PREVIOUS="workshopid" NEXT="description"/>
+        <FIELD NAME="description" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="The description of the dimension" PREVIOUS="sort" NEXT="descriptionformat"/>
+        <FIELD NAME="descriptionformat" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the description field" PREVIOUS="description"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="workshop_fk"/>
+        <KEY NAME="workshop_fk" TYPE="foreign" FIELDS="workshopid" REFTABLE="workshop" REFFIELDS="id" PREVIOUS="primary"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="workshop_forms_errorbanded" COMMENT="The assessment dimensions definitions of Error banded grading strategy forms" PREVIOUS="workshop_forms_nograding" NEXT="workshop_forms_accumulative">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="workshopid"/>
+        <FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the Workshop instance where this dimension is used as a part of evaluation form." PREVIOUS="id" NEXT="sort"/>
+        <FIELD NAME="sort" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The order of the dimension in the form" PREVIOUS="workshopid" NEXT="description"/>
+        <FIELD NAME="description" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="The description of the dimension" PREVIOUS="sort" NEXT="descriptionformat"/>
+        <FIELD NAME="descriptionformat" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the description field" PREVIOUS="description" NEXT="grade0"/>
+        <FIELD NAME="grade0" TYPE="char" LENGTH="50" NOTNULL="false" SEQUENCE="false" COMMENT="The word describing the negative evaluation (like Poor, Missing, Absent, etc.). If NULL, it defaults to a translated string False" PREVIOUS="descriptionformat" NEXT="grade1"/>
+        <FIELD NAME="grade1" TYPE="char" LENGTH="50" NOTNULL="false" SEQUENCE="false" COMMENT="A word for possitive evaluation (like Good, Present, OK etc). If NULL, it defaults to a translated string True" PREVIOUS="grade0" NEXT="weight"/>
+        <FIELD NAME="weight" TYPE="int" LENGTH="5" NOTNULL="false" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" COMMENT="Weight of this dimension" PREVIOUS="grade1"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="workshop_fk"/>
+        <KEY NAME="workshop_fk" TYPE="foreign" FIELDS="workshopid" REFTABLE="workshop" REFFIELDS="id" PREVIOUS="primary"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="workshop_forms_accumulative" COMMENT="The assessment dimensions definitions of Accumulative grading strategy forms" PREVIOUS="workshop_forms_errorbanded" NEXT="workshop_forms_rubric">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="workshopid"/>
+        <FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the Workshop instance where this dimension is used as a part of evaluation form." PREVIOUS="id" NEXT="sort"/>
+        <FIELD NAME="sort" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The order of the dimension in the form" PREVIOUS="workshopid" NEXT="description"/>
+        <FIELD NAME="description" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="The description of the dimension" PREVIOUS="sort" NEXT="descriptionformat"/>
+        <FIELD NAME="descriptionformat" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the description field" PREVIOUS="description" NEXT="grade"/>
+        <FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" COMMENT="If greater than 0, then the value is maximum grade on a scale 0..grade. If lesser than 0, then its absolute value is the id of a record in scale table. If equals 0, then no grading is possible for this dimension, just commenting." PREVIOUS="descriptionformat" NEXT="weight"/>
+        <FIELD NAME="weight" TYPE="int" LENGTH="5" NOTNULL="false" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" COMMENT="The weigh of the dimension" PREVIOUS="grade"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="workshop_fk"/>
+        <KEY NAME="workshop_fk" TYPE="foreign" FIELDS="workshopid" REFTABLE="workshop" REFFIELDS="id" PREVIOUS="primary"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="workshop_forms_rubric" COMMENT="The assessment dimensions definitions of Rubric grading strategy forms" PREVIOUS="workshop_forms_accumulative" NEXT="workshop_forms_rubric_levels">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="workshopid"/>
+        <FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the Workshop instance where this dimension is used as a part of evaluation form." PREVIOUS="id" NEXT="sort"/>
+        <FIELD NAME="sort" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The order of the dimension in the form" PREVIOUS="workshopid" NEXT="description"/>
+        <FIELD NAME="description" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="The description of the dimension" PREVIOUS="sort" NEXT="descriptionformat"/>
+        <FIELD NAME="descriptionformat" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the description field" PREVIOUS="description"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="workshop_fk"/>
+        <KEY NAME="workshop_fk" TYPE="foreign" FIELDS="workshopid" REFTABLE="workshop" REFFIELDS="id" PREVIOUS="primary"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="workshop_forms_rubric_levels" COMMENT="The definition of rubric rating scales" PREVIOUS="workshop_forms_rubric">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="dimensionid"/>
+        <FIELD NAME="dimensionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Which criterion this level is part of" PREVIOUS="id" NEXT="grade"/>
+        <FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Grade representing this level." PREVIOUS="dimensionid" NEXT="description"/>
+        <FIELD NAME="description" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="The definition of this level" PREVIOUS="grade" NEXT="descriptionformat"/>
+        <FIELD NAME="descriptionformat" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the description field" PREVIOUS="description"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="dimension_fk"/>
+        <KEY NAME="dimension_fk" TYPE="foreign" FIELDS="dimensionid" REFTABLE="workshop_forms_rubric" REFFIELDS="id" PREVIOUS="primary"/>
+      </KEYS>
+    </TABLE>
+  </TABLES>
+</XMLDB>
diff --git a/mod/workshop/editgradingform.php b/mod/workshop/editgradingform.php
new file mode 100644 (file)
index 0000000..860c062
--- /dev/null
@@ -0,0 +1,118 @@
+<?php
+// This file is part of Moodle - http://moodle.org/  
+// 
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+/**
+ * Edit grading form in for a particular instance of workshop
+ *
+ * @package   mod-workshop
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
+require_once(dirname(__FILE__).'/lib.php');
+
+$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
+$a  = optional_param('a', 0, PARAM_INT);  // workshop instance ID
+
+if ($id) {
+    if (! $cm = get_coursemodule_from_id('workshop', $id)) {
+        error('Course Module ID was incorrect');
+    }
+
+    if (! $course = $DB->get_record('course', array('id' => $cm->course))) {
+        error('Course is misconfigured');
+    }
+
+    if (! $workshop = $DB->get_record('workshop', array('id' => $cm->instance))) {
+        error('Course module is incorrect');
+    }
+
+} else if ($a) {
+    if (! $workshop = $DB->get_record('workshop', array('id' => $a))) {
+        error('Course module is incorrect');
+    }
+    if (! $course = $DB->get_record('course', array('id' => $workshop->course))) {
+        error('Course is misconfigured');
+    }
+    if (! $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id)) {
+        error('Course Module ID was incorrect');
+    }
+
+} else {
+    error('You must specify a course_module ID or an instance ID');
+}
+
+require_login($course, true, $cm);
+
+add_to_log($course->id, "workshop", "editgradingform", "editgradingform.php?id=$cm->id", "$workshop->id");
+
+// where should the user be sent in case of error of canceling
+$returnurl = "{$CFG->wwwroot}/mod/workshop/view.php?id={$cm->id}";
+$selfurl   = "{$CFG->wwwroot}/mod/workshop/editgradingform.php?id={$cm->id}";
+
+// todo
+$dimensions = $DB->get_records('workshop_forms_accumulative', array('workshopid' => $workshop->id), 'sort');
+
+// load the form to edit the grading strategy dimensions
+$strategylib = dirname(__FILE__) . '/grading/' . $workshop->strategy . '/edit_' . $workshop->strategy . '_strategy_form.php';
+if (file_exists($strategylib)) {
+    require_once($strategylib);
+} else {
+    print_error('errloadingstrategylib', 'workshop', $returnurl);
+}
+$classname = 'workshop_edit_' . $workshop->strategy . '_strategy_form';
+$mform = new $classname($selfurl, true, count($dimensions));
+
+// initialize form data
+$formdata = new stdClass;
+$formdata->workshopid   = $workshop->id;
+$formdata->strategy     = $workshop->strategy;
+$formdata->dimensions   = $dimensions;
+$mform->set_data($formdata);
+
+if ($mform->is_cancelled()) {
+    redirect($returnurl);
+} elseif ($data = $mform->get_data()) {
+    print_object($data); die();
+}
+
+// build the navigation and the header
+$navlinks = array();
+$navlinks[] = array('name' => get_string('modulenameplural', 'workshop'), 
+                    'link' => "index.php?id=$course->id", 
+                    'type' => 'activity');
+$navlinks[] = array('name' => format_string($workshop->name), 
+                    'link' => "view.php?id=$cm->id",
+                    'type' => 'activityinstance');
+$navlinks[] = array('name' => get_string('editinggradingform', 'workshop'), 
+                    'link' => '',
+                    'type' => 'title');
+$navigation = build_navigation($navlinks);
+
+// OUTPUT STARTS HERE
+
+print_header_simple(format_string($workshop->name), '', $navigation, '', '', true,
+              update_module_button($cm->id, $course->id, get_string('modulename', 'workshop')), navmenu($course, $cm));
+
+print_heading(get_string('strategy' . $workshop->strategy, 'workshop'));
+
+$mform->display();
+
+/// Finish the page
+print_footer($course);
diff --git a/mod/workshop/grading/accumulative/edit_accumulative_strategy_form.php b/mod/workshop/grading/accumulative/edit_accumulative_strategy_form.php
new file mode 100644 (file)
index 0000000..42b12a3
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+// This file is part of Moodle - http://moodle.org/  
+// 
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+/**
+ * This file defines an mform to edit accumulative grading strategy forms.
+ *
+ * @package   mod-workshop
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+if (!defined('MOODLE_INTERNAL')) {
+    die('Direct access to this script is forbidden.'); //  It must be included from a Moodle page
+}
+
+require_once(dirname(dirname(__FILE__)).'/edit_strategy_form.php');  // parent class definition
+
+
+/**
+ * Class for editing accumulative grading strategy forms.
+ *
+ * @uses moodleform
+ */
+class workshop_edit_accumulative_strategy_form extends workshop_edit_strategy_form {
+
+    /**
+     * Define the elements to be displayed at the form 
+     *
+     * Called by the parent::definition()
+     * 
+     * @access protected
+     * @return void
+     */
+    protected function definition_inner(&$mform) {
+
+        $gradeoptions = array(20 => 20, 10 => 10, 5 => 5);
+        $weights = workshop_get_dimension_weights();
+
+        $repeated = array();
+        $repeated[] =& $mform->createElement('hidden', 'dimensionid', 0);
+        $repeated[] =& $mform->createElement('header', 'dimension', get_string('dimension', 'workshop'));
+        $repeated[] =& $mform->createElement('textarea', 'description',
+                                                 get_string('dimensiondescription', 'workshop'), array('cols'=>60));
+        $repeated[] =& $mform->createElement('select', 'grade', get_string('grade'), $gradeoptions);
+        $repeated[] =& $mform->createElement('select', 'weight', get_string('dimensionweight', 'workshop'), $weights);
+        
+        $repeatedoptions = array();
+        $repeatedoptions['description']['type'] = PARAM_CLEANHTML;
+        $repeatedoptions['description']['helpbutton'] = array('dimensiondescription', 
+                                                            get_string('dimensiondescription', 'workshop'), 'workshop');
+        $repeatedoptions['grade']['default'] = 10;
+        $repeatedoptions['weight']['default'] = 1;
+
+        $numofdimensionstoadd   = 2;
+        $numofinitialdimensions = 3;
+        $numofdisplaydimensions = max($this->numofdimensions + $numofdimensionstoadd, $numofinitialdimensions);
+        $this->repeat_elements($repeated, $numofdisplaydimensions,  $repeatedoptions, 'numofdimensions', 'adddimensions', $numofdimensionstoadd, get_string('addmoredimensionblanks', 'workshop', $numofdimensionstoadd));
+    }
+
+
+    /**
+     * Return the mapping of the db fields to the form fields for every dimension of assessment
+     *  
+     * @access protected
+     * @return array Array ['field_db_name' => 'field_form_name']
+     */
+    protected function get_dimension_fieldnames() {
+        return array(
+                'id'                => 'dimensionid',
+                'description'       => 'description',
+                'descriptionformat' => 'descriptionformat',
+                'grade'             => 'grade',
+                'weight'            => 'weight',
+            );
+    }
+
+
+}
diff --git a/mod/workshop/grading/edit_strategy_form.php b/mod/workshop/grading/edit_strategy_form.php
new file mode 100644 (file)
index 0000000..4aa732d
--- /dev/null
@@ -0,0 +1,154 @@
+<?php
+// This file is part of Moodle - http://moodle.org/  
+// 
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+/**
+ * This file defines a base class for all grading strategy editing forms.
+ *
+ * @package   mod-workshop
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+if (!defined('MOODLE_INTERNAL')) {
+    die('Direct access to this script is forbidden.'); //  It must be included from a Moodle page
+}
+
+require_once($CFG->libdir . '/formslib.php'); // parent class definition
+
+
+/**
+ * Base class for editing all the strategy grading forms.
+ *
+ * This defines the common fields that all strategy grading forms need. 
+ * Strategies should define their own  class that inherits from this one, and 
+ * implements the definition_inner() method.
+ * 
+ * @uses moodleform
+ */
+class workshop_edit_strategy_form extends moodleform {
+
+    /**
+     * Number of dimensions that are populated from DB
+     * 
+     * @var mixed
+     * @access protected
+     */
+    protected $numofdimensions;
+
+    /**
+     * Constructor
+     * 
+     * @param str $actionurl URL to handle data
+     * @param bool $editable Should the form be editable?
+     * @param int $initialdimensions Number of assessment dimensions that are already filled
+     * @access public
+     * @return void
+     */
+    public function __construct($actionurl, $editable=true, $initialdimensions=0) {
+
+        $this->numofdimensions = $initialdimensions;
+        parent::moodleform($actionurl, null, 'post', '', array('class' => 'editstrategyform'), $editable);
+    }
+
+
+    /**
+     * Add the fields that are common for all grading strategies.
+     *
+     * If the strategy does not support all these fields, then you can override 
+     * this method and remove the ones you don't want with 
+     * $mform->removeElement().
+     * Stretegy subclassess should define their own fields in definition_inner()
+     * 
+     * @access public
+     * @return void
+     */
+    public function definition() {
+        global $CFG;
+
+        $mform = $this->_form;
+
+        $mform->addElement('hidden', 'workshopid');
+        $mform->setType('id', PARAM_INT);
+
+        $mform->addElement('hidden', 'strategy');
+        $mform->setType('id', PARAM_ALPHA);
+
+        $this->definition_inner($mform);
+
+        if (!empty($CFG->usetags)) {
+            $mform->addElement('header', 'tagsheader', get_string('tags'));
+            $mform->addElement('tags', 'tags', get_string('tags'));
+        }
+
+        $buttonarray = array();
+        $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
+        $buttonarray[] = &$mform->createElement('cancel');
+        $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
+        $mform->closeHeaderBefore('buttonar');
+    }
+
+
+    /**
+     * Add any strategy specific form fields.
+     *
+     * @param object $mform the form being built.
+     */
+    protected function definition_inner(&$mform) {
+        // By default, do nothing.
+    }
+
+
+    /**
+     * Set the form data before it is displayed
+     *
+     * Strategy plugins should provide the list of fields to be mapped from 
+     * DB record to the form fields in their get_dimension_fieldnames() method
+     * 
+     * @param object $formdata Should contain the array $formdata->dimensions
+     * @access public
+     * @return void
+     */
+    public function set_data($formdata) {
+
+        if (is_array($formdata->dimensions) && !empty($formdata->dimensions)) {
+            // $formdata->dimensions must be array of dimension records loaded from database
+            $key = 0;
+            $default_values = array();
+            foreach ($formdata->dimensions as $dimension) {
+                foreach ($this->get_dimension_fieldnames() as $fielddbname => $fieldformname) {
+                    $default_values[$fieldformname . '[' . $key . ']'] = $dimension->$fielddbname;
+                }
+                $key++;
+            }
+            $formdata = (object)((array)$formdata + $default_values);
+        }
+        parent::set_data($formdata);
+    }
+
+
+    /**
+     * Return the mapping of the db fields to the form fields for every assessment dimension
+     * 
+     * @access protected
+     * @return array Array ['field_db_name' => 'field_form_name']
+     */
+    protected function get_dimension_fieldnames() {
+        return array();
+    }
+
+}
diff --git a/mod/workshop/icon.gif b/mod/workshop/icon.gif
new file mode 100644 (file)
index 0000000..d9ffc4d
Binary files /dev/null and b/mod/workshop/icon.gif differ
diff --git a/mod/workshop/index.php b/mod/workshop/index.php
new file mode 100644 (file)
index 0000000..889a21b
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+// This file is part of Moodle - http://moodle.org/  
+// 
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+/**
+ * This is a one-line short description of the file
+ *
+ * You can have a rather longer description of the file as well,
+ * if you like, and it can span multiple lines.
+ *
+ * @package   mod-workshop
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/// Replace workshop with the name of your module and remove this line
+
+require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
+require_once(dirname(__FILE__).'/lib.php');
+
+$id = required_param('id', PARAM_INT);   // course
+
+if (! $course = $DB->get_record('course', array('id' => $id))) {
+    error('Course ID is incorrect');
+}
+
+require_course_login($course);
+
+add_to_log($course->id, 'workshop', 'view all', "index.php?id=$course->id", '');
+
+
+/// Get all required stringsworkshop
+
+$strworkshops = get_string('modulenameplural', 'workshop');
+$strworkshop  = get_string('modulename', 'workshop');
+
+
+/// Print the header
+
+$navlinks = array();
+$navlinks[] = array('name' => $strworkshops, 'link' => '', 'type' => 'activity');
+$navigation = build_navigation($navlinks);
+
+print_header_simple($strworkshops, '', $navigation, '', '', true, '', navmenu($course));
+
+/// Get all the appropriate data
+
+if (! $workshops = get_all_instances_in_course('workshop', $course)) {
+    notice('There are no workshops', "../../course/view.php?id=$course->id");
+    die;
+}
+
+/// Print the list of instances (your module will probably extend this)
+
+$timenow  = time();
+$strname  = get_string('name');
+$strweek  = get_string('week');
+$strtopic = get_string('topic');
+
+if ($course->format == 'weeks') {
+    $table->head  = array ($strweek, $strname);
+    $table->align = array ('center', 'left');
+} else if ($course->format == 'topics') {
+    $table->head  = array ($strtopic, $strname);
+    $table->align = array ('center', 'left', 'left', 'left');
+} else {
+    $table->head  = array ($strname);
+    $table->align = array ('left', 'left', 'left');
+}
+
+foreach ($workshops as $workshop) {
+    if (!$workshop->visible) {
+        //Show dimmed if the mod is hidden
+        $link = "<a class=\"dimmed\" href=\"view.php?id=$workshop->coursemodule\">$workshop->name</a>";
+    } else {
+        //Show normal if the mod is visible
+        $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);
+    } else {
+        $table->data[] = array ($link);
+    }
+}
+
+print_heading($strworkshops);
+print_table($table);
+
+/// Finish the page
+
+print_footer($course);
diff --git a/mod/workshop/lang/en_utf8/workshop.php b/mod/workshop/lang/en_utf8/workshop.php
new file mode 100644 (file)
index 0000000..8231247
--- /dev/null
@@ -0,0 +1,113 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/  
+// 
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ * English strings for Workshop module
+ *
+ * @package   mod-workshop
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['accesscontrol'] = 'Access control';
+$string['addmoredimensionblanks'] = 'Blanks for $a more dimensions';
+$string['agreeassessments'] = 'Assessments must be agreed';
+$string['agreeassessmentsdesc'] = 'Authors may comment assessments of their work and agree/disagree with it';
+$string['anonymity'] = 'Anonymity mode';
+$string['anonymityauthors'] = 'Reviewers can\'t see authors\' names';
+$string['anonymityboth'] = 'Fully anonymous';
+$string['anonymitynone'] = 'Not anonymous';
+$string['anonymityreviewers'] = 'Authors can\'t see reviewers\' names';
+$string['assessallexamples'] = 'Assess all examples';
+$string['assessmentcomps'] = 'Required level of assessments similarity';
+$string['assessmentend'] = 'End of assessment phase';
+$string['assessmentsettings'] = 'Assessment settings';
+$string['assessmentstart'] = 'Start of assessment phase';
+$string['assesswosubmission'] = 'Assess without submission';
+$string['assesswosubmissiondesc'] = 'Users can assess peers even without their own submission';
+$string['comparisonhigh'] = 'High';
+$string['comparisonlow'] = 'Low';
+$string['comparisonnormal'] = 'Normal';
+$string['comparisonveryhigh'] = 'Very high';
+$string['comparisonverylow'] = 'Very low';
+$string['configanonymity'] = 'Default anonymity mode in workshops';
+$string['configassessmentcomps'] = 'Default value of the setting that influences the calculation of the grade for assessment.';
+$string['configexamplesmode'] = 'Default mode of examples assessment in workshops';
+$string['configgrade'] = 'Default maximum grade for submission in workshops';
+$string['configgradinggrade'] = 'Default maximum grade for assessment in workshops';
+$string['configmaxbytes'] = 'Default maximum submission file size for all workshops on the site (subject to course limits and other local settings)';
+$string['confignexassessments'] = 'Default number of examples to be reviewed by a user in the example assessment phase';
+$string['confignsassessments'] = 'Default number of allocated submissions to be reviewed by a user in the assessment phase';
+$string['configstrategy'] = 'Default grading strategy for workshops';
+$string['editgradingform'] = 'Edit grading form';
+$string['editinggradingform'] = 'Editing grading form';
+$string['dimensiondescription'] = 'Dimension description';
+$string['dimensionweight'] = 'Dimension weight';
+$string['dimension'] = 'Dimension of assessment';
+$string['examplesbeforeassessment'] = 'Examples are available after own submission and must be assessed before peer/self assessment phase';
+$string['examplesbeforesubmission'] = 'Examples must be assessed before own submission';
+$string['examplesmode'] = 'Mode of examples assessment';
+$string['examplesvoluntary'] = 'Assessment of example submission is voluntary';
+$string['gradeforassessment'] = 'Grade for assessment';
+$string['gradeforsubmission'] = 'Grade for submission';
+$string['gradingsettings'] = 'Grading settings';
+$string['hidegradesdesc'] = 'If assessments must be agreed, should the grades be hidden from the author? If grades are hidden, authors can see only comments';
+$string['hidegrades'] = 'Hide grades before agreement';
+$string['introduction'] = 'Introduction';
+$string['latesubmissionsdesc'] = 'Allow submitting the work after the deadline';
+$string['latesubmissions'] = 'Late submissions';
+$string['maxbytes'] = 'Maximum file size';
+$string['modulenameplural'] = 'Workshops';
+$string['modulename'] = 'Workshop';
+$string['nattachments'] = 'Number of required submission attachments';
+$string['nexassessments'] = 'Number of required assessments of examples';
+$string['nsassessments'] = 'Number of required assessments of other users\' work';
+$string['releasegrades'] = 'Push final grades into the gradebook';
+$string['requirepassword'] = 'Require password';
+$string['strategyaccumulative'] = 'Accumulative grading';
+$string['strategyerrorbanded'] = 'Error banded grading';
+$string['strategy'] = 'Grading strategy';
+$string['strategynograding'] = 'No grading';
+$string['strategyrubric'] = 'Rubric grading';
+$string['submissionend'] = 'End of submission phase';
+$string['submissionsettings'] = 'Submission settings';
+$string['submissionstart'] = 'Start of submission phase';
+$string['teacherweight'] = 'Weight of the teacher\'s assessments';
+$string['useexamplesdesc'] = 'Users practise evaluating on example submissions';
+$string['useexamples'] = 'Use examples';
+$string['usepeerassessmentdesc'] = 'Users perform peer assessment of others\' work';
+$string['usepeerassessment'] = 'Use peer assessment';
+$string['useselfassessmentdesc'] = 'Users perform self assessment of their own work';
+$string['useselfassessment'] = 'Use self assessment';
+$string['workshopfeatures'] = 'Workshop features';
+$string['workshopname'] = 'Workshop name';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
+$string[''] = '';
diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php
new file mode 100644 (file)
index 0000000..9be5f0b
--- /dev/null
@@ -0,0 +1,423 @@
+<?php
+// This file is part of Moodle - http://moodle.org/  
+// 
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+/**
+ * Library of interface functions and constants for module workshop
+ *
+ * All the core Moodle functions, neeeded to allow the module to work 
+ * integrated in Moodle should be placed here.
+ * All the workshop specific functions, needed to implement all the module 
+ * logic, should go to locallib.php. This will help to save some memory when 
+ * Moodle is performing actions across all modules.
+ *
+ * @package   mod-workshop
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+/**
+ * The internal codes of the anonymity levels
+ */
+define('WORKSHOP_ANONYMITY_NONE',       0);     /* not anonymous */
+define('WORKSHOP_ANONYMITY_AUTHORS',    1);     /* authors hidden from reviewers */
+define('WORKSHOP_ANONYMITY_REVIEWERS',  2);     /* reviewers hidden from authors */
+define('WORKSHOP_ANONYMITY_BOTH',       3);     /* fully anonymous */
+
+
+/**
+ * The internal codes of the example assessment modes
+ */
+define('WORKSHOP_EXAMPLES_VOLUNTARY',           0);
+define('WORKSHOP_EXAMPLES_BEFORE_SUBMISSION',   1);
+define('WORKSHOP_EXAMPLES_BEFORE_ASSESSMENT',   2);
+
+
+/**
+ * The internal codes of the required level of assessment similarity
+ */
+define('WORKSHOP_COMPARISON_VERYLOW',   0);     /* f = 1.00 */
+define('WORKSHOP_COMPARISON_LOW',       1);     /* f = 1.67 */
+define('WORKSHOP_COMPARISON_NORMAL',    2);     /* f = 2.50 */
+define('WORKSHOP_COMPARISON_HIGH',      3);     /* f = 3.00 */
+define('WORKSHOP_COMPARISON_VERYHIGH',  4);     /* f = 5.00 */
+
+
+/**
+ * Given an object containing all the necessary data,
+ * (defined by the form in mod_form.php) this function
+ * will create a new instance and return the id number
+ * of the new instance.
+ *
+ * @param object $workshop An object from the form in mod_form.php
+ * @return int The id of the newly inserted workshop record
+ */
+function workshop_add_instance($workshop) {
+    global $DB;
+
+    $workshop->timecreated = time();
+    $workshop->timemodified = $workshop->timecreated;
+
+    return $DB->insert_record('workshop', $workshop);
+}
+
+
+/**
+ * Given an object containing all the necessary data,
+ * (defined by the form in mod_form.php) this function
+ * will update an existing instance with new data.
+ *
+ * @param object $workshop An object from the form in mod_form.php
+ * @return boolean Success/Fail
+ */
+function workshop_update_instance($workshop) {
+    global $DB;
+
+    $workshop->timemodified = time();
+    $workshop->id = $workshop->instance;
+
+    return $DB->update_record('workshop', $workshop);
+}
+
+
+/**
+ * Given an ID of an instance of this module,
+ * this function will permanently delete the instance
+ * and any data that depends on it.
+ *
+ * @param int $id Id of the module instance
+ * @return boolean Success/Failure
+ */
+function workshop_delete_instance($id) {
+    global $DB;
+
+    if (! $workshop = $DB->get_record('workshop', array('id' => $id))) {
+        return false;
+    }
+
+    $result = true;
+
+    # Delete any dependent records here #
+
+    if (! $DB->delete_records('workshop', array('id' => $workshop->id))) {
+        $result = false;
+    }
+
+    return $result;
+}
+
+
+/**
+ * Return a small object with summary information about what a
+ * user has done with a given particular instance of this module
+ * Used for user activity reports.
+ * $return->time = the time they did it
+ * $return->info = a short text description
+ *
+ * @return null
+ * @todo Finish documenting this function
+ */
+function workshop_user_outline($course, $user, $mod, $workshop) {
+    $return = new stdClass;
+    $return->time = 0;
+    $return->info = '';
+    return $return;
+}
+
+
+/**
+ * Print a detailed representation of what a user has done with
+ * a given particular instance of this module, for user activity reports.
+ *
+ * @return boolean
+ * @todo Finish documenting this function
+ */
+function workshop_user_complete($course, $user, $mod, $workshop) {
+    return true;
+}
+
+
+/**
+ * Given a course and a time, this module should find recent activity
+ * that has occurred in workshop activities and print it out.
+ * Return true if there was output, or false is there was none.
+ *
+ * @return boolean
+ * @todo Finish documenting this function
+ */
+function workshop_print_recent_activity($course, $isteacher, $timestart) {
+    return false;  //  True if anything was printed, otherwise false
+}
+
+
+/**
+ * Function to be run periodically according to the moodle cron
+ * This function searches for things that need to be done, such
+ * as sending out mail, toggling flags etc ...
+ *
+ * @return boolean
+ * @todo Finish documenting this function
+ **/
+function workshop_cron () {
+    return true;
+}
+
+
+/**
+ * Must return an array of user records (all data) who are participants
+ * for a given instance of workshop. Must include every user involved
+ * in the instance, independient of his role (student, teacher, admin...)
+ * See other modules as example.
+ *
+ * @param int $workshopid ID of an instance of this module
+ * @return mixed boolean/array of students
+ */
+function workshop_get_participants($workshopid) {
+    return false;
+}
+
+
+/**
+ * This function returns if a scale is being used by one workshop
+ * if it has support for grading and scales. Commented code should be
+ * modified if necessary. See forum, glossary or journal modules
+ * as reference.
+ *
+ * @param int $workshopid ID of an instance of this module
+ * @return mixed
+ * @todo Finish documenting this function
+ */
+function workshop_scale_used($workshopid, $scaleid) {
+    $return = false;
+
+    //$rec = get_record("workshop","id","$workshopid","scale","-$scaleid");
+    //
+    //if (!empty($rec) && !empty($scaleid)) {
+    //    $return = true;
+    //}
+
+    return $return;
+}
+
+
+/**
+ * Checks if scale is being used by any instance of workshop.
+ * This function was added in 1.9
+ *
+ * This is used to find out if scale used anywhere
+ * @param $scaleid int
+ * @return boolean True if the scale is used by any workshop
+ */
+function workshop_scale_used_anywhere($scaleid) {
+    if ($scaleid and record_exists('workshop', 'grade', -$scaleid)) {
+        return true;
+    } else {
+        return false;
+    }
+}
+
+
+/**
+ * Execute post-install custom actions for the module
+ * This function was added in 1.9
+ *
+ * @return boolean true if success, false on error
+ */
+function workshop_install() {
+    return true;
+}
+
+
+/**
+ * Execute post-uninstall custom actions for the module
+ * This function was added in 1.9
+ *
+ * @return boolean true if success, false on error
+ */
+function workshop_uninstall() {
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Other functions needed by Moodle core follows. They can't be put into      //
+// locallib.php because they are used by some core scripts (like modedit.php) //
+// where locallib.php is not included.                                        //
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Return an array of numeric values that can be used as maximum grades
+ *
+ * Used at several places where maximum grade for submission and grade for 
+ * assessment are defined via a HTML select form element. By default it returns
+ * an array 0, 1, 2, ..., 98, 99, 100.
+ * 
+ * @access public
+ * @return array Array of integers
+ */
+function workshop_get_maxgrades() {
+
+    $grades = array();
+    for ($i=100; $i>=0; $i--) {
+        $grades[$i] = $i;
+    }
+    return $grades;
+}
+
+
+/**
+ * Return an array of possible numbers of assessments to be done
+ *
+ * Should always contain numbers 1, 2, 3, ... 10 and possibly others up to a reasonable value
+ *
+ * @return array Array of integers
+ */
+function workshop_get_numbers_of_assessments() {
+
+    $options = array();
+    $options[30] = 30;
+    $options[20] = 20;
+    $options[15] = 15;
+    for ($i=10; $i>0; $i--) {
+        $options[$i] = $i;
+    }
+    return $options;
+}
+
+
+/**
+ * Return an array of possible values for weight of teacher assessment
+ * 
+ * @return array Array of integers 0, 1, 2, ..., 10
+ */
+function workshop_get_teacher_weights() {
+
+    $weights = array();
+    for ($i=10; $i>=0; $i--) {
+        $weights[$i] = $i;
+    }
+    return $weights;
+}
+
+
+/**
+ * Return an array of possible values of assessment dimension weight
+ * 
+ * @return array Array of integers 0, 1, 2, ..., 16
+ */
+function workshop_get_dimension_weights() {
+
+    $weights = array();
+    for ($i=16; $i>=0; $i--) {
+        $weights[$i] = $i;
+    }
+    return $weights;
+}
+
+
+/**
+ * Return an array of the localized grading strategy names
+ *
+ * @access public
+ * $return array Array ['string' => 'string']
+ */
+function workshop_get_strategies() {
+
+    $installed = get_list_of_plugins('mod/workshop/grading');
+    $forms = array();
+    foreach ($installed as $strategy) {
+        $forms[$strategy] = get_string('strategy' . $strategy, 'workshop');
+    }
+
+    return $forms;
+}
+
+
+/**
+ * Return an array of available anonymity modes
+ *
+ * @return array Array 'anonymity DB code'=>'anonymity mode name'
+ */
+function workshop_get_anonymity_modes() {
+    
+    $modes = array();
+    $modes[WORKSHOP_ANONYMITY_NONE]      = get_string('anonymitynone', 'workshop');
+    $modes[WORKSHOP_ANONYMITY_AUTHORS]   = get_string('anonymityauthors', 'workshop');
+    $modes[WORKSHOP_ANONYMITY_REVIEWERS] = get_string('anonymityreviewers', 'workshop');
+    $modes[WORKSHOP_ANONYMITY_BOTH]      = get_string('anonymityboth', 'workshop');
+
+    return $modes;
+}
+
+
+/**
+ * Return an array of available example assessment modes
+ *
+ * @return array Array 'mode DB code'=>'mode name'
+ */
+function workshop_get_example_modes() {
+
+    $modes = array();
+    $modes[WORKSHOP_EXAMPLES_VOLUNTARY]         = get_string('examplesvoluntary', 'workshop');
+    $modes[WORKSHOP_EXAMPLES_BEFORE_SUBMISSION] = get_string('examplesbeforesubmission', 'workshop');
+    $modes[WORKSHOP_EXAMPLES_BEFORE_ASSESSMENT] = get_string('examplesbeforeassessment', 'workshop');
+
+    return $modes;
+}
+
+
+/**
+ * Return array of assessment comparison levels
+ *
+ * The assessment comparison level influence how the grade for assessment is calculated.
+ * Each object in the returned array provides information about the name of the level
+ * and the value of the factor to be used in the calculation.
+ * The structure of the returned array is
+ * array[code int] of object (
+ *                      ->name string,
+ *                      ->value number,
+ *                      )
+ * where code if the integer code that is actually stored in the database.
+ *
+ * @return array Array of objects
+ */
+function workshop_get_comparison_levels() {
+
+    $levels = array();
+
+    $levels[WORKSHOP_COMPARISON_VERYHIGH] = new stdClass;
+    $levels[WORKSHOP_COMPARISON_VERYHIGH]->name = get_string('comparisonveryhigh', 'workshop');
+    $levels[WORKSHOP_COMPARISON_VERYHIGH]->value = 5.00;
+
+    $levels[WORKSHOP_COMPARISON_HIGH] = new stdClass;
+    $levels[WORKSHOP_COMPARISON_HIGH]->name = get_string('comparisonhigh', 'workshop');
+    $levels[WORKSHOP_COMPARISON_HIGH]->value = 3.00;
+
+    $levels[WORKSHOP_COMPARISON_NORMAL] = new stdClass;
+    $levels[WORKSHOP_COMPARISON_NORMAL]->name = get_string('comparisonnormal', 'workshop');
+    $levels[WORKSHOP_COMPARISON_NORMAL]->value = 2.50;
+
+    $levels[WORKSHOP_COMPARISON_LOW] = new stdClass;
+    $levels[WORKSHOP_COMPARISON_LOW]->name = get_string('comparisonlow', 'workshop');
+    $levels[WORKSHOP_COMPARISON_LOW]->value = 1.67;
+
+    $levels[WORKSHOP_COMPARISON_VERYLOW] = new stdClass;
+    $levels[WORKSHOP_COMPARISON_VERYLOW]->name = get_string('comparisonverylow', 'workshop');
+    $levels[WORKSHOP_COMPARISON_VERYLOW]->value = 1.00;
+
+    return $levels;
+}
diff --git a/mod/workshop/mod_form.php b/mod/workshop/mod_form.php
new file mode 100644 (file)
index 0000000..e4473e6
--- /dev/null
@@ -0,0 +1,233 @@
+<?php
+// This file is part of Moodle - http://moodle.org/  
+// 
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+/**
+ * The main workshop configuration form
+ *
+ * The UI mockup has been proposed in MDL-18688
+ * It uses the standard core Moodle formslib. For more info about them, please 
+ * visit: http://docs.moodle.org/en/Development:lib/formslib.php
+ *
+ * @package   mod-workshop
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once($CFG->dirroot.'/course/moodleform_mod.php');
+
+class mod_workshop_mod_form extends moodleform_mod {
+
+    function definition() {
+
+        global $CFG, $COURSE;
+        $workshopconfig = get_config('workshop');
+        $mform =& $this->_form;
+
+/// General --------------------------------------------------------------------
+        $mform->addElement('header', 'general', get_string('general', 'form'));
+
+    /// Workshop name
+        $label = get_string('workshopname', 'workshop');
+        $mform->addElement('text', 'name', $label, array('size'=>'64'));
+        if (!empty($CFG->formatstringstriptags)) {
+            $mform->setType('name', PARAM_TEXT);
+        } else {
+            $mform->setType('name', PARAM_CLEAN);
+        }
+        $mform->addRule('name', null, 'required', null, 'client');
+        $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
+        $mform->setHelpButton('name', array('workshopname', $label, 'workshop'));
+
+    /// Introduction
+        $this->add_intro_editor(false, get_string('introduction', 'workshop'));
+
+/// Workshop features ----------------------------------------------------------
+        $mform->addElement('header', 'workshopfeatures', get_string('workshopfeatures', 'workshop'));
+
+        $label = get_string('useexamples', 'workshop');
+        $text = get_string('useexamplesdesc', 'workshop');
+        $mform->addElement('advcheckbox', 'useexamples', $label, $text);
+        $mform->setHelpButton('useexamples', array('useexamples', $label, 'workshop'));
+
+        $label = get_string('usepeerassessment', 'workshop');
+        $text = get_string('usepeerassessmentdesc', 'workshop');
+        $mform->addElement('advcheckbox', 'usepeerassessment', $label, $text);
+        $mform->setHelpButton('usepeerassessment', array('usepeerassessment', $label, 'workshop'));
+
+        $label = get_string('useselfassessment', 'workshop');
+        $text = get_string('useselfassessmentdesc', 'workshop');
+        $mform->addElement('advcheckbox', 'useselfassessment', $label, $text);
+        $mform->setHelpButton('useselfassessment', array('useselfassessment', $label, 'workshop'));
+
+/// Grading settings -----------------------------------------------------------
+        $mform->addElement('header', 'gradingsettings', get_string('gradingsettings', 'workshop'));
+
+        $grades = workshop_get_maxgrades();
+
+        $label = get_string('gradeforsubmission', 'workshop');
+        $mform->addElement('select', 'grade', $label, $grades);
+        $mform->setDefault('grade', $workshopconfig->grade);
+        $mform->setHelpButton('grade', array('grade', $label, 'workshop'));
+
+        $label = get_string('gradeforassessment', 'workshop');
+        $mform->addElement('select', 'gradinggrade', $label , $grades);
+        $mform->setDefault('gradinggrade', $workshopconfig->gradinggrade);
+        $mform->setHelpButton('gradinggrade', array('gradinggrade', $label, 'workshop'));
+
+        $label = get_string('strategy', 'workshop');
+        $mform->addElement('select', 'strategy', $label, workshop_get_strategies());
+        $mform->setDefault('strategy', $workshopconfig->strategy);
+        $mform->setHelpButton('strategy', array('strategy', $label, 'workshop'));
+
+/// Submission settings --------------------------------------------------------
+        $mform->addElement('header', 'submissionsettings', get_string('submissionsettings', 'workshop'));
+
+        $label = get_string('latesubmissions', 'workshop');
+        $text = get_string('latesubmissionsdesc', 'workshop');
+        $mform->addElement('advcheckbox', 'latesubmissions', $label, $text);
+        $mform->setHelpButton('latesubmissions', array('latesubmissions', $label, 'workshop'));
+        $mform->setAdvanced('latesubmissions');
+
+        $options = array();
+        for ($i=7; $i>=0; $i--) {
+            $options[$i] = $i;
+        }
+        $label = get_string('nattachments', 'workshop');
+        $mform->addElement('select', 'nattachments', $label, $options);
+        $mform->setDefault('nattachments', 1);
+        $mform->setHelpButton('nattachments', array('nattachments', $label, 'workshop'));
+        $mform->setAdvanced('nattachments');
+
+        $options = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes); 
+        $options[0] = get_string('courseuploadlimit') . ' ('.display_size($COURSE->maxbytes).')';
+        $mform->addElement('select', 'maxbytes', get_string('maximumsize', 'assignment'), $options);
+        $mform->setDefault('maxbytes', $workshopconfig->maxbytes);
+        $mform->setHelpButton('maxbytes', array('maxbytes', $label, 'workshop'));
+        $mform->setAdvanced('maxbytes');
+
+/// Assessment settings
+        $mform->addElement('header', 'assessmentsettings', get_string('assessmentsettings', 'workshop'));
+
+        $options = workshop_get_anonymity_modes();
+        $label = get_string('anonymity', 'workshop');
+        $mform->addElement('select', 'anonymity', $label, $options);
+        $mform->setDefault('anonymity', $workshopconfig->anonymity);
+        $mform->setHelpButton('anonymity', array('anonymity', $label, 'workshop'));
+        $mform->disabledIf('anonymity', 'usepeerassessment');
+
+        $label = get_string('nsassessments', 'workshop');
+        $options = workshop_get_numbers_of_assessments();
+        $mform->addElement('select', 'nsassessments', $label, $options);
+        $mform->setDefault('nsassessments', $workshopconfig->nsassessments);
+        $mform->setHelpButton('nsassessments', array('nsassessments', $label, 'workshop'));
+
+        $label = get_string('nexassessments', 'workshop');
+        $options = workshop_get_numbers_of_assessments();
+        $options[0] = get_string('assessallexamples', 'workshop');
+        $mform->addElement('select', 'nexassessments', $label, $options);
+        $mform->setDefault('nexassessments', $workshopconfig->nexassessments);
+        $mform->setHelpButton('nexassessments', array('nexassessments', $label, 'workshop'));
+        $mform->disabledIf('nexassessments', 'useexamples');
+
+        $label = get_string('assesswosubmission', 'workshop');
+        $text = get_string('assesswosubmissiondesc', 'workshop');
+        $mform->addElement('advcheckbox', 'assesswosubmission', $label, $text);
+        $mform->setHelpButton('assesswosubmission', array('assesswosubmission', $label, 'workshop'));
+        $mform->setAdvanced('assesswosubmission');
+
+        $label = get_string('examplesmode', 'workshop');
+        $options = workshop_get_example_modes();
+        $mform->addElement('select', 'examplesmode', $label, $options);
+        $mform->setDefault('examplesmode', $workshopconfig->examplesmode);
+        $mform->setHelpButton('examplesmode', array('examplesmode', $label, 'workshop'));
+        $mform->setAdvanced('examplesmode');
+
+        $label = get_string('teacherweight', 'workshop');
+        $options = workshop_get_teacher_weights();
+        $mform->addElement('select', 'teacherweight', $label, $options);
+        $mform->setDefault('teacherweight', 1);
+        $mform->setHelpButton('teacherweight', array('teacherweight', $label, 'workshop'));
+        $mform->setAdvanced('teacherweight');
+
+        $label = get_string('agreeassessments', 'workshop');
+        $text = get_string('agreeassessmentsdesc', 'workshop');
+        $mform->addElement('advcheckbox', 'agreeassessments', $label, $text);
+        $mform->setHelpButton('agreeassessments', array('agreeassessments', $label, 'workshop'));
+        $mform->setAdvanced('agreeassessments');
+
+        $label = get_string('hidegrades', 'workshop');
+        $text = get_string('hidegradesdesc', 'workshop');
+        $mform->addElement('advcheckbox', 'hidegrades', $label, $text);
+        $mform->setHelpButton('hidegrades', array('hidegrades', $label, 'workshop'));
+        $mform->setAdvanced('hidegrades');
+
+        $label = get_string('assessmentcomps', 'workshop');
+        $levels = array();
+        foreach (workshop_get_comparison_levels() as $code => $level) {
+            $levels[$code] = $level->name;
+        }
+        $mform->addElement('select', 'assessmentcomps', $label, $levels);
+        $mform->setDefault('assessmentcomps', $workshopconfig->assessmentcomps);
+        $mform->setHelpButton('assessmentcomps', array('assessmentcomps', $label, 'workshop'));
+        $mform->setAdvanced('assessmentcomps');
+
+/// Access control
+        $mform->addElement('header', 'accesscontrol', get_string('accesscontrol', 'workshop'));
+
+        $label = get_string('submissionstart', 'workshop');
+        $mform->addElement('date_selector', 'submissionstart', $label, array('optional' => true));
+        $mform->setHelpButton('submissionstart', array('submissionstart', $label, 'workshop'));
+        $mform->setAdvanced('submissionstart');
+
+        $label = get_string('submissionend', 'workshop');
+        $mform->addElement('date_selector', 'submissionend', $label, array('optional' => true));
+        $mform->setHelpButton('submissionend', array('submissionend', $label, 'workshop'));
+        $mform->setAdvanced('submissionend');
+
+        $label = get_string('assessmentstart', 'workshop');
+        $mform->addElement('date_selector', 'assessmentstart', $label, array('optional' => true));
+        $mform->setHelpButton('assessmentstart', array('assessmentstart', $label, 'workshop'));
+        $mform->setAdvanced('assessmentstart');
+
+        $label = get_string('assessmentend', 'workshop');
+        $mform->addElement('date_selector', 'assessmentend', $label, array('optional' => true));
+        $mform->setHelpButton('assessmentend', array('assessmentend', $label, 'workshop'));
+        $mform->setAdvanced('assessmentend');
+
+        $label = get_string('releasegrades', 'workshop');
+        $mform->addElement('date_selector', 'releasegrades', $label, array('optional' => true));
+        $mform->setHelpButton('releasegrades', array('releasegrades', $label, 'workshop'));
+        $mform->setAdvanced('releasegrades');
+
+        $label = get_string('requirepassword', 'workshop');
+        $mform->addElement('passwordunmask', 'password', $label);
+        $mform->setType('quizpassword', PARAM_TEXT);
+        $mform->setHelpButton('password', array('requirepassword', $label, 'workshop'));
+        $mform->setAdvanced('password');
+
+
+/// Common module settinga, Restrict availability, Activity completion etc. ----
+        // add standard elements, common to all modules
+        $this->standard_coursemodule_elements();
+
+/// Save and close, Save, Cancel -----------------------------------------------
+        // add standard buttons, common to all modules
+        $this->add_action_buttons();
+
+    }
+}
diff --git a/mod/workshop/settings.php b/mod/workshop/settings.php
new file mode 100644 (file)
index 0000000..e6672b3
--- /dev/null
@@ -0,0 +1,49 @@
+<?php  //$Id$
+
+require_once($CFG->dirroot.'/mod/workshop/lib.php');
+
+$grades = workshop_get_maxgrades();
+
+$settings->add(new admin_setting_configselect('workshop/grade', get_string('gradeforsubmission', 'workshop'),
+                    get_string('configgrade', 'workshop'), 80, $grades));
+
+$settings->add(new admin_setting_configselect('workshop/gradinggrade', get_string('gradeforassessment', 'workshop'),
+                    get_string('configgradinggrade', 'workshop'), 20, $grades));
+
+$options = get_max_upload_sizes($CFG->maxbytes);
+$options[0] = get_string('courseuploadlimit');
+$settings->add(new admin_setting_configselect('workshop/maxbytes', get_string('maxbytes', 'workshop'),
+                    get_string('configmaxbytes', 'workshop'), 0, $options));
+
+$settings->add(new admin_setting_configselect('workshop/strategy', get_string('strategy', 'workshop'),
+                    get_string('configstrategy', 'workshop'), 'accumulative', workshop_get_strategies()));
+
+$options = workshop_get_anonymity_modes();
+$settings->add(new admin_setting_configselect('workshop/anonymity', get_string('anonymity', 'workshop'),
+                    get_string('configanonymity', 'workshop'), WORKSHOP_ANONYMITY_NONE, $options));
+
+$options = workshop_get_numbers_of_assessments();
+$settings->add(new admin_setting_configselect('workshop/nsassessments', get_string('nsassessments', 'workshop'),
+                    get_string('confignsassessments', 'workshop'), 3, $options));
+
+$options = workshop_get_numbers_of_assessments();
+$options[0] = get_string('assessallexamples', 'workshop');
+$settings->add(new admin_setting_configselect('workshop/nexassessments', get_string('nexassessments', 'workshop'),
+                    get_string('confignexassessments', 'workshop'), 0, $options));
+
+$options = workshop_get_example_modes();
+$settings->add(new admin_setting_configselect('workshop/examplesmode', get_string('examplesmode', 'workshop'),
+                    get_string('configexamplesmode', 'workshop'), WORKSHOP_EXAMPLES_VOLUNTARY, $options));
+
+$levels = array();
+foreach (workshop_get_comparison_levels() as $code => $level) {
+    $levels[$code] = $level->name;
+}
+$settings->add(new admin_setting_configselect('workshop/assessmentcomps', get_string('assessmentcomps', 'workshop'),
+                    get_string('configassessmentcomps', 'workshop'), WORKSHOP_COMPARISON_NORMAL, $levels));
+
+/*
+$settings->add(new admin_setting_configcheckbox('assignment_showrecentsubmissions', get_string('showrecentsubmissions', 'assignment'),
+                   get_string('configshowrecentsubmissions', 'assignment'), 1));
+*/
+?>
diff --git a/mod/workshop/simpletest/testlib.php b/mod/workshop/simpletest/testlib.php
new file mode 100644 (file)
index 0000000..93ef989
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+// This file is part of Moodle - http://moodle.org/  
+// 
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+/**
+ * Unit tests for (some of) mod/workshop/lib.php
+ *
+ * @package   mod-workshop
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+if (!defined('MOODLE_INTERNAL')) {
+    die('Direct access to this script is forbidden.'); //  It must be included from a Moodle page
+}
+// Make sure the code being tested is accessible.
+require_once($CFG->dirroot . '/mod/workshop/lib.php'); // Include the code to test
+/** 
+ * Test cases for the functions in lib.php
+ */
+class workshop_lib_test extends UnitTestCase {
+
+    function test_workshop_get_maxgrades() {
+        $this->assertIsA(workshop_get_maxgrades(), 'Array');
+        $this->assertTrue(workshop_get_maxgrades());
+        $values_are_integers = True;
+        foreach(workshop_get_maxgrades() as $key => $val) {
+            if (!is_int($val)) {
+                $values_are_integers = false;
+                break;
+            }
+        }
+        $this->assertTrue($values_are_integers, 'Array values must be integers');
+    }
+}
diff --git a/mod/workshop/version.php b/mod/workshop/version.php
new file mode 100644 (file)
index 0000000..d3c11cc
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+// This file is part of Moodle - http://moodle.org/  
+// 
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ * Defines the version of workshop
+ *
+ * This code fragment is called by moodle_needs_upgrading() and 
+ * /admin/index.php
+ *
+ * @package   mod-workshop
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$module->version  = 2009052100;
+$module->requires = 2009050619;  // Requires this Moodle version
+$module->cron     = 60;
diff --git a/mod/workshop/view.php b/mod/workshop/view.php
new file mode 100644 (file)
index 0000000..7f7c797
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+// This file is part of Moodle - http://moodle.org/  
+// 
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+/**
+ * Prints a particular instance of workshop
+ *
+ * You can have a rather longer description of the file as well,
+ * if you like, and it can span multiple lines.
+ *
+ * @package   mod-workshop
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/// (Replace workshop with the name of your module and remove this line)
+
+require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
+require_once(dirname(__FILE__).'/lib.php');
+
+$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
+$a  = optional_param('a', 0, PARAM_INT);  // workshop instance ID
+
+if ($id) {
+    if (! $cm = get_coursemodule_from_id('workshop', $id)) {
+        error('Course Module ID was incorrect');
+    }
+
+    if (! $course = $DB->get_record('course', array('id' => $cm->course))) {
+        error('Course is misconfigured');
+    }
+
+    if (! $workshop = $DB->get_record('workshop', array('id' => $cm->instance))) {
+        error('Course module is incorrect');
+    }
+
+} else if ($a) {
+    if (! $workshop = $DB->get_record('workshop', array('id' => $a))) {
+        error('Course module is incorrect');
+    }
+    if (! $course = $DB->get_record('course', array('id' => $workshop->course))) {
+        error('Course is misconfigured');
+    }
+    if (! $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id)) {
+        error('Course Module ID was incorrect');
+    }
+
+} else {
+    error('You must specify a course_module ID or an instance ID');
+}
+
+require_login($course, true, $cm);
+
+add_to_log($course->id, "workshop", "view", "view.php?id=$cm->id", "$workshop->id");
+
+/// Print the page header
+$strworkshops = get_string('modulenameplural', 'workshop');
+$strworkshop  = get_string('modulename', 'workshop');
+
+$navlinks = array();
+$navlinks[] = array('name' => $strworkshops, 'link' => "index.php?id=$course->id", 'type' => 'activity');
+$navlinks[] = array('name' => format_string($workshop->name), 'link' => '', 'type' => 'activityinstance');
+
+$navigation = build_navigation($navlinks);
+
+print_header_simple(format_string($workshop->name), '', $navigation, '', '', true,
+              update_module_button($cm->id, $course->id, $strworkshop), navmenu($course, $cm));
+
+/// Print the main part of the page
+
+echo "<a href=\"editgradingform.php?id={$cm->id}\">Edit grading form</a>";
+
+/// Finish the page
+print_footer($course);