Subversion Repositories wimsdev

Rev

Rev 17764 | Details | Compare with Previous | Last modification | View Log | RSS feed

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