Subversion Repositories wimsdev

Rev

Rev 7198 | Rev 15753 | 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)
12479 bpr 6
  error=not_secure
7
  !exit
217 bpr 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
12479 bpr 15
  !exit
217 bpr 16
!endif
17
!if $vote>0
18
  parmcnt=0
19
  !read $votedir/$vote.def
12479 bpr 20
  quote="
21
  sep_csv=;
22
  sep_xls=;
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
 
12479 bpr 30
  tit="$title_vote $vote"
31
  !writefile $fname $tit\
7198 bpr 32
 
12479 bpr 33
  !readdef $votedir/$vote.votes
34
  !readdef $votedir/$vote.comments
217 bpr 35
 
12479 bpr 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\
217 bpr 52
$tableau
12479 bpr 53
    !goto end
54
  !endif
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
217 bpr 60
    !for u = 1 to $vcnt
12479 bpr 61
      tableau=!replace line number $u by "$u"_,_$line in $tableau
217 bpr 62
    !next
12479 bpr 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
70
              line=!line $(v[$h]) of $tableau
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
77
        cnt_prov=!itemcnt $(comment_$(t))
78
        !for u = 1 to $vcnt
79
          line=!line $u of $tableau
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
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
217 bpr 97
  !endif
98
 
12479 bpr 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
123
                line=!line $(cnt_$u) of $tableau
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
217 bpr 131
      !endif
12479 bpr 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
 
12479 bpr 139
  :end
140
  tableau=!replace internal _,_ by $sep in $tableau
141
  !! !! the following messes up with username containing _
142
  !! !! testing!
143
  !!tableau=!replace internal _ by  in $tableau
144
  tableau=!replace internal --- by  in $tableau
7198 bpr 145
 
12479 bpr 146
  !appendfile $fname $tableau
217 bpr 147
 
12479 bpr 148
  infile=spreadsheet.$csvformat
149
  outfile=$fbase.$csvformat
150
  !mexec csv/getprep.sh
217 bpr 151
!endif
152
 
153
!reset csvtype