Rev 11870 | Rev 12120 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
!! file to manage score restriction for sheet, exam and other
!! don't forget to declare variable into var.def (with right number if in use) of the module
!! line 1 (2 words)
!! -first : html/put/get
!! html : html form to display
!! put : initialise var with date in third line
!! get : verify data from reply and make char wimsdata in output
!! -second : num of variable default empty (in case of several use in a same html page)
!! line 2 : value to put (default value in the form)
!distribute line $wims_read_parm into _job,_value
!distribute word $_job into _job,_num
!bound _job within html,put,get,empty default empty
!bound _num between 0 and 10 default $empty
!if $_job=empty
!exit
!endif
!goto $_job
:put
!set _value=!words2items $_value
!set _n=!itemcnt $_value
!reset IPscore$_num,begindscore$_num,enddscore$_num,begintscore$_num,endtscore$_num
!for _k=1 to $_n
!set _c=!char 1 of $(_value[$_k])
!if $_c=>
!set begindscore$_num=!char 2 to 9 of $(_value[$_k])
!set begintscore$_num=!char 11 to 15 of $(_value[$_k])
!else
!if $_c=<
!set enddscore$_num=!char 2 to 9 of $(_value[$_k])
!set endtscore$_num=!char 11 to 15 of $(_value[$_k])
!else
!set IPscore$_num=$(IPscore$_num) $(_value[$_k])
!endif
!endif
!next _k
!default begindscore$_num=$class_creation
!default enddscore$_num=$class_expiration
!default begintscore$_num=00:00
!default endtscore$_num=23:59
!exit
:html
<ul class="wims_nopuce">
<li>
$wims_name_from
!if $jquery_defined=yes
!read adm/datepickerform.phtml $(begindscore$_num)\
begindscore$_num\
"$class_creation","$class_expiration"
!else
<input size="8" name="begindscore$_num" value="$(begindscore$_num)" />
!endif
$wims_name_at <input size="5" name="begintscore$_num" value="$(begintscore$_num)" />
$wims_name_to
!if $jquery_defined=yes
!read adm/datepickerform.phtml $(enddscore$_num)\
enddscore$_num\
"$class_creation","$class_expiration"
!else
<input size="8" name="enddscore$_num" value="$(enddscore$_num)" />
!endif
$wims_name_at <input size="5" name="endtscore$_num" value="$(endtscore$_num)" />
</li><li>
$wims_name_IP <input size="20" name="IPscore$_num" value="$(IPscore$_num)" placeholder="127.0.0.1" />
</li>
</ul>
!exit
:get
!! error are not display to user but default value replace bad value
!! date format verification
!set _e=begin,end
!set _l=$class_creation,$class_expiration
!for _t=1 to 2
!set $(_e[$_t])dscore$_num=!text select 0123456789 in $($(_e[$_t])dscore$_num)
!bound $(_e[$_t])dscore$_num between $class_creation and $class_expiration default $(_l[$_t])
!set _y=!char 1 to 4 of $($(_e[$_t])dscore$_num)
!set _m=!char 5 to 6 of $($(_e[$_t])dscore$_num)
!set _d=!char 7 to 8 of $($(_e[$_t])dscore$_num)
!! ---- day and month check (not realy good test should be an exact test of existence of date)
!if $_m<1 or $_m>12 or $_d<1 or $_d>31
!set $(_e[$_t])dscore$_num=$(_l[$_t])
!endif
!next _t
!! time format verification
!set _l=00:00,23:59
!for _t=1 to 2
!set $(_e[$_t])tscore$_num=!text select 0123456789: in $($(_e[$_t])tscore$_num)
!set $(_e[$_t])tscore$_num=!replace internal : by , in $($(_e[$_t])tscore$_num)
!set _nb=!itemcnt $($(_e[$_t])tscore$_num)
!if $_nb=2
!distribute item $($(_e[$_t])tscore$_num) into _h,_m
!set _h=$[$_h*1]
!set _m=$[$_m*1]
!if $_h<0 or $_h>23 or $_m<0 or $_m>59 or NaN isin $_h$_m
!set $(_e[$_t])tscore$_num=$(_l[$_t])
!else
!set _h=!char 2 to 3 of $[100+$_h]
!set _m=!char 2 to 3 of $[100+$_m]
!set $(_e[$_t])tscore$_num=$_h:$_m
!endif
!else
!set $(_e[$_t])tscore$_num=$(_l[$_t])
!endif
!next _t
!! IP restriction char
!set IPscore$_num=!text select char 1234567890. in $(IPscore$_num)
!! write output
!reset _output
!if $(begindscore$_num)!=$empty and ($(begindscore$_num)!=$class_creation or $(begintscore$_num)!=00:00)
!set _output=$_output>$(begindscore$_num).$(begintscore$_num)
!endif
!if $(enddscore$_num)!=$empty and ($(enddscore$_num)!=$class_expiration or $(endtscore$_num)!=23:59)
!set _output=$_output <$(enddscore$_num).$(endtscore$_num)
!endif
!set _output=$_output $(IPscore$_num)
!exit