Subversion Repositories wimsdev

Rev

Rev 16295 | Rev 16685 | 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
16295 czzmrn 94
  !default lang_choice=$lang
15063 bpr 95
  !set title=!defof title_$lang_choice in $deffile
96
  !default title=!defof title in $deffile
97
  !set module_title=$title
98
  !set modtitle=$title
99
  !set module_author=$author
100
  !set module_address=$email
101
  nn=!itemcnt $shufflelist
102
  thisexo=!item ($reply_cnt)%$nn+1 of $shufflelist
103
  !readproc oef/valback.proc
104
  !readproc oef/imagedir.proc
105
  val1=$imagedir
106
  m_step=$oefstep
107
  !exit
108
!endif
109
 
110
!if $cmd=new or $cmd=renew
111
  starttime=$wims_nowseconds
112
!endif
113
 
114
!default insplot_set=size 0.6,0.6
115
!default idontknow=1
116
!default allchoices=0
117
 
118
!if $oef_test=yes
119
  print=
120
  qnum=1
121
  qcmlevel=1
122
  intro_qcmpresent=8
123
  intro_sol=1
124
  intro_feed=1
125
  freepower=2
126
  scorepower=1
127
  random=0
128
  exocnt=1
129
  precweight=0.9
130
 
131
  !if $retest=again
132
    !reset status retest oef_default
133
  !endif
134
!else
135
  !read $(class_header)Exindex
15746 bpr 136
  !! FIXME
137
  !! mis pour mémoire, pour l'instant rien n'est changé.
138
  !! essai de réparation de la perte de special_parm3
139
  !! on trafique ensuite module_init_parm et special_parm3
140
  !! mais si special_parm3 existe on n'en fait rien !
15063 bpr 141
  exocnt=!itemcnt $exolist
15746 bpr 142
  !!!if $special_parm3!=$empty
143
  !!  !read getparm $special_parm3 qnum
144
  !!  qnum=$get_qnum
145
  !!!else
15063 bpr 146
  !bound qnum between integer 1 and 9 default 1
147
  !bound qcmlevel between integer 1 and 9 default 3
148
  !bound random within 0,1 default 1
149
  tmp=!replace internal & by ; in $module_init_parm
150
  !! URL encode \n
151
  tmp=!replace internal $\
152
$ by %0A in $tmp
153
 
15746 bpr 154
    tmp=intro_check=$intro_check;random=$random;$tmp
155
    tmp=!replace internal scoredelay=; by scoredelay=0; in $tmp
156
    #tmp=!replace internal exo=; by exo=0; in $tmp
157
    special_parm3=!nospace $tmp
158
  !!!endif
15063 bpr 159
  !if $scoredelay!=$empty and $scoredelay!=0
160
    d_=!items2words $scoredelay
161
    !distribute words $d_ into delay1,delay2
162
    !bound delay1 between integer 0 and 2000 default 0
163
    !bound delay2 between integer $delay1 and 2000
164
  !endif
165
  !reset scoredelay tmp
166
!endif
167
!default format=html
168
 
169
!if $print!=$empty
170
  !changeto oef/print.proc
171
!endif
172
 
173
!if $cmd=reply and $status!=waiting
174
  error=double_reply
175
  !exit
176
!endif
177
 
178
!if $status=$empty
179
  !read oef/exo.init
180
!endif
181
 
182
!if $cmd iswordof new renew reply and \
183
  ($wims_user=supervisor or $wims_user=$empty or $wims_developer!=$empty)
184
  exonext=!positionof item $exo in $exolist
185
  exoprev=$[$exonext-1]
186
  exonext=$[$exonext+1]
187
  !if $exonext > $exocnt
188
    exonext=1
189
  !endif
190
  !if $exoprev < 1
191
    exoprev=$exocnt
192
  !endif
193
  exoprev=!item $exoprev of $exolist
194
  exonext=!item $exonext of $exolist
195
!endif
196
 
197
!if $status!=waiting
198
  !for i=1 to $limit_reply
199
    !reset replygood$i
200
  !next i
201
  !reset solution, hint, help, oefsteps, oefstepcnt, latex
202
  !for i=1 to 16
203
    savedraw$i=
204
    savetex$i=
205
  !next i
206
!endif
207
 
208
!if $oef_test=yes
209
  deffile=wimshome/$wims_sesdir/submit.def
210
!else
211
  nn=!itemcnt $shufflelist
212
  thisexo=!item ($reply_cnt)%$nn+1 of $shufflelist
213
  deffile=$(class_header)def/$thisexo.def
214
  !if $nn>1 and $status!=waiting
215
    wims_module_log=$wims_module_log got $thisexo
216
  !endif
217
!endif
218
!readproc oef/imagedir.proc
219
 
220
!distribute items 0,0,0,0,0,0 into \
221
	varcnt,postvarcnt,replycnt,choicecnt,conditioncnt,feedbackcnt
222
!if $status!=waiting
223
  !reset ansorder,oefstep,oefsteps,oefstepcnt,nextstep,dynsteps,\
224
	  cchoicecnt, creplycnt, embedcnt, vsavelist, leftrange, rightrange
225
  !read $deffile
226
  !read oef/var.prep
227
!else
228
 
229
  !read $deffile
230
  !if $savedraw1!=$empty
231
    savedrawcnt=0
232
    !for i=1 to 16
233
      !if $(savedraw$i)!=$empty
234
        !read oef/draw.phtml $(savedraw$i)
235
      !else
236
        !if $(savetex$i)!=$empty
237
          !read oef/teximg.phtml $(savetex$i)
238
        !endif
239
      !endif
240
    !next i
241
  !endif
242
  !readproc oef/valback.proc
243
  !if $oefsteps!=$empty
244
    !readproc oef/steps.proc
245
  !endif
246
!endif
247
!if $embedcnt>0 or $embedcnt=$empty
248
  hasembedding=yes
249
!endif
250
!if $oefsteps!=$empty
251
  thisstep=!line $oefstep of $oefsteps
252
  gotsteps=!line 1 to $oefstep of $oefsteps
253
  gotsteps=!lines2items $gotsteps
254
  m_step=$oefstep
255
!else
256
  cchoicecnt=$choicecnt
257
  creplycnt=$replycnt
258
!endif
259
 
260
!if $cmd=reply and $status=waiting
261
  !if ($oefsteps!=$empty and $oefstep<$oefstepcnt) or \
262
	($dynsteps=yes and $oefstep=$oefstepcnt)
263
    !readproc oef/step.proc
264
    !if $dynsteps=yes and $oefstep>$oefstepcnt
265
      oefstep=$[$oefstep-1]
266
      !goto ana
267
    !endif
268
    !if $stepdiag=ok or $error!=$empty
269
      !goto end
270
    !endif
271
  !else
272
    !if $oefsteps!=$empty and $oefstep=$oefstepcnt
273
      !for i=1 to $replycnt
274
        !if r$i isitemof $gotsteps and r$i notitemof $thisstep
275
          reply$i=$(saverep$i)
276
        !endif
277
      !next i
278
      !for i=1 to $choicecnt
279
        !if c$i isitemof $gotsteps and c$i notitemof $thisstep
280
          choice$i=$(savech$i)
281
        !endif
282
      !next i
283
    !endif
284
  !endif
285
  :ana
286
  !distribute item 0,0,0,0,0,0,0,0,0 into \
287
	conditionned, freegot, condgot, qcmgot, \
288
	precgood, weightadjust, gotadjust, cweightadjust, cgotadjust
289
  !for i=1 to $replycnt
290
    tt=!word 1 of $(replygood$i)
291
    tmp_oefsteps=!lines2items $oefsteps
292
    !if $tt=?analyze
293
      !if r$i isitemof $tmp_oefsteps or $gotsteps=$empty
294
        !advance conditionned
295
      !endif
296
    !else
297
      !if $oefsteps!=$empty and r$i notitemof $gotsteps
298
        !if r$i isitemof $tmp_oefsteps
299
          tmp_ans_w=$[$(replyweight$i)]
300
          !if $(replyweight$i)!=$empty and NaN notin $tmp_ans_w and Inf notin $tmp_ans_w and \
301
	            $tmp_ans_w!=1
302
            weightadjust=$[$weightadjust+$tmp_ans_w-1]
303
          !endif
304
          !reset tmp_ans_w tmp_oefsteps
305
        !endif
306
        !goto cont
307
      !endif
308
    !endif
309
    !if $(replygood$i)=$empty
310
      !advance freegot
311
      !goto cont
312
    !endif
313
    !if $(replytype$i)=coord and $(reply$i)=$empty
314
      reply$i=$click_x,$click_y
315
      reply$i=!nonempty item $(reply$i)
316
      !if $(reply$i)!=$empty
317
        reply$i=($(reply$i))
318
      !endif
319
    !endif
320
    r_=!trim $(reply$i)
321
    !if $(replytype$i)!=code
322
      reply$i=$r_
323
    !endif
324
    default_$i=!getopt default in $(replyoption$i)
325
    !if $(default_$i)!=$empty and ($r_=$empty or ($r_=$name_choose_code and $(replytype$i) iswordof menu))
326
      reply$i=$(default_$i)
327
      r_=$(default_$i)
328
    !endif
329
    !if $r_=$empty or \
330
	   ($(reply$i)=$name_choose_code and $(replytype$i) iswordof menu)
331
      !if $oefsteps=$empty or r$i isitemof $gotsteps
332
        error=empty_data
333
        !goto end
334
      !else
335
        reply$i=????
336
        diareply$i=bad
337
        !goto cont
338
      !endif
339
    !endif
340
    !! add default to fix a bug with nextstep and type click
341
    !default m_reply$i=$(reply$i)
342
    !default m_reply_$i=$(reply_$i)
343
    !default replytype$i=default
344
    tt=!word 1 of $(replygood$i)
345
  	# analyzed reply
346
    !if $tt=?analyze
347
      g_=!rows2lines $(replygood$i)
348
      g_=!line 1 of $g_
349
      tt=!word 2 of $g_
350
      !read oef/ans.proc $i nocompare
351
      !if $error!=$empty
352
        !goto end
353
      !endif
354
      !default m_reply$i=$(reply$i)
355
      !default m_reply_$i=$(reply_$i)
356
      !read oef/screply.proc
357
      val$tt=$(m_reply$i)
358
      !if NaN isin $test
359
        !goto badans
360
      !endif
361
      !goto cont
362
    !endif
363
    !read oef/ans.proc $i
364
    !if $error!=$empty
365
      !goto end
366
    !endif
367
    !default m_reply$i=$(reply$i)
368
    !default m_reply_$i=$(reply_$i)
369
    !default m_reply_$i=$(reply$i)
370
    !read oef/screply.proc
371
    !if bad isin $Test
372
      error=bad_exo $i
373
      !advance reply_cnt
374
      status=
375
      !goto end
376
    !endif
377
    !if NaN isin $test
378
      :badans
379
      error=bad_answer
380
      bad_name=$(replyname$i)
381
      bad_value=$(reply$i)
382
      !goto end
383
    !endif
384
  :cont
16294 guerimand 385
    !reset test Test
15063 bpr 386
  !next i
387
  !for i=1 to $choicecnt
388
    !if $oefsteps!=$empty and c$i notitemof $gotsteps
389
      !goto contc
390
    !endif
391
    !default choice$i=0
392
    choic=$[rint($(choice$i))]
393
    !if $choic=0 and ($oefsteps=$empty or c$i isitemof $gotsteps)
394
      error=empty_data
395
      !goto end
396
    !endif
397
    !if NaN isin $choic or $choic<1 or $choic>$(choiceitems$i)+2
398
      error=bad_answer
399
      bad_name=$(choicename$i)
400
      bad_value=$(choice$i)
401
      !goto end
402
    !else
403
      choice$i=$choic
404
    !endif
405
    ch=!item $choic of $(choicelist$i)
406
    m_choice$i=$ch
407
    !if $qcmgood<1 and $choic=$[$(choiceitems$i)+2]
408
      !if $(choicegood$i)=$empty
409
        chh=good
410
      !else
411
        chh=bad
412
      !endif
413
    !endif
414
    !if ($choic<=$(choiceitems$i) and $ch isitemof $(choicegood$i)) or $chh=good
415
      diachoice$i=good
416
      m_sc_choice$i=1
417
      !advance qcmgot
418
    !else
419
      diachoice$i=bad
420
      m_sc_choice$i=0
421
      !if $penalty>0 and $choic!=$[$(choiceitems$i)+1]
422
        cc=!itemcnt $(choicegood$i)
423
        !if $cc>=$(choiceitems$i)
424
          cc=$[$(choiceitems$i)-1]
425
        !endif
426
        qcmgot=$[$qcmgot-$cc/($(choiceitems$i)-$cc)]
427
      !endif
428
      !if $choic=$[$(choiceitems$i)+1]
429
        m_sc_choice$i=-1
430
      !endif
431
    !endif
432
    :contc
433
  !next i
434
  !if $postvarcnt>0 and $thisstep_postdef!=done
435
    !read $deffile postdef
436
  !endif
437
  !if $conditioncnt>0
438
    testcondition=yes
439
    condlist=all
440
    !read $deffile test
441
    testcondition=
442
    !if $condlist issametext all
443
      condlist=!values x for x=1 to $conditioncnt
444
    !else
445
      condlist=!words2items $condlist
446
    !endif
447
    conditioncnt=!itemcnt $condlist
448
    !for i in $condlist
449
      !default condweight$i=1
450
      weightadjust=$[$weightadjust+$(condweight$i)-1]
451
      !if $(condtest$i)>0
452
        condgot=$[$condgot+$(condweight$i)]
453
      !endif
454
    !next i
455
  !endif
456
  !advance reply_cnt
457
  freetot=$[$creplycnt+$conditioncnt-$conditionned+$weightadjust]
458
  !if $freetot>0
459
    freegot=$[$condgot+$freegot+$gotadjust+$precweight*$precgood]
460
  !else
461
    freegot=0
462
  !endif
463
  alltot=$[$freetot+$cchoicecnt]
464
  allgot=$[$freegot+$qcmgot]
465
  !if $alltot>0 and $allgot>0
466
    allgot=$[($allgot/$alltot)^$freepower*$alltot]
467
  !else
468
    allgot=0
469
  !endif
470
  score_got=$[$score_got+$allgot]
471
  score_should=$[$score_should+$alltot]
472
  status=done
473
  !if $reply_cnt>=$qnum
474
    !bound score_got between 0 and $score_should
475
    score=$[min(10,rint(100*($score_got/max(1,$score_should))^$scorepower)/10)]
476
    module_score=$score
477
    !if 0$delay2>0 and $starttime>0
478
      n_=$wims_nowseconds
479
      last=$[$n_-$starttime-4]
480
      !if $last>0$delay1
481
        toolate=$  $[$last-$delay1]-$[$last-$delay2]
482
        !if $last>0$delay2 or $module_score<=0
483
          module_score=0
484
        !else
485
          module_score=$[rint(10*$module_score*($delay2-$last)/($delay2-$delay1))/10]
486
        !endif
487
      !endif
488
    !endif
489
    !if $oef_test!=yes
490
      wims_module_log=score $module_score/10$toolate
491
    !endif
492
    status=
493
  !endif
494
!endif
495
 
496
:end
497
 
16683 guerimand 498
!if $cmd=hint or $cmd=resume
499
!! add to display student answer in case of use an hint or resume to work
500
 !for i=1 to $replycnt
501
    !default m_reply$i=$(reply$i)
502
 !next i
503
 !for i=1 to $choicecnt
504
    m_choice$i=!item $(choice$i) of $(choicelist$i)
505
 !next i
506
!endif
507
 
15063 bpr 508
!if $status=waiting
509
  !distribute item 1,1 into cntr,cntc
510
  form_=document.forms['replyform']
511
  !for t in $ansorder
512
    !if $oefsteps=$empty or $t$(cnt$t) isitemof $thisstep
513
      !if $t=r
15341 obado 514
        !if $(replytype$(cnt$t)) notwordof checkbox
15063 bpr 515
          defaultest=!getopt default in $(replyoption$(cnt$t))
516
          !if $defaultest=$empty
517
            wims_form_lock=!append line if($form_.reply$(cnt$t).value.length==0) return emptyfield(); to $wims_form_lock
518
          !else
519
            !if nocheck notwordof $(replyoption$(cnt$t))
520
              wims_form_lock=!append line if($form_.reply$(cnt$t).value.length==0) nb_default+=1; to $wims_form_lock
521
            !endif
522
          !endif
15341 obado 523
        !else
524
          !! test for checkboxes
525
          wims_form_lock=!append line if(verify_checkboxes('reply$(cnt$t)')==null) return emptyfield(); to $wims_form_lock
15063 bpr 526
        !endif
527
      !endif
528
    !endif
529
    !advance cnt$t
530
  !next t
531
  header_js=<script>\
532
function emptyfield() {\
533
 alert("$name_empty"); return false;\
534
}\
535
function formcheck() {\
536
  var nb_default=0;\
537
  $wims_form_lock\
538
  if(nb_default>0){\
15341 obado 539
    if("jQuery" in window){jQuery("#exo_formCheck").foundation('open');return false;}\
540
    {return window.confirm("$name_exo_form_check");}\
15063 bpr 541
  }\
542
  return true;\
543
}\
15341 obado 544
function verify_checkboxes(box_name) {\
545
  var checkedValue = null;\
546
  var inputElements = document.getElementsByName(box_name);\
547
  for(var i=0; inputElements[i]; ++i){\
548
    if(inputElements[i].checked){\
549
      checkedValue = inputElements[i].value;\
550
      break;\
551
    }\
552
  }\
553
  return checkedValue;\
554
}\
15063 bpr 555
</script>
556
!endif
557
 
558
savedrawcnt=0
559
savetexcnt=0