1 |
wakaba |
1.5 |
#!/usr/bin/perl |
2 |
wakaba |
1.2 |
|
3 |
|
|
use strict; |
4 |
wakaba |
1.5 |
|
5 |
|
|
for (split /[&;]/, $main::ENV{QUERY_STRING}) { |
6 |
|
|
|
7 |
|
|
} |
8 |
wakaba |
1.2 |
|
9 |
wakaba |
1.3 |
my %ex_point1 = (); |
10 |
|
|
( |
11 |
wakaba |
1.2 |
kokugo => 54, |
12 |
|
|
suugaku => 55, |
13 |
|
|
eigo => 57, |
14 |
|
|
sekaishi => 53, |
15 |
|
|
nihonshi => 0, |
16 |
|
|
chiri => 0, |
17 |
|
|
butsuri => 54, |
18 |
|
|
kagaku => 52, |
19 |
|
|
seibutsu => 0, |
20 |
|
|
_OBJECT => 57, |
21 |
|
|
); |
22 |
|
|
|
23 |
wakaba |
1.3 |
my %ex_point2 = (); |
24 |
|
|
( |
25 |
wakaba |
1.2 |
kokugo => 53, |
26 |
|
|
suugaku => 55, |
27 |
|
|
eigo => 55, |
28 |
|
|
sekaishi => 52, |
29 |
|
|
nihonshi => 0, |
30 |
|
|
chiri => 0, |
31 |
|
|
butsuri => 54, |
32 |
|
|
kagaku => 51, |
33 |
|
|
seibutsu => 0, |
34 |
|
|
_OBJECT => 58, |
35 |
|
|
); |
36 |
|
|
|
37 |
wakaba |
1.3 |
my %ex_haiten1 = (); |
38 |
|
|
( |
39 |
wakaba |
1.2 |
kokugo => 80, |
40 |
|
|
suugaku => 80, |
41 |
|
|
eigo => 80, |
42 |
|
|
sekaishi => 40, |
43 |
|
|
nihonshi => 0, |
44 |
|
|
chiri => 0, |
45 |
|
|
butsuri => 40, |
46 |
|
|
kagaku => 0, |
47 |
|
|
seibutsu => 0, |
48 |
|
|
); |
49 |
|
|
|
50 |
wakaba |
1.3 |
my %ex_haiten2 = (); |
51 |
|
|
( |
52 |
wakaba |
1.2 |
kokugo => 0, |
53 |
|
|
suugaku => 300, |
54 |
|
|
eigo => 150, |
55 |
|
|
sekaishi => 0, |
56 |
|
|
nihonshi => 0, |
57 |
|
|
chiri => 0, |
58 |
|
|
butsuri => 150, |
59 |
|
|
kagaku => 150, |
60 |
|
|
seibutsu => 0, |
61 |
|
|
); |
62 |
|
|
|
63 |
|
|
|
64 |
|
|
sub kanzan (%%%%) { |
65 |
|
|
my ($point1, $full1, $point2, $full2) = @_; |
66 |
|
|
my (%kanzaned1, %kanzaned2); |
67 |
|
|
$$full1{_ALL} = 0; |
68 |
|
|
for my $subject (keys %$full1) { |
69 |
|
|
next if $subject =~ /^_/; |
70 |
|
|
$kanzaned1{$subject} = $$point1{$subject}*$$full1{$subject}/100; |
71 |
|
|
$kanzaned1{_ALL} += $kanzaned1{$subject}; |
72 |
|
|
$$full1{_ALL} += $$full1{$subject}; |
73 |
|
|
} |
74 |
wakaba |
1.4 |
$kanzaned1{_PERCENT} = $$full1{_ALL}==0?0:100*$kanzaned1{_ALL}/$$full1{_ALL}; |
75 |
wakaba |
1.2 |
$$full2{_ALL} = 0; |
76 |
|
|
for my $subject (keys %$full2) { |
77 |
|
|
next if $subject =~ /^_/; |
78 |
|
|
$kanzaned2{$subject} = $$point2{$subject}*$$full2{$subject}/100; |
79 |
|
|
$kanzaned2{_ALL} += $kanzaned2{$subject}; |
80 |
|
|
$$full2{_ALL} += $$full2{$subject}; |
81 |
|
|
} |
82 |
wakaba |
1.4 |
$kanzaned2{_PERCENT} = $$full2{_ALL}==0?0:100*$kanzaned2{_ALL}/$$full2{_ALL}; |
83 |
wakaba |
1.2 |
|
84 |
|
|
my ($percent, $object_percent); |
85 |
wakaba |
1.4 |
$percent = ($$full1{_ALL}+$$full2{_ALL})==0?0: |
86 |
|
|
100*($kanzaned1{_ALL}+$kanzaned2{_ALL}) |
87 |
wakaba |
1.2 |
/($$full1{_ALL}+$$full2{_ALL}); |
88 |
wakaba |
1.4 |
$object_percent = ($$full1{_ALL}+$$full2{_ALL})==0?0: |
89 |
|
|
($$point1{_OBJECT}*$$full1{_ALL} |
90 |
wakaba |
1.2 |
+$$point2{_OBJECT}*$$full2{_ALL}) |
91 |
|
|
/($$full1{_ALL}+$$full2{_ALL}); |
92 |
|
|
($percent, $object_percent, \%kanzaned1, \%kanzaned2); |
93 |
|
|
} |
94 |
|
|
|
95 |
wakaba |
1.5 |
%Suika::CGI::param = %{__get_parameter ()}; |
96 |
wakaba |
1.2 |
my (%mypoint1, %mypoint2, %haiten1, %haiten2); |
97 |
|
|
if ($Suika::CGI::param{newform} ne 'no') { |
98 |
|
|
%mypoint1 = %ex_point1; |
99 |
|
|
%mypoint2 = %ex_point2; |
100 |
|
|
%haiten1 = %ex_haiten1; |
101 |
|
|
%haiten2 = %ex_haiten2; |
102 |
|
|
} else { |
103 |
|
|
for my $s (keys %Suika::CGI::param) { |
104 |
|
|
$mypoint1{$1} = $Suika::CGI::param{$s} if $s =~ /^(.+[^H_])1$/; |
105 |
|
|
$mypoint2{$1} = $Suika::CGI::param{$s} if $s =~ /^(.+[^H_])2$/; |
106 |
|
|
$mypoint1{'_'.$1} = $Suika::CGI::param{$s} if $s =~ /^(.+)_1$/; |
107 |
|
|
$mypoint2{'_'.$1} = $Suika::CGI::param{$s} if $s =~ /^(.+)_2$/; |
108 |
|
|
$haiten1{$1} = $Suika::CGI::param{$s} if $s =~ /^(.+)H1$/; |
109 |
|
|
$haiten2{$1} = $Suika::CGI::param{$s} if $s =~ /^(.+)H2$/; |
110 |
|
|
} |
111 |
|
|
} |
112 |
|
|
my ($percent, $object, $kanzan1, $kanzan2) |
113 |
|
|
= kanzan ({%mypoint1} => {%haiten1}, {%mypoint2} => {%haiten2}); |
114 |
|
|
|
115 |
wakaba |
1.3 |
print STDOUT "Content-Type: text/html; charset=euc-jp |
116 |
|
|
Content-Style-Type: text/css |
117 |
|
|
Content-Language: ja |
118 |
wakaba |
1.2 |
|
119 |
|
|
"; |
120 |
|
|
output_html (\%mypoint1 => \%haiten1 => $kanzan1, |
121 |
|
|
\%mypoint2 => \%haiten2 => $kanzan2, |
122 |
|
|
percent => $percent, object => $object); |
123 |
|
|
|
124 |
|
|
sub diffmark ($) { |
125 |
|
|
my $diff = shift; |
126 |
|
|
return '□' if $diff < -4; |
127 |
|
|
return '△' if $diff < -2; |
128 |
|
|
return '○' if $diff < 0; |
129 |
|
|
return '◎'; |
130 |
|
|
} |
131 |
|
|
|
132 |
|
|
sub output_html (%%%%%) { |
133 |
|
|
my ($p1 => $h1 => $k1, $p2 => $h2 => $k2, %misc) = @_; |
134 |
|
|
for my $n ($$k1{_PERCENT}, $$k2{_PERCENT}, $misc{percent}, $misc{object}) { |
135 |
|
|
$n = int ($n); |
136 |
|
|
} |
137 |
|
|
$$k1{_DIFF} = $$k1{_PERCENT}-$$p1{_OBJECT}; |
138 |
|
|
$$k2{_DIFF} = $$k2{_PERCENT}-$$p2{_OBJECT}; |
139 |
|
|
$misc{_DIFF} = $misc{percent}-$misc{object}; |
140 |
|
|
$$k1{_DIFFMARK} = diffmark ($$k1{_DIFF}); |
141 |
|
|
$$k2{_DIFFMARK} = diffmark ($$k2{_DIFF}); |
142 |
|
|
$misc{_DIFFMARK} = diffmark ($misc{_DIFF}); |
143 |
|
|
print <<EOH; |
144 |
|
|
<!DOCTYPE html PUBLIC "-//W3D//DTD HTML 4.01//EN"> |
145 |
|
|
<html lang="ja"> |
146 |
|
|
<head> |
147 |
|
|
<title>配点換算</title> |
148 |
wakaba |
1.4 |
<link rev="made" href="mailto:w\@suika.fam.cx"> |
149 |
wakaba |
1.5 |
<link rel="contents" href="http://tomikou.net/tokshuu/kanzan.html" title="換算点算出システム |
150 |
|
|
"> |
151 |
wakaba |
1.3 |
<link rel="contents" href="/chuubu/"> |
152 |
wakaba |
1.5 |
<link rel="stylesheet" href="/s/default/xhtml1" media="all"> |
153 |
wakaba |
1.6 |
<link rel="help" href="intro" title="説明" /> |
154 |
wakaba |
1.5 |
<style type="text/css" media="all"> |
155 |
wakaba |
1.2 |
input {width: 3em} |
156 |
|
|
</style> |
157 |
|
|
</head> |
158 |
|
|
<body> |
159 |
|
|
<h1>配点換算</h1> |
160 |
wakaba |
1.5 |
<form action="kanzan" method="post" accept-charset="iso-2022-jp"> |
161 |
wakaba |
1.2 |
<table> |
162 |
|
|
<thead> |
163 |
|
|
<tr> |
164 |
|
|
<th colspan="2">教科</th> |
165 |
|
|
<th>国語</th><th>数学</th><th>英語</th> |
166 |
|
|
<th>世界史</th><th>日本史</th><th>地理</th> |
167 |
|
|
<th>物理</th><th>化学</th><th>生物</th> |
168 |
|
|
</tr> |
169 |
|
|
</thead> |
170 |
|
|
<tbody> |
171 |
|
|
<tr> |
172 |
|
|
<th rowspan="3">一次</th><th>持ち点</th> |
173 |
|
|
<td><input type="text" name="kokugo1" value="$$p1{kokugo}"></td> |
174 |
|
|
<td><input type="text" name="suugaku1" value="$$p1{suugaku}"></td> |
175 |
|
|
<td><input type="text" name="eigo1" value="$$p1{eigo}"></td> |
176 |
|
|
<td><input type="text" name="sekaishi1" value="$$p1{sekaishi}"></td> |
177 |
|
|
<td><input type="text" name="nihonshi1" value="$$p1{nihonshi}"></td> |
178 |
|
|
<td><input type="text" name="chiri1" value="$$p1{chiri}"></td> |
179 |
|
|
<td><input type="text" name="butsuri1" value="$$p1{butsuri}"></td> |
180 |
|
|
<td><input type="text" name="kagaku1" value="$$p1{kagaku}"></td> |
181 |
|
|
<td><input type="text" name="seibutsu1" value="$$p1{seibutsu}"></td> |
182 |
|
|
</tr> |
183 |
|
|
<tr> |
184 |
|
|
<th>配点</th> |
185 |
|
|
<td><input type="text" name="kokugoH1" value="$$h1{kokugo}"></td> |
186 |
|
|
<td><input type="text" name="suugakuH1" value="$$h1{suugaku}"></td> |
187 |
|
|
<td><input type="text" name="eigoH1" value="$$h1{eigo}"></td> |
188 |
|
|
<td><input type="text" name="sekaishiH1" value="$$h1{sekaishi}"></td> |
189 |
|
|
<td><input type="text" name="nihonshiH1" value="$$h1{nihonshi}"></td> |
190 |
|
|
<td><input type="text" name="chiriH1" value="$$h1{chiri}"></td> |
191 |
|
|
<td><input type="text" name="butsuriH1" value="$$h1{butsuri}"></td> |
192 |
|
|
<td><input type="text" name="kagakuH1" value="$$h1{kagaku}"></td> |
193 |
|
|
<td><input type="text" name="seibutsuH1" value="$$h1{seibutsu}"></td> |
194 |
|
|
</tr> |
195 |
|
|
<tr> |
196 |
|
|
<th>換算点</th> |
197 |
|
|
<td>$$k1{kokugo}</td><td>$$k1{suugaku}</td><td>$$k1{eigo}</td> |
198 |
|
|
<td>$$k1{sekaishi}</td><td>$$k1{nihonshi}</td><td>$$k1{chiri}</td> |
199 |
|
|
<td>$$k1{butsuri}</td><td>$$k1{kagaku}</td><td>$$k1{seibutsu}</td> |
200 |
|
|
</tr> |
201 |
|
|
|
202 |
|
|
<tr> |
203 |
|
|
<th rowspan="3">二次</th><th>持ち点</th> |
204 |
|
|
<td><input type="text" name="kokugo2" value="$$p2{kokugo}"></td> |
205 |
|
|
<td><input type="text" name="suugaku2" value="$$p2{suugaku}"></td> |
206 |
|
|
<td><input type="text" name="eigo2" value="$$p2{eigo}"></td> |
207 |
|
|
<td><input type="text" name="sekaishi2" value="$$p2{sekaishi}"></td> |
208 |
|
|
<td><input type="text" name="nihonshi2" value="$$p2{nihonshi}"></td> |
209 |
|
|
<td><input type="text" name="chiri2" value="$$p2{chiri}"></td> |
210 |
|
|
<td><input type="text" name="butsuri2" value="$$p2{butsuri}"></td> |
211 |
|
|
<td><input type="text" name="kagaku2" value="$$p2{kagaku}"></td> |
212 |
|
|
<td><input type="text" name="seibutsu2" value="$$p2{seibutsu}"></td> |
213 |
|
|
</tr> |
214 |
|
|
<tr> |
215 |
|
|
<th>配点</th> |
216 |
|
|
<td><input type="text" name="kokugoH2" value="$$h2{kokugo}"></td> |
217 |
|
|
<td><input type="text" name="suugakuH2" value="$$h2{suugaku}"></td> |
218 |
|
|
<td><input type="text" name="eigoH2" value="$$h2{eigo}"></td> |
219 |
|
|
<td><input type="text" name="sekaishiH2" value="$$h2{sekaishi}"></td> |
220 |
|
|
<td><input type="text" name="nihonshiH2" value="$$h2{nihonshi}"></td> |
221 |
|
|
<td><input type="text" name="chiriH2" value="$$h2{chiri}"></td> |
222 |
|
|
<td><input type="text" name="butsuriH2" value="$$h2{butsuri}"></td> |
223 |
|
|
<td><input type="text" name="kagakuH2" value="$$h2{kagaku}"></td> |
224 |
|
|
<td><input type="text" name="seibutsuH2" value="$$h2{seibutsu}"></td> |
225 |
|
|
</tr> |
226 |
|
|
<tr> |
227 |
|
|
<th>換算点</th> |
228 |
|
|
<td>$$k2{kokugo}</td><td>$$k2{suugaku}</td><td>$$k2{eigo}</td> |
229 |
|
|
<td>$$k2{sekaishi}</td><td>$$k2{nihonshi}</td><td>$$k2{chiri}</td> |
230 |
|
|
<td>$$k2{butsuri}</td><td>$$k2{kagaku}</td><td>$$k2{seibutsu}</td> |
231 |
|
|
</tr> |
232 |
|
|
</tbody> |
233 |
|
|
</table> |
234 |
|
|
|
235 |
|
|
<table> |
236 |
|
|
<thead> |
237 |
|
|
<tr> |
238 |
|
|
<th></th><th>得点率</th><th>目標点</th><th colspan="2">差</th> |
239 |
|
|
</tr> |
240 |
|
|
</thead> |
241 |
|
|
<tbody> |
242 |
|
|
<tr> |
243 |
|
|
<th>一次</th> |
244 |
|
|
<td>$$k1{_PERCENT}</td> |
245 |
|
|
<td><input type="text" name="OBJECT_1" value="$$p1{_OBJECT}"></td> |
246 |
|
|
<td>$$k1{_DIFF}</td> |
247 |
|
|
<td>$$k1{_DIFFMARK}</td> |
248 |
|
|
</tr> |
249 |
|
|
<tr> |
250 |
|
|
<th>二次</th> |
251 |
|
|
<td>$$k2{_PERCENT}</td> |
252 |
|
|
<td><input type="text" name="OBJECT_2" value="$$p2{_OBJECT}"></td> |
253 |
|
|
<td>$$k2{_DIFF}</td> |
254 |
|
|
<td>$$k2{_DIFFMARK}</td> |
255 |
|
|
</tr> |
256 |
|
|
<tr> |
257 |
|
|
<th>合計</th> |
258 |
|
|
<td>$misc{percent}</td> |
259 |
|
|
<td>$misc{object}</td> |
260 |
|
|
<td>$misc{_DIFF}</td> |
261 |
|
|
<td>$misc{_DIFFMARK}</td> |
262 |
|
|
</tr> |
263 |
|
|
</tbody> |
264 |
|
|
</table> |
265 |
|
|
|
266 |
|
|
<p> |
267 |
|
|
<input type="hidden" name="newform" value="no"> |
268 |
|
|
<input type="submit" value="OK"> |
269 |
|
|
</p> |
270 |
|
|
</form> |
271 |
wakaba |
1.3 |
|
272 |
|
|
<div class="navigation"> |
273 |
wakaba |
1.5 |
[<a href="/gate/cvs/perl/kanzan/" lang="en">source</a>] |
274 |
wakaba |
1.6 |
[<a href="intro">説明</a>] |
275 |
wakaba |
1.3 |
</div> |
276 |
|
|
</body> |
277 |
|
|
</html> |
278 |
wakaba |
1.2 |
EOH |
279 |
|
|
} |
280 |
|
|
|
281 |
wakaba |
1.5 |
sub __get_parameter () { |
282 |
|
|
my @src; |
283 |
|
|
|
284 |
|
|
## Query-string of Request-URI |
285 |
|
|
my $qs = $main::ENV{QUERY_STRING}; |
286 |
|
|
push @src, $qs if (index ($qs, '=') > -1); |
287 |
|
|
|
288 |
|
|
## Entity-body |
289 |
|
|
if ($main::ENV{REQUEST_METHOD} eq 'POST') { |
290 |
|
|
my $mt = $main::ENV{CONTENT_TYPE}; |
291 |
|
|
if ($mt =~ m<^application/(?:x-www|sgml)-form-urlencoded\b>) { |
292 |
|
|
my $body; |
293 |
|
|
read STDIN, $body, $main::ENV{CONTENT_LENGTH}; |
294 |
|
|
push @src, $body; |
295 |
|
|
} |
296 |
|
|
} |
297 |
|
|
|
298 |
|
|
my %temp_params; |
299 |
|
|
for my $src (@src) { |
300 |
|
|
for (split /[;&]/, $src) { |
301 |
|
|
my ($name, $val) = split '=', $_, 2; |
302 |
|
|
for ($name, $val) { |
303 |
|
|
tr/+/ /; |
304 |
|
|
s/%([0-9A-Fa-f][0-9A-Fa-f])/pack 'C', hex $1/ge; |
305 |
|
|
} |
306 |
|
|
$temp_params{$name} = $val; |
307 |
|
|
} |
308 |
|
|
} |
309 |
|
|
\%temp_params; |
310 |
|
|
} |
311 |
|
|
|
312 |
|
|
|
313 |
wakaba |
1.3 |
=head1 LICENSE |
314 |
|
|
|
315 |
wakaba |
1.6 |
Copyright 2001-2004 Wakaba E<lt>w@suika.fam.cxE<gt>. |
316 |
wakaba |
1.3 |
|
317 |
|
|
This program is free software; you can redistribute it and/or modify |
318 |
|
|
it under the terms of the GNU General Public License as published by |
319 |
|
|
the Free Software Foundation; either version 2 of the License, or |
320 |
|
|
(at your option) any later version. |
321 |
|
|
|
322 |
|
|
This program is distributed in the hope that it will be useful, |
323 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
324 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
325 |
|
|
GNU General Public License for more details. |
326 |
|
|
|
327 |
|
|
You should have received a copy of the GNU General Public License |
328 |
|
|
along with this program; see the file COPYING. If not, write to |
329 |
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
330 |
|
|
Boston, MA 02111-1307, USA. |
331 |
|
|
|
332 |
|
|
=cut |
333 |
|
|
|
334 |
wakaba |
1.6 |
1; # $Date: 2003/11/05 12:52:46 $ |
335 |
wakaba |
1.5 |
|