#!/usr/bin/perl
require 'parse.pl';
&parse_form;
$mainf="evaldata.txt";
$evalf="evalresult.txt";
print "Content-type: text/html\n\n";
&checkpassword;
print "<html><body>";
open(FILE,"$mainf");
@ar = <FILE>;
close(FILE);
$cntar = @ar;
for $i (0 .. $cntar-1) {
@rg = split (',',$ar[$i]);
if ($rg[0] eq $v{'id'}) {
$ok='ok';
$cntrg = split (',',$ar[$i]);
for $j (1..$cntrg-1){
@reg = @complete = @rg;
$cntreg = $cntrg-1;
}
}
}
print "แบบประเมิน : <br>รหัสนักศึกษา(Student ID.) $v{'id'}";
open(STDIN, $grdfile ) ;
@ar = <STDIN>;
close(STDIN);
$cntn = @ar;
for $i (0 .. $cntn-1) {
@gn = split (',',$ar[$i]);
$cntn = split (',',$ar[$i]);
if ($gn[0] eq $v{'id'}) { print $gn[2];}
}
if (!$ok) { print "<hr>ไม่พบรหัสท่านในฐานข้อมูล"; exit;}
open(STDIN, $evalf );
@ar = <STDIN>;
close(STDIN);
$cntarev = @ar;
for $i (0 .. $cntarev-1) {
@rgev = split (',',$ar[$i]);
$cntrg = split (',',$ar[$i]);
if ($rgev[0] eq $v{'id'}) {
for $j (1 .. $cntreg-1) {
if ($complete[$j] eq $rgev[1]) { $complete[$j]="Done"; }
}
}
}
print '<form action=evalopt.pl method=post>';
print '<input type=hidden name=id value=',$v{'id'},'>';
for $j (1 .. $cntreg-1) {
if ($reg[$j]) {
if ($complete[$j] eq "Done") { print "<font color=#bbbbbb>"; }
print '<input type=radio name=subj value=',substr($reg[$j],0,8),'>';
print substr($reg[$j],0,6),' Sec: ',substr($reg[$j],6,2);
if ($complete[$j] ne "Done") {print" Not done";}else{print"</font> Complete.";}
print "<br>";
}
}
print '<input type=submit value="เปิดแบบประเมิน"></form></body></html>';
sub checkpassword {
$grdfile = join '',"grd",substr($v{'id'},0,3),".txt";
open(FILE, $grdfile ) ;
@ar = <FILE>;
close(FILE);
$cntn = @ar;
for $i (0 .. $cntn-1) {
@gn = split (',',$ar[$i]);
if ($gn[0] eq $v{'id'} && $gn[1] eq $v{'pass'}) { $found = 1; }
}
if (!$found && $v{'pass'} ne 'thaiall') { print "Invalid info, please back"; exit; }
}
จำนวน : 71 บรรทัด