Loading src/Service/Resultat/ResultatService.php +3 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ class ResultatService $counts = []; $results = []; $comments = []; /** @var Question $question */ foreach ($enquete->getQuestions() as $question) { Loading @@ -36,6 +37,7 @@ class ResultatService if ($item instanceof HasEnqueteInterface AND $item->getEnquete() AND $item->getEnquete()->getValidation()) $reponse = $item->getEnquete()->getReponseFor($question); if ($reponse) { if ($reponse->getReponse()) $results[$question->getId()][$reponse->getReponse()][] = $item->getId(); if ($reponse->getCommentaire()) $comments[$question->getId()][] = [$reponse->getReponse(), html_entity_decode(strip_tags($reponse->getCommentaire()))]; if ($reponse->getReponse() === "0") { $counts[$question->getId()]["sans"][] = $item->getId(); } else { Loading @@ -46,6 +48,6 @@ class ResultatService } } } return [$counts, $results]; return [$counts, $results, $comments]; } } No newline at end of file view/unicaen-enquete/resultat/resultats.phtml +25 −26 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use UnicaenEnquete\Entity\HasEnqueteInterface; * @var Enquete $enquete * @var array $results * @var array $counts * @var array $comments * @var string $retourLibelle * @var string $retourIcone * @var string $retourUrl Loading Loading @@ -286,18 +287,8 @@ $nbElements = count($elements); </div> <?php endif; ?> <?php $valeurs = []; foreach ($elements as $element) { $reponse = null; if ($reponse instanceof Instance) $reponse = $element->getReponseFor($question); if ($reponse instanceof HasEnqueteInterface AND $reponse->getEnquete() AND $reponse->getEnquete()->getValidation()) $reponse = $element->getEnquete()->getReponseFor($question); if ($reponse && $reponse->getCommentaire()) { $valeurs[$element->getEnquete()->getId()] = $reponse->getCommentaire(); } } ?> <script>commentaires[<?php echo $question->getId(); ?>] = <?php echo json_encode($valeurs); ?></script> <script>commentaires[<?php echo $question->getId(); ?>] = <?php echo json_encode($comments[$question->getId()]); ?></script> <?php if ($question->hasCommentaire()): ?> <div class="row"> Loading @@ -319,17 +310,23 @@ $nbElements = count($elements); <table class="table table-condensed"> <thead> <tr> <th style="width:10rem;"> Id.</th> <?php if ($question->hasNote()) : ?> <th style="width:10rem;"> Réponse</th> <?php endif; ?> <th> Commentaire</th> </tr> </thead> <tbody> <?php foreach ($valeurs as $id => $commentaire) : ?> <?php if (isset($comments[$question->getId()])) : ?> <?php foreach ($comments[$question->getId()] as [$note, $commentaire]) : ?> <tr> <th><?php echo $id; ?></th> <?php if ($question->hasNote()) : ?> <th><?php echo $note; ?></th> <?php endif; ?> <td><?php echo $commentaire; ?></td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> Loading @@ -349,13 +346,15 @@ $nbElements = count($elements); foreach ($elements as $element) { $data = []; $data['Id'] = ($element->getEnquete())?->getId(); foreach ($enquete->getQuestions() as $question) { $reponse = null; if ($reponse instanceof Instance) $reponse = $element->getReponseFor($question); if ($reponse instanceof HasEnqueteInterface AND $reponse->getEnquete() AND $reponse->getEnquete()->getValidation()) $reponse = $element->getEnquete()->getReponseFor($question); if ($element instanceof Instance) $reponse = $element; if ($element instanceof HasEnqueteInterface AND $element->getEnquete() AND $element->getEnquete()->getValidation()) $reponse = $reponse = $element->getEnquete(); if ($reponse) { if ($question->hasNote()) $data['evaluation_' . $question->getId()] = ($reponse->getReponse()) ?? ""; if ($question->hasCommentaire()) $data['commentaire_' . $question->getId()] = ($reponse->getCommentaire()) ?? ""; foreach ($enquete->getQuestions() as $question) { $current = $reponse->getReponseFor($question); if ($question->hasNote()) $data['evaluation_' . $question->getId()] = $reponses[$current->getReponse()] ?? ""; if ($question->hasCommentaire()) $data['commentaire_' . $question->getId()] = html_entity_decode(strip_tags($current->getCommentaire())) ?? ""; } } $brut[] = $data; Loading Loading @@ -423,7 +422,7 @@ $nbElements = count($elements); $('span.export#commentaire').on('click', function () { let question_id = $(this).data("questionId"); let header = {0: "Id", 1: "Commentaire"}; let header = {0: "Id", 1: "Note", 2: "Commentaire"}; let tableau = commentaires[question_id]; downloadCSVFromJson('enquete_commentaires_' + $(this).attr('id') + '_' + Date.now().toString() + '.csv', header, tableau); }); Loading Loading
src/Service/Resultat/ResultatService.php +3 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ class ResultatService $counts = []; $results = []; $comments = []; /** @var Question $question */ foreach ($enquete->getQuestions() as $question) { Loading @@ -36,6 +37,7 @@ class ResultatService if ($item instanceof HasEnqueteInterface AND $item->getEnquete() AND $item->getEnquete()->getValidation()) $reponse = $item->getEnquete()->getReponseFor($question); if ($reponse) { if ($reponse->getReponse()) $results[$question->getId()][$reponse->getReponse()][] = $item->getId(); if ($reponse->getCommentaire()) $comments[$question->getId()][] = [$reponse->getReponse(), html_entity_decode(strip_tags($reponse->getCommentaire()))]; if ($reponse->getReponse() === "0") { $counts[$question->getId()]["sans"][] = $item->getId(); } else { Loading @@ -46,6 +48,6 @@ class ResultatService } } } return [$counts, $results]; return [$counts, $results, $comments]; } } No newline at end of file
view/unicaen-enquete/resultat/resultats.phtml +25 −26 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use UnicaenEnquete\Entity\HasEnqueteInterface; * @var Enquete $enquete * @var array $results * @var array $counts * @var array $comments * @var string $retourLibelle * @var string $retourIcone * @var string $retourUrl Loading Loading @@ -286,18 +287,8 @@ $nbElements = count($elements); </div> <?php endif; ?> <?php $valeurs = []; foreach ($elements as $element) { $reponse = null; if ($reponse instanceof Instance) $reponse = $element->getReponseFor($question); if ($reponse instanceof HasEnqueteInterface AND $reponse->getEnquete() AND $reponse->getEnquete()->getValidation()) $reponse = $element->getEnquete()->getReponseFor($question); if ($reponse && $reponse->getCommentaire()) { $valeurs[$element->getEnquete()->getId()] = $reponse->getCommentaire(); } } ?> <script>commentaires[<?php echo $question->getId(); ?>] = <?php echo json_encode($valeurs); ?></script> <script>commentaires[<?php echo $question->getId(); ?>] = <?php echo json_encode($comments[$question->getId()]); ?></script> <?php if ($question->hasCommentaire()): ?> <div class="row"> Loading @@ -319,17 +310,23 @@ $nbElements = count($elements); <table class="table table-condensed"> <thead> <tr> <th style="width:10rem;"> Id.</th> <?php if ($question->hasNote()) : ?> <th style="width:10rem;"> Réponse</th> <?php endif; ?> <th> Commentaire</th> </tr> </thead> <tbody> <?php foreach ($valeurs as $id => $commentaire) : ?> <?php if (isset($comments[$question->getId()])) : ?> <?php foreach ($comments[$question->getId()] as [$note, $commentaire]) : ?> <tr> <th><?php echo $id; ?></th> <?php if ($question->hasNote()) : ?> <th><?php echo $note; ?></th> <?php endif; ?> <td><?php echo $commentaire; ?></td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> Loading @@ -349,13 +346,15 @@ $nbElements = count($elements); foreach ($elements as $element) { $data = []; $data['Id'] = ($element->getEnquete())?->getId(); foreach ($enquete->getQuestions() as $question) { $reponse = null; if ($reponse instanceof Instance) $reponse = $element->getReponseFor($question); if ($reponse instanceof HasEnqueteInterface AND $reponse->getEnquete() AND $reponse->getEnquete()->getValidation()) $reponse = $element->getEnquete()->getReponseFor($question); if ($element instanceof Instance) $reponse = $element; if ($element instanceof HasEnqueteInterface AND $element->getEnquete() AND $element->getEnquete()->getValidation()) $reponse = $reponse = $element->getEnquete(); if ($reponse) { if ($question->hasNote()) $data['evaluation_' . $question->getId()] = ($reponse->getReponse()) ?? ""; if ($question->hasCommentaire()) $data['commentaire_' . $question->getId()] = ($reponse->getCommentaire()) ?? ""; foreach ($enquete->getQuestions() as $question) { $current = $reponse->getReponseFor($question); if ($question->hasNote()) $data['evaluation_' . $question->getId()] = $reponses[$current->getReponse()] ?? ""; if ($question->hasCommentaire()) $data['commentaire_' . $question->getId()] = html_entity_decode(strip_tags($current->getCommentaire())) ?? ""; } } $brut[] = $data; Loading Loading @@ -423,7 +422,7 @@ $nbElements = count($elements); $('span.export#commentaire').on('click', function () { let question_id = $(this).data("questionId"); let header = {0: "Id", 1: "Commentaire"}; let header = {0: "Id", 1: "Note", 2: "Commentaire"}; let tableau = commentaires[question_id]; downloadCSVFromJson('enquete_commentaires_' + $(this).attr('id') + '_' + Date.now().toString() + '.csv', header, tableau); }); Loading