Subversion Repositories wimsdev

Rev

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