Skip to content
Permalink
Browse files

Merge branch 'MDL-37602-workshop-overall-feedback' of git://github.co…

…m/mudrd8mz/moodle
  • Loading branch information...
danpoltawski committed Apr 3, 2013
2 parents 178652e + e36942b commit f27be4c1aa36e7763a41ba09869f315f64da4910
@@ -137,7 +137,24 @@
// load the assessment form and process the submitted data eventually
$mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, $assessmenteditable,
array('editableweight' => $cansetassessmentweight, 'pending' => !empty($pending)));
$mform->set_data(array('weight' => $assessment->weight)); // other values are set by subplugins
// Set data managed by the workshop core, subplugins set their own data themselves.
$currentdata = (object)array(
'weight' => $assessment->weight,
'feedbackauthor' => $assessment->feedbackauthor,
'feedbackauthorformat' => $assessment->feedbackauthorformat,
);
if ($assessmenteditable and $workshop->overallfeedbackmode) {
$currentdata = file_prepare_standard_editor($currentdata, 'feedbackauthor', $workshop->overall_feedback_content_options(),
$workshop->context, 'mod_workshop', 'overallfeedback_content', $assessment->id);
if ($workshop->overallfeedbackfiles) {
$currentdata = file_prepare_standard_filemanager($currentdata, 'feedbackauthorattachment',
$workshop->overall_feedback_attachment_options(), $workshop->context, 'mod_workshop', 'overallfeedback_attachment',
$assessment->id);
}
}
$mform->set_data($currentdata);
if ($mform->is_cancelled()) {
redirect($workshop->view_url());
} elseif ($assessmenteditable and ($data = $mform->get_data())) {
@@ -146,10 +163,34 @@
} else {
$workshop->log('update assessment', $workshop->assess_url($assessment->id), $assessment->submissionid);
}
// Let the grading strategy subplugin save its data.
$rawgrade = $strategy->save_assessment($assessment, $data);
// Store the data managed by the workshop core.
$coredata = (object)array('id' => $assessment->id);
if (isset($data->feedbackauthor_editor)) {
$coredata->feedbackauthor_editor = $data->feedbackauthor_editor;
$coredata = file_postupdate_standard_editor($coredata, 'feedbackauthor', $workshop->overall_feedback_content_options(),
$workshop->context, 'mod_workshop', 'overallfeedback_content', $assessment->id);
unset($coredata->feedbackauthor_editor);
}
if (isset($data->feedbackauthorattachment_filemanager)) {
$coredata->feedbackauthorattachment_filemanager = $data->feedbackauthorattachment_filemanager;
$coredata = file_postupdate_standard_filemanager($coredata, 'feedbackauthorattachment',
$workshop->overall_feedback_attachment_options(), $workshop->context, 'mod_workshop', 'overallfeedback_attachment',
$assessment->id);
unset($coredata->feedbackauthorattachment_filemanager);
if (empty($coredata->feedbackauthorattachment)) {
$coredata->feedbackauthorattachment = 0;
}
}
if (isset($data->weight) and $cansetassessmentweight) {
$DB->set_field('workshop_assessments', 'weight', $data->weight, array('id' => $assessment->id));
$coredata->weight = $data->weight;
}
$DB->update_record('workshop_assessments', $coredata);
// And finally redirect the user's browser.
if (!is_null($rawgrade) and isset($data->saveandclose)) {
redirect($workshop->view_url());
} else if (!is_null($rawgrade) and isset($data->saveandshownext)) {
@@ -56,7 +56,8 @@ protected function define_structure() {
'strategy', 'evaluation', 'gradedecimals', 'nattachments',
'latesubmissions', 'maxbytes', 'examplesmode', 'submissionstart',
'submissionend', 'assessmentstart', 'assessmentend',
'conclusion', 'conclusionformat'));
'conclusion', 'conclusionformat', 'overallfeedbackmode',
'overallfeedbackfiles', 'overallfeedbackmaxbytes'));
// assessment forms definition
$this->add_subplugin_structure('workshopform', $workshop, true);
@@ -72,7 +73,8 @@ protected function define_structure() {
// reference assessment of the example submission
$referenceassessment = new backup_nested_element('referenceassessment', array('id'), array(
'timecreated', 'timemodified', 'grade'));
'timecreated', 'timemodified', 'grade', 'feedbackauthor', 'feedbackauthorformat',
'feedbackauthorattachment'));
// dimension grades for the reference assessment (that is how the form is filled)
$this->add_subplugin_structure('workshopform', $referenceassessment, true);
@@ -86,8 +88,8 @@ protected function define_structure() {
$exampleassessment = new backup_nested_element('exampleassessment', array('id'), array(
'reviewerid', 'weight', 'timecreated', 'timemodified', 'grade',
'gradinggrade', 'gradinggradeover', 'gradinggradeoverby',
'feedbackauthor', 'feedbackauthorformat', 'feedbackreviewer',
'feedbackreviewerformat'));
'feedbackauthor', 'feedbackauthorformat', 'feedbackauthorattachment',
'feedbackreviewer', 'feedbackreviewerformat'));
// dimension grades for the assessment of example submission (that is assessment forms are filled)
$this->add_subplugin_structure('workshopform', $exampleassessment, true);
@@ -105,8 +107,8 @@ protected function define_structure() {
$assessment = new backup_nested_element('assessment', array('id'), array(
'reviewerid', 'weight', 'timecreated', 'timemodified', 'grade',
'gradinggrade', 'gradinggradeover', 'gradinggradeoverby',
'feedbackauthor', 'feedbackauthorformat', 'feedbackreviewer',
'feedbackreviewerformat'));
'feedbackauthor', 'feedbackauthorformat', 'feedbackauthorattachment',
'feedbackreviewer', 'feedbackreviewerformat'));
// dimension grades for the assessment (that is assessment forms are filled)
$this->add_subplugin_structure('workshopform', $assessment, true);
@@ -200,9 +202,18 @@ protected function define_structure() {
$examplesubmission->annotate_files('mod_workshop', 'submission_content', 'id');
$examplesubmission->annotate_files('mod_workshop', 'submission_attachment', 'id');
$referenceassessment->annotate_files('mod_workshop', 'overallfeedback_content', 'id');
$referenceassessment->annotate_files('mod_workshop', 'overallfeedback_attachment', 'id');
$exampleassessment->annotate_files('mod_workshop', 'overallfeedback_content', 'id');
$exampleassessment->annotate_files('mod_workshop', 'overallfeedback_attachment', 'id');
$submission->annotate_files('mod_workshop', 'submission_content', 'id');
$submission->annotate_files('mod_workshop', 'submission_attachment', 'id');
$assessment->annotate_files('mod_workshop', 'overallfeedback_content', 'id');
$assessment->annotate_files('mod_workshop', 'overallfeedback_attachment', 'id');
// return the root element (workshop), wrapped into standard activity structure
return $this->prepare_activity_structure($workshop);
}
@@ -145,7 +145,7 @@ protected function process_workshop_referenceassessment($data) {
$data->timemodified = $this->apply_date_offset($data->timemodified);
$newitemid = $DB->insert_record('workshop_assessments', $data);
$this->set_mapping('workshop_referenceassessment', $oldid, $newitemid);
$this->set_mapping('workshop_referenceassessment', $oldid, $newitemid, true); // Mapping with files
}
protected function process_workshop_exampleassessment($data) {
@@ -160,7 +160,7 @@ protected function process_workshop_exampleassessment($data) {
$data->timemodified = $this->apply_date_offset($data->timemodified);
$newitemid = $DB->insert_record('workshop_assessments', $data);
$this->set_mapping('workshop_exampleassessment', $oldid, $newitemid);
$this->set_mapping('workshop_exampleassessment', $oldid, $newitemid, true); // Mapping with files
}
protected function process_workshop_submission($data) {
@@ -191,7 +191,7 @@ protected function process_workshop_assessment($data) {
$data->timemodified = $this->apply_date_offset($data->timemodified);
$newitemid = $DB->insert_record('workshop_assessments', $data);
$this->set_mapping('workshop_assessment', $oldid, $newitemid);
$this->set_mapping('workshop_assessment', $oldid, $newitemid, true); // Mapping with files
}
protected function process_workshop_aggregation($data) {
@@ -218,8 +218,20 @@ protected function after_execute() {
$this->add_related_files('mod_workshop', 'submission_content', 'workshop_examplesubmission');
$this->add_related_files('mod_workshop', 'submission_attachment', 'workshop_examplesubmission');
// Add reference assessment related files, matching by 'workshop_referenceassessment' itemname
$this->add_related_files('mod_workshop', 'overallfeedback_content', 'workshop_referenceassessment');
$this->add_related_files('mod_workshop', 'overallfeedback_attachment', 'workshop_referenceassessment');
// Add example assessment related files, matching by 'workshop_exampleassessment' itemname
$this->add_related_files('mod_workshop', 'overallfeedback_content', 'workshop_exampleassessment');
$this->add_related_files('mod_workshop', 'overallfeedback_attachment', 'workshop_exampleassessment');
// Add submission related files, matching by 'workshop_submission' itemname
$this->add_related_files('mod_workshop', 'submission_content', 'workshop_submission');
$this->add_related_files('mod_workshop', 'submission_attachment', 'workshop_submission');
// Add assessment related files, matching by 'workshop_assessment' itemname
$this->add_related_files('mod_workshop', 'overallfeedback_content', 'workshop_assessment');
$this->add_related_files('mod_workshop', 'overallfeedback_attachment', 'workshop_assessment');
}
}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/workshop/db" VERSION="20121024" COMMENT="XMLDB file for Moodle mod/workshop"
<XMLDB PATH="mod/workshop/db" VERSION="20130325" COMMENT="XMLDB file for Moodle mod/workshop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
@@ -36,6 +36,9 @@
<FIELD NAME="phaseswitchassessment" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Automatically switch to the assessment phase after the submissions deadline"/>
<FIELD NAME="conclusion" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="A text to be displayed at the end of the workshop."/>
<FIELD NAME="conclusionformat" TYPE="int" LENGTH="3" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="The format of the conclusion field content."/>
<FIELD NAME="overallfeedbackmode" TYPE="int" LENGTH="3" NOTNULL="false" DEFAULT="1" SEQUENCE="false" COMMENT="Mode of the overall feedback support."/>
<FIELD NAME="overallfeedbackfiles" TYPE="int" LENGTH="3" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="Number of allowed attachments to the overall feedback."/>
<FIELD NAME="overallfeedbackmaxbytes" TYPE="int" LENGTH="10" NOTNULL="false" DEFAULT="100000" SEQUENCE="false" COMMENT="Maximum size of one file attached to the overall feedback."/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
@@ -85,6 +88,7 @@
<FIELD NAME="gradinggradeoverby" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The id of the user who has overridden the grade for submission."/>
<FIELD NAME="feedbackauthor" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="The comment/feedback from the reviewer for the author."/>
<FIELD NAME="feedbackauthorformat" TYPE="int" LENGTH="3" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="feedbackauthorattachment" TYPE="int" LENGTH="3" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="Are there some files attached to the feedbackauthor field? Sets to 1 by file_postupdate_standard_filemanager()."/>
<FIELD NAME="feedbackreviewer" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="The comment/feedback from the teacher for the reviewer. For example the reason why the grade for assessment was overridden"/>
<FIELD NAME="feedbackreviewerformat" TYPE="int" LENGTH="3" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
</FIELDS>
@@ -112,6 +112,43 @@ function xmldb_workshop_upgrade($oldversion) {
// Moodle v2.4.0 release upgrade line
// Put any upgrade step following this
/**
* Add overall feedback related fields into the workshop table.
*/
if ($oldversion < 2013032500) {
$table = new xmldb_table('workshop');
$field = new xmldb_field('overallfeedbackmode', XMLDB_TYPE_INTEGER, '3', null, null, null, '1', 'conclusionformat');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('overallfeedbackfiles', XMLDB_TYPE_INTEGER, '3', null, null, null, '0', 'overallfeedbackmode');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('overallfeedbackmaxbytes', XMLDB_TYPE_INTEGER, '10', null, null, null, '100000', 'overallfeedbackfiles');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2013032500, 'workshop');
}
/**
* Add feedbackauthorattachment field into the workshop_assessments table.
*/
if ($oldversion < 2013032501) {
$table = new xmldb_table('workshop_assessments');
$field = new xmldb_field('feedbackauthorattachment', XMLDB_TYPE_INTEGER, '3', null, null, null, '0', 'feedbackauthorformat');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2013032501, 'workshop');
}
return true;
}
@@ -67,6 +67,23 @@
// load the assessment form and process the submitted data eventually
$mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, $assessmenteditable);
// Set data managed by the workshop core, subplugins set their own data themselves.
$currentdata = (object)array(
'feedbackauthor' => $assessment->feedbackauthor,
'feedbackauthorformat' => $assessment->feedbackauthorformat,
);
if ($assessmenteditable and $workshop->overallfeedbackmode) {
$currentdata = file_prepare_standard_editor($currentdata, 'feedbackauthor', $workshop->overall_feedback_content_options(),
$workshop->context, 'mod_workshop', 'overallfeedback_content', $assessment->id);
if ($workshop->overallfeedbackfiles) {
$currentdata = file_prepare_standard_filemanager($currentdata, 'feedbackauthorattachment',
$workshop->overall_feedback_attachment_options(), $workshop->context, 'mod_workshop', 'overallfeedback_attachment',
$assessment->id);
}
}
$mform->set_data($currentdata);
if ($mform->is_cancelled()) {
redirect($workshop->view_url());
} elseif ($assessmenteditable and ($data = $mform->get_data())) {
@@ -83,11 +100,34 @@
$workshop->log('update example assessment', $workshop->exassess_url($assessment->id), $assessment->submissionid);
}
}
// Let the grading strategy subplugin save its data.
$rawgrade = $strategy->save_assessment($assessment, $data);
// Store the data managed by the workshop core.
$coredata = (object)array('id' => $assessment->id);
if (isset($data->feedbackauthor_editor)) {
$coredata->feedbackauthor_editor = $data->feedbackauthor_editor;
$coredata = file_postupdate_standard_editor($coredata, 'feedbackauthor', $workshop->overall_feedback_content_options(),
$workshop->context, 'mod_workshop', 'overallfeedback_content', $assessment->id);
unset($coredata->feedbackauthor_editor);
}
if (isset($data->feedbackauthorattachment_filemanager)) {
$coredata->feedbackauthorattachment_filemanager = $data->feedbackauthorattachment_filemanager;
$coredata = file_postupdate_standard_filemanager($coredata, 'feedbackauthorattachment',
$workshop->overall_feedback_attachment_options(), $workshop->context, 'mod_workshop', 'overallfeedback_attachment',
$assessment->id);
unset($coredata->feedbackauthorattachment_filemanager);
if (empty($coredata->feedbackauthorattachment)) {
$coredata->feedbackauthorattachment = 0;
}
}
if ($canmanage) {
// remember the last one who edited the reference assessment
$DB->set_field('workshop_assessments', 'reviewerid', $USER->id, array('id' => $assessment->id));
// Remember the last one who edited the reference assessment.
$coredata->reviewerid = $USER->id;
}
$DB->update_record('workshop_assessments', $coredata);
if (!is_null($rawgrade) and isset($data->saveandclose)) {
if ($canmanage) {
redirect($workshop->view_url());

0 comments on commit f27be4c

Please sign in to comment.
You can’t perform that action at this time.