Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
10368 bpr 1
 
2691 czzmrn 2
quote="
3
fbase=data-$wims_class
4
fbase=!translate internal / to _ in $fbase
5
fname=wimshome/$wims_sesdir/spreadsheet.$csvformat
6
dl=!singlespace $csvdownload
10516 guerimand 7
!! no needed because no keyword are now directly writing and incompatible with techvar code name
8
!!dl=!lower $dl
9513 bpr 9
!if login notin $dl
10
  dl=login,$dl
11
!endif
2691 czzmrn 12
!for t in average,sheet,exam,manual
12467 bpr 13
  dl=!replace $t $ by $t in $dl
2691 czzmrn 14
!next t
15
dl=!items2words $dl
16
dl=!replace word names by name in $dl
17
dl=!replace grade by manual in $dl
18
dl=!replace word allscores by allscore in $dl
19
dl=!replace word name by lastname firstname in $dl
20
dl=!replace word allscore by averages sheets exams manuals in $dl
7364 bpr 21
dl_tmp=$dl
2691 czzmrn 22
 
8452 guerimand 23
!readproc csv/keyword.proc
9909 obado 24
 
9513 bpr 25
tmp=!column 2 to -1 of $se
26
tmp=!lines2words $tmp
27
tmp=!items2words $tmp
28
tmp=!singlespace $tmp
29
 
11145 bpr 30
good=$basic $av $sh $ex $ma $examduration $tmp $basic2 $basic3
9719 bpr 31
tmp=!column 2 to -1 of $exe
32
 
33
tmp=!lines2words $tmp
34
tmp=!items2words $tmp
35
tmp=!singlespace $tmp
36
good=$good $tmp
37
 
2691 czzmrn 38
dl=!replace word averages by $av in $dl
39
dl=!replace word sheets by $sh in $dl
40
dl=!replace word exams by $ex in $dl
41
dl=!replace word manuals by $ma in $dl
8452 guerimand 42
!if sheetexos isin $dl
14088 bpr 43
  tmp=!column 2 to -1 of $se
44
  tmp=!lines2words $tmp
45
  dl=!replace word sheetexos by $tmp in $dl
8452 guerimand 46
!else
47
  !for i in $activesh
48
    !if sheetexo$i iswordof $dl
9513 bpr 49
      tmp=!select $se where column 1 = $i
50
      dl=!replace word sheetexo$i by $(tmp[2..-1]) in $dl
8452 guerimand 51
      dl=!replace word sheetexo$i by  in $dl
52
    !endif
53
  !next i
54
!endif
7364 bpr 55
 
9719 bpr 56
!! aoption all for examexos, non active
57
!!!if examexos isin $dl
58
!! tmp=!column 2 to -1 of $exe
59
!! tmp=!lines2words $tmp
60
!! dl=!replace word examexos by $tmp in $dl
61
!!!else
12467 bpr 62
!for i in $activexams
15602 bpr 63
  !set nb_ses$i=!record $i of wimshome/log/classes/$wims_class/exams/.exams
64
  !set nb_ses$i=!line 3 of $(nb_ses$i)
65
  !set nb_ses$i=!word 2 of $(nb_ses$i)
12467 bpr 66
  !if examexo$i iswordof $dl
67
    tmp=!select $exe where column 1 = $i
68
    dl=!replace word examexo$i by $(tmp[2..-1]) in $dl
69
    dl=!replace word examexo$i by  in $dl
70
  !endif
71
!next i
9719 bpr 72
!!!endif
2691 czzmrn 73
dl=!words2items $dl
74
dl=!listuniq $dl
9719 bpr 75
 
10382 guerimand 76
good=!words2items $good,$regvarlist
10383 bpr 77
!! only techvar should be in dl_v other variable have to stay in good
78
!! (generic traitement for name)
2691 czzmrn 79
dl_v =!listcomplement $good in $dl
80
!if $dl_v!=
10378 guerimand 81
  dl_var=$empty
82
  !for k in $dl_v
10382 guerimand 83
    realname=!replace internal techvar_ by $empty in $k
84
    dl_var=!append item $(code_user_techvar_$(realname)) to $dl_var
10378 guerimand 85
  !next k
2691 czzmrn 86
!endif
87
dl=!listintersect $dl and $good
88
dl=!nospace $dl
89
dl_var=!nospace $dl_var
90
dl_v=!nospace $dl_v
91
dlcnt=!itemcnt $dl
92
!if $dlcnt=0
14088 bpr 93
  !exit
2691 czzmrn 94
!endif
10044 georgesk 95
 
2691 czzmrn 96
sep_csv=,
10044 georgesk 97
sep_ods=;
10940 obado 98
sep_xls=;
2691 czzmrn 99
sep_tsv=$	$
100
sep=$(sep_$csvformat)
101
dl2=!replace , by ,user_ in user_$dl
102
dl2=!translate , to $sep in $dl2
10017 guerimand 103
 
104
!if $dl_var!=$empty
12467 bpr 105
  dl4=!replace , by ,user_ in user_$dl_v
106
  dl4=$sep$dl4
107
  dl5=$sep$dl5
108
  dl=$dl$sep$dl_var
2691 czzmrn 109
!endif
10017 guerimand 110
 
2691 czzmrn 111
tit=!translate , to $sep in $dl
15602 bpr 112
!for i=1 to $examcnttot
113
  tmp=!makelist : for x=1 to $(nb_ses$i)
114
  tmp=!items2words $tmp
115
  tit=!replace internal exam$i by exam$i$tmp$ in $tit
116
!next
10383 bpr 117
!! quote the values (case of word groups)
10405 bpr 118
!for n in login,password,lastname,firstname,email,regnum,comments,\
10383 bpr 119
  participate,supervise,supervisable,external_auth,average0,average1,average2
120
  dl2=!replace user_$n by $(quote)user_$n$quote in $dl2
2691 czzmrn 121
!next n
10405 bpr 122
!if $regvarlist!=$empty
123
  !for n in $regvarlist
124
    dl2=!replace user_$n by $(quote)user_$n$quote in $dl2
125
  !next n
126
!endif
10021 guerimand 127
dl4r=!items2words $dl4
10017 guerimand 128
!if $dl4!=$empty
12467 bpr 129
  dl4=!replace , by $(quote),$(quote) in $(quote)$dl4$(quote)
130
  dl4=!char 3 to -1 of $dl4
131
  dl5=!replace user_ by $$name_user_ in $dl4
132
  dl4=!replace user_ by $$user_ in $dl4
10017 guerimand 133
!else
12467 bpr 134
  dl5=$empty
10017 guerimand 135
!endif
2691 czzmrn 136
dl3=!replace user_ by $$name_ in $dl2
137
dl2=!replace user_ by $$user_ in $dl2
10005 guerimand 138
 
2691 czzmrn 139
scores=no
140
!if average isin $dl or manual isin $dl or sheet isin $dl or exam isin $dl
12467 bpr 141
  scores=yes
2691 czzmrn 142
!endif
143
 
9909 obado 144
!read csv/csvnames
2691 czzmrn 145
!writefile $fname $tit\
146
$dl3$dl5\
147
 
9912 obado 148
!reset data_scores
2691 czzmrn 149
!for u=1 to $usercnt
12467 bpr 150
  !! reinitialise variables of type user_
151
  !reset user_lastname,user_firstname,user_email,user_regnum,user_comments,\
152
      user_external_auth,user_supervise,user_participate,user_supervisable
153
  !for n in $regvarlist
154
    !reset user_$n
155
  !next
156
  l=!record $u of wimshome/log/classes/$wims_class/.userlist
157
  user_login=!item 3 of $l
158
  uu=$user_login
159
  uuu=!hex $uu
160
  !reset $basic,$dl4r
161
  !read adm/class/userdef classes,$wims_class,$user_login
162
  !defread $userdef
163
  user_participate=!items2words $user_participate
164
  user_supervise=!items2words $user_supervise
165
  !if $scores=yes
166
    !read adm/class/userscore $uu
167
    user_average1=$per
168
    user_average2=$(manual_$uuu)
169
    !if average0 isitemof $dl
170
      user_average0=$[rint($manual*$user_average2+(100-$manual)*($per))/100]
2691 czzmrn 171
    !endif
12467 bpr 172
    !for i=1 to $sheetcnttot
173
      !if sheet$i isitemof $dl and $i isitemof $activesh
174
        p_=!line $i of $percents
175
        !distribute words $p_ into p1,p2,p3,p4
176
        !if $p2!=$empty
177
          ###f_$i is defined by var.proc.weights
178
          !distribute item $[$p1/100],$[$p2/10],$[$p3/100],$[$p4/100] into x0_,y_,x1_,x2_
179
          !set ff_$i=!mathsubst Q=$y_ in $(f_$i)
180
          !for sev=0 to 2
181
            !set ff_$i=!mathsubst I$sev=$(x$(sev)_) in $(ff_$i)
182
          !next
183
          user_sheet$i=$[rint(100*$scoremax*$(ff_$i))/100]
184
        !else
185
          user_sheet$i=0
186
        !endif
187
      !endif
188
    !next i
189
    !for i=1 to $sheetcnttot
190
      !if sheet$(i)_exo isin $dl and $i isitemof $activesh
191
        !let e_=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$i
192
        !for k_ = 1 to $e_
193
          d_=!getscore user=$uu sheet=$i work=$k_
194
          dd_=!getscorerequire user=$uu sheet=$i work=$k_
195
          m_=!getscoremean user=$uu sheet=$i work=$k_
196
          b_=!getscorebest user=$uu sheet=$i work=$k_
197
          l_=!getscorelevel user=$uu sheet=$i work=$k_
198
          user_sheet$(i)_exo_$(k_)_Q=$[$m_]
199
          user_sheet$(i)_exo_$(k_)_I0=$[ceil(100*$d_/$dd_)]
200
          user_sheet$(i)_exo_$(k_)_I1=$[ceil(100*$b_/$dd_)]
201
          user_sheet$(i)_exo_$(k_)_I2=$[$l_]
202
        !next k_
203
      !endif
204
    !next
15602 bpr 205
    !if _exexo_ isin $dl or examduration isin $dl or exam isin $dl
12467 bpr 206
      logdir=$wims_home/log/classes/$wims_class/examlog/$uu
207
      checksessions=!sh if [ -d $logdir ]; then cd $logdir; ls -tr; fi
208
      checksessions=!words2items $checksessions
209
      !read adm/class/userscore1 $uu
210
    !endif
211
    !for i=1 to $examcnttot
212
      !if exam$i isitemof $dl and $i isitemof $activexams
213
        user_exam$i=$[rint(10*$scoremax*$(es_$i))/100]
15602 bpr 214
        !set tmp=!listuniq $(sess_$i)
215
        !for j in $tmp
15607 bpr 216
          !set user_exam$i=$(user_exam$i):$[rint(10*$scoremax*$(score$(j)_$i))/100]
15602 bpr 217
        !next
218
        !set tmp=!itemcnt $tmp
219
        !for j= $tmp+1 to $(nb_ses$i)
220
          !set user_exam$i=$(user_exam$i):
221
        !next
12467 bpr 222
      !endif
223
      !if examduration$i isitemof $dl and $i isitemof $activexams
224
        user_examduration$i=!replace internal , by $ $ in $quote$(Dureeexam_$i)$quote
225
      !endif
226
      !if exam$(i)_exexo isin $dl and $i isitemof $activexams
227
        !set nb_ses=!record $i of wimshome/log/classes/$wims_class/exams/.exams
228
        !set nb_ses=!line 3 of $nb_ses
229
        !set nb_ses=!word 2 of $nb_ses
230
        !let e_=!recordcnt wimshome/log/classes/$wims_class/exams/.exam$i
231
        !set checksessions_cnt=!itemcnt $checksessions
232
        !for k_ = 1 to $e_
233
          !reset t_
234
          !set n_ses=0
235
          !for ses=1 to $checksessions_cnt
236
            !if $i isitemof $(exam_$ses)
237
              !set tmp=$(Exam_$(i)_$ses)
10019 bpr 238
            !set t_=$t_$(tmp[$k_]),
239
            !increase n_ses
12467 bpr 240
            !endif
241
          !next
242
          !set t_=$(t_[1..-2])
243
          !if $nb_ses>$n_ses
244
            !set oo=!makelist $ $ for x=1 to $[$nb_ses-$n_ses-1]
245
            !! leave the space ! useful for some spreadsheet
246
            !set t_=$t_ ,$oo
9719 bpr 247
          !endif
12467 bpr 248
          !set user_exam$(i)_exexo_$(k_)=!replace internal , by : in $t_
9719 bpr 249
        !next
12467 bpr 250
      !endif
14088 bpr 251
    !next i
12467 bpr 252
    !for i=1 to $gcnt
253
      !if manual$i isitemof $dl
254
        user_manual$i=!item $i of $(Manual_$uuu)
14341 guerimand 255
!!        !default user_manual$i=0    can have no score and don't replace by 0
12467 bpr 256
      !endif
257
    !next i
258
  !endif
259
  tmp=!trim $dl4
260
  !appendfile $fname $dl2$tmp
261
  data_scores=!append item $dl2$tmp to $data_scores
2691 czzmrn 262
!next u
263
 
10941 bpr 264
infile=spreadsheet.$csvformat
265
outfile=$fbase.$csvformat
10940 obado 266
!if $csvformat iswordof ods
12467 bpr 267
  !! it is format ods
268
  !mexec csv/mkODS.py
10044 georgesk 269
!else
12467 bpr 270
  !! it is format csv/tsv/xls
271
  !mexec csv/getprep.sh
10044 georgesk 272
!endif