1 |
#!/usr/local/bin/perl |
#!/usr/bin/perl |
2 |
|
|
3 |
use strict; |
use strict; |
|
require Suika::CGI; |
|
4 |
|
|
5 |
my %ex_point1 = ( |
for (split /[&;]/, $main::ENV{QUERY_STRING}) { |
6 |
|
|
7 |
|
} |
8 |
|
|
9 |
|
my %ex_point1 = (); |
10 |
|
( |
11 |
kokugo => 54, |
kokugo => 54, |
12 |
suugaku => 55, |
suugaku => 55, |
13 |
eigo => 57, |
eigo => 57, |
20 |
_OBJECT => 57, |
_OBJECT => 57, |
21 |
); |
); |
22 |
|
|
23 |
my %ex_point2 = ( |
my %ex_point2 = (); |
24 |
|
( |
25 |
kokugo => 53, |
kokugo => 53, |
26 |
suugaku => 55, |
suugaku => 55, |
27 |
eigo => 55, |
eigo => 55, |
34 |
_OBJECT => 58, |
_OBJECT => 58, |
35 |
); |
); |
36 |
|
|
37 |
my %ex_haiten1 = ( |
my %ex_haiten1 = (); |
38 |
|
( |
39 |
kokugo => 80, |
kokugo => 80, |
40 |
suugaku => 80, |
suugaku => 80, |
41 |
eigo => 80, |
eigo => 80, |
47 |
seibutsu => 0, |
seibutsu => 0, |
48 |
); |
); |
49 |
|
|
50 |
my %ex_haiten2 = ( |
my %ex_haiten2 = (); |
51 |
|
( |
52 |
kokugo => 0, |
kokugo => 0, |
53 |
suugaku => 300, |
suugaku => 300, |
54 |
eigo => 150, |
eigo => 150, |
71 |
$kanzaned1{_ALL} += $kanzaned1{$subject}; |
$kanzaned1{_ALL} += $kanzaned1{$subject}; |
72 |
$$full1{_ALL} += $$full1{$subject}; |
$$full1{_ALL} += $$full1{$subject}; |
73 |
} |
} |
74 |
$kanzaned1{_PERCENT} = 100*$kanzaned1{_ALL}/$$full1{_ALL}; |
$kanzaned1{_PERCENT} = $$full1{_ALL}==0?0:100*$kanzaned1{_ALL}/$$full1{_ALL}; |
75 |
$$full2{_ALL} = 0; |
$$full2{_ALL} = 0; |
76 |
for my $subject (keys %$full2) { |
for my $subject (keys %$full2) { |
77 |
next if $subject =~ /^_/; |
next if $subject =~ /^_/; |
79 |
$kanzaned2{_ALL} += $kanzaned2{$subject}; |
$kanzaned2{_ALL} += $kanzaned2{$subject}; |
80 |
$$full2{_ALL} += $$full2{$subject}; |
$$full2{_ALL} += $$full2{$subject}; |
81 |
} |
} |
82 |
$kanzaned2{_PERCENT} = 100*$kanzaned2{_ALL}/$$full2{_ALL}; |
$kanzaned2{_PERCENT} = $$full2{_ALL}==0?0:100*$kanzaned2{_ALL}/$$full2{_ALL}; |
83 |
|
|
84 |
my ($percent, $object_percent); |
my ($percent, $object_percent); |
85 |
$percent = 100*($kanzaned1{_ALL}+$kanzaned2{_ALL}) |
$percent = ($$full1{_ALL}+$$full2{_ALL})==0?0: |
86 |
|
100*($kanzaned1{_ALL}+$kanzaned2{_ALL}) |
87 |
/($$full1{_ALL}+$$full2{_ALL}); |
/($$full1{_ALL}+$$full2{_ALL}); |
88 |
$object_percent = ($$point1{_OBJECT}*$$full1{_ALL} |
$object_percent = ($$full1{_ALL}+$$full2{_ALL})==0?0: |
89 |
|
($$point1{_OBJECT}*$$full1{_ALL} |
90 |
+$$point2{_OBJECT}*$$full2{_ALL}) |
+$$point2{_OBJECT}*$$full2{_ALL}) |
91 |
/($$full1{_ALL}+$$full2{_ALL}); |
/($$full1{_ALL}+$$full2{_ALL}); |
92 |
($percent, $object_percent, \%kanzaned1, \%kanzaned2); |
($percent, $object_percent, \%kanzaned1, \%kanzaned2); |
93 |
} |
} |
94 |
|
|
95 |
|
%Suika::CGI::param = %{__get_parameter ()}; |
96 |
my (%mypoint1, %mypoint2, %haiten1, %haiten2); |
my (%mypoint1, %mypoint2, %haiten1, %haiten2); |
97 |
if ($Suika::CGI::param{newform} ne 'no') { |
if ($Suika::CGI::param{newform} ne 'no') { |
98 |
%mypoint1 = %ex_point1; |
%mypoint1 = %ex_point1; |
112 |
my ($percent, $object, $kanzan1, $kanzan2) |
my ($percent, $object, $kanzan1, $kanzan2) |
113 |
= kanzan ({%mypoint1} => {%haiten1}, {%mypoint2} => {%haiten2}); |
= kanzan ({%mypoint1} => {%haiten1}, {%mypoint2} => {%haiten2}); |
114 |
|
|
115 |
print STDOUT "Content-Type: text/html; charset=euc-jisx0213 |
print STDOUT "Content-Type: text/html; charset=euc-jp |
116 |
|
Content-Style-Type: text/css |
117 |
|
Content-Language: ja |
118 |
|
|
119 |
"; |
"; |
120 |
output_html (\%mypoint1 => \%haiten1 => $kanzan1, |
output_html (\%mypoint1 => \%haiten1 => $kanzan1, |
145 |
<html lang="ja"> |
<html lang="ja"> |
146 |
<head> |
<head> |
147 |
<title>配点換算</title> |
<title>配点換算</title> |
148 |
<style type="text/css"> |
<link rev="made" href="mailto:w\@suika.fam.cx"> |
149 |
|
<link rel="contents" href="http://tomikou.net/tokshuu/kanzan.html" title="換算点算出システム |
150 |
|
"> |
151 |
|
<link rel="contents" href="/chuubu/"> |
152 |
|
<link rel="stylesheet" href="/s/default/xhtml1" media="all"> |
153 |
|
<link rel="help" href="intro" title="説明" /> |
154 |
|
<style type="text/css" media="all"> |
155 |
input {width: 3em} |
input {width: 3em} |
156 |
</style> |
</style> |
157 |
</head> |
</head> |
158 |
<body> |
<body> |
159 |
<h1>配点換算</h1> |
<h1>配点換算</h1> |
160 |
<form action="kanzan" method="post" accept-charset="iso-2022-jp, iso-2022-jp-3"> |
<form action="kanzan" method="post" accept-charset="iso-2022-jp"> |
161 |
<table> |
<table> |
162 |
<thead> |
<thead> |
163 |
<tr> |
<tr> |
268 |
<input type="submit" value="OK"> |
<input type="submit" value="OK"> |
269 |
</p> |
</p> |
270 |
</form> |
</form> |
271 |
|
|
272 |
|
<div class="navigation"> |
273 |
|
[<a href="/gate/cvs/perl/kanzan/" lang="en">source</a>] |
274 |
|
[<a href="intro">説明</a>] |
275 |
|
</div> |
276 |
|
</body> |
277 |
|
</html> |
278 |
EOH |
EOH |
279 |
} |
} |
280 |
|
|
281 |
1; |
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 |
|
=head1 LICENSE |
314 |
|
|
315 |
|
Copyright 2001-2004 Wakaba E<lt>w@suika.fam.cxE<gt>. |
316 |
|
|
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 |
|
1; # $Date$ |
335 |
|
|