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

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24