/[suikacvs]/perl/kanzan/kanzan.cgi
Suika

Diff of /perl/kanzan/kanzan.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.3

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24