]> git.mjollnir.org Git - moodle.git/commitdiff
Instructions for reviewers work
authorDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 18:07:17 +0000 (18:07 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 18:07:17 +0000 (18:07 +0000)
mod/workshop/lib.php
mod/workshop/mod_form.php
mod/workshop/view.php

index ae24537b93020ef0c94b6010a3b661b5642753b7..1ea2bef1f3a904fac7a2a1a7cc28587ea98883f6 100644 (file)
@@ -103,6 +103,12 @@ function workshop_add_instance($data) {
         $data->instructauthorsformat = $data->instructauthorseditor['format'];
     }
 
+    if ($draftitemid = $data->instructreviewerseditor['itemid']) {
+        $data->instructreviewers = file_save_draft_area_files($draftitemid, $context->id, 'workshop_instructreviewers',
+                0, workshop::instruction_editors_options($context), $data->instructreviewerseditor['text']);
+        $data->instructreviewersformat = $data->instructreviewerseditor['format'];
+    }
+
     // re-save the record with the replaced URLs in editor fields
     $DB->update_record('workshop', $data);
 
@@ -137,6 +143,12 @@ function workshop_update_instance($data) {
         $data->instructauthorsformat = $data->instructauthorseditor['format'];
     }
 
+    if ($draftitemid = $data->instructreviewerseditor['itemid']) {
+        $data->instructreviewers = file_save_draft_area_files($draftitemid, $context->id, 'workshop_instructreviewers',
+                0, workshop::instruction_editors_options($context), $data->instructreviewerseditor['text']);
+        $data->instructreviewersformat = $data->instructreviewerseditor['format'];
+    }
+
     // re-save the record with the replaced URLs in editor fields
     return $DB->update_record('workshop', $data);
 }
@@ -365,6 +377,27 @@ function workshop_pluginfile($course, $cminfo, $context, $filearea, array $args,
         send_stored_file($file, $lifetime, 0);
     }
 
+    if ($filearea === 'workshop_instructreviewers') {
+        // submission instructions may contain sensitive data
+        if (!has_any_capability(array('moodle/course:manageactivities', 'mod/workshop:peerassess'), $context)) {
+            send_file_not_found();
+        }
+
+        array_shift($args); // we do not use itemids here
+        $relativepath = '/' . implode('/', $args);
+        $fullpath = $context->id . $filearea . '0' . $relativepath; // beware, slashes are not used here!
+
+        $fs = get_file_storage();
+        if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
+            send_file_not_found();
+        }
+
+        $lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400;
+
+        // finally send the file
+        send_stored_file($file, $lifetime, 0);
+    }
+
     // the following file areas are for the files embedded into the assessment forms
     if (in_array($filearea, array(
             'workshopform_comments_description',
index dc11faf6dbdb6107a688b86f9eccc3043a939a73..75f187e3749b1da4879b94f1e3b40b2173183808 100644 (file)
@@ -132,9 +132,9 @@ class mod_workshop_mod_form extends moodleform_mod {
         // Assessment settings --------------------------------------------------------
         $mform->addElement('header', 'assessmentsettings', get_string('assessmentsettings', 'workshop'));
 
-//        $label = get_string('instructreviewers', 'workshop');
-//        $mform->addElement('editor', 'instructreviewerseditor', $label, null,
-//                            workshop::instruction_editors_options($this->context));
+        $label = get_string('instructreviewers', 'workshop');
+        $mform->addElement('editor', 'instructreviewerseditor', $label, null,
+                            workshop::instruction_editors_options($this->context));
 
         $label = get_string('nexassessments', 'workshop');
         $options = workshop_get_numbers_of_assessments();
@@ -229,11 +229,23 @@ class mod_workshop_mod_form extends moodleform_mod {
                                 $data['instructauthors']);
             $data['instructauthorseditor']['format'] = $data['instructauthorsformat'];
             $data['instructauthorseditor']['itemid'] = $draftitemid;
+
+            $draftitemid = file_get_submitted_draft_itemid('instructreviewers');
+            $data['instructreviewerseditor']['text'] = file_prepare_draft_area($draftitemid, $this->context->id,
+                                'workshop_instructreviewers', false,
+                                workshop::instruction_editors_options($this->context),
+                                $data['instructreviewers']);
+            $data['instructreviewerseditor']['format'] = $data['instructreviewersformat'];
+            $data['instructreviewerseditor']['itemid'] = $draftitemid;
         } else {
             // adding a new workshop instance
             $draftitemid = file_get_submitted_draft_itemid('instructauthors');
             file_prepare_draft_area($draftitemid, null, null, null);    // no context, no filearea yet
             $data['instructauthorseditor'] = array('text' => '', 'format' => FORMAT_HTML, 'itemid' => $draftitemid);
+
+            $draftitemid = file_get_submitted_draft_itemid('instructreviewers');
+            file_prepare_draft_area($draftitemid, null, null, null);    // no context, no filearea yet
+            $data['instructreviewerseditor'] = array('text' => '', 'format' => FORMAT_HTML, 'itemid' => $draftitemid);
         }
     }
 }
index 803f3df28f5185a7ea196398e04a3fde52fb7e8e..cf3e356130cc3e4c9b55360220700b672ddf4cfa 100644 (file)
@@ -117,6 +117,11 @@ case workshop::PHASE_SUBMISSION:
     }
     break;
 case workshop::PHASE_ASSESSMENT:
+    if (trim(strip_tags($workshop->instructreviewers))) {
+        $instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id,
+            'workshop_instructreviewers', 0, workshop::instruction_editors_options($PAGE->context));
+        echo $OUTPUT->box(format_text($instructions, $workshop->instructreviewersformat), array('generalbox', 'instructions'));
+    }
     if (! $assessments = $workshop->get_assessments_by_reviewer($USER->id)) {
         echo $OUTPUT->heading(get_string('assignedassessmentsnone', 'workshop'), 3);
     } else {