1 |
#!/usr/local/bin/perl
|
2 |
|
3 |
use strict;
|
4 |
require Suika::CGI;
|
5 |
|
6 |
my %ex_point1 = (
|
7 |
kokugo => 54,
|
8 |
suugaku => 55,
|
9 |
eigo => 57,
|
10 |
sekaishi => 53,
|
11 |
nihonshi => 0,
|
12 |
chiri => 0,
|
13 |
butsuri => 54,
|
14 |
kagaku => 52,
|
15 |
seibutsu => 0,
|
16 |
_OBJECT => 57,
|
17 |
);
|
18 |
|
19 |
my %ex_point2 = (
|
20 |
kokugo => 53,
|
21 |
suugaku => 55,
|
22 |
eigo => 55,
|
23 |
sekaishi => 52,
|
24 |
nihonshi => 0,
|
25 |
chiri => 0,
|
26 |
butsuri => 54,
|
27 |
kagaku => 51,
|
28 |
seibutsu => 0,
|
29 |
_OBJECT => 58,
|
30 |
);
|
31 |
|
32 |
my %ex_haiten1 = (
|
33 |
kokugo => 80,
|
34 |
suugaku => 80,
|
35 |
eigo => 80,
|
36 |
sekaishi => 40,
|
37 |
nihonshi => 0,
|
38 |
chiri => 0,
|
39 |
butsuri => 40,
|
40 |
kagaku => 0,
|
41 |
seibutsu => 0,
|
42 |
);
|
43 |
|
44 |
my %ex_haiten2 = (
|
45 |
kokugo => 0,
|
46 |
suugaku => 300,
|
47 |
eigo => 150,
|
48 |
sekaishi => 0,
|
49 |
nihonshi => 0,
|
50 |
chiri => 0,
|
51 |
butsuri => 150,
|
52 |
kagaku => 150,
|
53 |
seibutsu => 0,
|
54 |
);
|
55 |
|
56 |
|
57 |
sub kanzan (%%%%) {
|
58 |
my ($point1, $full1, $point2, $full2) = @_;
|
59 |
my (%kanzaned1, %kanzaned2);
|
60 |
$$full1{_ALL} = 0;
|
61 |
for my $subject (keys %$full1) {
|
62 |
next if $subject =~ /^_/;
|
63 |
$kanzaned1{$subject} = $$point1{$subject}*$$full1{$subject}/100;
|
64 |
$kanzaned1{_ALL} += $kanzaned1{$subject};
|
65 |
$$full1{_ALL} += $$full1{$subject};
|
66 |
}
|
67 |
$kanzaned1{_PERCENT} = 100*$kanzaned1{_ALL}/$$full1{_ALL};
|
68 |
$$full2{_ALL} = 0;
|
69 |
for my $subject (keys %$full2) {
|
70 |
next if $subject =~ /^_/;
|
71 |
$kanzaned2{$subject} = $$point2{$subject}*$$full2{$subject}/100;
|
72 |
$kanzaned2{_ALL} += $kanzaned2{$subject};
|
73 |
$$full2{_ALL} += $$full2{$subject};
|
74 |
}
|
75 |
$kanzaned2{_PERCENT} = 100*$kanzaned2{_ALL}/$$full2{_ALL};
|
76 |
|
77 |
my ($percent, $object_percent);
|
78 |
$percent = 100*($kanzaned1{_ALL}+$kanzaned2{_ALL})
|
79 |
/($$full1{_ALL}+$$full2{_ALL});
|
80 |
$object_percent = ($$point1{_OBJECT}*$$full1{_ALL}
|
81 |
+$$point2{_OBJECT}*$$full2{_ALL})
|
82 |
/($$full1{_ALL}+$$full2{_ALL});
|
83 |
($percent, $object_percent, \%kanzaned1, \%kanzaned2);
|
84 |
}
|
85 |
|
86 |
my (%mypoint1, %mypoint2, %haiten1, %haiten2);
|
87 |
if ($Suika::CGI::param{newform} ne 'no') {
|
88 |
%mypoint1 = %ex_point1;
|
89 |
%mypoint2 = %ex_point2;
|
90 |
%haiten1 = %ex_haiten1;
|
91 |
%haiten2 = %ex_haiten2;
|
92 |
} else {
|
93 |
for my $s (keys %Suika::CGI::param) {
|
94 |
$mypoint1{$1} = $Suika::CGI::param{$s} if $s =~ /^(.+[^H_])1$/;
|
95 |
$mypoint2{$1} = $Suika::CGI::param{$s} if $s =~ /^(.+[^H_])2$/;
|
96 |
$mypoint1{'_'.$1} = $Suika::CGI::param{$s} if $s =~ /^(.+)_1$/;
|
97 |
$mypoint2{'_'.$1} = $Suika::CGI::param{$s} if $s =~ /^(.+)_2$/;
|
98 |
$haiten1{$1} = $Suika::CGI::param{$s} if $s =~ /^(.+)H1$/;
|
99 |
$haiten2{$1} = $Suika::CGI::param{$s} if $s =~ /^(.+)H2$/;
|
100 |
}
|
101 |
}
|
102 |
my ($percent, $object, $kanzan1, $kanzan2)
|
103 |
= kanzan ({%mypoint1} => {%haiten1}, {%mypoint2} => {%haiten2});
|
104 |
|
105 |
print STDOUT "Content-Type: text/html; charset=euc-jisx0213
|
106 |
|
107 |
";
|
108 |
output_html (\%mypoint1 => \%haiten1 => $kanzan1,
|
109 |
\%mypoint2 => \%haiten2 => $kanzan2,
|
110 |
percent => $percent, object => $object);
|
111 |
|
112 |
sub diffmark ($) {
|
113 |
my $diff = shift;
|
114 |
return '□' if $diff < -4;
|
115 |
return '△' if $diff < -2;
|
116 |
return '○' if $diff < 0;
|
117 |
return '◎';
|
118 |
}
|
119 |
|
120 |
sub output_html (%%%%%) {
|
121 |
my ($p1 => $h1 => $k1, $p2 => $h2 => $k2, %misc) = @_;
|
122 |
for my $n ($$k1{_PERCENT}, $$k2{_PERCENT}, $misc{percent}, $misc{object}) {
|
123 |
$n = int ($n);
|
124 |
}
|
125 |
$$k1{_DIFF} = $$k1{_PERCENT}-$$p1{_OBJECT};
|
126 |
$$k2{_DIFF} = $$k2{_PERCENT}-$$p2{_OBJECT};
|
127 |
$misc{_DIFF} = $misc{percent}-$misc{object};
|
128 |
$$k1{_DIFFMARK} = diffmark ($$k1{_DIFF});
|
129 |
$$k2{_DIFFMARK} = diffmark ($$k2{_DIFF});
|
130 |
$misc{_DIFFMARK} = diffmark ($misc{_DIFF});
|
131 |
print <<EOH;
|
132 |
<!DOCTYPE html PUBLIC "-//W3D//DTD HTML 4.01//EN">
|
133 |
<html lang="ja">
|
134 |
<head>
|
135 |
<title>配点換算</title>
|
136 |
<style type="text/css">
|
137 |
input {width: 3em}
|
138 |
</style>
|
139 |
</head>
|
140 |
<body>
|
141 |
<h1>配点換算</h1>
|
142 |
<form action="kanzan" method="post" accept-charset="iso-2022-jp, iso-2022-jp-3">
|
143 |
<table>
|
144 |
<thead>
|
145 |
<tr>
|
146 |
<th colspan="2">教科</th>
|
147 |
<th>国語</th><th>数学</th><th>英語</th>
|
148 |
<th>世界史</th><th>日本史</th><th>地理</th>
|
149 |
<th>物理</th><th>化学</th><th>生物</th>
|
150 |
</tr>
|
151 |
</thead>
|
152 |
<tbody>
|
153 |
<tr>
|
154 |
<th rowspan="3">一次</th><th>持ち点</th>
|
155 |
<td><input type="text" name="kokugo1" value="$$p1{kokugo}"></td>
|
156 |
<td><input type="text" name="suugaku1" value="$$p1{suugaku}"></td>
|
157 |
<td><input type="text" name="eigo1" value="$$p1{eigo}"></td>
|
158 |
<td><input type="text" name="sekaishi1" value="$$p1{sekaishi}"></td>
|
159 |
<td><input type="text" name="nihonshi1" value="$$p1{nihonshi}"></td>
|
160 |
<td><input type="text" name="chiri1" value="$$p1{chiri}"></td>
|
161 |
<td><input type="text" name="butsuri1" value="$$p1{butsuri}"></td>
|
162 |
<td><input type="text" name="kagaku1" value="$$p1{kagaku}"></td>
|
163 |
<td><input type="text" name="seibutsu1" value="$$p1{seibutsu}"></td>
|
164 |
</tr>
|
165 |
<tr>
|
166 |
<th>配点</th>
|
167 |
<td><input type="text" name="kokugoH1" value="$$h1{kokugo}"></td>
|
168 |
<td><input type="text" name="suugakuH1" value="$$h1{suugaku}"></td>
|
169 |
<td><input type="text" name="eigoH1" value="$$h1{eigo}"></td>
|
170 |
<td><input type="text" name="sekaishiH1" value="$$h1{sekaishi}"></td>
|
171 |
<td><input type="text" name="nihonshiH1" value="$$h1{nihonshi}"></td>
|
172 |
<td><input type="text" name="chiriH1" value="$$h1{chiri}"></td>
|
173 |
<td><input type="text" name="butsuriH1" value="$$h1{butsuri}"></td>
|
174 |
<td><input type="text" name="kagakuH1" value="$$h1{kagaku}"></td>
|
175 |
<td><input type="text" name="seibutsuH1" value="$$h1{seibutsu}"></td>
|
176 |
</tr>
|
177 |
<tr>
|
178 |
<th>換算点</th>
|
179 |
<td>$$k1{kokugo}</td><td>$$k1{suugaku}</td><td>$$k1{eigo}</td>
|
180 |
<td>$$k1{sekaishi}</td><td>$$k1{nihonshi}</td><td>$$k1{chiri}</td>
|
181 |
<td>$$k1{butsuri}</td><td>$$k1{kagaku}</td><td>$$k1{seibutsu}</td>
|
182 |
</tr>
|
183 |
|
184 |
<tr>
|
185 |
<th rowspan="3">二次</th><th>持ち点</th>
|
186 |
<td><input type="text" name="kokugo2" value="$$p2{kokugo}"></td>
|
187 |
<td><input type="text" name="suugaku2" value="$$p2{suugaku}"></td>
|
188 |
<td><input type="text" name="eigo2" value="$$p2{eigo}"></td>
|
189 |
<td><input type="text" name="sekaishi2" value="$$p2{sekaishi}"></td>
|
190 |
<td><input type="text" name="nihonshi2" value="$$p2{nihonshi}"></td>
|
191 |
<td><input type="text" name="chiri2" value="$$p2{chiri}"></td>
|
192 |
<td><input type="text" name="butsuri2" value="$$p2{butsuri}"></td>
|
193 |
<td><input type="text" name="kagaku2" value="$$p2{kagaku}"></td>
|
194 |
<td><input type="text" name="seibutsu2" value="$$p2{seibutsu}"></td>
|
195 |
</tr>
|
196 |
<tr>
|
197 |
<th>配点</th>
|
198 |
<td><input type="text" name="kokugoH2" value="$$h2{kokugo}"></td>
|
199 |
<td><input type="text" name="suugakuH2" value="$$h2{suugaku}"></td>
|
200 |
<td><input type="text" name="eigoH2" value="$$h2{eigo}"></td>
|
201 |
<td><input type="text" name="sekaishiH2" value="$$h2{sekaishi}"></td>
|
202 |
<td><input type="text" name="nihonshiH2" value="$$h2{nihonshi}"></td>
|
203 |
<td><input type="text" name="chiriH2" value="$$h2{chiri}"></td>
|
204 |
<td><input type="text" name="butsuriH2" value="$$h2{butsuri}"></td>
|
205 |
<td><input type="text" name="kagakuH2" value="$$h2{kagaku}"></td>
|
206 |
<td><input type="text" name="seibutsuH2" value="$$h2{seibutsu}"></td>
|
207 |
</tr>
|
208 |
<tr>
|
209 |
<th>換算点</th>
|
210 |
<td>$$k2{kokugo}</td><td>$$k2{suugaku}</td><td>$$k2{eigo}</td>
|
211 |
<td>$$k2{sekaishi}</td><td>$$k2{nihonshi}</td><td>$$k2{chiri}</td>
|
212 |
<td>$$k2{butsuri}</td><td>$$k2{kagaku}</td><td>$$k2{seibutsu}</td>
|
213 |
</tr>
|
214 |
</tbody>
|
215 |
</table>
|
216 |
|
217 |
<table>
|
218 |
<thead>
|
219 |
<tr>
|
220 |
<th></th><th>得点率</th><th>目標点</th><th colspan="2">差</th>
|
221 |
</tr>
|
222 |
</thead>
|
223 |
<tbody>
|
224 |
<tr>
|
225 |
<th>一次</th>
|
226 |
<td>$$k1{_PERCENT}</td>
|
227 |
<td><input type="text" name="OBJECT_1" value="$$p1{_OBJECT}"></td>
|
228 |
<td>$$k1{_DIFF}</td>
|
229 |
<td>$$k1{_DIFFMARK}</td>
|
230 |
</tr>
|
231 |
<tr>
|
232 |
<th>二次</th>
|
233 |
<td>$$k2{_PERCENT}</td>
|
234 |
<td><input type="text" name="OBJECT_2" value="$$p2{_OBJECT}"></td>
|
235 |
<td>$$k2{_DIFF}</td>
|
236 |
<td>$$k2{_DIFFMARK}</td>
|
237 |
</tr>
|
238 |
<tr>
|
239 |
<th>合計</th>
|
240 |
<td>$misc{percent}</td>
|
241 |
<td>$misc{object}</td>
|
242 |
<td>$misc{_DIFF}</td>
|
243 |
<td>$misc{_DIFFMARK}</td>
|
244 |
</tr>
|
245 |
</tbody>
|
246 |
</table>
|
247 |
|
248 |
<p>
|
249 |
<input type="hidden" name="newform" value="no">
|
250 |
<input type="submit" value="OK">
|
251 |
</p>
|
252 |
</form>
|
253 |
EOH
|
254 |
}
|
255 |
|
256 |
1;
|