Subversion Repositories wimsdev

Rev

Rev 11807 | Rev 11970 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed


!read adm/class/classlang names.phtml
wims_prefix=class user tmp techvar
!default activeexo=10
optionlist=autogen
!read tabletheme
sh=!itemcnt $asheets
!if $sh<1
 error=no_sheet
 !exit
!endif

scnt=!recordcnt wimshome/log/classes/$wims_class/exams/.exams
!if $exam>$scnt
 wims_infoshow=yes
 !setdef wims_infoshow=$wims_infoshow in wimshome/sessions/$wims_session/var.stat
!endif
!if $cmd=resume
 !bound infoshow within yes,no default $wims_infoshow
 wims_infoshow=$infoshow
 !setdef wims_infoshow=$wims_infoshow in wimshome/sessions/$wims_session/var.stat
!endif

max_exams=!defof MAX_EXAMS in wimshome/public_html/bases/sys/define.conf
title_limit=80
desc_limit=4000
etitle_limit=100
edesc_limit=400

duration_min=2
duration_max=600
duration_default=90

tries_min=1
tries_max=100
tries_default=3

!default duration=$duration_default
wims_helper=chapter=3

!if $wims_user!=supervisor
 !bound job within student, score, scorereg default student
!endif

!!if $job iswordof student score or $cmd=resume
  wims_ariane_self=no
!!endif
!if $seq>0
  wims_sequence=$seq
!endif

!if $job=duplicate
 !changeto $job.proc
!endif

today=!char 1 to 8 of $wims_now
thisyear=!char 1 to 4 of $today

!if $class_expiration=$empty or $class_creation=$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
jquery_defined=!defof jquery_defined in themes/$wims_theme/header.phtml
!if $jquery_defined=yes
    expmon=!char 5 to 6 of $expdate
    expday=!char 7 to 8 of $expdate
    expyear=!char 1 to 4 of $expdate
!endif
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_exams
 error=bad_exam
 !exit
!endif

# menu preparation
!if $job!=$empty and $job iswordof \
    prep_activate prep_erase prep_expire
 title=!record $exam of wimshome/log/classes/$wims_class/exams/.exams
 title=!line 4 of $title
 error=$job
 !exit
!endif

!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
 !readproc adm/updatesequence.proc exam,$exam
 !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
 !if $job=student
  !if exrandomlist iswordof $class_option
   !default exolist=!shuffle $exocnt
  !else
   !default exolist=!makelist x for x = 1 to $exocnt
  !endif
 !endif
!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==$exam){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
!! ---------------------------

!readproc adm/vfilter/listvarfilter.proc
!if $allow=yes and $wims_user=supervisor
 !if $tv_listname=$empty
    !bound allowtype within all,simulation,none,select default all
 !else
    !bound allowtype within all,simulation,none,select,techvar default all
 !endif
 !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
  !read adm/scorerestriction get
  IPlist=!translate ,;\
* to $    $ in $_output
  IPlist=!trim $IPlist
  !if $allowtype=select and $IPlist=$empty and $save!=$empty
   allowtype=all
  !endif
  !if $allowtype=all
   allow_parm=
  !endif
  !if $allowtype=none
   allow_parm=none
  !endif
  !if $allowtype=select
   allow_parm=$IPlist
  !endif
  !if $allowtype=techvar
   !readproc adm/vfilter/shexselect.proc E$exam
  !endif
!! --- save modification of allow parameters
  !if $save!=$empty
   !if $allow_parm=$empty
    !sh for c in $setclass; do rm -f $wims_home/log/classes/$$c/.E$exam; done
   !else
    !for c in $setclass
     !writefile wimshome/log/classes/$c/.E$exam $allow_parm
    !next c
   !endif
   wims_class_log=exam $exam allow $allowtype $allowshare by $wims_realuser
  !endif
!! --- end of saving

  !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
!endif

!if $allow=$empty or $save!=$empty
!! --- read saving configuration for allow parameters initial time and after saving
 !readproc adm/vfilter/shexread.proc E$exam
 !read adm/scorerestriction put\
$IPlist
!endif
old_allowtype=$allowtype
old_allowtechvar=$allowtechvar
!reset allow,save

!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 $duration_min and $duration_max default $duration_default
  !bound tries between integer $tries_min and $tries_max default $tries_default
  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 &#13; 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 $save2!=$empty
  !if $echoose=$empty
    !if $c_!=$empty
      echoose=$c_
    !else
      error=prep_noexercise
      !reset save2
      !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 save2
  !read update.exo
  !reset job,sasheets
  !if $error=$empty
   msg_info=addexook
  !endif
  !changeto var.proc
 !else
  eweight=$w_
  echoose=$c_
  ename=$n_
  edep=$d_
  eopt=$o_
  ecomment=$co_
 !endif

 !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 cpexam
 !read $job.proc
!endif