Пример #1
0
 private function checkAnsweredQuestion(Question $question)
 {
     $questionId = $question->getId();
     $answeredQuestions = $this->surveyManager->checkQuestionAnswersByQuestions([$question]);
     if (isset($answeredQuestions[$questionId]) && $answeredQuestions[$questionId]) {
         throw new AccessDeniedException();
     }
 }
Пример #2
0
 /**
  * @EXT\Route(
  *     "/survey/{survey}/question/{question}/results/export",
  *     name="claro_survey_question_results_export"
  * )
  * @EXT\ParamConverter("user", options={"authenticatedUser" = true})
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function questionResultsExcelExportAction(Survey $survey, Question $question)
 {
     $canEdit = $this->hasSurveyRight($survey, 'EDIT');
     if (!$canEdit && !$survey->getHasPublicResult()) {
         throw new AccessDeniedException();
     }
     $results = array();
     $comments = array();
     $results[$question->getId()] = $this->showTypedQuestionResults($survey, $question, 1, 20, true)->getContent();
     $response = new Response($this->templating->render("ClarolineSurveyBundle:Survey:surveyResultsExport.html.twig", array('survey' => $survey, 'questions' => array($question), 'results' => $results, 'comments' => $comments)));
     $fileName = $this->translator->trans('results', array(), 'platform');
     $response->headers->set('Content-Transfer-Encoding', 'octet-stream');
     $response->headers->set('Content-Type', 'application/force-download');
     $response->headers->set('Content-Disposition', 'attachment; filename=' . $fileName . '.xls');
     $response->headers->set('Content-Type', 'application/vnd.ms-excel; charset=utf-8');
     return $response;
 }