Subversion Repositories wimsdev

Rev

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