コード例 #1
0
 /**
  * Any data processing needed before the form is displayed
  * (needed to set up draft areas for editor and filemanager elements)
  * @param array $defaultvalues
  */
 public function data_preprocessing(&$defaultvalues)
 {
     global $DB;
     $ctx = null;
     if ($this->current && $this->current->coursemodule) {
         $cm = get_coursemodule_from_instance('sepl', $this->current->id, 0, false, MUST_EXIST);
         $ctx = context_module::instance($cm->id);
     }
     $seplment = new sepl($ctx, null, null);
     if ($this->current && $this->current->course) {
         if (!$ctx) {
             $ctx = context_course::instance($this->current->course);
         }
         $course = $DB->get_record('course', array('id' => $this->current->course), '*', MUST_EXIST);
         $seplment->set_course($course);
     }
     $draftitemid = file_get_submitted_draft_itemid('introattachments');
     file_prepare_draft_area($draftitemid, $ctx->id, 'mod_sepl', ASSIGN_INTROATTACHMENT_FILEAREA, 0, array('subdirs' => 0));
     $defaultvalues['introattachments'] = $draftitemid;
     $seplment->plugin_data_preprocessing($defaultvalues);
 }