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