コード例 #1
0
 public function updateReview(DB $db, APIRequest $request, APIResponse $response)
 {
     $this->vars->review = new PerformanceReview();
     $this->vars->review->loadById($db, $request->get('reviewId'));
     //validate?
     foreach ($request->post('questions') as $questionId => $answerPost) {
         $answer = new ReviewAnswer();
         if (!$answer->loadOneWhere($db, 'question_id = ? and review_id = ?', [$questionId, $this->vars->review->id])) {
             $answer->questionId = $questionId;
             $answer->reviewId = $this->vars->review->id;
         }
         $answer->text = $answerPost['text'];
         $answer->scale = $answerPost['scale'];
         $answer->store($db);
     }
     if ($_POST['action'] == 'submit') {
         $this->vars->review->submitted = 'yes';
         $this->vars->review->submittedYmdt = gmdate('Y-m-d H:i:s');
         $this->vars->review->submit($db);
         $updater = new WorkflowUpdater();
         $workflow = new Workflow();
         $workflow->loadOneWhere($db, 'table_row_id = ? and type = ?', [$this->vars->review->id, 'review']);
         $updater->complete($db, $workflow);
     }
     $response->success();
 }
コード例 #2
0
 public function updateReview(APIRequest $request, APIResponse $response)
 {
     $reviewId = $request->get('id');
     try {
         //The API could use a different Request object, as long as it implements the right
         //interface.
         $reviewAnswers = new ReviewAnswersRequest($reviewId, $request->post('questions'));
     } catch (InvalidArgumentException $exception) {
         //invalid data posted.
         $response->errorCode(400);
         $response->errorMessage('You did it wrong!');
         return true;
     }
     $this->getPerformanceReviewService()->answerReviewQuestions($reviewAnswers);
     $response->successCode(200);
     return true;
 }