Grades

\n

Enter Student ID

HTML; } //Selecting the assignments // Process Form to display the grades function display_grades() { $found = false; $total = 0; $index = 0; // student file: ID|name|email|username|lab1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|ass#1|2|3|4|5|..|10|midterm|final $file = "data/student.txt"; // location of the student file // open the file for reading if ($fh = fopen("$file", 'rb')) { // loop through the file by reading 1000 bytes or one line // whichever comes first with each iteration. // The data being read is broken into an array // using the | to indicate the separate elements. // $line[1]=name, $line[4]= lab1...$line[22]=assignment 1,...$line[27]=midterm, $line[28]=final while ($line = fgetcsv($fh, 1000, "|")) { $count = count($line); // get the size of the array if ($line[0] == $_POST[student]) { // display grades echo <<

$line[1]

EOF; $size = count($line)-2; for ($key = 4, $size; $key < $size; $key++) { $i = $key-3; $total += $line[$key]; switch ($i) { case 22: $index = "assignment#1"; break; case 23: $index = "assignment#2"; break; case 24: $index = "assignment#3"; break; case 25: $index = "assignment#4"; break; case 26: $index = "assignment#5"; break; case 27: $index = "assignment#6"; break; case 28: $index = "assignment#7"; break; case 29: $index = "assignment#8"; break; case 30: $index = "assignment#9"; break; case 31: $index = "assignment#10"; break; default: $index= "lab#".$i; } echo ""; } $total += $line[$size]; echo ""; $size +=1; $total += $line[$size]; echo ""; echo ""; echo "
AssignmentGrade (points)
$index$line[$key]
Midterm$line[$size]
Final$line[$size]
Total$total
"; echo <<
Points Grading
950-1000 (95-100%) A
900-949 (90-94%) A-
870-899 (87-89%) B+
840-869 (84-86%) B
800-839 (80-83%) B-
770-799 (77-79%) C+
740-769 (74-76%) C
700-739 (70-73%) C-
670-699 (67-69%) D+
640-669 (64-66%) D
600-639 (60-63%) D-
0-599 (0-59%) F
EOF; $found = true; break; } } // close the file fclose($fh); } // close reading if (!$found) { // display no student echo <<

Sorry wrong Student ID

Enter Student ID

EOF; } } // end display grades ?>