Subversion Repositories wimsdev

Rev

Rev 10284 | Rev 13581 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5181 guerimand 1
!read adm/language lang/names.phtml
2433 bpr 2
 
10284 bpr 3
!if $wims_developer!=$empty
4
  !set wims_ariane_self=no
5
  !set wims_ariane=!append line modtool,1,module=adm/modtool&job=flist&modreq=$catmodule\
6
  to $wims_ariane
7
!endif
8
 
666 bpr 9
wims_helper=chapter=4&open=4_oef#oef
10
wims_form_method=post
3699 bpr 11
wims_nw=existing catmodule catmodule1 newone oef_fname level vsave \
666 bpr 12
	delete deltitle mode realtest deffile wims_noexport \
13
	empty wims_module_log class_header
14
wims_nr=wims_sesrandom
15
wims_trustfile=oef/embed.phtml oef/special.phtml oef/togetfile.proc
16
slib/circuits/draw slib/circuits/drawcomp slib/circuits/range\
17
slib/circuits/comppos
8368 bpr 18
answerlim=!defof MAX_OEFREPLIES in wimshome/public_html/bases/sys/define.conf
19
choicelim=!defof MAX_OEFCHOICES in wimshome/public_html/bases/sys/define.conf
20
!distribute item 10,40 into condlim,promptlim
666 bpr 21
!bound mode within raw,file,model default $
22
!read tabletheme
23
!if $wims_user!=$empty or $wims_developer!=$empty
24
 !default oef_author=!trim $wims_firstname $wims_lastname
25
 !default oef_email=$wims_email
26
 !if $wims_developer!=$empty
27
  !read adm/getdeveloper
28
  !default oef_author=$dv_name
29
  !default oef_email=$dv_email
30
 !endif
31
 !if $newone=1
32
  existing=
33
  newone=
34
 !endif
35
 !if (..devel/ notin ..$catmodule or $wims_developer=$empty) and \
36
	$existing!=$empty and $wims_user!=supervisor \
37
	and ..*/$wims_user. notin ..*/$existing
38
  existing=
39
 !endif
40
 !if $existing!=$empty and $level=$empty
41
  !if $catmodule!=$empty
42
   !if ..devel/ isin ..$catmodule and ($wims_developer= or \
43
	..devel/$wims_developer notin ..$catmodule)
44
    !goto nonexist
45
   !endif
46
   !if .. isin $catmodule or ..adm/ isin ..$catmodule or \
47
	..classes/ isin ..$catmodule
48
    !goto nonexist
49
   !endif
50
  !endif
51
  src=!mexec catexisting.sh $existing
52
  !if $src!=$empty
53
   mode=raw
54
   level=1
55
  !else
56
   :nonexist
57
   error=not_exist
58
   del=$existing
8839 bpr 59
   existing=
666 bpr 60
   !exit
61
  !endif
62
 !endif
63
!else
64
 existing=
65
!endif
66
 
67
!if $cmd=help
68
 !if $realtest=yes
10258 bpr 69
!!variable for ariane
70
   !set ariane_title=$$wims_name_createxo
71
   !set wims_ariane=!append line backcreatexo,1,module=adm/createxo&cmd=resume&realtest=no\
72
testexo,1,module=$module&cmd=resume\
73
to $wims_ariane
74
   !changeto oef/var.proc
75
 !else
76
   !set wims_ariane=!append line resume,1,module=$module&cmd=resume\
77
to $wims_ariane
78
   !if $modtoolhelp!=yes
79
!!trouble with mhelp=%2Cmhelp (coming from ,mhelp)
80
     !if $special_parm!=$empty and ($special_parm notwordof mhelp help and mhelp notin $special_parm)
81
      !set wims_ariane=!append line back2 $$wims_name_help,1,cmd=help\
82
 to $wims_ariane
83
     !endif
84
   !endif
666 bpr 85
 !endif
10355 bpr 86
 !if $modtoolhelp=yes
87
    !distribute items no,no, into wims_ariane_home,wims_ariane_self,wims_ariane
88
 !endif
666 bpr 89
 !exit
90
!endif
10355 bpr 91
!if $modtoolhelp=yes
92
  !distribute items no,no, into wims_ariane_home,wims_ariane_self,wims_ariane
93
!endif
666 bpr 94
!if $delete!=$empty
95
 !if $wims_class==$empty
96
  error=not_class
97
  !exit
98
 !endif
99
 !if $wims_user!=supervisor
100
  error=not_supervisor
101
  !exit
102
 !endif
103
 del=!word 1 of $delete
104
 delete=
105
 deleted=!mexec delexo.sh $del
106
 !if $deleted=$empty
107
  error=not_exist
108
 !else
109
  wims_module_log=delete $wims_class/$del
110
 !endif
111
 !exit
112
!endif
113
 
10179 bpr 114
!if $level notwordof 2 and ($realtest!=no and $realtest!=$empty)
115
  !set wims_ariane=!append line backcreatexo,1,cmd=resume&realtest=no\
116
  to $wims_ariane
117
!endif
118
!if $level iswordof 6
119
  !set wims_ariane=!append line backcreatexo,1,cmd=reply&level=3\
120
  to $wims_ariane
121
!endif
666 bpr 122
!if $mode=model and $model!=$empty
123
 model=!text select abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 in $model
2455 bpr 124
 !sh cp -f $wims_home/public_html/scripts/model/$lang/src/$model.oef $wims_home/sessions/$wims_session/user-deposit\
666 bpr 125
   cp -f $wims_home/sessions/$wims_session/user-deposit $wims_home/sessions/$wims_session/submit.oef
126
 !if $level=3 and $realtest=yes
127
  !mexec makedef.sh
128
 !endif
129
 !reset status
130
 model=
131
!endif
132
 
133
!if $level=2 and $mode=model
134
 !read model/cut.proc
135
 !if $cnt<6 or $sps=$empty or $parms=$empty or $desc=$empty or\
136
	$model_type=$empty or statementrec=$empty
137
  mode=
138
  !goto nomodel
139
 !endif
10179 bpr 140
 !set wims_ariane=!append line modellist,1,cmd=reply&level=1&mode=model\
141
to $wims_ariane
666 bpr 142
!endif
143
 
144
!if $level=2 and $mode=$empty
10179 bpr 145
  !set wims_ariane=!append line normalmode,1,cmd=reply&level=1\
146
to $wims_ariane
666 bpr 147
 !read model/cut.proc
148
 !if $cnt>=6 and $sps!=$empty and $parms!=$empty and $desc!=$empty and\
149
	$model_type!=$empty and statementrec>1
150
  mode=model
151
  rawinp=
152
 !endif
153
!endif
154
 
155
:nomodel
156
!if $level=3 and $realtest=yes
10179 bpr 157
  oef_test=yes
666 bpr 158
 !changeto oef/var.proc
159
!else
160
 !if $realtest=no
161
  question=
162
  hint=
163
  solution=
164
  status=
165
  varcnt=0
166
  replycnt=0
167
  choicecnt=0
168
  score=
169
  !if $mode=model
170
   !for i=1 to 100
171
    reply$i=
172
   !next i
3699 bpr 173
  !endif model
174
 !endif realtest
666 bpr 175
 !reset status realtest retest
3699 bpr 176
!endif level=3
666 bpr 177
 
178
!if $rawinp!=$empty
179
 mode=raw
180
 level=1
181
 rawinp=
182
!endif
183
 
184
!if $mode=raw and $level<=2
185
 modeltest=!recordcnt wimshome/sessions/$wims_session/submit.oef
186
 !if $modeltest>6
187
  modeltest=!record 0 of wimshome/sessions/$wims_session/submit.oef
188
  modeltest=!getopt type in $modeltest
189
  !if $modeltest!=$empty
190
   modeltest=yes
191
   !sh cd $wims_home/sessions/$wims_session\
192
    [ -s user-deposit ] || cp -f submit.oef user-deposit
193
  !endif
194
 !endif
195
!endif
196
 
197
!bound oef_format within tex,html default html
198
!bound oef_answercnt between integer 0 and $answerlim default 1
199
!bound oef_choicecnt between integer 0 and $choicelim default 0
200
!bound oef_condcnt   between integer 0 and $condlim   default 0
201
!bound oef_precision within 100,1000,10000,100000,1000000 default 10000
202
!bound oef_computeanswer within yes,no default no
3699 bpr 203
!bound level between integer 0 and 7 default 0
666 bpr 204
!if $level=6 and $wims_user!=supervisor
205
 level=1
206
!endif
207
 
208
!for i in l,r
209
 oef_range$i=!trim $(oef_range$i)
210
 !if $(oef_range$i)!=$empty
211
  oef_range$i=$[$(oef_range$i)]
212
  !if NaN isin $(oef_range$i)] or Inf isin $(oef_range$i)
213
   oef_range$i=
214
  !endif
215
 !endif
216
!next i
217
!default oef_rangel=-5
218
!default oef_ranger=5
219
!if $oef_rangel=$oef_ranger
220
 oef_rangel=-5
221
 oef_ranger=5
222
!endif
223
!if $oef_rangel>$oef_ranger
224
 range=$oef_rangel
225
 oef_rangel=$oef_ranger
226
 oef_ranger=$range
227
!endif
228
 
229
!if $level>1 and $mode=$empty
230
 oef_title=!trim $oef_title
231
 !if $oef_title=$empty and $level>1
232
  error=no_title
233
  !exit
234
 !endif
235
# !if $oef_answercnt+$oef_choicecnt<=0
236
#  error=no_answer
237
#  !exit
238
# !endif
239
!endif
3699 bpr 240
!if $level=7 and $wims_developer!=$empty
241
  !reset file_name_src
242
   list_mod=!sh ls $wims_home/public_html/modules/devel/$wims_developer
243
   list_mod=!words2items $list_mod
244
   list_mod_oef=
245
   !for a in $list_mod
8368 bpr 246
     category = !module category devel/$wims_developer/$a
3699 bpr 247
    !if oef isin $category
248
       list_mod_oef=!append item $a to $list_mod_oef
249
    !endif
250
   !next
251
   !if $list_mod_oef=$empty
252
     error = $error oefempty
253
   !endif
254
!endif
666 bpr 255
 
256
!if $level=3
257
 !if $mode=$empty
258
  header=\language{$lang}\
259
\range{$oef_rangel..$oef_ranger}
260
  !for i in author,email,computeanswer,format,precision
261
   oef_$i=!trim $(oef_$i)
262
   !if $(oef_$i)!=$empty
263
    header=!append line \$i{$(oef_$i)} to $header
264
   !endif
265
  !next i
266
  oef_statement=!trim $oef_statement
267
  !if $oef_statement=$empty
268
   error=no_statement
269
   !exit
270
  !endif
271
  answers=
272
  !for i=1 to $oef_answercnt
273
   ansprompt$i=!trim $(ansprompt$i)
274
   prompt=!char 1 to $promptlim of $(ansprompt$i)
275
   ansgood$i=!trim $(ansgood$i)
276
   !if $prompt!=$empty and $(ansgood$i)!=$empty
277
    !default anstype$i=default
278
    answers=!append line \answer{$prompt}{$(ansgood$i)}{type=$(anstype$i)} to $answers
279
   !endif
280
  !next i
281
  replycnt=!linecnt $answers
282
  choices=
283
  !for i=1 to $oef_choicecnt
284
   choiprompt$i=!trim $(choiprompt$i)
285
   prompt=!char 1 to $promptlim of $(choiprompt$i)
286
   choigood$i=!trim $(choigood$i)
287
   choibad$i=!trim $(choibad$i)
288
   !if $prompt!=$empty and $(choigood$i)!=$empty and $(choibad$i)!=$empty
289
    choices=!append line \choice{$prompt}{$(choigood$i)}{$(choibad$i)} to $choices
290
   !endif
291
  !next i
292
  choicecnt=!linecnt $choices
293
  conditions=
294
  !for i=1 to $oef_condcnt
295
   cn=!trim $(Condname$i)
296
   ct=!trim $(Condtest$i)
297
   !if $cn!=$empty and $ct!=$empty
298
    conditions=!append line \condition{$cn}{$ct} to $conditions
299
   !endif
300
  !next i
301
#  !ifval $replycnt+$choicecnt=0
302
#   error=no_reply2
303
#   !exit
304
#  !endif
305
  oef_hint=!trim $oef_hint
306
  !if $oef_hint!=$empty
307
   hints=\hint{$oef_hint}
308
  !endif
309
  oef_solution=!trim $oef_solution
310
  !if $oef_solution!=$empty
311
   solutions=\solution{$oef_solution}
312
  !endif
313
  source=!mexec makedef.sh
314
 !else
315
  !if $mode=model
316
   !read model/cutback.proc
317
  !endif
318
  !mexec makedef.sh
319
 !endif mode=$empty
320
 status=waiting
321
 oef2wims_out=!record 0 of wimshome/$wims_sesdir/oef2wims.out
322
 !if ERROR iswordof $oef2wims_out
323
  :diagerror
324
  test=!line 1 of $oef2wims_out
325
  !if ERROR notin $test
326
   oef2wims_out=!line 2 to -1 of $oef2wims_out
327
  !endif
328
  error=def_fail
329
  !exit
330
 !endif
331
 replycnt=
332
 choicecnt=
333
 varcnt=
334
 !read wimshome/$wims_sesdir/submit.def
335
 !if $replycnt=$empty or $choicecnt=$empty or $varcnt=$empty
336
  !goto diagerror
337
  !exit
338
 !endif
339
 title=!trim $title
340
 !if $title=$empty
341
  error=empty_title
342
  !exit
343
 !endif
344
 oef_fname=
345
 titlen=!charcnt $title
346
 !for i=1 to $titlen
347
  c=!char $i of $title
348
  !if $c isin 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_
349
   oef_fname=$oef_fname$c
350
  !endif
351
 !next i
352
 oef_fname=!char 1 to 14 of $oef_fname
353
 !if $wims_user!=$empty and $wims_user!=supervisor
354
  oef_fname=$wims_user.$oef_fname
355
 !endif
356
!endif
357
 
358
!if $level=4 and $wims_user!=$empty
359
 regout=!mexec regclass.sh
360
 reg1=!word 1 of $regout
361
 !if $reg1=success
362
  fnamebase=!word 2 of $regout
1489 bpr 363
  existing=$fnamebase
364
  success=1
666 bpr 365
 !else
366
  error=!word 2 of $regout
367
  !if $error!=already
368
   !exit
369
  !else
370
   error=
371
   already=yes
372
  !endif
373
 !endif
374
 !if $wims_user!=supervisor and ..devel/ notin ..$catmodule
375
  prefix=$wims_user.
376
 !else
377
  prefix=
378
 !endif
379
 wims_module_log=Regclass $wims_class $mode $prefix$oef_title
380
!endif
381
 
3699 bpr 382
!if $level=4
8368 bpr 383
 !if $catmodule1 !=
3699 bpr 384
  catmodule=devel/$wims_developer/$catmodule1
385
  !reset catmodule1
386
 !endif
8368 bpr 387
 
388
 existing_new=!replace internal .oef by in $file_name_src
3719 bpr 389
 !set existing_new=!text select ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_1234567890 in $existing_new
390
 !if $existing_new != $empty
3699 bpr 391
  existing=$existing_new
3719 bpr 392
 !endif
3699 bpr 393
!endif
666 bpr 394
!if $level=4 and $wims_developer!=$empty and ..devel/ isin ..$catmodule and \
3699 bpr 395
   .. notin $catmodule $existing
666 bpr 396
 wims_exec_error=
397
 !sh cp $wims_home/sessions/$wims_session/submit.oef modules/$catmodule/src/$existing.oef\
398
    cd modules/$catmodule; src2def
4924 bpr 399
 test_image=!sh ls $wims_home/sessions/$wims_session/getfile/oefimg 2>/dev/null
4644 bpr 400
 !if $test_image!=$empty
401
   !reset test_common
402
   test_common=!defof common_images in wimshome/public_html/modules/$catmodule/var.proc
403
   !if $test_common!=$empty
8368 bpr 404
    !if $test_common notwordof no yes
4644 bpr 405
      wims_exec_error=!append word imagedir=$test_common to $wims_exec_error
406
    !else
407
     !if $test_common iswordof no or $test_common=$empty
408
       im_dir=images/$existing
409
     !else
410
       im_dir=images
411
     !endif
412
     !sh mkdir -p modules/$catmodule/$im_dir ;\
413
       cp $wims_home/sessions/$wims_session/getfile/oefimg/* modules/$catmodule/$im_dir
414
    !endif
415
  !endif
416
 !endif
417
 !reset test_image
666 bpr 418
 !reset already regout prefix
419
 !if $wims_exec_error=$empty
420
  reg1=success
421
  regout=$existing
422
 !else
423
  reg1=fail
424
 !endif
425
 wims_module_log=Regdev $catmodule $existing
426
 !goto l4end
427
!endif
428
 
429
!if ($level=4 and $wims_user=$empty) or $level=5
430
 regout=!mexec regpub.sh
431
 reg1=!word 1 of $regout
432
 !if $reg1=success
433
  fnamebase=!word 2 of $regout
434
 !else
435
  error=!word 2 of $regout
436
  !exit
437
 !endif
438
 wims_module_log=Regpub $mode $oef_title
439
!endif
440
 
441
:l4end
442
!if $level=6
443
 !if $wims_deposit!=$empty and .. notin $wims_deposit and / notin $wims_deposit
444
  !read adm/du $wims_home/log/classes/$wims_class
445
  !if $du>=$wims_class_quota-1
446
   quota=yes
447
  !else
448
   !sh cd $wims_home/$wims_sesdir\
449
	mkdir -p getfile/oefimg\
450
	mv user-deposit getfile/oefimg/$wims_deposit\
451
	cp oefdeposit user-deposit 2>/dev/null
452
  !endif
453
  imgfname=$wims_deposit
454
  wims_deposit=
455
 !else
456
  !sh cd $wims_home/$wims_sesdir\
457
	if [ -f user-deposit ]; then cp user-deposit oefdeposit; fi
458
  !if $delfile!=$empty and .. notin $delfile
459
   !sh rm -f $wims_home/$wims_sesdir/getfile/oefimg/$delfile
460
  !endif
461
 !endif
462
 imglist=!filelist $wims_home/$wims_sesdir/getfile/oefimg
463
 imglist=!words2items $imglist
464
!endif