예제 #1
0
 /**
  * レポートの追加は生徒のみ行えるよ
  *
  * @return void
  * @param id これは所属する課題ID
  */
 public function add($id = null)
 {
     if (!$id) {
         throw new NotFoundException(__('課題エラー'));
     }
     // 課題の引数が間違えてる場合はダメ
     $this->loadModel('Assignment');
     if (!$this->Assignment->exists($id)) {
         throw new NotFoundException(__('課題エラー'));
     }
     if ($this->request->is('post')) {
         //  			debug($this->request->data);
         //  			throw new NotFoundException();
         //$this->Report->create ();
         if ($this->Report->createWithAttachments($this->request->data)) {
             // 通知処理
             $RM = new ReadManagementsController();
             $RM->createWithStudentRM($this->Report->getLastInsertID(), 'Report', $this->Auth->user('id'));
             $this->Session->setFlash(__('課題の提出を行いました。'));
             return $this->redirect(array('action' => 'index', $id));
         } else {
             $this->Session->setFlash(__('提出ができませんでした。再試行してください。'));
         }
     }
     $this->Assignment->recursive = 0;
     $this->set('assignment', $this->Assignment->find('first', array('conditions' => array('Assignment.id' => $id))));
 }