Subversion Repositories wimsdev

Rev

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
12479 bpr 2
  error=bad_vote
3
  job=home
4
  !changeto home.proc
23 reyssat 5
!endif
6
 
7
!readdef $userfile
8
!if $(user_vote_$Vote)=$empty and $(user_vote_$vote)!=$empty
12479 bpr 9
  user_vote_$Vote=$(user_vote_$vote)
23 reyssat 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
12479 bpr 16
  error=already_voted
17
  !exit
23 reyssat 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
12479 bpr 29
  !advance vcnt
30
  voteset=vcnt=$vcnt
23 reyssat 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
12479 bpr 37
  !if $(vote_description[$t;2])=textarea
38
    !if $vote_option!=nominative
39
      tt = !singlespace $(parm$t)
40
      tt = !char 1 to $limit_textarea of $tt
41
      !appendfile $votedir/$(vote)_$t.comments :$tt
42
    !endif
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
23 reyssat 65
  !endif
66
!next t
67
 
217 bpr 68
 
69
# paramcnt: nombre de questions
70
 
71
 
23 reyssat 72
!if $vote_option=anonymous
12479 bpr 73
  user_vote_$Vote=yes
23 reyssat 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
 
12479 bpr 93
  tt=$empty
94
  !for t=1 to $parmcnt
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
100
        !for v in $old
101
          vv=!replace item $option by $ in $(votes_$(t)_$v)
102
          vv=!nonempty items $vv
103
          voteset=!append line votes_$(t)_$v=$vv to $voteset
104
          votes_$(t)_$v=$vv
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
112
      !next v
113
    !else
114
      tt=!append item 0 to $tt
115
    !endif
116
  !next t
117
  !if $vote_option=trace
118
    user_vote_$Vote=yes
4191 guerimand 119
  !else
12479 bpr 120
    user_vote_$Vote=$tt
217 bpr 121
  !endif
23 reyssat 122
!endif
123
 
124
!setdef !set user_vote_$Vote=$(user_vote_$Vote) in $userfile
125
!if $voteset!=$empty
12479 bpr 126
  !setdef $voteset in $votedir/$vote.votes
23 reyssat 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
 
23 reyssat 133
ccc=!itemcnt $uvcnt
10146 guerimand 134
!if $ccc>0
12479 bpr 135
  !readproc adm/vfilter/listvarfilter.proc
136
  !for i=1 to $ccc
137
    uvc=!item $i of $uvcnt
138
    uvn=!item $i of $uvname
139
    !! no registery if the technical variable is not already defined
140
    !if $uvn isitemof $tv_listlocalcode
10146 guerimand 141
      uvv=!line $i of $uvval
142
      uvv=!item $(parm$uvc)+1 of $uvv
12479 bpr 143
      !! check if the value exists for this technical variable (only defined values can be save in user .def file)
10736 guerimand 144
      po=!positionof item $uvn in $tv_listcode
10146 guerimand 145
      don=!line $po of $tv_listtechvar
146
      !distribute item $don into name,classid,number
147
      don=!record $number of wimshome/log/classes/$wims_class/.techvar
148
      don=!line 2 of $don
149
      !if $uvv notitemof $don
14335 bpr 150
        uvv=$empty
10146 guerimand 151
      !endif
10702 guerimand 152
      classid=!replace internal / by _ in $classid
10736 guerimand 153
      !setdef !set user_techvar_$(uvn)=$uvv in $userfile
12479 bpr 154
    !endif
155
  !next i
10146 guerimand 156
!endif
4191 guerimand 157
!! -------------------------------------------
23 reyssat 158
 
4191 guerimand 159
!restart module=adm/vote&job=read&vote=$vote