Listing of grades.php


<?php //----------------------------------------------------------------- // if first entry, just blank the entry values //----------------------------------------------------------------- if ($_SERVER['REQUEST_METHOD'] == 'GET') { $id = ""; $loginStatus = ""; //----------------------------------------------------------------- // second entry, check the userid //----------------------------------------------------------------- } else { $xml = simplexml_load_file('../data/Grades.xml'); if ($xml == NULL) { $loginStatus = "noconnect"; } else { $id = $_POST['userID']; $test = strtolower( $id ); $test = preg_replace("/\s*/", "", $test); $rows = $xml->Worksheet[0]->Table[0]->Row; $loginStatus = "nouser"; $top = ""; foreach ($rows as $row) { if ($row->Cell[0]->Data == "TOT") { $top = $row; } else if ($row->Cell[0]->Data == "STU" && $row->Cell[1]->Data == $test) { $loginStatus = "good"; break; } } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!-- =============================================================== --> <!-- Jan Gombert: Grades --> <!-- =============================================================== --> <title>Jan Gombert: Grades</title> <link href="images/Normal.css" rel="stylesheet" type="text/css" /> <link rel="Shortcut Icon" href="images/favicon.ico" /> <script type="text/javascript"> //----------------------------------------------------------------- // show or hide the User ID entry //----------------------------------------------------------------- function showUserID(show) { var id = document.getElementById("userID"); var val = document.getElementById("userIDValue").value; var prologue = '<p>User ID:  <input name="userID" size="40" id="userIDValue" value="'; if (show) { id.innerHTML = prologue + val + '" type="input"/></p>'; } else { id.innerHTML = prologue + val + '" type="password"/></p>'; } } <?php include 'scripts/buttons.php'; buttonFuncs('images'); // initialize, set image directory buttonLoad("buttonHome"); buttonLoad("buttonSchedule"); buttonLoad("buttonGrades"); buttonLoad("buttonLogin"); ?> </script> </head> <!-- =============================================================== --> <body> <div id="container"> <div id="header"> <img src="images/headGrades.gif" alt="Jan Gombert" /> </div> <!-- =============================================================== --> <div id="main"> <?php if ($loginStatus == "good") { $average = number_format(100 * (float)$row->Cell[4]->Data); $quizzes = number_format(100 * (float)$row->Cell[8]->Data); $hw = number_format((float)$row->Cell[7]->Data); $hwAll = number_format((float)$top->Cell[7]->Data); $at = number_format((float)$row->Cell[6]->Data); $atAll = number_format((float)$top->Cell[6]->Data); ?> <p class="H1">Summary for <?php echo "{$row->Cell[3]->Data}" ?></p> <p class="Text">An overall grade will be given after the first test.</p> <!-- =============================================================== --> <!-- table that displays the grades by category --> <!-- =============================================================== --> <table border="1" cellspacing="0" cellpadding="4" class="Text" style="font-size:14px" align="center" width="400"> <tr bgcolor="#FFEEBB"> <th width="80">Grade</td> <th width="240">Description</td> <th width="80">Share</td> </tr> <tr> <td align="right" width="80"> </td> <td width="240">Overall letter grade</td> <td align="right" width="80"> </td> </tr> <tr> <td align="right"> </td> <td>Overall average (%)</td> <td align="right"> </td> </tr> <tr> <td align="right"><?php echo "{$at} / {$atAll}" ?></td> <td>Attendance</td> <td align="right"> </td> </tr> <tr> <td align="right"><?php echo "{$hw} / {$hwAll}" ?></td> <td>Homework</td> <td align="right">20%</td> </tr> <tr> <td align="right"><?php echo "{$quizzes}%" ?></td> <td>Quizzes</td> <td align="right">10%</td> </tr> <tr> <td align="right"> </td> <td>LEE Test</td> <td align="right">10%</td> </tr> <tr> <td align="right"> </td> <td>Test 1: Chapter 1</td> <td align="right">8%</td> </tr> <tr> <td align="right"> </td> <td>Test 2: Chapter 2</td> <td align="right">8%</td> </tr> <tr> <td align="right"> </td> <td>Test 3: Chapter 3 & 7</td> <td align="right">8%</td> </tr> <tr> <td align="right"> </td> <td>Test 4: Chapter 8</td> <td align="right">8%</td> </tr> <tr> <td align="right"> </td> <td>Test 5: Chapter 4</td> <td align="right">8%</td> </tr> <tr> <td align="right"> </td> <td>Test 6: Chapter 5</td> <td align="right">8%</td> </tr> <tr> <td align="right"> </td> <td>Test 7: Final Exam</td> <td align="right">12%</td> </tr> </table> <?php } else { ?> <!-- =============================================================== --> <!-- Login page --> <!-- =============================================================== --> <form method="POST" action="grades.php" class="Text" name="login"> <p>Login to see your grades.</p> <div id="userID"> <p>User ID:  <input type="password" name="userID" size="40" id="userIDValue" value="<?php echo $id; ?>" /></p> </div> <p class="TextSmall"><input type="checkbox" name="show" onChange="showUserID(this.checked)"/> Show User ID?</p> <p><input type=image value="Login" src="images/buttonLogin.gif" onmouseout ="button_up('buttonLogin'); return true" onmouseover="button_dn('buttonLogin'); return true"></p> </form> <?php if ($loginStatus == "nouser") { echo '<p class="Text">User ID not found.</p>'; } elseif ($loginStatus != "") { echo "<p>Problem connecting to the database.</p>"; } } ?> </div> <!-- =============================================================== --> <div id="menu"> <?php buttonActive("buttonHome", "./"); buttonActive("buttonSchedule", "schedule.php"); buttonStatic("buttonGrades"); ?> </div> <!-- =============================================================== --> <div id="footer" class="Small"> <a href="./">Home</a>   |   <a href="schedule.php">Schedule</a>   |   Grades </div> </div> </body> </html>