Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-35421 Make the new conclusion field editable via mod_form

  • Loading branch information...
commit 5a49f825bd5e9ad703d7b6a53a7e483d99fd41eb 1 parent d898206
David Mudrák mudrd8mz authored
4 mod/workshop/lang/en/workshop.php
@@ -35,6 +35,7 @@
35 35 $string['allocationconfigured'] = 'Allocation configured';
36 36 $string['allsubmissions'] = 'All submissions ({$a})';
37 37 $string['alreadygraded'] = 'Already graded';
  38 +$string['areaconclusion'] = 'Conclusion text';
38 39 $string['areainstructauthors'] = 'Instructions for submission';
39 40 $string['areainstructreviewers'] = 'Instructions for assessment';
40 41 $string['areasubmissionattachment'] = 'Submission attachments';
@@ -77,6 +78,8 @@
77 78 $string['clearassessments_help'] = 'The calculated grades for submission and grades for assessment will be reset. The information how the assessment forms are filled is still kept, but all the reviewers must open the assessment form again and re-save it to get the given grades calculated again.';
78 79 $string['clearassessmentsconfirm'] = 'Are you sure you want to clear all assessment grades? You will not be able to get the information back on your own, reviewers will have to re-assess the allocated submissions.';
79 80 $string['clearaggregatedgradesconfirm'] = 'Are you sure you want to clear the calculated grades for submissions and grades for assessment?';
  81 +$string['conclusion'] = 'Conclusion';
  82 +$string['conclusion_help'] = 'Conclusion is a text displayed to participants at the end of the activity. You may want to provide an overall feedback, summary or suggestions on what should be done next (e.g. writing a blog post reflecting the new experience).';
80 83 $string['configexamplesmode'] = 'Default mode of examples assessment in workshops';
81 84 $string['configgrade'] = 'Default maximum grade for submission in workshops';
82 85 $string['configgradedecimals'] = 'Default number of digits that should be shown after the decimal point when displaying grades.';
@@ -157,6 +160,7 @@
157 160 $string['latesubmissions_help'] = 'If enabled, an author may submit their work after the submissions deadline or during the assessment phase. Late submissions cannot be edited though.';
158 161 $string['latesubmissionsallowed'] = 'Late submissions are allowed';
159 162 $string['maxbytes'] = 'Maximum file size';
  163 +$string['miscellaneoussettings'] = 'Miscellaneous settings';
160 164 $string['modulename'] = 'Workshop';
161 165 $string['modulename_help'] = 'The workshop activity module enables the collection, review and peer assessment of students\' work.
162 166
38 mod/workshop/lib.php
@@ -104,6 +104,12 @@ function workshop_add_instance(stdclass $workshop) {
104 104 $workshop->instructreviewersformat = $workshop->instructreviewerseditor['format'];
105 105 }
106 106
  107 + if ($draftitemid = $workshop->conclusioneditor['itemid']) {
  108 + $workshop->conclusion = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'conclusion',
  109 + 0, workshop::instruction_editors_options($context), $workshop->conclusioneditor['text']);
  110 + $workshop->conclusionformat = $workshop->conclusioneditor['format'];
  111 + }
  112 +
107 113 // re-save the record with the replaced URLs in editor fields
108 114 $DB->update_record('workshop', $workshop);
109 115
@@ -137,8 +143,7 @@ function workshop_update_instance(stdclass $workshop) {
137 143 $workshop->latesubmissions = (int)!empty($workshop->latesubmissions);
138 144 $workshop->phaseswitchassessment = (int)!empty($workshop->phaseswitchassessment);
139 145
140   - // todo - if the grading strategy is being changed, we must replace all aggregated peer grades with nulls
141   - // todo - if maximum grades are being changed, we should probably recalculate or invalidate them
  146 + // todo - if the grading strategy is being changed, we may want to replace all aggregated peer grades with nulls
142 147
143 148 $DB->update_record('workshop', $workshop);
144 149 $context = context_module::instance($workshop->coursemodule);
@@ -156,6 +161,12 @@ function workshop_update_instance(stdclass $workshop) {
156 161 $workshop->instructreviewersformat = $workshop->instructreviewerseditor['format'];
157 162 }
158 163
  164 + if ($draftitemid = $workshop->conclusioneditor['itemid']) {
  165 + $workshop->conclusion = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'conclusion',
  166 + 0, workshop::instruction_editors_options($context), $workshop->conclusioneditor['text']);
  167 + $workshop->conclusionformat = $workshop->conclusioneditor['format'];
  168 + }
  169 +
159 170 // re-save the record with the replaced URLs in editor fields
160 171 $DB->update_record('workshop', $workshop);
161 172
@@ -1172,6 +1183,7 @@ function workshop_get_file_areas($course, $cm, $context) {
1172 1183 $areas['instructreviewers'] = get_string('areainstructreviewers', 'workshop');
1173 1184 $areas['submission_content'] = get_string('areasubmissioncontent', 'workshop');
1174 1185 $areas['submission_attachment'] = get_string('areasubmissionattachment', 'workshop');
  1186 + $areas['conclusion'] = get_string('areaconclusion', 'workshop');
1175 1187
1176 1188 return $areas;
1177 1189 }
@@ -1182,7 +1194,7 @@ function workshop_get_file_areas($course, $cm, $context) {
1182 1194 * Apart from module intro (handled by pluginfile.php automatically), workshop files may be
1183 1195 * media inserted into submission content (like images) and submission attachments. For these two,
1184 1196 * the fileareas submission_content and submission_attachment are used.
1185   - * Besides that, areas instructauthors and instructreviewers contain the media
  1197 + * Besides that, areas instructauthors, instructreviewers and conclusion contain the media
1186 1198 * embedded using the mod_form.php.
1187 1199 *
1188 1200 * @package mod_workshop
@@ -1220,9 +1232,23 @@ function workshop_pluginfile($course, $cm, $context, $filearea, array $args, $fo
1220 1232
1221 1233 // finally send the file
1222 1234 send_stored_file($file, $lifetime, 0, $forcedownload, $options);
1223   - }
1224 1235
1225   - if ($filearea === 'instructreviewers') {
  1236 + } else if ($filearea === 'instructreviewers') {
  1237 + array_shift($args); // itemid is ignored here
  1238 + $relativepath = implode('/', $args);
  1239 + $fullpath = "/$context->id/mod_workshop/$filearea/0/$relativepath";
  1240 +
  1241 + $fs = get_file_storage();
  1242 + if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
  1243 + send_file_not_found();
  1244 + }
  1245 +
  1246 + $lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400;
  1247 +
  1248 + // finally send the file
  1249 + send_stored_file($file, $lifetime, 0, $forcedownload, $options);
  1250 +
  1251 + } else if ($filearea === 'conclusion') {
1226 1252 array_shift($args); // itemid is ignored here
1227 1253 $relativepath = implode('/', $args);
1228 1254 $fullpath = "/$context->id/mod_workshop/$filearea/0/$relativepath";
@@ -1397,7 +1423,7 @@ function workshop_get_file_info($browser, $areas, $course, $cm, $context, $filea
1397 1423 return new file_info_stored($browser, $context, $storedfile, $urlbase, $topvisiblename, true, true, false, false);
1398 1424 }
1399 1425
1400   - if ($filearea == 'instructauthors' or $filearea == 'instructreviewers') {
  1426 + if ($filearea == 'instructauthors' or $filearea == 'instructreviewers' or $filearea == 'conclusion') {
1401 1427 // always only itemid 0
1402 1428
1403 1429 $filepath = is_null($filepath) ? '/' : $filepath;
20 mod/workshop/mod_form.php
@@ -172,6 +172,14 @@ public function definition() {
172 172 $mform->disabledIf('examplesmode', 'useexamples');
173 173 $mform->setAdvanced('examplesmode');
174 174
  175 + // Miscellaneous settings
  176 + $mform->addElement('header', 'miscellaneoussettings', get_string('miscellaneoussettings', 'workshop'));
  177 +
  178 + $label = get_string('conclusion', 'workshop');
  179 + $mform->addElement('editor', 'conclusioneditor', $label, null,
  180 + workshop::instruction_editors_options($this->context));
  181 + $mform->addHelpButton('conclusioneditor', 'conclusion', 'workshop');
  182 +
175 183 // Access control -------------------------------------------------------------
176 184 $mform->addElement('header', 'accesscontrol', get_string('accesscontrol', 'workshop'));
177 185
@@ -237,6 +245,14 @@ public function data_preprocessing(&$data) {
237 245 $data['instructreviewers']);
238 246 $data['instructreviewerseditor']['format'] = $data['instructreviewersformat'];
239 247 $data['instructreviewerseditor']['itemid'] = $draftitemid;
  248 +
  249 + $draftitemid = file_get_submitted_draft_itemid('conclusion');
  250 + $data['conclusioneditor']['text'] = file_prepare_draft_area($draftitemid, $this->context->id,
  251 + 'mod_workshop', 'conclusion', 0,
  252 + workshop::instruction_editors_options($this->context),
  253 + $data['conclusion']);
  254 + $data['conclusioneditor']['format'] = $data['conclusionformat'];
  255 + $data['conclusioneditor']['itemid'] = $draftitemid;
240 256 } else {
241 257 // adding a new workshop instance
242 258 $draftitemid = file_get_submitted_draft_itemid('instructauthors');
@@ -246,6 +262,10 @@ public function data_preprocessing(&$data) {
246 262 $draftitemid = file_get_submitted_draft_itemid('instructreviewers');
247 263 file_prepare_draft_area($draftitemid, null, 'mod_workshop', 'instructreviewers', 0); // no context yet, itemid not used
248 264 $data['instructreviewerseditor'] = array('text' => '', 'format' => editors_get_preferred_format(), 'itemid' => $draftitemid);
  265 +
  266 + $draftitemid = file_get_submitted_draft_itemid('conclusion');
  267 + file_prepare_draft_area($draftitemid, null, 'mod_workshop', 'conclusion', 0); // no context yet, itemid not used
  268 + $data['conclusioneditor'] = array('text' => '', 'format' => editors_get_preferred_format(), 'itemid' => $draftitemid);
249 269 }
250 270 }
251 271

0 comments on commit 5a49f82

Please sign in to comment.
Something went wrong with that request. Please try again.