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

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24