Subversion Repositories wimsdev

Rev

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