Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
217 bpr 1
 
2
sec=!defof class_secure in wimshome/log/classes/$wims_class/.def
3
sec=!trim $sec
4
htest=!checkhost $sec
5
!if $wims_sup_secure<0 or ($sec!=$empty and $htest<1)
6
 error=not_secure
7
 !exit
8
!endif
9
 
10
!!typename=!defof class_typename in wimshome/log/classes/$wims_class/.def
11
!!classtype=!defof class_type in wimshome/log/classes/$wims_class/.def
12
 
13
!bound csvformat within xls,csv,tsv default xls
14
!if $csvtype!=download
15
 !exit
16
!endif
17
!if $vote>0
18
  parmcnt=0
19
  !read $votedir/$vote.def
20
 quote="
248 bpr 21
 sep_csv=;
22
 sep_xls=;
217 bpr 23
 sep_tsv=$	$
24
 sep=$(sep_$csvformat)
25
 !default sep=$(sep_xls)
26
 fbase=data-$wims_class-vote-$vote
27
 fbase=!translate internal / to _ in $fbase
28
 fname=wimshome/$wims_sesdir/spreadsheet.$csvformat
7198 bpr 29
 
217 bpr 30
 tit="$title_vote $vote"
31
 !writefile $fname $tit\
7198 bpr 32
 
217 bpr 33
 !readdef $votedir/$vote.votes
34
 !readdef $votedir/$vote.comments
35
 
36
 !if $vote_option=anonymous or $csvoption=global
37
### en ligne les questions, en colonne le nombre de votants pour chaque réponse
38
  tableau=
39
  maxchoice=1
40
  !for t = 1 to $parmcnt
41
    maxchoice=$[max($maxchoice, $(choices$t))]
42
    line=Q.$t _
43
    !if $(type_comment$t)!=yes
44
     !for r = 0 to $[$(choices$t)]
45
      line=!append item _ $(vcnt_$(t)_$(r)) _ to $line
46
     !next
47
    !endif
48
    tableau =!append line $line to $tableau
49
    prel=!makelist _ $name_choice x _ for x = 0 to $maxchoice
50
  !next
51
  tableau=_,$prel\
52
$tableau
53
  !goto end
7198 bpr 54
!endif
217 bpr 55
!if $vote_option=trace
56
 tableau=!makelist x for x = 1 to $vcnt
57
 tableau=!replace internal , by ; in $tableau
58
 tableau=!rows2lines $tableau
59
 line=!makelist _0_ for x=1 to $parmcnt
60
 !for u = 1 to $vcnt
61
    tableau=!replace line number $u by "$u"_,_$line in $tableau
62
 !next
63
 !for t = 1 to $parmcnt
64
  !if $(type_comment$t)!=yes
65
   !for l = 0 to $[$(choices$t)]
66
     v=$(votes_$(t)_$l)
67
     v1=!itemcnt $v
68
     !if $v1>0
69
      !for h = 1 to $v1
7198 bpr 70
       line=!line $(v[$h]) of $tableau
217 bpr 71
       line=!replace item number $[$t+1] by _$(l)_ in $line
72
       tableau=!replace internal line number $(v[$h]) by $line in $tableau
73
      !next
74
     !endif
75
   !next
76
  !else
576 bpr 77
    cnt_prov=!itemcnt $(comment_$(t))
217 bpr 78
    !for u = 1 to $vcnt
79
       line=!line $u of $tableau
576 bpr 80
 ### changement de format - transitoire
81
       !if $u <= $cnt_prov
82
         c=!declosing $(comment_$(t)[$u])
83
       !else
84
         uprov=$[$u-$cnt_prov]
85
         c=!record $uprov of $votedir/$(vote)_$t.comments
86
       !endif
87
       c=!replace internal ; by -- in $c
88
       c=!replace internal , by - in $c
217 bpr 89
       line=!replace item number $[$t+1] by _$c _ in $line
90
       tableau=!replace internal line number $u by $line in $tableau
91
    !next
92
  !endif
93
 !next
94
 entete= !makelist _ Q.x _ for x=1 to $parmcnt
95
 tableau=_,$entete\
96
 $tableau
97
!endif
98
 
99
!if $vote_option=nominative
100
 tableau=!makelist x for x = 1 to $vcnt
101
 tableau=!replace internal , by ; in $tableau
102
 tableau=!rows2lines $tableau
103
 line=!makelist _0_ for x=1 to $parmcnt
104
 !for u = 1 to $vcnt
105
  tableau=!replace line number $u by "$u"_,_$line in $tableau
106
 !next
107
 cmp=0
108
 !for t = 1 to $parmcnt
109
  !if $(type_comment$t)!=yes
110
   !for l = 0 to $[$(choices$t)]
111
    v=$(votes_$(t)_$l)
112
    v1=!itemcnt $v
113
    !if $v1>0
114
     !for h = 1 to $v1
115
      !if supervisor/ notin $(v[$h])/
116
       u=!replace internal / by _ in $(v[$h])
117
       u=!replace internal @ by ___ in $u
118
       !if $(cnt_$u)=
119
        cmp=$[$cmp+1]
120
        cnt_$u=$cmp
121
        item1=$u
122
       !endif
7198 bpr 123
       line=!line $(cnt_$u) of $tableau
217 bpr 124
       line=!replace item number 1 by $(v[$h])_ in $line
125
       line=!replace item number $[$t+1] by _$(l)_ in $line
126
       tableau=!replace internal line number $(cnt_$u) by $line in $tableau
127
      !endif
128
     !next
129
    !endif
130
   !next
131
 !endif
132
!next
133
entete= !makelist _ Q.x _ for x=1 to $parmcnt
134
 tableau=_,$entete\
135
 $tableau
136
 !goto end
137
!endif
7198 bpr 138
 
217 bpr 139
:end
140
tableau=!replace internal _,_ by $sep in $tableau
2255 bpr 141
!! !! the following messes up with username containing _
142
!! !! testing!
143
!!tableau=!replace internal _ by  in $tableau
217 bpr 144
tableau=!replace internal --- by  in $tableau
7198 bpr 145
 
217 bpr 146
!appendfile $fname $tableau
147
 
148
infile=spreadsheet.$csvformat
149
outfile=$fbase.$csvformat
150
!mexec csv/getprep.sh
151
!endif
152
 
153
!reset csvtype
154