コード例 #1
0
ファイル: PlanController.php プロジェクト: shivap87/cost
 function sendsummaryAction()
 {
     if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
         return $this->redirect()->toUrl('/');
     }
     $session = new Container('user');
     $username = $session->username;
     $uid = $session->userid;
     $questionList = $session->questionList;
     // get All answer list
     $apimanager = new RESTJSONManager();
     $url = Constants::PLAN_GET_ANSWERED_QUESTIONS;
     $url = str_replace('<UID>', $uid, $url);
     $result = $apimanager->PlanJSONManager('GET', $url, null, $uid);
     $allAnswer = json_decode($result->getBody(), true);
     $bodyMsg = "<table border=1>";
     foreach ($allAnswer['userChoices'] as $row) {
         $bodyMsg .= "<tr>";
         $bodyMsg .= "<td>Question</td>";
         $context = $row['contextId'];
         $question = $row['excerptId'];
         $userAns = $row['userAnswer'];
         $bodyMsg .= "<td>" . $questionList[$context][$question]['excerpt'] . "</td>";
         $bodyMsg .= "</tr>";
         $bodyMsg .= "<tr><td>User Answer </td>";
         $bodyMsg .= "<td>" . $userAns . "</td></tr>";
         $bodyMsg .= "<tr><td>Correct Answer</td>";
         $bodyMsg .= "<td>" . $questionList[$context][$question]['correctAnswer'] . "</td></tr>";
         $bodyMsg .= "<tr><td>Correct Answer Description </td>";
         $desc = str_replace("The answer you chose is CORRECT!", '', $questionList[$context][$question]['correctAnswerDescription']);
         $bodyMsg .= "<td>" . $desc . "</td></tr>";
     }
     $bodyMsg .= "</table>";
     //echo $bodyMsg;
     $mail = new EmailManager();
     $mail->sendPersonalStatement($username, $username, $bodyMsg);
     $view = new JsonModel(array('flag' => true));
     return $view;
 }