Subversion Repositories wimsdev

Rev

Rev 10702 | Rev 12479 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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