mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
MDL-37602 Put the overall feedback fields to the bottom of the assessment form
The assessment form can be displayed as editable or read-only (frozen). Neither the editor element nor the filemanager element support displaying frozen content themselves so we need to pre-format and inject static texts. The list of attachments should be ideally generated by the renderer and probably improved a bit - just quick and dirty solution must be enough for now though (2.5 coding freeze is just behind the corner...). AMOS BEGIN CPY [submissionattachment,mod_workshop],[feedbackauthorattachment,mod_workshop] AMOS END
This commit is contained in:
parent
3ac58f227a
commit
c6a793d5a2
4 changed files with 124 additions and 6 deletions
|
@ -37,6 +37,7 @@
|
|||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once(dirname(__FILE__).'/locallib.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
$asid = required_param('asid', PARAM_INT); // assessment id
|
||||
$assessment = $DB->get_record('workshop_assessments', array('id' => $asid), '*', MUST_EXIST);
|
||||
|
@ -135,9 +136,69 @@ if (is_null($assessment->grade) and !$assessmenteditable) {
|
|||
$pending = array();
|
||||
}
|
||||
// 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
|
||||
$feedbackauthoreditoropts = array(
|
||||
'maxbytes' => $workshop->overallfeedbackmaxbytes,
|
||||
'maxfiles' => $workshop->overallfeedbackfiles,
|
||||
'changeformat' => 1,
|
||||
'context' => $workshop->context,
|
||||
);
|
||||
$feedbackauthorattachmentopts = array(
|
||||
'maxbytes' => $workshop->overallfeedbackmaxbytes,
|
||||
'maxfiles' => $workshop->overallfeedbackfiles,
|
||||
'return_types' => FILE_INTERNAL,
|
||||
);
|
||||
$mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, $assessmenteditable, array(
|
||||
'editableweight' => $cansetassessmentweight,
|
||||
'pending' => !empty($pending),
|
||||
'feedbackauthoreditoropts' => $feedbackauthoreditoropts,
|
||||
'feedbackauthorattachmentopts' => $feedbackauthorattachmentopts,
|
||||
));
|
||||
|
||||
// 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 (!empty($workshop->overallfeedbackmode)) {
|
||||
if ($assessmenteditable) {
|
||||
$currentdata = file_prepare_standard_editor($currentdata, 'feedbackauthor', $feedbackauthoreditoropts,
|
||||
$workshop->context, 'mod_workshop', 'overallfeedback_content', $assessment->id);
|
||||
if (!empty($workshop->overallfeedbackfiles)) {
|
||||
$currentdata = file_prepare_standard_filemanager($currentdata, 'feedbackauthorattachment',
|
||||
$feedbackauthorattachmentopts, $workshop->context, 'mod_workshop', 'overallfeedback_attachment',
|
||||
$assessment->id);
|
||||
}
|
||||
|
||||
} else {
|
||||
$currentdata->feedbackauthor = file_rewrite_pluginfile_urls($currentdata->feedbackauthor, 'pluginfile.php',
|
||||
$workshop->context->id, 'mod_workshop', 'overallfeedback_content', $assessment->id);
|
||||
$currentdata->feedbackauthor = format_text($currentdata->feedbackauthor, $currentdata->feedbackauthorformat,
|
||||
array('overflowdiv' => true, 'context' => $workshop->context));
|
||||
$currentdata->feedbackauthorattachment = '-';
|
||||
if (!empty($assessment->feedbackauthorattachment)) {
|
||||
$fs = get_file_storage();
|
||||
$files = $fs->get_area_files($workshop->context->id, 'mod_workshop', 'overallfeedback_attachment', $assessment->id);
|
||||
$list = '';
|
||||
foreach ($files as $file) {
|
||||
if ($file->is_directory()) {
|
||||
continue;
|
||||
}
|
||||
$filepath = $file->get_filepath();
|
||||
$filename = $file->get_filename();
|
||||
$fileurl = moodle_url::make_pluginfile_url($workshop->context->id, 'mod_workshop', 'overallfeedback_attachment',
|
||||
$assessment->id, $filepath, $filename, true);
|
||||
$link = html_writer::link($fileurl, s($filename));
|
||||
$list .= html_writer::tag('li', $link);
|
||||
}
|
||||
$list = html_writer::tag('ul', $list, array('class' => 'overallfeedback_attachments'));
|
||||
$currentdata->feedbackauthorattachment = $list;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$mform->set_data($currentdata);
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($workshop->view_url());
|
||||
} elseif ($assessmenteditable and ($data = $mform->get_data())) {
|
||||
|
@ -146,10 +207,34 @@ if (is_null($assessment->grade) and !$assessmenteditable) {
|
|||
} 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);
|
||||
if (isset($data->weight) and $cansetassessmentweight) {
|
||||
$DB->set_field('workshop_assessments', 'weight', $data->weight, array('id' => $assessment->id));
|
||||
|
||||
// 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', $feedbackauthoreditoropts,
|
||||
$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',
|
||||
$feedbackauthorattachmentopts, $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) {
|
||||
$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)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue