Loading view/unicaen-enquete/resultat/resultats.phtml +33 −8 Original line number Diff line number Diff line Loading @@ -245,16 +245,17 @@ $nbElements = count($elements); </tr> </thead> <tbody> <?php //$nbReponseQuestion = count($results[$question->getId()]); ?> <?php $nbReponseQuestion = count($counts[$question->getId()]["avec"]); ?> <?php foreach ($reponses as $id => $valeur) : ?> <?php if ($id != 0) : ?> <?php $nbOccurence = isset($results[$question->getId()][$id]) ? count($results[$question->getId()][$id]) : 0; $nbReponse = isset($results[$question->getId()][$id]) ? count($results[$question->getId()][$id]) : 0; $ratio = ($nbReponse !== 0) ? $nbOccurence / $nbReponse * 100 : 0; $ratio = ($nbReponseQuestion !== 0) ? ((float) $nbReponse) / $nbReponseQuestion * 100 : 0; ?> <tr> <td> <?php echo $valeur; ?> </td> <td class="num"> <?php echo $nbOccurence; ?> </td> <td class="num"> <?php echo $nbReponse; ?> </td> <td class="num"> <?php echo number_format($ratio, 2, ","); ?>%</td> </tr> <?php endif; ?> Loading Loading @@ -336,14 +337,32 @@ $nbElements = count($elements); </thead> <tbody> <?php if (isset($comments[$question->getId()])) : ?> <?php foreach ($comments[$question->getId()] as [$note, $commentaire]) : ?> <tr> <?php $commentaires = $comments[$question->getId()]; usort($commentaires, function ($a, $b) { return $a[0] <=> $b[0]; }); $sortedCommentaires = []; foreach ($commentaires as $commentaire) { $sortedCommentaires[$commentaire[0]][] = $commentaire[1]; } ?> <?php foreach ($sortedCommentaires as $note => $liste) : ?> <?php if ($question->hasNote()) : ?> <th><?php echo $note; ?></th> <tr> <th rowspan="<?php echo count($liste)+1; ?>" class="toggler" id="<?php echo $note; ?>"> <?php echo $reponses[$note]??"Sans avis"; ?> </th> <td> <?php echo count($liste); ?> réponse·s</td> </tr> <?php endif; ?> <?php foreach ($liste as $commentaire) : ?> <tr class="comments_<?php echo $note; ?>"> <td><?php echo $commentaire; ?></td> </tr> <?php endforeach; ?> <?php endforeach; ?> <?php endif; ?> </tbody> </table> Loading Loading @@ -460,4 +479,10 @@ $nbElements = count($elements); let tableau = brut; downloadCSVFromJson('enquete_brut_' + $(this).attr('id') + '_' + Date.now().toString() + '.csv', header, tableau); }); $('th.toggler').on('click', function () { let id = $(this).attr("id"); console.log(id); $('tr.comments_' + id + ' td').toggle(); }); </script> No newline at end of file Loading
view/unicaen-enquete/resultat/resultats.phtml +33 −8 Original line number Diff line number Diff line Loading @@ -245,16 +245,17 @@ $nbElements = count($elements); </tr> </thead> <tbody> <?php //$nbReponseQuestion = count($results[$question->getId()]); ?> <?php $nbReponseQuestion = count($counts[$question->getId()]["avec"]); ?> <?php foreach ($reponses as $id => $valeur) : ?> <?php if ($id != 0) : ?> <?php $nbOccurence = isset($results[$question->getId()][$id]) ? count($results[$question->getId()][$id]) : 0; $nbReponse = isset($results[$question->getId()][$id]) ? count($results[$question->getId()][$id]) : 0; $ratio = ($nbReponse !== 0) ? $nbOccurence / $nbReponse * 100 : 0; $ratio = ($nbReponseQuestion !== 0) ? ((float) $nbReponse) / $nbReponseQuestion * 100 : 0; ?> <tr> <td> <?php echo $valeur; ?> </td> <td class="num"> <?php echo $nbOccurence; ?> </td> <td class="num"> <?php echo $nbReponse; ?> </td> <td class="num"> <?php echo number_format($ratio, 2, ","); ?>%</td> </tr> <?php endif; ?> Loading Loading @@ -336,14 +337,32 @@ $nbElements = count($elements); </thead> <tbody> <?php if (isset($comments[$question->getId()])) : ?> <?php foreach ($comments[$question->getId()] as [$note, $commentaire]) : ?> <tr> <?php $commentaires = $comments[$question->getId()]; usort($commentaires, function ($a, $b) { return $a[0] <=> $b[0]; }); $sortedCommentaires = []; foreach ($commentaires as $commentaire) { $sortedCommentaires[$commentaire[0]][] = $commentaire[1]; } ?> <?php foreach ($sortedCommentaires as $note => $liste) : ?> <?php if ($question->hasNote()) : ?> <th><?php echo $note; ?></th> <tr> <th rowspan="<?php echo count($liste)+1; ?>" class="toggler" id="<?php echo $note; ?>"> <?php echo $reponses[$note]??"Sans avis"; ?> </th> <td> <?php echo count($liste); ?> réponse·s</td> </tr> <?php endif; ?> <?php foreach ($liste as $commentaire) : ?> <tr class="comments_<?php echo $note; ?>"> <td><?php echo $commentaire; ?></td> </tr> <?php endforeach; ?> <?php endforeach; ?> <?php endif; ?> </tbody> </table> Loading Loading @@ -460,4 +479,10 @@ $nbElements = count($elements); let tableau = brut; downloadCSVFromJson('enquete_brut_' + $(this).attr('id') + '_' + Date.now().toString() + '.csv', header, tableau); }); $('th.toggler').on('click', function () { let id = $(this).attr("id"); console.log(id); $('tr.comments_' + id + ' td').toggle(); }); </script> No newline at end of file