Subversion Repositories wimsdev

Rev

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