Subversion Repositories wimsdev

Rev

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