Rev 14775 | Rev 14791 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
# Variable calculations should be done in this file.
# It is read and interpreted by wims for all valid calls to the module.
!! --- securise variable
wims_prefix=class user
!!wims_writable=
!!wims_readable=
!if $notallowed=1
error=notallowedmodule
!exit
!endif
!! file number to read in function of type
lpara_type=1,1,3,4
listfilename_ztype=geogebra,texte,file
!! la zone file est à faire
nbztype=!itemcnt $listfilename_ztype
!! check access
!if $statutfreework!=open
!restart module=home
!endif
!read adm/language lang/names.phtml
tmp=!defof MAX_FREEWORKS\
MAX_USERFORGRADES in wimshome/public_html/bases/sys/define.conf
!distribute line $tmp into max_freeworks,max_userforgrades
title_limit=80
desc_limit=4000
!if $cmd=help
!exit
!endif
!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
jquery_defined=!defof jquery_defined in wimshome/public_html/themes/$class_theme/header.phtml
!if $cmd=resume and $jquery_defined!=yes
!for k in infoshow1,infoshow2
!bound $k within yes,no default yes
!if $(wims_$k)!=$($k)
wims_$k=$($k)
!setdef wims_$k=$($k) in wimshome/session/$wims_session/var.stat
!endif
!next k
!endif
!! ------ check job function of user right
!! this test is not necessary while there is only one job for student.
!!!if $job isitemof student1,student2,student3
!! job=student
!!!endif
!if $wims_user=supervisor
listjob=configfw,prep_activate,expire,hide,reactivate,deactivate,prep_erase,uploadco,savescore,viewuser3,uploadco3
defjob=configfw
!else
listjob=student
defjob=student
!endif
!bound job within $listjob default $defjob
today=!char 1 to 8 of $wims_now
!! --------- read general data of the freework
nbfreework=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freeworks
!if $wims_user=supervisor
!if $job=configfw
!bound freework between 1 and $[$nbfreework+1] default $[$nbfreework+1]
!else
!bound freework between 1 and $nbfreework default 1
!endif
!else
!reset save
!bound freework between 1 and $nbfreework default 1
!endif
!if $freework>$max_freeworks
error=bad_maxfreework
!exit
!endif
!! -------- make manual score index
uucnt=!recordcnt wimshome/log/classes/$wims_class/.grades
!if $uucnt>0
!! --- check for column for score
tmp=!record 1 of wimshome/log/classes/$wims_class/.grades
!distribute line $tmp into bl,score_title,bl
score_title=!item 3 to -1 of $score_title
nbscore=!itemcnt $score_title
!! --- check for score key for each user
uucnt=$[$uucnt-1]
!for i=1 to $uucnt
u_=!record $i+1 of wimshome/log/classes/$wims_class/.grades
n_=!item 1 of $u_
uulist=!append item $n_ to $uulist
!next i
!else
nbscore=0
!endif
! ------------ end manual score index
!if $save=$empty and $freework<=$nbfreework
tmp=!record $freework of wimshome/log/classes/$wims_class/freeworks/.freeworks
!distribute line $tmp into activetest,expdate,title,desc,comment,type,deadline,soldate,sizelimitfile,scoring,seealltime
!for val in deadline,soldate
t=!replace internal . by , in $($val)
!distribute item $t into $val,time$val
!default $val=$today
!default time$val=00:00
!next val
!bound activetest between 0 and 3
!endif
!if $freework>$nbfreework
!default deadline=$today
!default timedeadline=00:00
!default soldate=$today
!default timesoldate=00:01
!default sizelimitfile=4
wims_infoshow1=yes
scoring=0
seealltime=0
!endif
!! --------- check variable values
title=!singlespace $title
title=!detag $title
title=!char 1 to $title_limit of $title
title=!replace internal : by : in $title
desc=!replace internal $\
$ by $ $ in $desc
desc=!char 1 to $desc_limit of $desc
desc=!replace internal : by : in $desc
comment=!replace internal $\
$ by $ $ in $comment
comment=!singlespace $comment
comment=!detag $comment
!bound type between 1 and 4 default 1
!if $type=1
sizelimitfile=$empty
!else
!bound sizelimitfile between 1 and 10 default 4
!if $type=3
!! ------ incase of type=3 sizelimitfile=0 if no student filezone
nb=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freework$freework
numberfilezone=0
!for k=1 to $nb
test=!record $k of wimshome/log/classes/$wims_class/freeworks/.freework$freework
test=!line 1 of $test
!distribute word $test into s,z
!if $s=file and $z=student
!increase numberfilezone
!endif
!next k
!if $numberfilezone=0
sizelimitfile=$empty
!endif
!endif
!endif
!if $jquery_defined!=yes and $save!=$empty
!for k in deadline,soldate
!for l in month,day
$(l)$(k)=$[100+$($(l)$(k))]
$(l)$(k)=!char 2 to 3 of $($(l)$(k))
!next l
!next k
deadline=$yeardeadline$monthdeadline$daydeadline
soldate=$yearsoldate$monthsoldate$daysoldate
!endif
t=0
!for val in deadline,soldate
!! -- check date format
$val=!text select 0123456789 in $($val)
expmon=!char 5 to 6 of $($val)
expday=!char 7 to 8 of $($val)
expyear=!char 1 to 4 of $($val)
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 $($val)<=$class_expiration \
and N notin $expmon$expday$expyear
$val=$expyear$expmon$expday
!else
$val=$class_expiration
!endif
!! -- check time format
time$val=!text select 0123456789: in $(time$val)
time$val=!replace internal : by , in $(time$val)
nb=!itemcnt $(time$val)
!if $nb=2
!distribute item $(time$val) into h,m
h=$[$h*1]
m=$[$m*1]
!if $h<0 or $h>23 or $m<0 or $m>59 or NaN isin $h$m
time$val=00:0$t
!else
h=!char 2 to 3 of $[100+$h]
m=!char 2 to 3 of $[100+$m]
time$val=$h:$m
!endif
!else
time$val=00:0$t
!endif
!increase t
!next val
!if $type>=2 and $nbscore>0
!bound scoring between 0 and $nbscore default 0
!if $scoring>0
m=!record 0 of wimshome/log/classes/$wims_class/sheets/.severity
maxscore=!word 1 of $m
!bound maxscore between 0 and 100000 default 10
!endif
!else
scoring=0
!endif
!bound seealltime between 0 and 1 default 0
!! ----------- end check general variable
!! -------------- check right for download/upload participant file and etc... (see description below)
!! define variables :
!! loadwork=1 supervisor can download/see user work
!! nbcopies : number of student deposit work
!! nbcorrectedcopies : number of work corrected by supervisor
!! notcorrected : difference between last two values
!! putworkco=1 supervisor can modify/delete global correction file
!! putiworkco=1 supervisor can upload individual correction/remark/score
!! displaysolution=1 student can download géneral solution
!! codownload=1 student can download personnal solution
!! this variable can be use in subfile of each type
!!
d1=!text select char 0123456789 in $(deadline)$(timedeadline)
d2=!text select char 0123456789 in $(soldate)$(timesoldate)
now=!text select char 0123456789 in $wims_now
now=!char 1 to 12 of $now
!distribute item 0,0 into loadwork,putworkco
!if $activetest=1 and $type>1 and ($now>$d1 or $seealltime=1)
loadwork=1
!endif
!if $activetest>=1
!if $activetest=1
!distribute item 0,0,0,0 into putworkco,putiworkco,displaysolution,codownload
n1=!filelist $wims_home/log/classes/$wims_class/freeworksdata/$freework/work
n2=!filelist $wims_home/log/classes/$wims_class/freeworksdata/$freework/co
!if $type=2
!! --- calcul for type=2
nbcopies=!linecnt $n1
nbcorrectedcopies=!linecnt $n2
!else
!! --- calcul for type=3
n1=!replace internal - by , in $n1
n1=!column 1 of $n1
n1=!listuniq $n1
nbcopies=!itemcnt $n1
nbcorrectedcopies=!linecnt $n2
!endif
notcorrected=$[$nbcopies-$nbcorrectedcopies]
!if $now<$d2
putworkco=1
!else
displaysolution=1
!endif
!if ($notcorrected>0 or $now<$d2) and $type>1 and $now>=$d1
putiworkco=1
!endif
!if $now>=$d2 and $notcorrected=0 and $type>1
codownload=1
!endif
!else
putworkco=0
putiworkco=0
loadwork=1
displaysolution=1
codownload=0
!endif
!! --- general solution diffused if solutiondate pass or activetest>=2
!if $now>$d2 or $activetest>=2
displaysolution=1
!endif
!endif
!if $activetest=0
loadwork=0
putworkco=1
putiworkco=0
displaysolution=0
codownload=0
!endif
!! ------- end global variable
!! ------ make file link for download and some title
!if $wims_user=supervisor
!if $freework>$nbfreework
activetest=-1
name_title=$name_tmkfreework
!else
name_title=$name_managefreework
!endif
!if $activetest>=0 and $type<=3
!sh cd $wims_home/$wims_sesdir;\
mkdir -p getfile;\
cd getfile;\
mkdir -p freeworks;\
cd freeworks;\
rm -f $freework;\
ln -s $wims_home/log/classes/$wims_class/freeworks/$freework $freework;
!endif
!else
name_title=!nosubst $wims_name_Freework $freework
!if $activetest>=1
nb=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freework$freework
!reset flistsolution,flistsubject
!for k=1 to $nb
dt=!record $k of wimshome/log/classes/$wims_class/freeworks/.freework$freework
!if $(dt[1;]) isitemof subject,solution
flist$(dt[1;])=!line 2 to -1 of $dt
flist$(dt[1;])=!nonempty line $(flist$(dt[1;]))
flist$(dt[1;])=!lines2items $(flist$(dt[1;]))
!endif
!next k
!if $displaysolution=1
flist=!listunion $flistsolution and $flistsubject
!else
flist=$flistsubject
!endif
flist=!nonempty item $flist
flist=!listuniq $flist
flist=!items2words $flist
!endif
!if $flist!=$empty
testfile=!word 1 of $flist
test=!fileexists wimshome/sessions/$wims_session/getfile/freeworks/$freework/$testfile
!if $test!=yes
!sh cd $wims_home/$wims_sesdir;\
mkdir -p getfile;\
cd getfile;\
rm -rf freeworks;\
mkdir -p freeworks;\
cd freeworks;\
mkdir $freework;\
cd $freework;\
for k in $flist; do\
ln -s $wims_home/log/classes/$wims_class/freeworks/$freework/$$k $$k;\
done;
!endif
!endif
!sh mkdir -p $wims_home/sessions/$wims_session/getfile/freeworksdata
!endif
!read lang.phtml.$lang
!if $job=student
job=student$(lpara_type[$type])
!endif
!changeto $job.proc