Subversion Repositories wimsdev

Rev

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