Subversion Repositories wimsdev

Rev

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