Rev 3245 | Rev 6176 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
!!!### language independant
!!
!read adm/class/classlang names.phtml
wims_prefix=class user tmp
!default activeexo=10
optionlist=autogen
!read tabletheme
sh=!itemcnt $asheets
!if $sh<1
error=no_sheet
!exit
!endif
max_exam=32
title_limit=80
desc_limit=4000
etitle_limit=100
edesc_limit=400
!default duration=90
wims_helper=chapter=3
!if $wims_user!=supervisor
!bound job within student, score, scorereg default student
!endif
!if $seq>0
wims_sequence=$seq
!endif
today=!char 1 to 8 of $wims_now
thisyear=!char 1 to 4 of $today
!if $class_expiration=$empty
!defread wimshome/log/classes/$wims_class/.def
!if $wims_superclass!=$empty
class_expiration=!defof class_expiration in wimshome/log/classes/$wims_superclass/.def
!endif
!endif
!if $class_expiration=$empty
error=bad_class
!exit
!endif
sharers=
sharing1=!defof sharable_sheet in wimshome/log/classes/$wims_class/neighbors
!for c in $sharing1
d=!defof sharing_sheet in wimshome/log/classes/$c/neighbors
!if $d issametext $wims_class
sharers=!append item $c to $sharers
!endif
!next c
expmon=!char 2,3 of $[abs(floor($expmon))+100]
expday=!char 2,3 of $[abs(floor($expday))+100]
expyear=!char -4 to -1 of $[abs(floor($expyear))+100000]
!if $expday>=1 and $expday<=31 and $expmon>=1 and $expmon<=12 \
and $expyear>=$thisyear and $expyear<=$thisyear+1 \
and $expyear$expmon$expday>$today \
and $expyear$expmon$expday<=$class_expiration
and N notin $expmon$expday$expyear
expiration=$expyear$expmon$expday
!endif
!if $exam<1 or $exam>$max_exam
error=bad_exam
!exit
!endif
# menu preparation
!if $job!=$empty and $job iswordof \
prep_activate prep_erase prep_expire
error=$job
!exit
!endif
scnt=!recordcnt wimshome/log/classes/$wims_class/exams/.exams
!if $job=erase and $exam>=1 and $exam<=$scnt
test=
!for s=$exam+1 to $scnt
l=!record $s of wimshome/log/classes/$wims_class/exams/.exams
l=!line 1 of $l
!if $l>0
test=notclean
!endif
!next s
!if $test=$empty
update_field=0
!read update.exam
!endif
!restart module=home
!endif
!if $job=expire
!distribute item 1,2 into update_field,update_content
!read update.exam
job=
!endif
!if $job=hide
!distribute item 1,3 into update_field,update_content
!read update.exam
job=
!endif
!if $job=reactivate
!distribute item 1,1 into update_field,update_content
!read update.exam
job=
!endif
activetest=!record $exam of wimshome/log/classes/$wims_class/exams/.exams
a_=!line 1 of $activetest
a_=!trim $a_
expp=!line 2 of $activetest
!default expiration=$expp
!if $expiration>$class_expiration
expiration=$class_expiration
!endif
ecnt=!recordcnt wimshome/log/classes/$wims_class/exams/.exam$exam
activetest=!replace line 4 by $ecnt in $activetest
!if $job=putsource and $a_=0
source=!trim $source
!writefile $srcname $source
putcnt=!recordcnt $srcname
!for i=1 to $putcnt
s_=!record $i of $srcname
n_=!linecnt $s_
bad_source=$i
!if $n_>=5 and $n_<10
!distribute lines $s_ into di,pa,re,we,ti,de
!for k in re,we,di,pa,ti,de
$k=!trim $($k)
w$k=!wordcnt $($k)
!next k
!if NaN isin $[$re]$[$we] or $[$wre*$wwe*$wdi]!=1 or $wpa>1 or $ti=$empty or\
.. isin $di or $re<0 or $we<0 or ($re>0 and $we=0)
error=bad_source
!exit
!endif
ti=!char 1 to $etitle_limit of $ti
de=!char 1 to $edesc_limit of $de
source_$i=$s_
last=$i
!else
# last record may be empty
!if $i!=$putcnt
error=bad_source
!exit
!endif
!endif
!next i
!for i=1 to $last
!appendfile wimshome/log/classes/$wims_class/exams/.exam$exam :$(source_$i)
!next i
!endif
!if $activetest!=$empty
exam_exist=yes
!default expiration=!line 2 of $activetest
activetest=!line 1 of $activetest
exocnt=!recordcnt wimshome/log/classes/$wims_class/exams/.exam$exam
!else
exam_exist=no
activetest=-1
exocnt=0
!default expiration=$class_expiration
!endif
!! ---------- desactivation d'examen soumis à condition : pas de partage, pas de score élève, certains type de classe (FG).
testsharing=!defof sharable_exam\
sharing_exam in wimshome/log/classes/$wims_class/neighbors
testsharing=!lines2items $testsharing
deactivate=yes
!if $testsharing!=$empty or $activetest<1
deactivate=sharing
!else
!if $class_type!=0 and ($class_type!=1 or $wims_superclass!=$class_parent)
deactivate=badstructure
!else
test=!sh cd $wims_home/log/classes/$wims_class/;\
list=`ls noscore | grep -v supervisor`;\
cd noscore;\
awk 'length($$1)==18{if($$3==1){print "no";exit};}' $$list;
!if no isin $test
deactivate=score
!endif
!endif
!endif
!if $job=deactivate
!if yes isin $deactivate
!distribute item 1,0 into update_field,update_content
!read update.exam
job=
!read var.proc
!else
error=nodeactivate
!endif
!endif
!! ---------------------------
!if $allow=yes and $wims_user=supervisor
!bound allowtype within all,simulation,none,select default all
!if $sharers!=$empty and $allowshare=1
setclass=$wims_class,$sharers
!else
setclass=$wims_class
!endif
!if $allowtype=simulation
!for c in $setclass
!writefile wimshome/log/classes/$c/.E$exam #
!next c
!else
IPlist=!translate ,;\
* to $ $ in $IPlist
IPlist=!trim $IPlist
!if $allowtype=select and $IPlist=$empty
allowtype=all
!endif
!if $allowtype=all
allow_parm=
!endif
!if $allowtype=none
allow_parm=none
!endif
!if $allowtype=select
allow_parm=$IPlist
!endif
!for c in $setclass
!writefile wimshome/log/classes/$c/.E$exam $allow_parm
!next c
!endif
!if $cutt notsametext $cutt_save
cutt=!translate ,; to $ $ in $cutt
cutt=!sort words $cutt
cutt=!singlespace $cutt
!distribute lines 6\
$cutt into update_field,update_content
!read update.exam
cutt_save=$cutt
!endif
!endif
allow=
allowlist=!record 0 of wimshome/log/classes/$wims_class/.E$exam
allowlist=!trim $allowlist
!if $allowlist=$empty
allowtype=all
!else
!if $allowlist=#
allowtype=simulation
!else
!if none iswordof $allowlist
allowtype=none
!else
allowtype=select
IPlist=$allowlist
!endif
!endif
!endif
!if $job iswordof student score
!if $wims_user=supervisor
allowtype=simulation
!else
simutest=!record 0 of wimshome/$wims_sesdir/examsimu.$exam
!if $allowtype!=simulation and yes iswordof $simutest
error=simuchange
!exit
!endif
!endif
!endif
expmon=!char 5,6 of $expiration
expday=!char 7,8 of $expiration
expyear=!char 1,2,3,4 of $expiration
!if $job!=text
!if $title_save$desc_save=$empty
rec=!record $exam of wimshome/log/classes/$wims_class/exams/.exams
!distribute lines $rec into bidon,bidon,setup_save,title_save,desc_save,cutt_save,comment_save
!endif
setup=$setup_save
title=$title_save
desc=$desc_save
cutt=$cutt_save
comment=$comment_save
!else
!if $title=$empty
error=no_title
!exit
!endif
!ifval $activetest<=0
!bound duration between integer 2 and 600 default 90
!bound tries between integer 1 and 100 default 3
setup=$duration $tries
!else
rec=!record $exam of wimshome/log/classes/$wims_class/exams/.exams
!distribute lines $rec into bidon,bidon,setup_save
setup=$setup_save
!endif
desc=!replace $\
$ by in $desc
title=!singlespace $title
desc=!singlespace $desc
title=!char 1 to $title_limit of $title
desc=!char 1 to $desc_limit of $desc
!if $exam_exist=yes
!distribute lines 2\
$expiration into update_field,update_content
!read update.exam
!distribute lines 3\
$setup into update_field,update_content
!read update.exam
!distribute lines 4\
$title into update_field,update_content
!read update.exam
!distribute lines 5\
$desc into update_field,update_content
!read update.exam
!distribute lines 6\
$cutt into update_field,update_content
!read update.exam
!distribute lines 7\
$comment into update_field,update_content
!read update.exam
!else
!appendfile wimshome/log/classes/$wims_class/exams/.exams :0\
$expiration\
$setup\
$title\
$desc\
$cutt\
$comment
exam_exist=yes
activetest=0
exam=!recordcnt wimshome/log/classes/$wims_class/exams/.exams
!writefile wimshome/log/classes/$wims_class/exams/.exam$exam
!endif
title_save=$title
desc_save=$desc
setup_save=$setup
cutt_save=$cutt
comment_save=$comment
!endif
!distribute words $setup into sdure,stries,sprime
!default sprime=0
duration=$sdure
!if $activetest>0 or $wims_user=supervisor
!read score.proc
!endif
!if $job=activate and $[$activetest]=0
!distribute item 1,1 into update_field,update_content
!read update.exam
activetest=1
!endif
# delete an item
!if $job=delete and $delete>0 and $delete<=$exocnt
!distribute items -1,$delete into update_field,exo
!read update.exo
delete=
exocnt=!recordcnt wimshome/log/classes/$wims_class/exams/.exam$exam
!endif
# move up an item
!if $job=moveup and $moveup>1 and $moveup<=$exocnt
x_=!record $moveup-1 of wimshome/log/classes/$wims_class/exams/.exam$exam
y_=!record $moveup of wimshome/log/classes/$wims_class/exams/.exam$exam
!distribute items 0,$[$moveup-1] into update_field,exo
update_content=$y_
!read update.exo
!distribute items 0,$moveup into update_field,exo
update_content=$x_
!read update.exo
!endif
# modify an exercise
!if $job=exo
!if $activetest>0
error=active_exam
job=$empty
!exit
!endif
!bound $exo between integer 1 and $exocnt+1 default $exocnt+1
ee=!record $exo of wimshome/log/classes/$wims_class/exams/.exam$exam
!distribute lines $ee into w_,c_,n_,d_,o_,co_
!! !if $echoose$ename$eweight!=$empty
!if $save!=$empty
!if $echoose=$empty
!if $c_!=$empty
echoose=$c_
!else
error=prep_noexercise
!exit
!endif
!endif
!bound eweight between 0,10 default 1
ename=!singlespace $ename
ename=!char 1 to $etitle_limit of $ename
!default ename=Ex
edep=!char 1 to 100 of $edep
eopt=!listintersect $eopt and $optionlist
update_content=$eweight\
$echoose\
$ename\
$edep\
$eopt\
$ecomment
update_field=0
!reset save
!read update.exo
!reset job,sasheets
!changeto var.proc
!else
eweight=$w_
echoose=$c_
ename=$n_
edep=$d_
eopt=$o_
ecomment=$co_
!endif
!endif
erasable=no
!if $[$activetest]=0
erasable=yes
scnt=!recordcnt wimshome/log/classes/$wims_class/exams/.exams
!for s=$exam+1 to $scnt
l=!record $s of wimshome/log/classes/$wims_class/exams/.exams
l=!line 1 of $l
!if $l>0
erasable=no
!endif
!next s
!endif
!if $back=1 and $error=$empty
!restart module=home
!endif
!if $job iswordof scorereg renew cpsheet
!read $job.proc
!endif