[PLUGINS] +set de base
[lhc/web/www.git] / www / plugins / formidable_1_0 / modeles / formulaire_analyse.html
1 <BOUCLE_formulaire(FORMULAIRES){id_formulaire}>
2 <div class='formidable_analyse'>
3 [(#REM) On fait un tableau qui contient toutes les réponses, classées par champ ]
4 #SET{valeurs,#ARRAY}
5 #SET{reponses_total,0}
6 <BOUCLE_reponses(FORMULAIRES_REPONSES){id_formulaire}>
7 <BOUCLE_champs(FORMULAIRES_REPONSES_CHAMPS){id_formulaires_reponse}{nom ?= #ENV{nom}}>
8 #SET_MERGE{liste_valeurs, #GET{valeurs}|table_valeur{#NOM}|sinon{#ARRAY}, #ARRAY{0,#VALEUR|tenter_unserialize}}
9 #SET_MERGE{valeurs, #ARRAY{#NOM,#GET{liste_valeurs}}}
10 </BOUCLE_champs>
11 </BOUCLE_reponses>
12 #SET{reponses_total,#TOTAL_BOUCLE}
13 <strong class='nombre_reponse'>
14 [(#TOTAL_BOUCLE|singulier_ou_pluriel{formidable:reponse_une,formidable:reponses_nb})]
15 </strong>
16 </B_reponses>
17 <strong class='nombre_reponse'><:formidable:reponse_aucune:></strong>
18 <//B_reponses>
19
20 <BOUCLE_saisies(POUR){tableau #SAISIES|unserialize|saisies_lister_par_nom}>
21 [(#VAL{saisie}|array_key_exists{#VALEUR}|oui)
22 [(#CLE|=={#ENV{nom,#CLE}}|oui)
23 [(#VALEUR|formidable_analyser_saisie{#GET{valeurs}, #GET{reponses_total}})]
24 ]
25 ]
26 </BOUCLE_saisies>
27
28 </div><!-- formidable_analyse -->
29 <script type='text/javascript'>
30 (function($){
31 $(document).ready(function(){
32 /* Récupérer tous les tableaux d'analyse non décorés */
33 $('.formidable_analyse table:not(.stat_done)').each(function() {
34 $(this).addClass('stat_done');
35 /* Le tableau contient le nombre total d'élément. On parcours chaque valeur */
36 $nbtotal = $(this).data('nombre');
37 $(this).find('td.stat').each(function(){
38 $val = $(this).html();
39 /* Certaines valeurs sont a ignorer (les moyennes) */
40 $ignore = $(this).is('.ignore');
41 if (!$ignore) {
42 /* Calcul du pourcentage */
43 $taux = Math.round($val/$nbtotal*100);
44 /* On affiche le nombre de réponses */
45 $reponses = $(this).attr('title');
46 if (!parseInt($val) || ($reponses === undefined)) {
47 $reponses = '';
48 } else {
49 $reponses = "<small> - " + $reponses + "</small>";
50 }
51 $text = "\
52 <div class='[(#CONFIG{formidable/analyse/classe}) ]progress-bar'>\
53 <span></span><strong>" + $taux + "%" + $reponses + "</strong>\
54 </div>";
55 $(this).html($text).find('span').width($taux + '%');
56 }
57 });
58 });
59 });
60 })(jQuery);
61 </script>
62 <style type='text/css'>
63 <INCLURE{fond=css/formidable_analyse.css} />
64 </style>
65 </BOUCLE_formulaire>