Subversion Repositories wimsdev

Rev

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