Subversion Repositories wimsdev

Rev

Rev 576 | Rev 4197 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

!if $vote_status!=1
 error=bad_vote
 job=home
 !changeto home.proc
!endif

!readdef $userfile
!if $(user_vote_$Vote)=$empty and $(user_vote_$vote)!=$empty
    user_vote_$Vote=$(user_vote_$vote)
!endif

# pour un questionnaire tracé ou anonyme on interdit de 
# modifier son vote.

!if $vote_option!=nominative and $(user_vote_$Vote)!=$empty
 error=already_voted
 !exit
!endif

!readdef $votedir/$vote.votes

!readdef $votedir/$vote.comments
quote="
!for t=1 to $parmcnt
  !if $vote_option!=nominative and $(type_comment$t)=yes
    tt = !singlespace $(parm$t)
    tt = !char 1 to 600 of $tt
    !appendfile $votedir/$(vote)_$t.comments :$tt
!!    tt = !append item ---$quote($tt)$quote to $(comment_$t)
!!    tt = !char 1 to 24000 of $tt
!!    !setdef comment_$t=$tt in $votedir/$vote.comments
!!    !setdef comment_$t=yes in $votedir/$vote.comments
  !endif
!next t
voteset=
!if $(user_vote_$Vote)=$empty
 !advance vcnt
 voteset=vcnt=$vcnt
!endif

# on récupère le nombre de votes déjà exprimés
nbvotes=$vcnt

!for t=1 to $parmcnt
 !for k=0 to $(choices$t)
  vc_$k=$(vcnt_$(t)_$k)
 !next k
 !bound parm$t between integer 1 and $(choices$t) default 0
 !default vc_$(parm$t)=0
 !advance vc_$(parm$t)
 old=!item $t of $(user_vote_$Vote)
 !for v in $old
  vc_$v=$[max(0,$(vc_$v)-1)]
 !next v
 !for k=0 to $(choices$t)
  !default vc_$k=0
  !if $(vc_$k) != $(vcnt_$(t)_$k)
   voteset=!append line vcnt_$(t)_$k=$(vc_$k) to $voteset
  !endif
 !next k
!next t


# paramcnt: nombre de questions


!if $vote_option=anonymous
 user_vote_$Vote=yes
!else
  # nouvelle option pour le tracage des reponses.
  # on ne garde pas le nom du votant mais on lui donne un numéro qui
  # est égal au nombre de votes exprimés.
  # 
  # comme on est dans le ELSE du anonymous, on n'a plus que 2 choix possibles:
  #   nominatif ou tracage
  # d'où le IF/ELSE simple
  # si un autre cas devait être intégré il faudrait faire un test un peu plus poussé
  
  # la partie du fichier obtenu est de la forme vote
  option=$empty

  !if $vote_option iswordof nominative
    option=$wims_class/$wims_user
  !else
    option=$nbvotes
  !endif

 tt=
 !for t=1 to $parmcnt
  !if $(type_comment$t)!=yes
   old=!item $t of $(user_vote_$Vote)
    !for v in $old
     vv=!replace item $wims_class/$wims_user by $ in $(votes_$(t)_$v)
     vv=!nonempty items $vv
     voteset=!append line votes_$(t)_$v=$vv to $voteset
     votes_$(t)_$v=$vv
   !next v
   tt=!append item $(parm$t) to $tt

#  vv=!append item $wims_class/$wims_user to $(votes_$(t)_$(parm$t))
   vv=!append item $option to $(votes_$(t)_$(parm$t))

   voteset=!append line votes_$(t)_$(parm$t)=$vv to $voteset
  !endif
 !next t
 !if $vote_option=trace
  user_vote_$Vote=yes
 !else
  user_vote_$Vote=$tt
 !endif
!endif

!setdef !set user_vote_$Vote=$(user_vote_$Vote) in $userfile
!if $voteset!=$empty
 !setdef $voteset in $votedir/$vote.votes
!endif

ccc=!itemcnt $uvcnt
!for i=1 to $ccc
 uvc=!item $i of $uvcnt
 uvn=!item $i of $uvname
 uvv=!line $i of $uvval
 uvv=!item $(parm$uvc)+1 of $uvv
 !setdef !set user__$uvn=$uvv in $userfile
!next uv

job=read
!changeto read.proc