assignment MDL-23683 online assignment filearea changed for consistency from 'online_...
authorAparup Banerjee <nebgor@gmail.com>
Thu, 30 Sep 2010 06:30:34 +0000 (06:30 +0000)
committerAparup Banerjee <nebgor@gmail.com>
Thu, 30 Sep 2010 06:30:34 +0000 (06:30 +0000)
mod/assignment/type/online/assignment.class.php
mod/assignment/type/online/file.php

index 3257c11..fce9463 100644 (file)
@@ -8,6 +8,8 @@ require_once($CFG->dirroot . '/mod/assignment/lib.php');
  */
 class assignment_online extends assignment_base {
 
+    var $filearea = 'submission';
+
     function assignment_online($cmid='staticonly', $assignment=NULL, $cm=NULL, $course=NULL) {
         parent::assignment_base($cmid, $assignment, $cm, $course);
         $this->type = 'online';
@@ -49,7 +51,7 @@ class assignment_online extends assignment_base {
                 $data->textformat = NULL;
             }
 
-            $data = file_prepare_standard_editor($data, 'text', $editoroptions, $this->context, 'mod_assignment', 'online_submission', $data->sid);
+            $data = file_prepare_standard_editor($data, 'text', $editoroptions, $this->context, 'mod_assignment', $this->filearea, $data->sid);
 
             $mform = new mod_assignment_online_edit_form(null, array($data, $editoroptions));
 
@@ -60,7 +62,7 @@ class assignment_online extends assignment_base {
             if ($data = $mform->get_data()) {
                 $submission = $this->get_submission($USER->id, true); //create the submission if needed & its id
 
-                $data = file_postupdate_standard_editor($data, 'text', $editoroptions, $this->context, 'mod_assignment', 'online_submission', $submission->id);
+                $data = file_postupdate_standard_editor($data, 'text', $editoroptions, $this->context, 'mod_assignment', $this->filearea, $submission->id);
 
                 $submission = $this->update_submission($data);
 
@@ -97,14 +99,14 @@ class assignment_online extends assignment_base {
             } else {
                 echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter', 'online');
                 if ($submission && has_capability('mod/assignment:exportownsubmission', $this->context)) {
-                    $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'mod_assignment', 'online_submission', $submission->id);
+                    $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'mod_assignment', $this->filearea, $submission->id);
                     echo format_text($text, $submission->data2);
                     if ($CFG->enableportfolios) {
                         require_once($CFG->libdir . '/portfoliolib.php');
                         $button = new portfolio_add_button();
                         $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id), '/mod/assignment/locallib.php');
                         $fs = get_file_storage();
-                        if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', 'online_submission', $submission->id, "timemodified", false)) {
+                        if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', $this->filearea, $submission->id, "timemodified", false)) {
                             $button->set_formats(PORTFOLIO_FORMAT_RICHHTML);
                         } else {
                             $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML);
@@ -230,7 +232,7 @@ class assignment_online extends assignment_base {
         }
         $wordcount .= '</p>';
 
-        $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'mod_assignment', 'online_submission', $submission->id);
+        $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'mod_assignment', $this->filearea, $submission->id);
         return $wordcount . format_text($text, $submission->data2);
 
 
@@ -276,7 +278,7 @@ class assignment_online extends assignment_base {
     function portfolio_load_data($caller) {
         $submission = $this->get_submission();
         $fs = get_file_storage();
-        if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', 'online_submission', $submission->id, "timemodified", false)) {
+        if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', $this->filearea, $submission->id, "timemodified", false)) {
             $caller->set('multifiles', $files);
         }
     }
@@ -294,7 +296,7 @@ class assignment_online extends assignment_base {
     function portfolio_prepare_package($exporter, $user) {
         $submission = $this->get_submission($user->id);
         $html = format_text($submission->data1, $submission->data2);
-        $html = portfolio_rewrite_pluginfile_urls($html, $this->context->id, 'mod_assignment', 'online_submission', $submission->id, $exporter->get('format'));
+        $html = portfolio_rewrite_pluginfile_urls($html, $this->context->id, 'mod_assignment', $this->filearea, $submission->id, $exporter->get('format'));
         if (in_array($exporter->get('formatclass'), array(PORTFOLIO_FORMAT_PLAINHTML, PORTFOLIO_FORMAT_RICHHTML))) {
             if ($files = $exporter->get('caller')->get('multifiles')) {
                 foreach ($files as $f) {
index 10da899..368f20c 100644 (file)
@@ -59,7 +59,7 @@ if ($submission = $assignmentinstance->get_submission($user->id)) {
     echo '</table>';
     echo $OUTPUT->box_end();
 
-    $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $context->id, 'mod_assignment', 'online_submission', $submission->id);
+    $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $context->id, 'mod_assignment', $assignmentinstance->filearea, $submission->id);
     echo $OUTPUT->box(format_text($text, $submission->data2), 'generalbox boxaligncenter boxwidthwide');
     echo $OUTPUT->close_window_button();
     echo $OUTPUT->footer();