--- /dev/null
+<?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/>.
+
+/**
+ * A form used by teachers to give feedback to authors on their submission
+ *
+ * @package mod-workshop
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+require_once($CFG->dirroot . '/lib/formslib.php');
+
+class workshop_feedbackauthor_form extends moodleform {
+
+ function definition() {
+ $mform = $this->_form;
+
+ $current = $this->_customdata['current'];
+ $workshop = $this->_customdata['workshop'];
+ $opts = $this->_customdata['feedbackopts'];
+
+ $mform->addElement('header', 'feedbackauthorform', get_string('feedbackauthor', 'workshop'));
+
+ $mform->addElement('static', 'grade', get_string('gradecalculated', 'workshop'));
+
+ $grades = array('' => get_string('notoverridden', 'workshop'));
+ for ($i = (int)$workshop->grade; $i >= 0; $i--) {
+ $grades[$i] = $i;
+ }
+ $mform->addElement('select', 'gradeover', get_string('gradeover', 'workshop'), $grades);
+
+ $mform->addElement('editor', 'feedbackauthor_editor', get_string('feedbackauthor', 'workshop'), null, $opts);
+ $mform->setType('feedbackauthor_editor', PARAM_RAW);
+
+ $mform->addElement('hidden', 'submissionid');
+
+ $mform->addElement('submit', 'save', get_string('saveandclose', 'workshop'));
+
+ $this->set_data($current);
+ }
+
+ function validation($data, $files) {
+ global $CFG, $USER, $DB;
+
+ $errors = parent::validation($data, $files);
+ return $errors;
+ }
+}
$string['examplesbeforesubmission'] = 'Examples must be assessed before own submission';
$string['examplesmode'] = 'Mode of examples assessment';
$string['examplesvoluntary'] = 'Assessment of example submission is voluntary';
+$string['feedbackauthor'] = 'Feedback for the author';
$string['feedbackreviewer'] = 'Feedback for the reviewer';
$string['formataggregatedgrade'] = '$a->grade';
$string['formataggregatedgradeover'] = '<del>$a->grade</del><br /><ins>$a->over</ins>';
$string['formatpeergrade'] = '$a->grade ($a->gradinggrade)';
$string['formatpeergradeover'] = '$a->grade (<del>$a->gradinggrade</del> / <ins>$a->gradinggradeover</ins>)';
-$string['givengradestatus'] = 'Status: $a';
$string['givengrades'] = 'Given grades';
+$string['givengradestatus'] = 'Status: $a';
+$string['gradecalculated'] = 'Calculated grade for submission';
$string['gradedecimals'] = 'Decimal places in grades';
$string['gradegivento'] = ' > ';
+$string['gradeover'] = 'Override grade for submission';
$string['gradereceivedfrom'] = ' < ';
$string['gradinggradecalculated'] = 'Calculated grade for assessment';
$string['gradinggrade'] = 'Grade for assessment';
*/
public function real_grade_value($value, $max) {
$localized = true;
- if (is_null($value)) {
+ if (is_null($value) or $value === '') {
return null;
} elseif ($max == 0) {
return 0;
* @return float suitable to be stored as numeric(10,5)
*/
public function raw_grade_value($value, $max) {
- if (is_null($value)) {
+ if (is_null($value) or $value === '') {
return null;
}
if ($max == 0 or $value < 0) {
* @return string
*/
public function format_total_grade($raw) {
- if (is_null($raw)) {
+ if (is_null($raw) or $raw === '') {
return null;
}
return format_float($raw, $this->gradedecimals, true);
$current = new stdClass();
$current->submissionid = $submission->id;
- $current->grade = $this->real_grade($assessment->grade);
- $current->gradeover = $this->real_grade($assessment->gradeover);
- $current->feedbackauthor = $assessment->feedbackreviewer;
- $current->feedbackauthorformat = $assessment->feedbackreviewerformat;
+ $current->grade = $this->real_grade($submission->grade);
+ $current->gradeover = $this->real_grade($submission->gradeover);
+ $current->feedbackauthor = $submission->feedbackauthor;
+ $current->feedbackauthorformat = $submission->feedbackauthorformat;
if (is_null($current->grade)) {
$current->grade = get_string('nullgrade', 'workshop');
}
$formdata->example = 0; // todo add examples support
$formdata->authorid = $USER->id;
$formdata->timecreated = $timenow;
+ $formdata->feedbackauthorformat = FORMAT_HTML; // todo better default
}
$formdata->timemodified = $timenow;
$formdata->title = trim($formdata->title);
}
}
+// load the form to override gradinggrade and process the submitted data eventually
+if (!$edit and $canoverride) {
+ $feedbackform = $workshop->get_feedbackauthor_form($PAGE->url, $submission);
+ if ($data = $feedbackform->get_data()) {
+ $data = file_postupdate_standard_editor($data, 'feedbackauthor', array(), $workshop->context);
+ $record = new stdClass();
+ $record->id = $submission->id;
+ $record->gradeover = $workshop->raw_grade_value($data->gradeover, $workshop->grade);
+ $record->gradeoverby = $USER->id;
+ $record->feedbackauthor = $data->feedbackauthor;
+ $record->feedbackauthorformat = $data->feedbackauthorformat;
+ $DB->update_record('workshop_submissions', $record);
+ redirect($workshop->view_url());
+ }
+}
+
$PAGE->set_title($workshop->name);
$PAGE->set_heading($course->fullname);
if ($edit) {
$strategy = $workshop->grading_strategy_instance();
}
+if (!$edit and $canoverride) {
+ // display a form to override the submission grade
+ $feedbackform->display();
+}
+
echo $OUTPUT->footer();