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