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