File: scorerestriction

package info (click to toggle)
wims 2%3A4.29a%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 185,704 kB
  • sloc: xml: 366,687; javascript: 120,570; ansic: 62,341; java: 62,170; sh: 7,744; perl: 3,937; yacc: 3,217; cpp: 1,915; lex: 1,805; makefile: 1,084; lisp: 914; pascal: 601; python: 520; php: 318; asm: 7
file content (173 lines) | stat: -rw-r--r-- 5,907 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
!!### adm/scorerestriction
!! 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 second 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
!set MAXnbvalue=!defof MAX_TECHVARVAL in wimshome/public_html/bases/sys/define.conf
!bound _num between 0 and $MAXnbvalue 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
!set datecheck$_num=$empty
!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
!let _now=!char 1 to 8 of $wims_now
!if $(begindscore$_num)=$class_creation or $(begindscore$_num)=$empty
  !let begindscore$_num=$_now
  !if $(enddscore$_num)=$empty
    !let datecheck$_num=none
  !endif
!endif
!default enddscore$_num=$class_expiration
!default begintscore$_num=00:00
!default endtscore$_num=23:59
!exit

:html
!let _now=!char 1 to 8 of $wims_now
!if exam isin $module
  !set allid_=3,4
!else
  !set allid_=2,3
!endif
!if $_num != $empty
  !! score restriction use a $_num for each techvar
  <label for="datecheck$_num">$(name_shinfo[6])</label>
  <select name="datecheck$_num" id="datecheck$_num"
          !if $jquery_defined=yes
            onchange="toggle_select_option(this, 'select')"
          !else
            onchange="submit()"
          !endif
  >
    <option value="none"
      !if $(datecheck$_num)=none
        selected="selected"
      !endif
    >$(name_allowtype[$(allid_[1])])</option>
    <option value="select"
      !if $(datecheck$_num)!=none
        selected="selected"
      !endif
    >$(name_allowtype[$(allid_[2])])</option>
  </select>
!endif

<ul class="wims_nopuce"
  !if $_num != $empty and $(datecheck$_num)=none
    style="display:none"
  !else
    style="display:block"
  !endif
>
  <li>
    <label for="begindscore$_num">$wims_name_from</label>
    !if $(begindscore$_num) < $class_creation
      <div class="wims_msg warning">$wims_name_corrected_date ($(begindscore$_num))</div>
      !let begindscore$_num=$class_creation

    !endif
    !read adm/datepickerform.phtml $(begindscore$_num)\
begindscore$_num\
"$class_creation","$class_expiration"

    <label for="begintscore$_num">$wims_name_at</label>
    <input type="time" size="5" name="begintscore$_num" id="begintscore$_num" value="$(begintscore$_num)">

    <label for="enddscore$_num">$wims_name_to</label>
    !if $(enddscore$_num) < $class_creation
      <div class="wims_msg warning">$wims_name_corrected_date ($(enddscore$_num))</div>
      !let enddscore$_num=$class_creation
    !endif
    !read adm/datepickerform.phtml $(enddscore$_num)\
enddscore$_num\
"$class_creation","$class_expiration"

    <label for="endtscore$_num">$wims_name_at</label>
    <input type="time" size="5" name="endtscore$_num" id="endtscore$_num" value="$(endtscore$_num)">

  </li><li>
    <label for="IPscore$_num">$wims_name_IP</label>
    <input size="15" name="IPscore$_num" id="IPscore$_num" value="$(IPscore$_num)" placeholder="127.0.0.1">
  </li>
</ul>
!reset datecheck$_num
!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) and none notin $(datecheck$_num)
  !set _output=$_output>$(begindscore$_num).$(begintscore$_num)
!endif
!if $(enddscore$_num)!=$empty and ($(enddscore$_num)!=$class_expiration or $(endtscore$_num)!=23:59) and none notin $(datecheck$_num)
  !set _output=$_output <$(enddscore$_num).$(endtscore$_num)
!endif
!set _output=$_output $(IPscore$_num)
!exit