Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
14297 guerimand 1
# Variable calculations should be done in this file.
2
# It is read and interpreted by wims for all valid calls to the module.
3
 
14775 guerimand 4
!! --- securise variable
5
wims_prefix=class user
6
!!wims_writable=
7
!!wims_readable=
8
 
14297 guerimand 9
!if $notallowed=1
10
  error=notallowedmodule
11
  !exit
12
!endif
13
 
14537 guerimand 14
!! file number to read in function of type
16307 guerimand 15
lpara_type=1,1,3
16
listfilename_ztype=geogebra,texte,file,wimsexo
14537 guerimand 17
nbztype=!itemcnt $listfilename_ztype
18
 
14297 guerimand 19
!! check access
20
!if $statutfreework!=open
21
  !restart module=home
22
!endif
23
 
24
!read adm/language lang/names.phtml
25
 
14339 guerimand 26
tmp=!defof MAX_FREEWORKS\
27
MAX_USERFORGRADES in wimshome/public_html/bases/sys/define.conf
28
!distribute line $tmp into max_freeworks,max_userforgrades
14796 guerimand 29
title_limit=50
30
desc_limit=2000
31
textezone_limit=10000
14297 guerimand 32
 
14339 guerimand 33
!if $cmd=help
34
  !exit
35
!endif
36
 
14901 guerimand 37
!! initializing counter for opening file in popup window
38
windowfilenumber=0
39
 
14297 guerimand 40
!if $class_expiration=$empty
41
  !defread wimshome/log/classes/$wims_class/.def
42
  !if $wims_superclass!=$empty
43
    class_expiration=!defof class_expiration in wimshome/log/classes/$wims_superclass/.def
44
  !endif
45
!endif
46
 
47
!if $class_expiration=$empty
48
  error=bad_class
49
  !exit
50
!endif
51
 
52
jquery_defined=!defof jquery_defined in wimshome/public_html/themes/$class_theme/header.phtml
53
 
54
!if $cmd=resume and $jquery_defined!=yes
55
  !for k in infoshow1,infoshow2
56
    !bound $k within yes,no default yes
57
    !if $(wims_$k)!=$($k)
58
      wims_$k=$($k)
59
      !setdef wims_$k=$($k) in wimshome/session/$wims_session/var.stat
60
    !endif
61
  !next k
62
!endif
63
 
64
!! ------ check job function of user right
65
!if $wims_user=supervisor
16307 guerimand 66
  listjob=configfw,prep_activate,expire,hide,reactivate,deactivate,prep_erase,uploadco,savescore,viewuser3,uploadco3,archive,student,exocheck,addexo,directexo,delexo
14297 guerimand 67
  defjob=configfw
68
!else
16087 guerimand 69
  listjob=student,exolog,exocheck,directexo
14537 guerimand 70
  defjob=student
14297 guerimand 71
!endif
72
!bound job within $listjob default $defjob
73
 
74
today=!char 1 to 8 of $wims_now
75
!! --------- read general data of the freework
76
nbfreework=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freeworks
16087 guerimand 77
!if $job=addexo
78
  !changeto $job.proc
79
!endif
14297 guerimand 80
!if $wims_user=supervisor
81
  !if $job=configfw
82
    !bound freework between 1 and $[$nbfreework+1] default $[$nbfreework+1]
83
  !else
84
    !bound freework between 1 and $nbfreework default 1
85
  !endif
86
!else
14537 guerimand 87
  !reset save
14297 guerimand 88
  !bound freework between 1 and $nbfreework default 1
89
!endif
90
!if $freework>$max_freeworks
91
  error=bad_maxfreework
92
  !exit
93
!endif
94
 
14537 guerimand 95
!! --------   make manual score index
14339 guerimand 96
  uucnt=!recordcnt wimshome/log/classes/$wims_class/.grades
97
  !if $uucnt>0
98
    !! --- check for column for score
99
    tmp=!record 1 of wimshome/log/classes/$wims_class/.grades
100
    !distribute line $tmp into bl,score_title,bl
101
    score_title=!item 3 to -1 of $score_title
102
    nbscore=!itemcnt $score_title
103
    !! --- check for score key for each user
104
    uucnt=$[$uucnt-1]
105
    !for i=1 to $uucnt
106
      u_=!record $i+1 of wimshome/log/classes/$wims_class/.grades
107
      n_=!item 1 of $u_
108
      uulist=!append item $n_ to $uulist
109
    !next i
110
  !else
111
    nbscore=0
112
  !endif
14537 guerimand 113
!  ------------ end manual score index
14339 guerimand 114
 
14297 guerimand 115
!if $save=$empty and $freework<=$nbfreework
116
  tmp=!record $freework of wimshome/log/classes/$wims_class/freeworks/.freeworks
14537 guerimand 117
  !distribute line $tmp into activetest,expdate,title,desc,comment,type,deadline,soldate,sizelimitfile,scoring,seealltime
14297 guerimand 118
  !for val in deadline,soldate
119
    t=!replace internal . by , in $($val)
120
    !distribute item $t into $val,time$val
121
    !default $val=$today
122
    !default time$val=00:00
123
  !next val
124
  !bound activetest between 0 and 3
125
!endif
126
 
127
!if $freework>$nbfreework
128
  !default deadline=$today
129
  !default timedeadline=00:00
130
  !default soldate=$today
131
  !default timesoldate=00:01
132
  !default sizelimitfile=4
133
  wims_infoshow1=yes
14889 guerimand 134
  scoring=no
14537 guerimand 135
  seealltime=0
14297 guerimand 136
!endif
137
 
14537 guerimand 138
!! ---------  check variable values
14297 guerimand 139
title=!singlespace $title
14616 guerimand 140
title=!detag $title
14297 guerimand 141
title=!char 1 to $title_limit of $title
142
title=!replace internal : by &#58; in $title
143
 
144
desc=!replace internal $\
145
$ by $ $ in $desc
14636 guerimand 146
desc=!char 1 to $desc_limit of $desc
14297 guerimand 147
desc=!replace internal : by &#58; in $desc
148
 
149
comment=!replace internal $\
150
$ by $ $ in $comment
151
comment=!singlespace $comment
14616 guerimand 152
comment=!detag $comment
14297 guerimand 153
 
15346 guerimand 154
 
155
!! ------- manage activation or not of upload file for student (option manage by wims.conf)
15016 guerimand 156
!if $activetest<1 and $conf_nofile=yes
157
  !bound type within 1,3 default 1
15346 guerimand 158
  listfilename_ztype_teacher=$listfilename_ztype
159
  listfilename_ztype_student=!listcomplement file in $listfilename_ztype
15016 guerimand 160
!else
16307 guerimand 161
  !bound type between 1 and 3 default 1
15346 guerimand 162
  listfilename_ztype_teacher=$listfilename_ztype
163
  listfilename_ztype_student=$listfilename_ztype
15016 guerimand 164
!endif
16307 guerimand 165
listfilename_ztype_student=!listcomplement wimsexo in $listfilename_ztype
15346 guerimand 166
nbztype_teacher=!itemcnt $listfilename_ztype_teacher
167
nbztype_student=!itemcnt $listfilename_ztype_student
168
 
14297 guerimand 169
!if $type=1
170
  sizelimitfile=$empty
171
!else
16307 guerimand 172
  !bound sizelimitfile between 1 and 10 default 4
14788 guerimand 173
  !if $type=3
174
    !! ------ incase of type=3 sizelimitfile=0 if no student filezone
175
    nb=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freework$freework
176
    numberfilezone=0
177
    !for k=1 to $nb
178
      test=!record $k of wimshome/log/classes/$wims_class/freeworks/.freework$freework
179
      test=!line 1 of $test
180
      !distribute word $test into s,z
181
      !if $s=file and $z=student
182
        !increase numberfilezone
183
      !endif
184
    !next k
185
    !if $numberfilezone=0
186
      sizelimitfile=$empty
187
    !endif
188
  !endif
14297 guerimand 189
!endif
190
 
191
!if $jquery_defined!=yes and $save!=$empty
192
  !for k in deadline,soldate
193
    !for l in month,day
14299 guerimand 194
      $(l)$(k)=$[100+$($(l)$(k))]
195
      $(l)$(k)=!char 2 to 3 of $($(l)$(k))
14297 guerimand 196
    !next l
197
  !next k
14299 guerimand 198
  deadline=$yeardeadline$monthdeadline$daydeadline
199
  soldate=$yearsoldate$monthsoldate$daysoldate
14297 guerimand 200
!endif
201
 
202
t=0
203
!for val in deadline,soldate
204
  !! -- check date format
205
  $val=!text select 0123456789 in $($val)
206
  expmon=!char 5 to 6 of $($val)
207
  expday=!char 7 to 8 of $($val)
208
  expyear=!char 1 to 4 of $($val)
209
  expmon=!char 2,3 of $[abs(floor($expmon))+100]
210
  expday=!char 2,3 of $[abs(floor($expday))+100]
211
  expyear=!char -4 to -1 of $[abs(floor($expyear))+100000]
212
  !if $expday>=1 and $expday<=31 and $expmon>=1 and $expmon<=12 \
14335 bpr 213
      and $($val)<=$class_expiration \
214
      and N notin $expmon$expday$expyear
14297 guerimand 215
    $val=$expyear$expmon$expday
216
  !else
217
    $val=$class_expiration
218
  !endif
219
  !! -- check time format
220
  time$val=!text select 0123456789: in $(time$val)
221
  time$val=!replace internal : by , in $(time$val)
222
  nb=!itemcnt $(time$val)
223
  !if $nb=2
224
    !distribute item $(time$val) into h,m
225
    h=$[$h*1]
226
    m=$[$m*1]
227
    !if $h<0 or $h>23 or $m<0 or $m>59 or NaN isin $h$m
228
      time$val=00:0$t
229
    !else
230
      h=!char 2 to 3 of $[100+$h]
231
      m=!char 2 to 3 of $[100+$m]
232
      time$val=$h:$m
233
    !endif
234
  !else
235
    time$val=00:0$t
236
  !endif
237
  !increase t
238
!next val
239
 
14889 guerimand 240
!if $type>=2
241
  v=!values v,-v for v=1 to $nbscore
14936 guerimand 242
  !if $activetest=0
243
    !bound scoring within $v,no,0 default no
244
  !else
245
    !bound scoring within $v,0 default 0
246
  !endif
14537 guerimand 247
  !if $scoring>0
248
    m=!record 0 of wimshome/log/classes/$wims_class/sheets/.severity
249
    maxscore=!word 1 of $m
250
    !bound maxscore between 0 and 100000 default 10
251
  !endif
252
!else
253
  scoring=0
254
!endif
255
!bound seealltime between 0 and 1 default 0
14297 guerimand 256
 
14537 guerimand 257
!! ----------- end check general variable
14297 guerimand 258
 
14960 guerimand 259
!! -------------- check right for download/upload participant file and etc...
14990 czzmrn 260
!readproc proc/mkglobalvar.proc
14297 guerimand 261
 
14947 guerimand 262
!! ------- read existant file for subject/solution
263
nb=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freework$freework
264
!reset flistsolution,flistsubject
265
!for k=1 to $nb
266
  dt=!record $k of wimshome/log/classes/$wims_class/freeworks/.freework$freework
267
  !if $(dt[1;]) isitemof subject,solution
268
    flist$(dt[1;])=!line 2 to -1 of $dt
269
    flist$(dt[1;])=!nonempty line $(flist$(dt[1;]))
270
    flist$(dt[1;])=!lines2items $(flist$(dt[1;]))
271
    field_$(dt[1;])=$k
272
  !endif
273
!next k
14537 guerimand 274
 
14297 guerimand 275
!! ------ make file link for download and some title
276
!if $wims_user=supervisor
277
  !if $freework>$nbfreework
278
    activetest=-1
279
    name_title=$name_tmkfreework
280
  !else
281
    name_title=$name_managefreework
282
  !endif
14537 guerimand 283
  !if $activetest>=0 and $type<=3
14297 guerimand 284
    !sh cd $wims_home/$wims_sesdir;\
285
       mkdir -p getfile;\
286
       cd getfile;\
287
       mkdir -p freeworks;\
288
       cd freeworks;\
289
       rm -f $freework;\
290
       ln -s $wims_home/log/classes/$wims_class/freeworks/$freework $freework;
291
  !endif
292
!else
293
  name_title=!nosubst $wims_name_Freework $freework
294
  !if $activetest>=1
14537 guerimand 295
    !if $displaysolution=1
296
      flist=!listunion $flistsolution and $flistsubject
14297 guerimand 297
    !else
14537 guerimand 298
      flist=$flistsubject
14297 guerimand 299
    !endif
14537 guerimand 300
    flist=!nonempty item $flist
301
    flist=!listuniq $flist
14297 guerimand 302
    flist=!items2words $flist
303
  !endif
304
  !if $flist!=$empty
305
    testfile=!word 1 of $flist
306
    test=!fileexists wimshome/sessions/$wims_session/getfile/freeworks/$freework/$testfile
307
    !if $test!=yes
308
      !sh cd $wims_home/$wims_sesdir;\
309
         mkdir -p getfile;\
310
         cd getfile;\
311
         rm -rf freeworks;\
312
         mkdir -p freeworks;\
313
         cd freeworks;\
314
         mkdir $freework;\
315
         cd $freework;\
316
         for k in $flist; do\
317
           ln -s $wims_home/log/classes/$wims_class/freeworks/$freework/$$k $$k;\
318
         done;
319
    !endif
320
  !endif
321
  !sh mkdir -p $wims_home/sessions/$wims_session/getfile/freeworksdata
322
!endif
323
 
324
!read lang.phtml.$lang
14537 guerimand 325
!if $job=student
326
  job=student$(lpara_type[$type])
327
!endif
14297 guerimand 328
!changeto $job.proc