Subversion Repositories wimsdev

Rev

Rev 17565 | Rev 17593 | 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
14537 guerimand 146
  !distribute line $tmp into activetest,expdate,title,desc,comment,type,deadline,soldate,sizelimitfile,scoring,seealltime
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
14297 guerimand 165
!endif
166
 
14537 guerimand 167
!! ---------  check variable values
14297 guerimand 168
title=!singlespace $title
14616 guerimand 169
title=!detag $title
14297 guerimand 170
title=!char 1 to $title_limit of $title
171
title=!replace internal : by &#58; in $title
172
 
173
desc=!replace internal $\
174
$ by $ $ in $desc
14636 guerimand 175
desc=!char 1 to $desc_limit of $desc
14297 guerimand 176
desc=!replace internal : by &#58; in $desc
177
 
178
comment=!replace internal $\
179
$ by $ $ in $comment
180
comment=!singlespace $comment
14616 guerimand 181
comment=!detag $comment
14297 guerimand 182
 
15346 guerimand 183
 
184
!! ------- manage activation or not of upload file for student (option manage by wims.conf)
15016 guerimand 185
!if $activetest<1 and $conf_nofile=yes
186
  !bound type within 1,3 default 1
15346 guerimand 187
  listfilename_ztype_teacher=$listfilename_ztype
17565 czzmrn 188
  listfilename_ztype_student=!listcomplement $studentfile_ztype in $listfilename_ztype
15016 guerimand 189
!else
16307 guerimand 190
  !bound type between 1 and 3 default 1
15346 guerimand 191
  listfilename_ztype_teacher=$listfilename_ztype
192
  listfilename_ztype_student=$listfilename_ztype
15016 guerimand 193
!endif
17565 czzmrn 194
listfilename_ztype_student=!listcomplement $nostudent_ztype in $listfilename_ztype_student
15346 guerimand 195
nbztype_teacher=!itemcnt $listfilename_ztype_teacher
196
nbztype_student=!itemcnt $listfilename_ztype_student
197
 
14297 guerimand 198
!if $type=1
199
  sizelimitfile=$empty
200
!else
16307 guerimand 201
  !bound sizelimitfile between 1 and 10 default 4
14788 guerimand 202
  !if $type=3
203
    !! ------ incase of type=3 sizelimitfile=0 if no student filezone
204
    nb=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freework$freework
205
    numberfilezone=0
206
    !for k=1 to $nb
207
      test=!record $k of wimshome/log/classes/$wims_class/freeworks/.freework$freework
208
      test=!line 1 of $test
209
      !distribute word $test into s,z
210
      !if $s=file and $z=student
211
        !increase numberfilezone
212
      !endif
213
    !next k
214
    !if $numberfilezone=0
215
      sizelimitfile=$empty
216
    !endif
217
  !endif
14297 guerimand 218
!endif
219
 
220
t=0
221
!for val in deadline,soldate
222
  !! -- check date format
223
  $val=!text select 0123456789 in $($val)
224
  expmon=!char 5 to 6 of $($val)
225
  expday=!char 7 to 8 of $($val)
226
  expyear=!char 1 to 4 of $($val)
227
  expmon=!char 2,3 of $[abs(floor($expmon))+100]
228
  expday=!char 2,3 of $[abs(floor($expday))+100]
229
  expyear=!char -4 to -1 of $[abs(floor($expyear))+100000]
230
  !if $expday>=1 and $expday<=31 and $expmon>=1 and $expmon<=12 \
14335 bpr 231
      and $($val)<=$class_expiration \
232
      and N notin $expmon$expday$expyear
14297 guerimand 233
    $val=$expyear$expmon$expday
234
  !else
235
    $val=$class_expiration
236
  !endif
237
  !! -- check time format
238
  time$val=!text select 0123456789: in $(time$val)
239
  time$val=!replace internal : by , in $(time$val)
240
  nb=!itemcnt $(time$val)
241
  !if $nb=2
242
    !distribute item $(time$val) into h,m
243
    h=$[$h*1]
244
    m=$[$m*1]
245
    !if $h<0 or $h>23 or $m<0 or $m>59 or NaN isin $h$m
246
      time$val=00:0$t
247
    !else
248
      h=!char 2 to 3 of $[100+$h]
249
      m=!char 2 to 3 of $[100+$m]
250
      time$val=$h:$m
251
    !endif
252
  !else
253
    time$val=00:0$t
254
  !endif
255
  !increase t
256
!next val
257
 
14889 guerimand 258
!if $type>=2
16733 guerimand 259
  !if $wims_supertype!=4
260
    v=!values v,-v for v=1 to $nbscore
261
    !if $activetest=0
262
      !bound scoring within $v,no,0 default no
263
    !else
264
      !bound scoring within $v,0 default 0
265
    !endif
14936 guerimand 266
  !else
16733 guerimand 267
    !if $activetest=0
268
      scoring=no
269
    !else
270
      scoring=0
271
    !endif
14936 guerimand 272
  !endif
14537 guerimand 273
  !if $scoring>0
274
    m=!record 0 of wimshome/log/classes/$wims_class/sheets/.severity
275
    maxscore=!word 1 of $m
276
    !bound maxscore between 0 and 100000 default 10
277
  !endif
278
!else
279
  scoring=0
280
!endif
281
!bound seealltime between 0 and 1 default 0
14297 guerimand 282
 
14537 guerimand 283
!! ----------- end check general variable
14297 guerimand 284
 
14960 guerimand 285
!! -------------- check right for download/upload participant file and etc...
14990 czzmrn 286
!readproc proc/mkglobalvar.proc
14297 guerimand 287
 
14947 guerimand 288
!! ------- read existant file for subject/solution
289
nb=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freework$freework
290
!reset flistsolution,flistsubject
291
!for k=1 to $nb
292
  dt=!record $k of wimshome/log/classes/$wims_class/freeworks/.freework$freework
293
  !if $(dt[1;]) isitemof subject,solution
294
    flist$(dt[1;])=!line 2 to -1 of $dt
295
    flist$(dt[1;])=!nonempty line $(flist$(dt[1;]))
296
    flist$(dt[1;])=!lines2items $(flist$(dt[1;]))
297
    field_$(dt[1;])=$k
298
  !endif
299
!next k
14537 guerimand 300
 
14297 guerimand 301
!! ------ make file link for download and some title
302
!if $wims_user=supervisor
303
  !if $freework>$nbfreework
304
    activetest=-1
305
    name_title=$name_tmkfreework
306
  !else
307
    name_title=$name_managefreework
308
  !endif
14537 guerimand 309
  !if $activetest>=0 and $type<=3
14297 guerimand 310
    !sh cd $wims_home/$wims_sesdir;\
311
       mkdir -p getfile;\
312
       cd getfile;\
313
       mkdir -p freeworks;\
314
       cd freeworks;\
315
       rm -f $freework;\
316
       ln -s $wims_home/log/classes/$wims_class/freeworks/$freework $freework;
317
  !endif
318
!else
319
  name_title=!nosubst $wims_name_Freework $freework
320
  !if $activetest>=1
14537 guerimand 321
    !if $displaysolution=1
322
      flist=!listunion $flistsolution and $flistsubject
14297 guerimand 323
    !else
14537 guerimand 324
      flist=$flistsubject
14297 guerimand 325
    !endif
14537 guerimand 326
    flist=!nonempty item $flist
327
    flist=!listuniq $flist
14297 guerimand 328
    flist=!items2words $flist
329
  !endif
330
  !if $flist!=$empty
331
    testfile=!word 1 of $flist
332
    test=!fileexists wimshome/sessions/$wims_session/getfile/freeworks/$freework/$testfile
333
    !if $test!=yes
334
      !sh cd $wims_home/$wims_sesdir;\
335
         mkdir -p getfile;\
336
         cd getfile;\
337
         rm -rf freeworks;\
338
         mkdir -p freeworks;\
339
         cd freeworks;\
340
         mkdir $freework;\
341
         cd $freework;\
342
         for k in $flist; do\
343
           ln -s $wims_home/log/classes/$wims_class/freeworks/$freework/$$k $$k;\
344
         done;
345
    !endif
346
  !endif
347
  !sh mkdir -p $wims_home/sessions/$wims_session/getfile/freeworksdata
348
!endif
349
 
350
!read lang.phtml.$lang
16558 guerimand 351
!reset firstsee
14537 guerimand 352
!if $job=student
16554 guerimand 353
  !! log first connect of student after $soldate (and all copies corrected)
354
  !if (($codownload=1 and $type=1) or ($type>1 and $codownload=1)) and $wims_user!=supervisor
355
    test=!defof freework_seeco_$wims_user in wimshome/log/classes/$wims_class/freeworksdata/$freework/.seeco
356
    !if $test=$empty
357
      !appendfile wimshome/log/classes/$wims_class/freeworksdata/$freework/.seeco freework_seeco_$wims_user=$wims_now
16558 guerimand 358
      firstsee=1
16554 guerimand 359
    !endif
360
  !endif
14537 guerimand 361
  job=student$(lpara_type[$type])
362
!endif
14297 guerimand 363
!changeto $job.proc