Subversion Repositories wimsdev

Rev

Rev 17170 | Rev 17530 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11809 guerimand 1
!! file to manage score restriction for sheet, exam and other
11814 guerimand 2
!! don't forget to declare variable into var.def (with right number if in use) of the module
11870 bpr 3
!! line 1 (2 words)
12801 obado 4
!!  -first : html/put/get
5
!!    html : html form to display
12994 guerimand 6
!!    put  : initialise var with date in second line
12801 obado 7
!!    get  : verify data from reply and make char wimsdata in output
8
!!  -second : num of variable default empty (in case of several use in a same html page)
11814 guerimand 9
!! line 2 : value to put (default value in the form)
11809 guerimand 10
 
11814 guerimand 11
!distribute line $wims_read_parm into _job,_value
12
!distribute word $_job into _job,_num
11809 guerimand 13
!bound _job within html,put,get,empty default empty
12022 czzmrn 14
!set MAXnbvalue=!defof MAX_TECHVARVAL in wimshome/public_html/bases/sys/define.conf
15
!bound _num between 0 and $MAXnbvalue default $empty
11809 guerimand 16
 
17
!if $_job=empty
12801 obado 18
  !exit
11809 guerimand 19
!endif
11846 guerimand 20
!goto $_job
11809 guerimand 21
 
11846 guerimand 22
:put
12927 guerimand 23
  !set _value=!words2items $_value
24
  !set _n=!itemcnt $_value
25
  !reset IPscore$_num,begindscore$_num,enddscore$_num,begintscore$_num,endtscore$_num
26
  !set datecheck$_num=$empty
27
  !for _k=1 to $_n
28
    !set _c=!char 1 of $(_value[$_k])
29
    !if $_c=>
30
      !set begindscore$_num=!char 2 to 9 of $(_value[$_k])
31
      !set begintscore$_num=!char 11 to 15 of $(_value[$_k])
12801 obado 32
    !else
12927 guerimand 33
      !if $_c=<
34
        !set enddscore$_num=!char 2 to 9 of $(_value[$_k])
35
        !set endtscore$_num=!char 11 to 15 of $(_value[$_k])
36
      !else
37
        !set IPscore$_num=$(IPscore$_num) $(_value[$_k])
38
      !endif
12801 obado 39
    !endif
12927 guerimand 40
  !next _k
41
  !let _now=!char 1 to 8 of $wims_now
42
  !if $(begindscore$_num)=$class_creation or $(begindscore$_num)=$empty
43
    !let begindscore$_num=$_now
44
    !if $(enddscore$_num)=$empty
12977 obado 45
      !let datecheck$_num=none
12927 guerimand 46
    !endif
12801 obado 47
  !endif
12927 guerimand 48
  !default enddscore$_num=$class_expiration
49
  !default begintscore$_num=00:00
50
  !default endtscore$_num=23:59
51
  !exit
11846 guerimand 52
 
11809 guerimand 53
:html
12986 guerimand 54
!if exam isin $module
55
 !set allid_=3,4
56
!else
57
 !set allid_=2,3
58
!endif
12977 obado 59
!if $_num != $empty
60
  !! score restriction use a $_num for each techvar
61
  <select name="datecheck$_num" id="datecheck$_num"
14367 guerimand 62
          !if $jquery_defined=yes
63
            onchange="toggle_select_option(this, 'select')"
64
          !else
65
            onchange="submit()"
66
          !endif
67
  >
12977 obado 68
    <option value="none"
69
      !if $(datecheck$_num)=none
70
        selected="selected"
71
      !endif
12986 guerimand 72
    >$(name_allowtype[$(allid_[1])])</option>
12977 obado 73
    <option value="select"
74
      !if $(datecheck$_num)!=none
75
        selected="selected"
76
      !endif
12986 guerimand 77
    >$(name_allowtype[$(allid_[2])])</option>
12977 obado 78
  </select>
79
!endif
80
 
81
<ul class="wims_nopuce"
82
!if $_num != $empty and $(datecheck$_num)=none
83
  style="display:none"
84
!else
85
  style="display:block"
86
!endif
87
>
12801 obado 88
  <li>
89
    <label for="begindscore$_num">$wims_name_from</label>
12988 obado 90
 
12927 guerimand 91
      !read adm/datepickerform.phtml $(begindscore$_num)\
11835 guerimand 92
begindscore$_num\
93
"$class_creation","$class_expiration"
12801 obado 94
    <label for="begintscore$_num">$wims_name_at</label>
17170 bpr 95
    <input type="time" size="5" name="begintscore$_num" id="begintscore$_num" value="$(begintscore$_num)">
11809 guerimand 96
 
12801 obado 97
    <label for="enddscore$_num">$wims_name_to</label>
12927 guerimand 98
      !read adm/datepickerform.phtml $(enddscore$_num)\
11835 guerimand 99
enddscore$_num\
100
"$class_creation","$class_expiration"
12801 obado 101
    <label for="endtscore$_num">$wims_name_at</label>
17170 bpr 102
    <input type="time" size="5" name="endtscore$_num" id="endtscore$_num" value="$(endtscore$_num)">
12977 obado 103
 
12801 obado 104
  </li><li>
105
    <label for="IPscore$_num">$wims_name_IP</label>
17170 bpr 106
    <input size="15" name="IPscore$_num" id="IPscore$_num" value="$(IPscore$_num)" placeholder="127.0.0.1">
12801 obado 107
  </li>
11870 bpr 108
</ul>
12977 obado 109
!reset datecheck$_num
11809 guerimand 110
!exit
111
 
112
:get
11836 guerimand 113
!! error are not display to user but default value replace bad value
11814 guerimand 114
!! date format verification
12803 bpr 115
!set _e=begin,end
116
!set _l=$class_creation,$class_expiration
117
!for _t=1 to 2
12801 obado 118
  !set $(_e[$_t])dscore$_num=!text select 0123456789 in $($(_e[$_t])dscore$_num)
119
  !bound $(_e[$_t])dscore$_num between $class_creation and $class_expiration default $(_l[$_t])
120
  !set _y=!char 1 to 4 of $($(_e[$_t])dscore$_num)
121
  !set _m=!char 5 to 6 of $($(_e[$_t])dscore$_num)
122
  !set _d=!char 7 to 8 of $($(_e[$_t])dscore$_num)
123
  !! ---- day and month check (not realy good test should be an exact test of existence of date)
124
  !if $_m<1 or $_m>12 or $_d<1 or $_d>31
125
    !set $(_e[$_t])dscore$_num=$(_l[$_t])
126
  !endif
12803 bpr 127
!next _t
11814 guerimand 128
!! time format verification
12803 bpr 129
!set _l=00:00,23:59
130
!for _t=1 to 2
12801 obado 131
  !set $(_e[$_t])tscore$_num=!text select 0123456789: in $($(_e[$_t])tscore$_num)
132
  !set $(_e[$_t])tscore$_num=!replace internal : by , in $($(_e[$_t])tscore$_num)
133
  !set _nb=!itemcnt $($(_e[$_t])tscore$_num)
134
  !if $_nb=2
135
    !distribute item $($(_e[$_t])tscore$_num) into _h,_m
136
    !set _h=$[$_h*1]
137
    !set _m=$[$_m*1]
138
    !if $_h<0 or $_h>23 or $_m<0 or $_m>59 or NaN isin $_h$_m
139
      !set $(_e[$_t])tscore$_num=$(_l[$_t])
140
    !else
141
      !set _h=!char 2 to 3 of $[100+$_h]
142
      !set _m=!char 2 to 3 of $[100+$_m]
143
      !set $(_e[$_t])tscore$_num=$_h:$_m
144
    !endif
145
  !else
146
    !set $(_e[$_t])tscore$_num=$(_l[$_t])
147
  !endif
12803 bpr 148
!next _t
11814 guerimand 149
!! IP restriction char
12803 bpr 150
!set IPscore$_num=!text select char 1234567890. in $(IPscore$_num)
11815 guerimand 151
!! write output
12803 bpr 152
!reset _output
12977 obado 153
!if $(begindscore$_num)!=$empty and ($(begindscore$_num)!=$class_creation or $(begintscore$_num)!=00:00) and none notin $(datecheck$_num)
12801 obado 154
  !set _output=$_output>$(begindscore$_num).$(begintscore$_num)
12803 bpr 155
!endif
12977 obado 156
!if $(enddscore$_num)!=$empty and ($(enddscore$_num)!=$class_expiration or $(endtscore$_num)!=23:59) and none notin $(datecheck$_num)
12801 obado 157
  !set _output=$_output <$(enddscore$_num).$(endtscore$_num)
12803 bpr 158
!endif
159
!set _output=$_output $(IPscore$_num)
160
!exit