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