Rev 16792 | Rev 17565 | 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 : 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 : 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 | t=0 |
||
200 | !for val in deadline,soldate |
||
201 | !! -- check date format |
||
202 | $val=!text select 0123456789 in $($val) |
||
203 | expmon=!char 5 to 6 of $($val) |
||
204 | expday=!char 7 to 8 of $($val) |
||
205 | expyear=!char 1 to 4 of $($val) |
||
206 | expmon=!char 2,3 of $[abs(floor($expmon))+100] |
||
207 | expday=!char 2,3 of $[abs(floor($expday))+100] |
||
208 | expyear=!char -4 to -1 of $[abs(floor($expyear))+100000] |
||
209 | !if $expday>=1 and $expday<=31 and $expmon>=1 and $expmon<=12 \ |
||
14335 | bpr | 210 | and $($val)<=$class_expiration \ |
211 | and N notin $expmon$expday$expyear |
||
14297 | guerimand | 212 | $val=$expyear$expmon$expday |
213 | !else |
||
214 | $val=$class_expiration |
||
215 | !endif |
||
216 | !! -- check time format |
||
217 | time$val=!text select 0123456789: in $(time$val) |
||
218 | time$val=!replace internal : by , in $(time$val) |
||
219 | nb=!itemcnt $(time$val) |
||
220 | !if $nb=2 |
||
221 | !distribute item $(time$val) into h,m |
||
222 | h=$[$h*1] |
||
223 | m=$[$m*1] |
||
224 | !if $h<0 or $h>23 or $m<0 or $m>59 or NaN isin $h$m |
||
225 | time$val=00:0$t |
||
226 | !else |
||
227 | h=!char 2 to 3 of $[100+$h] |
||
228 | m=!char 2 to 3 of $[100+$m] |
||
229 | time$val=$h:$m |
||
230 | !endif |
||
231 | !else |
||
232 | time$val=00:0$t |
||
233 | !endif |
||
234 | !increase t |
||
235 | !next val |
||
236 | |||
14889 | guerimand | 237 | !if $type>=2 |
16733 | guerimand | 238 | !if $wims_supertype!=4 |
239 | v=!values v,-v for v=1 to $nbscore |
||
240 | !if $activetest=0 |
||
241 | !bound scoring within $v,no,0 default no |
||
242 | !else |
||
243 | !bound scoring within $v,0 default 0 |
||
244 | !endif |
||
14936 | guerimand | 245 | !else |
16733 | guerimand | 246 | !if $activetest=0 |
247 | scoring=no |
||
248 | !else |
||
249 | scoring=0 |
||
250 | !endif |
||
14936 | guerimand | 251 | !endif |
14537 | guerimand | 252 | !if $scoring>0 |
253 | m=!record 0 of wimshome/log/classes/$wims_class/sheets/.severity |
||
254 | maxscore=!word 1 of $m |
||
255 | !bound maxscore between 0 and 100000 default 10 |
||
256 | !endif |
||
257 | !else |
||
258 | scoring=0 |
||
259 | !endif |
||
260 | !bound seealltime between 0 and 1 default 0 |
||
14297 | guerimand | 261 | |
14537 | guerimand | 262 | !! ----------- end check general variable |
14297 | guerimand | 263 | |
14960 | guerimand | 264 | !! -------------- check right for download/upload participant file and etc... |
14990 | czzmrn | 265 | !readproc proc/mkglobalvar.proc |
14297 | guerimand | 266 | |
14947 | guerimand | 267 | !! ------- read existant file for subject/solution |
268 | nb=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freework$freework |
||
269 | !reset flistsolution,flistsubject |
||
270 | !for k=1 to $nb |
||
271 | dt=!record $k of wimshome/log/classes/$wims_class/freeworks/.freework$freework |
||
272 | !if $(dt[1;]) isitemof subject,solution |
||
273 | flist$(dt[1;])=!line 2 to -1 of $dt |
||
274 | flist$(dt[1;])=!nonempty line $(flist$(dt[1;])) |
||
275 | flist$(dt[1;])=!lines2items $(flist$(dt[1;])) |
||
276 | field_$(dt[1;])=$k |
||
277 | !endif |
||
278 | !next k |
||
14537 | guerimand | 279 | |
14297 | guerimand | 280 | !! ------ make file link for download and some title |
281 | !if $wims_user=supervisor |
||
282 | !if $freework>$nbfreework |
||
283 | activetest=-1 |
||
284 | name_title=$name_tmkfreework |
||
285 | !else |
||
286 | name_title=$name_managefreework |
||
287 | !endif |
||
14537 | guerimand | 288 | !if $activetest>=0 and $type<=3 |
14297 | guerimand | 289 | !sh cd $wims_home/$wims_sesdir;\ |
290 | mkdir -p getfile;\ |
||
291 | cd getfile;\ |
||
292 | mkdir -p freeworks;\ |
||
293 | cd freeworks;\ |
||
294 | rm -f $freework;\ |
||
295 | ln -s $wims_home/log/classes/$wims_class/freeworks/$freework $freework; |
||
296 | !endif |
||
297 | !else |
||
298 | name_title=!nosubst $wims_name_Freework $freework |
||
299 | !if $activetest>=1 |
||
14537 | guerimand | 300 | !if $displaysolution=1 |
301 | flist=!listunion $flistsolution and $flistsubject |
||
14297 | guerimand | 302 | !else |
14537 | guerimand | 303 | flist=$flistsubject |
14297 | guerimand | 304 | !endif |
14537 | guerimand | 305 | flist=!nonempty item $flist |
306 | flist=!listuniq $flist |
||
14297 | guerimand | 307 | flist=!items2words $flist |
308 | !endif |
||
309 | !if $flist!=$empty |
||
310 | testfile=!word 1 of $flist |
||
311 | test=!fileexists wimshome/sessions/$wims_session/getfile/freeworks/$freework/$testfile |
||
312 | !if $test!=yes |
||
313 | !sh cd $wims_home/$wims_sesdir;\ |
||
314 | mkdir -p getfile;\ |
||
315 | cd getfile;\ |
||
316 | rm -rf freeworks;\ |
||
317 | mkdir -p freeworks;\ |
||
318 | cd freeworks;\ |
||
319 | mkdir $freework;\ |
||
320 | cd $freework;\ |
||
321 | for k in $flist; do\ |
||
322 | ln -s $wims_home/log/classes/$wims_class/freeworks/$freework/$$k $$k;\ |
||
323 | done; |
||
324 | !endif |
||
325 | !endif |
||
326 | !sh mkdir -p $wims_home/sessions/$wims_session/getfile/freeworksdata |
||
327 | !endif |
||
328 | |||
329 | !read lang.phtml.$lang |
||
16558 | guerimand | 330 | !reset firstsee |
14537 | guerimand | 331 | !if $job=student |
16554 | guerimand | 332 | !! log first connect of student after $soldate (and all copies corrected) |
333 | !if (($codownload=1 and $type=1) or ($type>1 and $codownload=1)) and $wims_user!=supervisor |
||
334 | test=!defof freework_seeco_$wims_user in wimshome/log/classes/$wims_class/freeworksdata/$freework/.seeco |
||
335 | !if $test=$empty |
||
336 | !appendfile wimshome/log/classes/$wims_class/freeworksdata/$freework/.seeco freework_seeco_$wims_user=$wims_now |
||
16558 | guerimand | 337 | firstsee=1 |
16554 | guerimand | 338 | !endif |
339 | !endif |
||
14537 | guerimand | 340 | job=student$(lpara_type[$type]) |
341 | !endif |
||
14297 | guerimand | 342 | !changeto $job.proc |