Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
15063 bpr 1
!nocache
2
 
3
!set modu_lang=$lang
4
!!! FIXME variable jquery_defined is not accessible here
5
!if $wims_theme!=default
6
  !set jquery_defined=yes
7
!endif
15870 bpr 8
!read getparm $module_init_parm seed
9
!if $get_seed!=$empty
10
  !setseed $get_seed
11
  module_init_parm=!replace internal seed=$get_seed by in $module_init_parm
12
  !reset get_seed
13
!endif
15063 bpr 14
!!wseed=$seed
15
!!!if $wseed!=$empty and $wims_user=supervisor
16
!!  !setseed $wseed
17
!!!endif
15186 bpr 18
oefenv_presentgood=$presentgood
15342 obado 19
!read oef/$lang/names.proc
15063 bpr 20
!if $lang_exists!=yes
21
  !let modu_lang=en
15342 obado 22
  !read oef/$modu_lang/names.proc
15063 bpr 23
!endif
24
!set module_language=$lang
25
translation_language=!module translation_language $module
26
oefenv_lang=$lang
27
 
28
!if $translation_language!=$empty and $lang_choice!=$empty
29
  oefenv_lang=$lang_choice
30
!endif
31
 
32
!set name_choose_code=!defof name_choose_code in anstype/menu.input
33
!default module_help=popup
34
 
35
#if you change these limits, you have to modify var.def!
36
limit_var=2048
37
!!does not work because it is not an administrative modules but the limit are here
38
!!limit_choice=!getdef MAX_OEFCHOICES in wimshome/public_html/bases/sys/define.conf
39
!!limit_reply=!getdef MAX_OEFREPLIES in wimshome/public_html/bases/sys/define.conf
40
 
41
limit_reply=100
42
limit_choice=30
43
testnum=10
44
savedrawcnt=1
45
savetexcnt=1
46
proc=oef
47
!if $cmd=new and $allow_missing_data != yes
48
  module_checkdata=!checkdata
49
  !if $module_checkdata!=yes
50
    wims_module_log=Missing datamodule $module_checkdata
51
    !exit
52
  !endif
53
!else
54
  module_checkdata=yes
55
!endif
56
wims_noexport=$wims_noexport reply choice score oef hint fill val vsave \
57
	deffile tmp thisexo ch_ exolist titlelist shufflelist \
58
	name_ parm exo posvar sp_ slib_
59
wims_multiexec=pari maxima yacas octave gap
60
insmath_rawmath=yes
61
wims_backslash_insmath=yes
62
 
63
# Limit Pari precision, for otherwise many computations will fail.
64
proc_oef=yes
65
!default precision=10000
66
!default pari_precision=18
67
!default print_precision=8
68
!default maxima_precision=$print_precision
69
wims_print_precision=$print_precision
70
maxima_header=expon:0; expop:0; factlim:6; prederror: false;\
71
	maxnegex:20; maxposex:20; ratfac:true; keepfloat:true;\
72
    ordergreat(x,y,z,t)
73
 
74
pari_header=x;y;z;t;
75
executed_str=__EXECUTED_1692754_EXERCISE__
76
 
77
!for j_ in lastname,firstname,login,now
78
  !default m_oef_$(j_)=$(wims_$(j_))
79
  !default m_oef_$(j_)=$(name_$(j_))
80
!next
81
!default m_oef_lang=$lang
82
!default m_oef_login=anonymous
83
 
84
m_oefenv=!replace word debug by $ in $m_oefenv
85
!if ($wims_developer!=$empty and ../devel/$wims_developer isin ../$module \
86
		and _test isin $wims_session) or \
87
    ../adm/createxo isin ../$module or \
88
    ($wims_user=supervisor and $wims_isexam<1 and _check notin $wims_session)
89
  !default oef_default=no
90
  m_oefenv=!singlespace $m_oefenv debug
91
!endif
92
 
93
!if $cmd=help
94
  !set title=!defof title_$lang_choice in $deffile
95
  !default title=!defof title in $deffile
96
  !set module_title=$title
97
  !set modtitle=$title
98
  !set module_author=$author
99
  !set module_address=$email
100
  nn=!itemcnt $shufflelist
101
  thisexo=!item ($reply_cnt)%$nn+1 of $shufflelist
102
  !readproc oef/valback.proc
103
  !readproc oef/imagedir.proc
104
  val1=$imagedir
105
  m_step=$oefstep
106
  !exit
107
!endif
108
 
109
!if $cmd=new or $cmd=renew
110
  starttime=$wims_nowseconds
111
!endif
112
 
113
!default insplot_set=size 0.6,0.6
114
!default idontknow=1
115
!default allchoices=0
116
 
117
!if $oef_test=yes
118
  print=
119
  qnum=1
120
  qcmlevel=1
121
  intro_qcmpresent=8
122
  intro_sol=1
123
  intro_feed=1
124
  freepower=2
125
  scorepower=1
126
  random=0
127
  exocnt=1
128
  precweight=0.9
129
 
130
  !if $retest=again
131
    !reset status retest oef_default
132
  !endif
133
!else
134
  !read $(class_header)Exindex
15746 bpr 135
  !! FIXME
136
  !! mis pour mémoire, pour l'instant rien n'est changé.
137
  !! essai de réparation de la perte de special_parm3
138
  !! on trafique ensuite module_init_parm et special_parm3
139
  !! mais si special_parm3 existe on n'en fait rien !
15063 bpr 140
  exocnt=!itemcnt $exolist
15746 bpr 141
  !!!if $special_parm3!=$empty
142
  !!  !read getparm $special_parm3 qnum
143
  !!  qnum=$get_qnum
144
  !!!else
15063 bpr 145
  !bound qnum between integer 1 and 9 default 1
146
  !bound qcmlevel between integer 1 and 9 default 3
147
  !bound random within 0,1 default 1
148
  tmp=!replace internal & by ; in $module_init_parm
149
  !! URL encode \n
150
  tmp=!replace internal $\
151
$ by %0A in $tmp
152
 
15746 bpr 153
    tmp=intro_check=$intro_check;random=$random;$tmp
154
    tmp=!replace internal scoredelay=; by scoredelay=0; in $tmp
155
    #tmp=!replace internal exo=; by exo=0; in $tmp
156
    special_parm3=!nospace $tmp
157
  !!!endif
15063 bpr 158
  !if $scoredelay!=$empty and $scoredelay!=0
159
    d_=!items2words $scoredelay
160
    !distribute words $d_ into delay1,delay2
161
    !bound delay1 between integer 0 and 2000 default 0
162
    !bound delay2 between integer $delay1 and 2000
163
  !endif
164
  !reset scoredelay tmp
165
!endif
166
!default format=html
167
 
168
!if $print!=$empty
169
  !changeto oef/print.proc
170
!endif
171
 
172
!if $cmd=reply and $status!=waiting
173
  error=double_reply
174
  !exit
175
!endif
176
 
177
!if $status=$empty
178
  !read oef/exo.init
179
!endif
180
 
181
!if $cmd iswordof new renew reply and \
182
  ($wims_user=supervisor or $wims_user=$empty or $wims_developer!=$empty)
183
  exonext=!positionof item $exo in $exolist
184
  exoprev=$[$exonext-1]
185
  exonext=$[$exonext+1]
186
  !if $exonext > $exocnt
187
    exonext=1
188
  !endif
189
  !if $exoprev < 1
190
    exoprev=$exocnt
191
  !endif
192
  exoprev=!item $exoprev of $exolist
193
  exonext=!item $exonext of $exolist
194
!endif
195
 
196
!if $status!=waiting
197
  !for i=1 to $limit_reply
198
    !reset replygood$i
199
  !next i
200
  !reset solution, hint, help, oefsteps, oefstepcnt, latex
201
  !for i=1 to 16
202
    savedraw$i=
203
    savetex$i=
204
  !next i
205
!endif
206
 
207
!if $oef_test=yes
208
  deffile=wimshome/$wims_sesdir/submit.def
209
!else
210
  nn=!itemcnt $shufflelist
211
  thisexo=!item ($reply_cnt)%$nn+1 of $shufflelist
212
  deffile=$(class_header)def/$thisexo.def
213
  !if $nn>1 and $status!=waiting
214
    wims_module_log=$wims_module_log got $thisexo
215
  !endif
216
!endif
217
!readproc oef/imagedir.proc
218
 
219
!distribute items 0,0,0,0,0,0 into \
220
	varcnt,postvarcnt,replycnt,choicecnt,conditioncnt,feedbackcnt
221
!if $status!=waiting
222
  !reset ansorder,oefstep,oefsteps,oefstepcnt,nextstep,dynsteps,\
223
	  cchoicecnt, creplycnt, embedcnt, vsavelist, leftrange, rightrange
224
  !read $deffile
225
  !read oef/var.prep
226
!else
227
 
228
  !read $deffile
229
  !if $savedraw1!=$empty
230
    savedrawcnt=0
231
    !for i=1 to 16
232
      !if $(savedraw$i)!=$empty
233
        !read oef/draw.phtml $(savedraw$i)
234
      !else
235
        !if $(savetex$i)!=$empty
236
          !read oef/teximg.phtml $(savetex$i)
237
        !endif
238
      !endif
239
    !next i
240
  !endif
241
  !readproc oef/valback.proc
242
  !if $oefsteps!=$empty
243
    !readproc oef/steps.proc
244
  !endif
245
!endif
246
!if $embedcnt>0 or $embedcnt=$empty
247
  hasembedding=yes
248
!endif
249
!if $oefsteps!=$empty
250
  thisstep=!line $oefstep of $oefsteps
251
  gotsteps=!line 1 to $oefstep of $oefsteps
252
  gotsteps=!lines2items $gotsteps
253
  m_step=$oefstep
254
!else
255
  cchoicecnt=$choicecnt
256
  creplycnt=$replycnt
257
!endif
258
 
259
!if $cmd=reply and $status=waiting
260
  !if ($oefsteps!=$empty and $oefstep<$oefstepcnt) or \
261
	($dynsteps=yes and $oefstep=$oefstepcnt)
262
    !readproc oef/step.proc
263
    !if $dynsteps=yes and $oefstep>$oefstepcnt
264
      oefstep=$[$oefstep-1]
265
      !goto ana
266
    !endif
267
    !if $stepdiag=ok or $error!=$empty
268
      !goto end
269
    !endif
270
  !else
271
    !if $oefsteps!=$empty and $oefstep=$oefstepcnt
272
      !for i=1 to $replycnt
273
        !if r$i isitemof $gotsteps and r$i notitemof $thisstep
274
          reply$i=$(saverep$i)
275
        !endif
276
      !next i
277
      !for i=1 to $choicecnt
278
        !if c$i isitemof $gotsteps and c$i notitemof $thisstep
279
          choice$i=$(savech$i)
280
        !endif
281
      !next i
282
    !endif
283
  !endif
284
  :ana
285
  !distribute item 0,0,0,0,0,0,0,0,0 into \
286
	conditionned, freegot, condgot, qcmgot, \
287
	precgood, weightadjust, gotadjust, cweightadjust, cgotadjust
288
  !for i=1 to $replycnt
289
    tt=!word 1 of $(replygood$i)
290
    tmp_oefsteps=!lines2items $oefsteps
291
    !if $tt=?analyze
292
      !if r$i isitemof $tmp_oefsteps or $gotsteps=$empty
293
        !advance conditionned
294
      !endif
295
    !else
296
      !if $oefsteps!=$empty and r$i notitemof $gotsteps
297
        !if r$i isitemof $tmp_oefsteps
298
          tmp_ans_w=$[$(replyweight$i)]
299
          !if $(replyweight$i)!=$empty and NaN notin $tmp_ans_w and Inf notin $tmp_ans_w and \
300
	            $tmp_ans_w!=1
301
            weightadjust=$[$weightadjust+$tmp_ans_w-1]
302
          !endif
303
          !reset tmp_ans_w tmp_oefsteps
304
        !endif
305
        !goto cont
306
      !endif
307
    !endif
308
    !if $(replygood$i)=$empty
309
      !advance freegot
310
      !goto cont
311
    !endif
312
    !if $(replytype$i)=coord and $(reply$i)=$empty
313
      reply$i=$click_x,$click_y
314
      reply$i=!nonempty item $(reply$i)
315
      !if $(reply$i)!=$empty
316
        reply$i=($(reply$i))
317
      !endif
318
    !endif
319
    r_=!trim $(reply$i)
320
    !if $(replytype$i)!=code
321
      reply$i=$r_
322
    !endif
323
    default_$i=!getopt default in $(replyoption$i)
324
    !if $(default_$i)!=$empty and ($r_=$empty or ($r_=$name_choose_code and $(replytype$i) iswordof menu))
325
      reply$i=$(default_$i)
326
      r_=$(default_$i)
327
    !endif
328
    !if $r_=$empty or \
329
	   ($(reply$i)=$name_choose_code and $(replytype$i) iswordof menu)
330
      !if $oefsteps=$empty or r$i isitemof $gotsteps
331
        error=empty_data
332
        !goto end
333
      !else
334
        reply$i=????
335
        diareply$i=bad
336
        !goto cont
337
      !endif
338
    !endif
339
    !! add default to fix a bug with nextstep and type click
340
    !default m_reply$i=$(reply$i)
341
    !default m_reply_$i=$(reply_$i)
342
    !default replytype$i=default
343
    tt=!word 1 of $(replygood$i)
344
  	# analyzed reply
345
    !if $tt=?analyze
346
      g_=!rows2lines $(replygood$i)
347
      g_=!line 1 of $g_
348
      tt=!word 2 of $g_
349
      !read oef/ans.proc $i nocompare
350
      !if $error!=$empty
351
        !goto end
352
      !endif
353
      !default m_reply$i=$(reply$i)
354
      !default m_reply_$i=$(reply_$i)
355
      !read oef/screply.proc
356
      val$tt=$(m_reply$i)
357
      !if NaN isin $test
358
        !goto badans
359
      !endif
360
      !goto cont
361
    !endif
362
    !read oef/ans.proc $i
363
    !if $error!=$empty
364
      !goto end
365
    !endif
366
    !default m_reply$i=$(reply$i)
367
    !default m_reply_$i=$(reply_$i)
368
    !default m_reply_$i=$(reply$i)
369
    !read oef/screply.proc
370
    !if bad isin $Test
371
      error=bad_exo $i
372
      !advance reply_cnt
373
      status=
374
      !goto end
375
    !endif
376
    !if NaN isin $test
377
      :badans
378
      error=bad_answer
379
      bad_name=$(replyname$i)
380
      bad_value=$(reply$i)
381
      !goto end
382
    !endif
383
  :cont
384
  !next i
385
  !for i=1 to $choicecnt
386
    !if $oefsteps!=$empty and c$i notitemof $gotsteps
387
      !goto contc
388
    !endif
389
    !default choice$i=0
390
    choic=$[rint($(choice$i))]
391
    !if $choic=0 and ($oefsteps=$empty or c$i isitemof $gotsteps)
392
      error=empty_data
393
      !goto end
394
    !endif
395
    !if NaN isin $choic or $choic<1 or $choic>$(choiceitems$i)+2
396
      error=bad_answer
397
      bad_name=$(choicename$i)
398
      bad_value=$(choice$i)
399
      !goto end
400
    !else
401
      choice$i=$choic
402
    !endif
403
    ch=!item $choic of $(choicelist$i)
404
    m_choice$i=$ch
405
    !if $qcmgood<1 and $choic=$[$(choiceitems$i)+2]
406
      !if $(choicegood$i)=$empty
407
        chh=good
408
      !else
409
        chh=bad
410
      !endif
411
    !endif
412
    !if ($choic<=$(choiceitems$i) and $ch isitemof $(choicegood$i)) or $chh=good
413
      diachoice$i=good
414
      m_sc_choice$i=1
415
      !advance qcmgot
416
    !else
417
      diachoice$i=bad
418
      m_sc_choice$i=0
419
      !if $penalty>0 and $choic!=$[$(choiceitems$i)+1]
420
        cc=!itemcnt $(choicegood$i)
421
        !if $cc>=$(choiceitems$i)
422
          cc=$[$(choiceitems$i)-1]
423
        !endif
424
        qcmgot=$[$qcmgot-$cc/($(choiceitems$i)-$cc)]
425
      !endif
426
      !if $choic=$[$(choiceitems$i)+1]
427
        m_sc_choice$i=-1
428
      !endif
429
    !endif
430
    :contc
431
  !next i
432
  !if $postvarcnt>0 and $thisstep_postdef!=done
433
    !read $deffile postdef
434
  !endif
435
  !if $conditioncnt>0
436
    testcondition=yes
437
    condlist=all
438
    !read $deffile test
439
    testcondition=
440
    !if $condlist issametext all
441
      condlist=!values x for x=1 to $conditioncnt
442
    !else
443
      condlist=!words2items $condlist
444
    !endif
445
    conditioncnt=!itemcnt $condlist
446
    !for i in $condlist
447
      !default condweight$i=1
448
      weightadjust=$[$weightadjust+$(condweight$i)-1]
449
      !if $(condtest$i)>0
450
        condgot=$[$condgot+$(condweight$i)]
451
      !endif
452
    !next i
453
  !endif
454
  !advance reply_cnt
455
  freetot=$[$creplycnt+$conditioncnt-$conditionned+$weightadjust]
456
  !if $freetot>0
457
    freegot=$[$condgot+$freegot+$gotadjust+$precweight*$precgood]
458
  !else
459
    freegot=0
460
  !endif
461
  alltot=$[$freetot+$cchoicecnt]
462
  allgot=$[$freegot+$qcmgot]
463
  !if $alltot>0 and $allgot>0
464
    allgot=$[($allgot/$alltot)^$freepower*$alltot]
465
  !else
466
    allgot=0
467
  !endif
468
  score_got=$[$score_got+$allgot]
469
  score_should=$[$score_should+$alltot]
470
  status=done
471
  !if $reply_cnt>=$qnum
472
    !bound score_got between 0 and $score_should
473
    score=$[min(10,rint(100*($score_got/max(1,$score_should))^$scorepower)/10)]
474
    module_score=$score
475
    !if 0$delay2>0 and $starttime>0
476
      n_=$wims_nowseconds
477
      last=$[$n_-$starttime-4]
478
      !if $last>0$delay1
479
        toolate=$  $[$last-$delay1]-$[$last-$delay2]
480
        !if $last>0$delay2 or $module_score<=0
481
          module_score=0
482
        !else
483
          module_score=$[rint(10*$module_score*($delay2-$last)/($delay2-$delay1))/10]
484
        !endif
485
      !endif
486
    !endif
487
    !if $oef_test!=yes
488
      wims_module_log=score $module_score/10$toolate
489
    !endif
490
    status=
491
  !endif
492
!endif
493
 
494
:end
495
 
496
!if $status=waiting
497
  !distribute item 1,1 into cntr,cntc
498
  form_=document.forms['replyform']
499
  !for t in $ansorder
500
    !if $oefsteps=$empty or $t$(cnt$t) isitemof $thisstep
501
      !if $t=r
15341 obado 502
        !if $(replytype$(cnt$t)) notwordof checkbox
15063 bpr 503
          defaultest=!getopt default in $(replyoption$(cnt$t))
504
          !if $defaultest=$empty
505
            wims_form_lock=!append line if($form_.reply$(cnt$t).value.length==0) return emptyfield(); to $wims_form_lock
506
          !else
507
            !if nocheck notwordof $(replyoption$(cnt$t))
508
              wims_form_lock=!append line if($form_.reply$(cnt$t).value.length==0) nb_default+=1; to $wims_form_lock
509
            !endif
510
          !endif
15341 obado 511
        !else
512
          !! test for checkboxes
513
          wims_form_lock=!append line if(verify_checkboxes('reply$(cnt$t)')==null) return emptyfield(); to $wims_form_lock
15063 bpr 514
        !endif
515
      !endif
516
    !endif
517
    !advance cnt$t
518
  !next t
519
  header_js=<script>\
520
function emptyfield() {\
521
 alert("$name_empty"); return false;\
522
}\
523
function formcheck() {\
524
  var nb_default=0;\
525
  $wims_form_lock\
526
  if(nb_default>0){\
15341 obado 527
    if("jQuery" in window){jQuery("#exo_formCheck").foundation('open');return false;}\
528
    {return window.confirm("$name_exo_form_check");}\
15063 bpr 529
  }\
530
  return true;\
531
}\
15341 obado 532
function verify_checkboxes(box_name) {\
533
  var checkedValue = null;\
534
  var inputElements = document.getElementsByName(box_name);\
535
  for(var i=0; inputElements[i]; ++i){\
536
    if(inputElements[i].checked){\
537
      checkedValue = inputElements[i].value;\
538
      break;\
539
    }\
540
  }\
541
  return checkedValue;\
542
}\
15063 bpr 543
</script>
544
!endif
545
 
546
savedrawcnt=0
547
savetexcnt=0