Rev 14335 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
15753 | bpr | 1 | !! use to replace space if necessary |
2 | !set joker=___ |
||
3 | |||
23 | reyssat | 4 | !if $vote_status!=1 |
12479 | bpr | 5 | error=bad_vote |
6 | job=home |
||
7 | !changeto home.proc |
||
23 | reyssat | 8 | !endif |
9 | |||
10 | !readdef $userfile |
||
11 | !if $(user_vote_$Vote)=$empty and $(user_vote_$vote)!=$empty |
||
12479 | bpr | 12 | user_vote_$Vote=$(user_vote_$vote) |
23 | reyssat | 13 | !endif |
14 | |||
7198 | bpr | 15 | # pour un questionnaire tracé ou anonyme on interdit de |
217 | bpr | 16 | # modifier son vote. |
23 | reyssat | 17 | |
217 | bpr | 18 | !if $vote_option!=nominative and $(user_vote_$Vote)!=$empty |
12479 | bpr | 19 | error=already_voted |
20 | !exit |
||
23 | reyssat | 21 | !endif |
22 | |||
23 | !readdef $votedir/$vote.votes |
||
24 | |||
25 | !readdef $votedir/$vote.comments |
||
4191 | guerimand | 26 | vote_description=$empty |
27 | noprint=yes |
||
28 | !reset parmcnt |
||
29 | !readproc $votedir/$vote.def |
||
23 | reyssat | 30 | voteset= |
31 | !if $(user_vote_$Vote)=$empty |
||
12479 | bpr | 32 | !advance vcnt |
33 | voteset=vcnt=$vcnt |
||
23 | reyssat | 34 | !endif |
217 | bpr | 35 | |
36 | # on récupère le nombre de votes déjà exprimés |
||
37 | nbvotes=$vcnt |
||
15753 | bpr | 38 | !!__ is to keep trace of single space |
23 | reyssat | 39 | !for t=1 to $parmcnt |
15753 | bpr | 40 | !if ($(vote_description[$t;2])=textarea and $vote_option!=nominative) \ |
41 | or $(vote_description[$t;2]) iswordof inputfield |
||
42 | tt =!singlespace $(parm$t) |
||
43 | tt =!singlespace $tt |
||
44 | tt=!trim $tt |
||
45 | !if $(vote_description[$t;2]) iswordof inputfield |
||
46 | tt=!replace internal $ $ by $joker in $tt |
||
47 | tt=!replace internal , by . in $tt |
||
12479 | bpr | 48 | !endif |
15753 | bpr | 49 | tt = !char 1 to $limit_textarea of $tt |
50 | !appendfile $votedir/$(vote)_$t.comments :$tt |
||
12479 | bpr | 51 | !else |
52 | !for k=0 to $(choices$t) |
||
53 | vc_$k=$(vcnt_$(t)_$k) |
||
54 | !next k |
||
55 | tmp=!values v for v=1 to $(choices$t) |
||
56 | parm$t=!nospace $(parm$t) |
||
57 | parm$t=!listintersect $(parm$t) and $tmp |
||
58 | !for k in $(parm$t) |
||
59 | !default vc_$k=0 |
||
60 | !advance vc_$k |
||
61 | !next k |
||
62 | old=!item $t of $(user_vote_$Vote) |
||
63 | old=!words2items $old |
||
64 | !for v in $old |
||
65 | vc_$v=$[max(0,$(vc_$v)-1)] |
||
66 | !next v |
||
67 | !for k=0 to $(choices$t) |
||
68 | !default vc_$k=0 |
||
69 | !if $(vc_$k) != $(vcnt_$(t)_$k) |
||
70 | voteset=!append line vcnt_$(t)_$k=$(vc_$k) to $voteset |
||
71 | !endif |
||
72 | !next k |
||
23 | reyssat | 73 | !endif |
74 | !next t |
||
75 | |||
217 | bpr | 76 | # paramcnt: nombre de questions |
77 | |||
23 | reyssat | 78 | !if $vote_option=anonymous |
12479 | bpr | 79 | user_vote_$Vote=yes |
23 | reyssat | 80 | !else |
217 | bpr | 81 | # nouvelle option pour le tracage des reponses. |
82 | # on ne garde pas le nom du votant mais on lui donne un numéro qui |
||
83 | # est égal au nombre de votes exprimés. |
||
7198 | bpr | 84 | # |
217 | bpr | 85 | # comme on est dans le ELSE du anonymous, on n'a plus que 2 choix possibles: |
86 | # nominatif ou tracage |
||
87 | # d'où le IF/ELSE simple |
||
88 | # si un autre cas devait être intégré il faudrait faire un test un peu plus poussé |
||
7198 | bpr | 89 | |
217 | bpr | 90 | # la partie du fichier obtenu est de la forme vote |
91 | option=$empty |
||
92 | |||
93 | !if $vote_option iswordof nominative |
||
94 | option=$wims_class/$wims_user |
||
95 | !else |
||
96 | option=$nbvotes |
||
97 | !endif |
||
98 | |||
12479 | bpr | 99 | tt=$empty |
100 | !for t=1 to $parmcnt |
||
15753 | bpr | 101 | !if $(vote_description[$t;2]) notwordof textarea inputfield |
12479 | bpr | 102 | !if $vote_option=nominative |
103 | !! erase old vote. allowed only with vote_option=nominative |
||
104 | old=!item $t of $(user_vote_$Vote) |
||
105 | old=!words2items $old |
||
106 | !for v in $old |
||
107 | vv=!replace item $option by $ in $(votes_$(t)_$v) |
||
108 | vv=!nonempty items $vv |
||
109 | voteset=!append line votes_$(t)_$v=$vv to $voteset |
||
110 | votes_$(t)_$v=$vv |
||
111 | !next v |
||
112 | !endif |
||
113 | tmp=!items2words $(parm$t) |
||
114 | tt=!append item $tmp to $tt |
||
115 | !for v in $(parm$t) |
||
116 | vv=!append item $option to $(votes_$(t)_$(v)) |
||
117 | voteset=!append line votes_$(t)_$v=$vv to $voteset |
||
118 | !next v |
||
119 | !else |
||
120 | tt=!append item 0 to $tt |
||
121 | !endif |
||
122 | !next t |
||
123 | !if $vote_option=trace |
||
124 | user_vote_$Vote=yes |
||
4191 | guerimand | 125 | !else |
12479 | bpr | 126 | user_vote_$Vote=$tt |
217 | bpr | 127 | !endif |
23 | reyssat | 128 | !endif |
129 | |||
130 | !setdef !set user_vote_$Vote=$(user_vote_$Vote) in $userfile |
||
131 | !if $voteset!=$empty |
||
12479 | bpr | 132 | !setdef $voteset in $votedir/$vote.votes |
23 | reyssat | 133 | !endif |
134 | |||
4191 | guerimand | 135 | !! -------------------------- |
10736 | guerimand | 136 | !! these lines are writing the variable user_techvar_ttt in the user file when |
4197 | bpr | 137 | !!\uservar{ttt, ....} |
138 | |||
23 | reyssat | 139 | ccc=!itemcnt $uvcnt |
10146 | guerimand | 140 | !if $ccc>0 |
12479 | bpr | 141 | !readproc adm/vfilter/listvarfilter.proc |
142 | !for i=1 to $ccc |
||
143 | uvc=!item $i of $uvcnt |
||
144 | uvn=!item $i of $uvname |
||
145 | !! no registery if the technical variable is not already defined |
||
146 | !if $uvn isitemof $tv_listlocalcode |
||
10146 | guerimand | 147 | uvv=!line $i of $uvval |
148 | uvv=!item $(parm$uvc)+1 of $uvv |
||
12479 | bpr | 149 | !! check if the value exists for this technical variable (only defined values can be save in user .def file) |
10736 | guerimand | 150 | po=!positionof item $uvn in $tv_listcode |
10146 | guerimand | 151 | don=!line $po of $tv_listtechvar |
152 | !distribute item $don into name,classid,number |
||
153 | don=!record $number of wimshome/log/classes/$wims_class/.techvar |
||
154 | don=!line 2 of $don |
||
155 | !if $uvv notitemof $don |
||
14335 | bpr | 156 | uvv=$empty |
10146 | guerimand | 157 | !endif |
10702 | guerimand | 158 | classid=!replace internal / by _ in $classid |
10736 | guerimand | 159 | !setdef !set user_techvar_$(uvn)=$uvv in $userfile |
12479 | bpr | 160 | !endif |
161 | !next i |
||
10146 | guerimand | 162 | !endif |
4191 | guerimand | 163 | !! ------------------------------------------- |
23 | reyssat | 164 | |
4191 | guerimand | 165 | !restart module=adm/vote&job=read&vote=$vote |