Example #1
0
                } else {
                    redirect($PAGE->url);
                    // This should never happen but just in case...
                }
            } else {
                // either it is not possible to calculate the $rawgrade
                // or the reviewer has chosen "Save and continue"
                redirect($PAGE->url);
            }
        }
    }
}
// load the form to override gradinggrade and/or set weight and process the submitted data eventually
if ($canoverridegrades or $cansetassessmentweight) {
    $options = array('editable' => true, 'editableweight' => $cansetassessmentweight, 'overridablegradinggrade' => $canoverridegrades);
    $feedbackform = $teamwork->get_feedbackreviewer_form($PAGE->url, $assessment, $options);
    if ($data = $feedbackform->get_data()) {
        $data = file_postupdate_standard_editor($data, 'feedbackreviewer', array(), $teamwork->context);
        $record = new stdclass();
        $record->id = $assessment->id;
        if ($cansetassessmentweight) {
            $record->weight = $data->weight;
        }
        if ($canoverridegrades) {
            $record->gradinggradeover = $teamwork->raw_grade_value($data->gradinggradeover, $teamwork->gradinggrade);
            $record->gradinggradeoverby = $USER->id;
            $record->feedbackreviewer = $data->feedbackreviewer;
            $record->feedbackreviewerformat = $data->feedbackreviewerformat;
        }
        $DB->update_record('teamwork_assessments', $record);
        redirect($teamwork->view_url());