Example #1
0
 /**
  * Setup all the various parts of an assignment activity including creating an onlinetext submission.
  */
 protected function setUp()
 {
     $this->user = $this->getDataGenerator()->create_user();
     $this->course = $this->getDataGenerator()->create_course();
     $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
     $params['course'] = $this->course->id;
     $instance = $generator->create_instance($params);
     $this->cm = get_coursemodule_from_instance('assign', $instance->id);
     $this->context = context_module::instance($this->cm->id);
     $this->assign = new testable_assign($this->context, $this->cm, $this->course);
     $this->setUser($this->user->id);
     $this->submission = $this->assign->get_user_submission($this->user->id, true);
     $this->data = new stdClass();
     $this->data->onlinetext_editor = array('itemid' => file_get_unused_draft_itemid(), 'text' => 'Submission text', 'format' => FORMAT_PLAIN);
 }
Example #2
0
 /**
  * Setup all the various parts of an assignment activity including creating a file submission.
  */
 protected function setUp()
 {
     $this->user = $this->getDataGenerator()->create_user();
     $this->course = $this->getDataGenerator()->create_course();
     $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
     $params['course'] = $this->course->id;
     $instance = $generator->create_instance($params);
     $this->cm = get_coursemodule_from_instance('assign', $instance->id);
     $this->context = context_module::instance($this->cm->id);
     $this->assign = new testable_assign($this->context, $this->cm, $this->course);
     $this->setUser($this->user->id);
     $this->submission = $this->assign->get_user_submission($this->user->id, true);
     $fs = get_file_storage();
     $dummy = (object) array('contextid' => $this->context->id, 'component' => 'assignsubmission_onenote', 'filearea' => \local_onenote\api\base::ASSIGNSUBMISSION_ONENOTE_FILEAREA, 'itemid' => $this->submission->id, 'filepath' => '/', 'filename' => 'myassignmnent.pdf');
     $this->fi = $fs->create_file_from_string($dummy, 'Content of ' . $dummy->filename);
     $dummy = (object) array('contextid' => $this->context->id, 'component' => 'assignsubmission_onenote', 'filearea' => \local_onenote\api\base::ASSIGNSUBMISSION_ONENOTE_FILEAREA, 'itemid' => $this->submission->id, 'filepath' => '/', 'filename' => 'myassignmnent.png');
     $this->fi2 = $fs->create_file_from_string($dummy, 'Content of ' . $dummy->filename);
     $this->files = $fs->get_area_files($this->context->id, 'assignsubmission_onenote', \local_onenote\api\base::ASSIGNSUBMISSION_ONENOTE_FILEAREA, $this->submission->id, 'id', false);
 }