Subversion Repositories wimsdev

Rev

Rev 17636 | 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
 
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)
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
14297 guerimand 331
    !sh cd $wims_home/$wims_sesdir;\
332
       mkdir -p getfile;\
333
       cd getfile;\
334
       mkdir -p freeworks;\
335
       cd freeworks;\
336
       rm -f $freework;\
337
       ln -s $wims_home/log/classes/$wims_class/freeworks/$freework $freework;
338
  !endif
339
!else
340
  name_title=!nosubst $wims_name_Freework $freework
341
  !if $activetest>=1
14537 guerimand 342
    !if $displaysolution=1
343
      flist=!listunion $flistsolution and $flistsubject
14297 guerimand 344
    !else
14537 guerimand 345
      flist=$flistsubject
14297 guerimand 346
    !endif
14537 guerimand 347
    flist=!nonempty item $flist
348
    flist=!listuniq $flist
14297 guerimand 349
    flist=!items2words $flist
350
  !endif
351
  !if $flist!=$empty
352
    testfile=!word 1 of $flist
353
    test=!fileexists wimshome/sessions/$wims_session/getfile/freeworks/$freework/$testfile
354
    !if $test!=yes
355
      !sh cd $wims_home/$wims_sesdir;\
356
         mkdir -p getfile;\
357
         cd getfile;\
358
         rm -rf freeworks;\
359
         mkdir -p freeworks;\
360
         cd freeworks;\
361
         mkdir $freework;\
362
         cd $freework;\
363
         for k in $flist; do\
364
           ln -s $wims_home/log/classes/$wims_class/freeworks/$freework/$$k $$k;\
365
         done;
366
    !endif
367
  !endif
368
  !sh mkdir -p $wims_home/sessions/$wims_session/getfile/freeworksdata
369
!endif
370
 
371
!read lang.phtml.$lang
16558 guerimand 372
!reset firstsee
14537 guerimand 373
!if $job=student
16554 guerimand 374
  !! log first connect of student after $soldate (and all copies corrected)
375
  !if (($codownload=1 and $type=1) or ($type>1 and $codownload=1)) and $wims_user!=supervisor
376
    test=!defof freework_seeco_$wims_user in wimshome/log/classes/$wims_class/freeworksdata/$freework/.seeco
377
    !if $test=$empty
378
      !appendfile wimshome/log/classes/$wims_class/freeworksdata/$freework/.seeco freework_seeco_$wims_user=$wims_now
16558 guerimand 379
      firstsee=1
16554 guerimand 380
    !endif
381
  !endif
14537 guerimand 382
  job=student$(lpara_type[$type])
383
!endif
17593 czzmrn 384
 
14297 guerimand 385
!changeto $job.proc