computer science project

profileMr. Joe
oexam.rar

oexam/admin/admwelcome.php

<?php error_reporting(0); session_start(); if(!isset($_SESSION['admname'])){ $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if(isset($_REQUEST['logout'])){ unset($_SESSION['admname']); $_GLOBALS['message']="Loggged Out."; header('Location: index.php'); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Admin Home</title> <link rel="stylesheet" type="text/css" href="../oes.css"/> </head> <body> <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <div class="sidebar1"> <form name="admwelcome" action="admwelcome.php" method="post"> <?php if(isset($_SESSION['admname'])){ ?> <ul class="nav"> <li><input type="submit" value="Log Out" name="logout" class="linkbutn" title="CAREFUL !! Log Out"/></li> </ul> <?php } ?> </form> <aside> <p> Use this page to do administrative work. </p> </aside> <!-- end .sidebar1 --></div> <article class="content"> <section> <h1>Admin Home</h1> <p> <div id="content"> <?php if(isset($_SESSION['admname'])){ ?> <table class="hometable" cellspacing="0"> <tr> <td width="20"> <p title="Manage Users"> <a href="usermng.php"><img src="../images/manageusers.png" name="imags" height="120" width="200" /></a> </p> <p><a href="usermng.php">Manage Students</a></p></td> <td> <p title="Manage Examiners"> <a href="tcmng.php"><img src="../images/managexaminer.png" name="imags" height="120" width="200" /></a></p> <p><a href="tcmng.php">Manage Examiners</a></p></td> <td> <p title="Manage Subjects"> <a href="submng.php"><img src="../images/managesubjects.png" name="imags" height="120" width="200" /></a></p> <p><a href="tcmng.php">Manage Subjects</a></p></td> </tr> </table> <?php }?> </div> </p> </section> <!-- end .content --></article> <!-- end .container --></div> </body> </html>

oexam/admin/index.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if(isset($_REQUEST['admsubmit'])) { $result=executeQuery("select * from adminlogin where admname='".htmlspecialchars($_REQUEST['name'],ENT_QUOTES)."' and admpassword='".md5(htmlspecialchars($_REQUEST['password'],ENT_QUOTES))."'"); // $result=mysql_query("select * from adminlogin where admname='".htmlspecialchars($_REQUEST['name'])."' and admpassword='".md5(htmlspecialchars($_REQUEST['password']))."'"); if(mysql_num_rows($result)>0) { $r=mysql_fetch_array($result); if(strcmp($r['admpassword'],md5(htmlspecialchars($_REQUEST['password'],ENT_QUOTES)))==0) { $_SESSION['admname']=htmlspecialchars_decode($r['admname'],ENT_QUOTES); unset($_GLOBALS['message']); header('Location: admwelcome.php'); }else { $_GLOBALS['message']="Check Your user name and Password."; } } else { $_GLOBALS['message']="Check Your user name and Password."; } closedb(); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Admin Log In </title> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <div class="sidebar1"> <ul class="nav"> <li><a href="../index.php" title="Click here to Register">Home</a></li> </ul> <aside> <p> This page allows you to login as the admin. </p> </aside> <!-- end .sidebar1 --></div> <article class="content"> <section> <h1>Admin Login</h1> <p> <div id="content"> <table class="loginf"> <form id="indexform" action="index.php" method="post"> <tr> <td> Username </td> <td><input type="text" name="name" tabindex="1" value="" placeholder="Username" /></td> </tr> <tr> <td> Password </td><td><input type="password" name="password" value="" placeholder="Password" /></td> </tr> <tr> <td></td> <td><input type="submit" name="admsubmit" value="Log In" /></td> </tr> </form> </table> </div> </p> </section> <!-- end .content --></article> <!-- end .container --></div> </body> </html>

oexam/admin/rsltmng.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if(!isset($_SESSION['admname'])) { $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if(isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['admname']); header('Location: index.php'); } else if(isset($_REQUEST['dashboard'])) { //redirect to home header('Location: admwelcome.php'); } else if(isset($_REQUEST['back'])) { //redirect to Result Management header('Location: rsltmng.php'); } ?> <html> <head> <title>Manage Results</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form name="rsltmng" action="rsltmng.php" method="post"> <?php if (isset($_SESSION['admname'])) { ?> <div class="sidebar1"> <ul class="nav"> <?php if(isset($_REQUEST['testid'])) { ?> <li><input type="submit" value="Back" name="back" title="Manage Results"/></li> <?php }else { ?> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <?php } ?> <!-- For default add or delete functions--> <li><input type="submit" value="Add New" name="add" title="Add new records"/></li> <li><input type="submit" value="Delete Selected" name="delete" title="Delete Selected records"/></li> <!-- log out function--> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to perform administrative duties on results data.</p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Manage Results</h1> <p> <div id="content"> <?php if(isset($_REQUEST['testid'])) { // Defualt Mode: Displays the Detailed Test Results. $result=executeQuery("select t.testname,DATE_FORMAT(t.testfrom,'%d %M %Y') as fromdate,DATE_FORMAT(t.testto,'%d %M %Y %H:%i:%S') as todate,sub.subname,IFNULL((select sum(marks) from question where testid=".$_REQUEST['testid']."),0) as maxmarks from test as t, subject as sub where sub.subid=t.subid and t.testid=".$_REQUEST['testid'].";") ; if(mysql_num_rows($result)!=0) { $r=mysql_fetch_array($result); ?> <table class="loginf"> <tr> <td colspan="2"><h3 style="color:#0000cc;text-align:center;">Test Summary</h3></td> </tr> <tr> <td colspan="2" ><hr style="color:#ff0000;border-width:4px;"/></td> </tr> <tr> <td>Test Name</td> <td><?php echo htmlspecialchars_decode($r['testname'],ENT_QUOTES); ?></td> </tr> <tr> <td>Subject Name</td> <td><?php echo htmlspecialchars_decode($r['subname'],ENT_QUOTES); ?></td> </tr> <tr> <td>Validity</td> <td><?php echo $r['fromdate']." To ".$r['todate']; ?></td> </tr> <tr> <td>Max. Marks</td> <td><?php echo $r['maxmarks']; ?></td> </tr> <tr><td colspan="2"><hr style="color:#ff0000;border-width:2px;"/></td></tr> <tr> <td colspan="2"><h3 style="color:#0000cc;text-align:center;">Attempted Students</h3></td> </tr> <tr> <td colspan="2" ><hr style="color:#ff0000;border-width:4px;"/></td> </tr> </table> <?php $result1=executeQuery("select s.stdname,s.emailid,IFNULL((select sum(q.marks) from studentquestion as sq,question as q where q.qnid=sq.qnid and sq.testid=".$_REQUEST['testid']." and sq.stdid=st.stdid and sq.stdanswer=q.correctanswer),0) as om from studenttest as st, student as s where s.stdid=st.stdid and st.testid=".$_REQUEST['testid'].";" ); if(mysql_num_rows($result1)==0) { echo"<h3 style=\"color:#0000cc;text-align:center;\">No Students Yet Attempted this Test!</h3>"; } else { ?> <table cellpadding="30" cellspacing="10" class="datatable"> <tr> <th>Student Name</th> <th>Email-ID</th> <th>Obtained Marks</th> <th>Result(%)</th> </tr> <?php while($r1=mysql_fetch_array($result1)) { ?> <tr> <td><?php echo htmlspecialchars_decode($r1['stdname'],ENT_QUOTES); ?></td> <td><?php echo htmlspecialchars_decode($r1['emailid'],ENT_QUOTES); ?></td> <td><?php echo $r1['om']; ?></td> <td><?php echo ($r1['om']/$r['maxmarks']*100)." %"; ?></td> </tr> <?php } } } else { echo"<h3 style=\"color:#0000cc;text-align:center;\">Something went wrong. Please logout and Try again.</h3>"; } ?> </table> <?php } else { // Defualt Mode: Displays the Test Results. $result=executeQuery("select t.testid,t.testname,DATE_FORMAT(t.testfrom,'%d %M %Y') as fromdate,DATE_FORMAT(t.testto,'%d %M %Y %H:%i:%S') as todate,sub.subname,(select count(stdid) from studenttest where testid=t.testid) as attemptedstudents from test as t, subject as sub where sub.subid=t.subid;"); if(mysql_num_rows($result)==0) { echo "<h3 style=\"color:#0000cc;text-align:center;\">No Tests Yet...!</h3>"; } else { $i=0; ?> <table cellpadding="30" cellspacing="10" class="datatable"> <tr> <th>Test Name</th> <th>Validity</th> <th>Subject Name</th> <th>Attempted Students</th> <th>Details</th> </tr> <?php while($r=mysql_fetch_array($result)) { $i=$i+1; if($i%2==0) { echo "<tr class=\"alt\">"; } else { echo "<tr>";} echo "<td>".htmlspecialchars_decode($r['testname'],ENT_QUOTES)."</td><td>".$r['fromdate']." To ".$r['todate']." PM </td>" ."<td>".htmlspecialchars_decode($r['subname'],ENT_QUOTES)."</td><td>".$r['attemptedstudents']."</td>" ."<td class=\"tddata\"><a title=\"Details\" href=\"rsltmng.php?testid=".$r['testid']."\"><img src=\"../images/detail.png\" height=\"30\" width=\"40\" alt=\"Details\" /></a></td></tr>"; } ?> </table> <?php } } closedb(); } ?> </div> </form> </div> </body> </html>

oexam/admin/submng.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if (!isset($_SESSION['admname'])) { $_GLOBALS['message'] = "Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if (isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['admname']); header('Location: index.php'); } else if (isset($_REQUEST['dashboard'])) { //redirect to home header('Location: admwelcome.php'); } else if (isset($_REQUEST['delete'])) { //delete selected subjects unset($_REQUEST['delete']); $hasvar = false; foreach ($_REQUEST as $variable) { if (is_numeric($variable)) { //some session values are also passed with request $hasvar = true; if (!@executeQuery("delete from subject where subid=$variable")) { if (mysql_errno () == 1451) //Children are dependent value $_GLOBALS['message'] = "System will not allow propagated deletions.<br/><b>Help:</b> If you still want to delete this subject, manually delete all the records that are dependent on it first."; else $_GLOBALS['message'] = mysql_errno(); } } } if (!isset($_GLOBALS['message']) && $hasvar == true) $_GLOBALS['message'] = "Selected subjects deleted"; else if (!$hasvar) { $_GLOBALS['message'] = "Select the subjects to delete."; } } else if (isset($_REQUEST['savem'])) { //updating the modified values if (empty($_REQUEST['subname']) || empty($_REQUEST['subdesc'])) { $_GLOBALS['message'] = "Some fields are empty.No updates made."; } else { $query = "update subject set subname='" . htmlspecialchars($_REQUEST['subname'], ENT_QUOTES) . "', subdesc='" . htmlspecialchars($_REQUEST['subdesc'], ENT_QUOTES) . "'where subid=" . $_REQUEST['subject'] . ";"; if (!@executeQuery($query)) $_GLOBALS['message'] = mysql_error(); else $_GLOBALS['message'] = "Subject information updated."; } closedb(); } else if (isset($_REQUEST['savea'])) { //Add the new subject information to db $result = executeQuery("select max(subid) as sub from subject"); $r = mysql_fetch_array($result); if (is_null($r['sub'])) $newstd = 1; else $newstd=$r['sub'] + 1; $result = executeQuery("select subname as sub from subject where subname='" . htmlspecialchars($_REQUEST['subname'], ENT_QUOTES) . "';"); // $_GLOBALS['message']=$newstd; if (empty($_REQUEST['subname']) || empty($_REQUEST['subdesc'])) { $_GLOBALS['message'] = "Some required fields are empty"; } else if (mysql_num_rows($result) > 0) { $_GLOBALS['message'] = "Subject already exists."; } else { $query = "insert into subject values($newstd,'" . htmlspecialchars($_REQUEST['subname'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['subdesc'], ENT_QUOTES) . "',NULL)"; if (!@executeQuery($query)) { if (mysql_errno () == 1062) //duplicate value $_GLOBALS['message'] = "The subject name voilates some constraints, try another name."; else $_GLOBALS['message'] = mysql_error(); } else $_GLOBALS['message'] = "Subject created."; } closedb(); } ?> <html> <head> <title>Manage subjects</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form name="submng" action="submng.php" method="post"> <?php if (isset($_SESSION['admname'])) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <!-- For default add or delete functions--> <li><input type="submit" value="Add New" name="add" title="Add new subjects"/></li> <!-- log out function--> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to do administrative work such subjects. </p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Manage subjects</h1> <p> <div id="content"> <?php if (isset($_SESSION['admname'])) { if (isset($_REQUEST['add'])) { ?> <!--Form for the new subject--> <table class="loginf" > <tr> <td>Subject Name</td> <td><input type="text" name="subname" value="" size="16" onKeyUp="isalphanum(this)" onBlur="if(this.value==''){alert('Subject Name is Empty');this.focus();this.value='';}"/></td> </tr> <tr> <td>Subject Description</td> <td><textarea name="subdesc" cols="20" rows="3" onBlur="if(this.value==''){alert('Subject Description is Empty');this.focus();this.value='';}"></textarea></td> </tr> <!--For Add option--> <?php if (isset($_REQUEST['add'])) { ?> <tr> <td> <input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savea" class="subbtn" onClick="validatesubform('submng')" title="Save"/></td> </tr> <?php } ?> </table> <?php } else if (isset($_REQUEST['edit'])) { //Edit existing subjects and their details. $result = executeQuery("select subid,subname,subdesc from subject where subname='" . htmlspecialchars($_REQUEST['edit'], ENT_QUOTES) . "';"); if (mysql_num_rows($result) == 0) { header('submng.php'); } else if ($r = mysql_fetch_array($result)) { //editing components ?> <table class="loginf"> <tr> <td>Subject Name</td> <td><input type="text" name="subname" value="<?php echo htmlspecialchars_decode($r['subname'], ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)"/></td> </tr> <tr> <td>Subject Description</td> <td><textarea name="subdesc" cols="20" rows="3"><?php echo htmlspecialchars_decode($r['subdesc'], ENT_QUOTES); ?></textarea><input type="hidden" name="subject" value="<?php echo $r['subid']; ?>"/></td> </tr> <!--For Edit option--> <?php } if (isset($_REQUEST['edit'])) { ?> <tr> <td><input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savem" class="subbtn" onClick="validatesubform('submng')" title="Save"/></td> </tr> </table> <?php closedb(); } } else { // Default : displays existing subjects. $result = executeQuery("select * from subject order by subid;"); if (mysql_num_rows($result) == 0) { echo "<h3 style=\"color:#0000cc;text-align:center;\">No Subjets Yet..!</h3>"; } else { $i = 0; ?> <table class="dashboards" cellspacing="10"> <tr> <th>&nbsp;</th> <th>Subject Name</th> <th>Subject Description</th> <th>Edit</th> </tr> <?php while ($r = mysql_fetch_array($result)) { $i = $i + 1; if ($i % 2 == 0) { echo "<tr class=\"alt\">"; } else { echo "<tr>"; } echo "<td style=\"text-align:center;\"><input type=\"checkbox\" name=\"d$i\" value=\"" . $r['subid'] . "\" /></td><td>" . htmlspecialchars_decode($r['subname'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['subdesc'], ENT_QUOTES) . "</td>" . "<td class=\"tddata\"><a title=\"Edit " . htmlspecialchars_decode($r['stdname'], ENT_QUOTES) . "\"href=\"submng.php?edit=" . htmlspecialchars_decode($r['subname'], ENT_QUOTES) . "\"><img src=\"../images/edit.png\" height=\"30\" width=\"40\" alt=\"Edit\" /></a></td></tr>"; } ?> </table> <?php } closedb(); } } ?> </div> </form> </div> </body> </html>

oexam/admin/tcmng.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if (!isset($_SESSION['admname'])) { $_GLOBALS['message'] = "Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if (isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['admname']); header('Location: index.php'); } else if (isset($_REQUEST['dashboard'])) { //redirect to home header('Location: admwelcome.php'); } else if (isset($_REQUEST['delete'])) { //deleting the selected teachers records unset($_REQUEST['delete']); $hasvar = false; foreach ($_REQUEST as $variable) { if (is_numeric($variable)) { //some session values are also passed with request $hasvar = true; if (!@executeQuery("delete from testconductor where tcid=$variable")){ if (mysql_errno () == 1451) //Children are dependent value $_GLOBALS['message'] = "System will not allow propagated deletions.<br/><b>Help:</b> Delete all records that are associated with this user first."; else $_GLOBALS['message'] = mysql_errno(); } // $_GLOBALS['message']=$_GLOBALS['message'].$variable; } } if (!isset($_GLOBALS['message']) && $hasvar == true) $_GLOBALS['message'] = "Selected teacher/s records deleted"; else if (!$hasvar) { $_GLOBALS['message'] = "Select teacher/s records to delete."; } } else if (isset($_REQUEST['savem'])) { /* * ************************ Step 2 - Case 4 ************************ */ //updating the modified values if (empty($_REQUEST['cname']) || empty($_REQUEST['password']) || empty($_REQUEST['email'])) { $_GLOBALS['message'] = "Some fields are empty.No updates made."; } else { $query = "update testconductor set tcname='" . htmlspecialchars($_REQUEST['cname'],ENT_QUOTES) . "', tcpassword=ENCODE('" . htmlspecialchars($_REQUEST['password'],ENT_QUOTES) . "','oespass'),emailid='" . htmlspecialchars($_REQUEST['email'],ENT_QUOTES) . "',contactno='" . htmlspecialchars($_REQUEST['contactno'],ENT_QUOTES) . "',address='" .htmlspecialchars($_REQUEST['address'],ENT_QUOTES) . "',city='" . htmlspecialchars($_REQUEST['city'],ENT_QUOTES) . "',pincode='" . htmlspecialchars($_REQUEST['pin'],ENT_QUOTES) . "' where tcid='" . $_REQUEST['tc'] . "';"; if (!@executeQuery($query)) $_GLOBALS['message'] = mysql_error(); else $_GLOBALS['message'] = "Teacher information updated."; } closedb(); } else if (isset($_REQUEST['savea'])) { //Add the new test teacher information to the db $result = executeQuery("select max(tcid) as tc from testconductor"); $r = mysql_fetch_array($result); if (is_null($r['tc'])) $newstd = 1; else $newstd=$r['tc'] + 1; $result = executeQuery("select tcname as tc from testconductor where tcname='" . htmlspecialchars($_REQUEST['cname'],ENT_QUOTES) . "';"); if (empty($_REQUEST['cname']) || empty($_REQUEST['password']) || empty($_REQUEST['email'])) { $_GLOBALS['message'] = "Some required fields are empty"; } else if (mysql_num_rows($result) > 0) { $_GLOBALS['message'] = "User already exists."; } else { $query = "insert into testconductor values($newstd,'" . htmlspecialchars($_REQUEST['cname'],ENT_QUOTES) . "',ENCODE('" . htmlspecialchars($_REQUEST['password'],ENT_QUOTES) . "','oespass'),'" . htmlspecialchars($_REQUEST['email'],ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['contactno'],ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['address'],ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['city'],ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['pin'],ENT_QUOTES) . "')"; if (!@executeQuery($query)) { if(mysql_errno ()==1062) //duplicate value $_GLOBALS['message'] = "The teacher name voilates some constraints, try another name."; else $_GLOBALS['message'] = mysql_error(); } else $_GLOBALS['message'] = "Teacher record created."; } closedb(); } ?> <html> <head> <title>Manage Teachers</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form name="tcmng" action="tcmng.php" method="post"> <?php if (isset($_SESSION['admname'])) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <!-- For default add or delete functions--> <li><input type="submit" value="Add New" name="add" title="Add new Examiner"/></li> <li><input type="submit" value="Delete Selected" name="delete" title="Delete Selected records"/></li> <!-- log out function--> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to perform administrative duties on teachers data. You can edit teachers data where changes are required.</p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Manage Examiners</h1> <p> <div id="content"> <?php if (isset($_SESSION['admname'])) { if (isset($_REQUEST['add'])) { ?> <!--Form for the new teacher--> <table class="loginf" > <tr> <td>Username</td> <td><input type="text" name="cname" value="" size="16" onKeyUp="isalphanum(this)"/></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" value="" size="16" onKeyUp="isalphanum(this)" /></td> </tr> <tr> <td>Retype Password</td> <td><input type="password" name="repass" value="" size="16" onKeyUp="isalphanum(this)" /></td> </tr> <tr> <td>E mail</td> <td><input type="text" name="email" value="" size="16" /></td> </tr> <tr> <td>Phone No</td> <td><input type="number" pattern=".{9}" maxlength="12" required title="Enter enough digits" name="contactno" value="" size="16" onKeyUp="isnum(this)"/></td> </tr> <tr> <td>Address</td> <td><textarea name="address" cols="20" rows="3"></textarea></td> </tr> <tr> <td>Town</td> <td><input type="text" name="city" value="" size="16" onKeyUp="isalpha(this)"/></td> </tr> <tr> <td>PIN No</td> <td><input type="text" name="pin" value="" size="16" onKeyUp="isnum(this)" /></td> </tr> <!--For Add option--> <?php if (isset($_REQUEST['add'])) { ?> <tr> <td><input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savea" class="subbtn" onClick="validateform('usermng')" title="Save"/></td> </tr> <?php } ?> </table> <?php } else if (isset($_REQUEST['edit'])) { //Edit existing teacher information $result = executeQuery("select tcid,tcname,DECODE(tcpassword,'oespass') as tcpass ,emailid,contactno,address,city,pincode from testconductor where tcname='" . htmlspecialchars($_REQUEST['edit'],ENT_QUOTES) . "';"); if (mysql_num_rows($result) == 0) { header('Location: tcmng.php'); } else if ($r = mysql_fetch_array($result)) { //editing components ?> <!--Form to edit existing teachers--> <table class="loginf"> <tr> <td>Username</td> <td><input type="text" name="cname" value="<?php echo htmlspecialchars_decode($r['tcname'],ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)"/></td> </tr> <tr> <td>Password</td> <td><input type="text" name="password" value="<?php echo htmlspecialchars_decode($r['tcpass'],ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)" /></td> </tr> <tr> <td>E mail</td> <td><input type="text" name="email" value="<?php echo htmlspecialchars_decode($r['emailid'],ENT_QUOTES); ?>" size="16" /></td> </tr> <tr> <td>Phone No</td> <td><input type="text" name="contactno" value="<?php echo htmlspecialchars_decode($r['contactno'],ENT_QUOTES); ?>" size="16" onKeyUp="isnum(this)"/></td> </tr> <tr> <td>Address</td> <td><textarea name="address" cols="20" rows="3"><?php echo htmlspecialchars_decode($r['address'],ENT_QUOTES); ?></textarea></td> </tr> <tr> <td>Town</td> <td><input type="text" name="city" value="<?php echo htmlspecialchars_decode($r['city'],ENT_QUOTES); ?>" size="16" onKeyUp="isalpha(this)"/></td> </tr> <tr> <td>PIN Code</td> <td><input type="hidden" name="tc" value="<?php echo htmlspecialchars_decode($r['tcid'],ENT_QUOTES); ?>"/><input type="text" name="pin" value="<?php echo htmlspecialchars_decode($r['pincode'],ENT_QUOTES); ?>" size="16" onKeyUp="isnum(this)" /></td> </tr> <!--For Edit option--> <?php } else if (isset($_REQUEST['edit'])) { ?> <tr> <td><input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savem" class="subbtn" onClick="validateform('usermng')" title="Save"/></td> </tr> </table> <?php closedb(); } } else { // Default: displays the existing teachers. $result = executeQuery("select * from testconductor order by tcid;"); if (mysql_num_rows($result) == 0) { echo "<h3 style=\"color:#0000cc;text-align:center;\">No Test Conductors Yet..!</h3>"; } else { $i = 0; ?> <table class="dashboards" cellspacing="10"> <tr> <th>&nbsp;</th> <th>Teacher name</th> <th>Email-ID</th> <th>Contact Number</th> <th>Edit</th> </tr> <?php while ($r = mysql_fetch_array($result)) { $i = $i + 1; if ($i % 2 == 0) echo "<tr class=\"alt\">"; else echo "<tr>"; echo "<td style=\"text-align:center;\"><input type=\"checkbox\" name=\"d$i\" value=\"" . $r['tcid'] . "\" /></td><td>" . htmlspecialchars_decode($r['tcname'],ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['emailid'],ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['contactno'],ENT_QUOTES) . "</td>" . "<td class=\"tddata\"><a title=\"Edit " . htmlspecialchars_decode($r['tcname'],ENT_QUOTES) . "\"href=\"tcmng.php?edit=" . htmlspecialchars_decode($r['tcname'],ENT_QUOTES) . "\"><img src=\"../images/edit.png\" height=\"30\" width=\"40\" alt=\"Edit\" /></a></td></tr>"; } ?> </table> <?php } closedb(); } } ?> </div> </form> </div> </body> </html>

oexam/admin/testmng.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if (!isset($_SESSION['admname'])) { $_GLOBALS['message'] = "Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if (isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['admname']); header('Location: index.php'); } else if (isset($_REQUEST['dashboard'])) { //redirect to home header('Location: admwelcome.php'); } else if (isset($_REQUEST['delete'])) { //deleting the selected tests unset($_REQUEST['delete']); $hasvar = false; foreach ($_REQUEST as $variable) { if (is_numeric($variable)) { //some session values are also passed with request $hasvar = true; if (!@executeQuery("delete from test where testid=$variable")) { if (mysql_errno () == 1451) //Children are dependent value $_GLOBALS['message'] = "System will not allow propagated deletions.<br/><b>Help:</b> If you still want to delete this test, manually delete all the records that are associated with this test first."; else $_GLOBALS['message'] = mysql_errno(); } } } if (!isset($_GLOBALS['message']) && $hasvar == true) $_GLOBALS['message'] = "Selected test/s deleted"; else if (!$hasvar) { $_GLOBALS['message'] = "First select the test/s to delete."; } } else if (isset($_REQUEST['savem'])) { //update modified values $fromtime = $_REQUEST['testfrom'] . " " . date("H:i:s"); $totime = $_REQUEST['testto'] . " 23:59:59"; $_GLOBALS['message'] = strtotime($totime) . " " . strtotime($fromtime) . " " . time(); if (strtotime($fromtime) > strtotime($totime) || strtotime($totime) < time()) $_GLOBALS['message'] = "Start date of test is less than end date or last date of test is less than today's date.<br/>No updates made"; else if (empty($_REQUEST['testname']) || empty($_REQUEST['testdesc']) || empty($_REQUEST['totalqn']) || empty($_REQUEST['duration']) || empty($_REQUEST['testfrom']) || empty($_REQUEST['testto']) || empty($_REQUEST['testcode'])) { $_GLOBALS['message'] = "Some fields are empty.No updates made"; } else { $query = "update test set testname='" . htmlspecialchars($_REQUEST['testname'], ENT_QUOTES) . "',testdesc='" . htmlspecialchars($_REQUEST['testdesc'], ENT_QUOTES) . "',subid=" . htmlspecialchars($_REQUEST['subject'], ENT_QUOTES) . ",testfrom='" . $fromtime . "',testto='" . $totime . "',duration=" . htmlspecialchars($_REQUEST['duration'], ENT_QUOTES) . ",totalquestions=" . htmlspecialchars($_REQUEST['totalqn'], ENT_QUOTES) . ",testcode=ENCODE('" . htmlspecialchars($_REQUEST['testcode'], ENT_QUOTES) . "','oespass') where testid=" . $_REQUEST['testid'] . ";"; if (!@executeQuery($query)) $_GLOBALS['message'] = mysql_error(); else $_GLOBALS['message'] = "Test information updated."; } closedb(); } else if (isset($_REQUEST['savea'])) { //Add the new test information in the database $noerror = true; $fromtime = $_REQUEST['testfrom'] . " " . date("H:i:s"); $totime = $_REQUEST['testto'] . " 23:59:59"; if (strtotime($fromtime) > strtotime($totime) || strtotime($fromtime) < (time() - 3600)) { $noerror = false; $_GLOBALS['message'] = "Start date of test is either less than today's date or greater than last date of test."; } else if ((strtotime($totime) - strtotime($fromtime)) <= 3600 * 24) { $noerror = true; $_GLOBALS['message'] = "Note:<br/>The test is valid upto " . date(DATE_RFC850, strtotime($totime)); } //$_GLOBALS['message']="time".date_format($first, DATE_ATOM)."<br/>time ".date_format($second, DATE_ATOM); $result = executeQuery("select max(testid) as tst from test"); $r = mysql_fetch_array($result); if (is_null($r['tst'])) $newstd = 1; else $newstd=$r['tst'] + 1; // $_GLOBALS['message']=$newstd; if (strcmp($_REQUEST['subject'], "<Choose the Subject>") == 0 || empty($_REQUEST['testname']) || empty($_REQUEST['testdesc']) || empty($_REQUEST['totalqn']) || empty($_REQUEST['duration']) || empty($_REQUEST['testfrom']) || empty($_REQUEST['testto']) || empty($_REQUEST['testcode'])) { $_GLOBALS['message'] = "Some of the required Fields are Empty"; } else if ($noerror) { $query = "insert into test values($newstd,'" . htmlspecialchars($_REQUEST['testname'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['testdesc'], ENT_QUOTES) . "',(select curDate()),(select curTime())," . htmlspecialchars($_REQUEST['subject'], ENT_QUOTES) . ",'" . $fromtime . "','" . $totime . "'," . htmlspecialchars($_REQUEST['duration'], ENT_QUOTES) . "," . htmlspecialchars($_REQUEST['totalqn'], ENT_QUOTES) . ",0,ENCODE('" . htmlspecialchars($_REQUEST['testcode'], ENT_QUOTES) . "','oespass'),NULL)"; if (!@executeQuery($query)) { if (mysql_errno () == 1062) //duplicate value $_GLOBALS['message'] = "The test name violates some constraints, please try another name."; else $_GLOBALS['message'] = mysql_error(); } else $_GLOBALS['message'] = $_GLOBALS['message'] . "<br/> New test created."; } closedb(); } else if (isset($_REQUEST['manageqn'])) { //Store the Test identity in session varibles and redirect to prepare question section. //$tempa=explode(" ",$_REQUEST['testqn']); // $testname=substr($_REQUEST['manageqn'],0,-10); $testname = $_REQUEST['manageqn']; $result = executeQuery("select testid from test where testname='" . htmlspecialchars($testname, ENT_QUOTES) . "';"); if ($r = mysql_fetch_array($result)) { $_SESSION['testname'] = $testname; $_SESSION['testqn'] = $r['testid']; // $_GLOBALS['message']=$_SESSION['testname']; header('Location: prepqn.php'); } } ?> <html> <head> <title>Manage Tests</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> <link rel="stylesheet" type="text/css" media="all" href="../calendar/jsDatePick.css" /> <script type="text/javascript" src="../calendar/jsDatePick.full.1.1.js"></script> <script type="text/javascript"> window.onload = function(){ new JsDatePick({ useMode:2, target:"testfrom" //limitToToday:true <-- Add this should you want to limit the calendar until today. }); new JsDatePick({ useMode:2, target:"testto" //limitToToday:true <-- Add this should you want to limit the calendar until today. }); }; </script> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form name="testmng" action="testmng.php" method="post"> <?php if (isset($_SESSION['admname'])) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <!-- For default add or delete functions--> <li><input type="submit" value="Add New" name="add" title="Add new test"/></li> <li><input type="submit" value="Delete Selected" name="delete" title="Delete Selected records"/></li> <!-- log out function--> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to perform administrative duties on students data. You can edit student data where changes are required. </p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Manage Tests</h1> <p> <div id="content"> <?php if (isset($_SESSION['admname'])) { // To display the Help Message if (isset($_REQUEST['forpq'])) echo "<div class=\"pmsg\" style=\"text-align:center\"> Which test questions Do you want to Manage? <br/><b>Help:</b>Click on Questions button to manage the questions of respective tests</div>"; if (isset($_REQUEST['add'])) { ?> <?php if (isset($_SESSION['admname'])) { if (isset($_REQUEST['add'])) { ?> <!--Form for the new student--> <table class="loginf"> <tr> <td>Subject Name</td> <td> <select name="subject"> <option selected value="<Choose the Subject>">&lt;Choose the Subject&gt;</option> <?php $result = executeQuery("select subid,subname from subject;"); while ($r = mysql_fetch_array($result)) { echo "<option value=\"" . $r['subid'] . "\">" . htmlspecialchars_decode($r['subname'], ENT_QUOTES) . "</option>"; } closedb(); ?> </select> </td> </tr> <tr> <td>Test Name</td> <td><input type="text" name="testname" value="" size="16" onKeyUp="isalphanum(this)" /></td> <td><div class="help"><b>Note:</b><br/>Test Name must be Unique<br/> in order to identify different<br/> tests on same subject.</div></td> </tr> <tr> <td>Test Description</td> <td><textarea name="testdesc" cols="20" rows="3" ></textarea></td> <td><div class="help"><b>Describe here:</b><br/>What the test is all about?</div></td> </tr> <tr> <td>Total Questions</td> <td><input type="text" name="totalqn" value="" size="16" onKeyUp="isnum(this)" /></td> </tr> <tr> <td>Duration(Mins)</td> <td><input type="text" name="duration" value="" size="16" onKeyUp="isnum(this)" /></td> </tr> <tr> <td>Test From </td> <td><input id="testfrom" type="text" name="testfrom" value="" size="16" readonly /></td> </tr> <tr> <td>Test To </td> <td><input id="testto" type="text" name="testto" value="" size="16" readonly /></td> </tr> <tr> <td>Test Secret Code</td> <td><input type="text" name="testcode" value="" size="16" onKeyUp="isalphanum(this)" /></td> <td><div class="help"><b>Note:</b><br/>Candidates must enter<br/>this code in order to <br/> take the test</div></td> </tr> <!--For Add option--> <?php if (isset($_REQUEST['add'])) { ?> <tr> <td> <input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savea" class="subbtn" onClick="validateform('testmng')" title="Save"/></td> </tr> <?php } ?> </table> <?php } else if (isset($_REQUEST['edit'])) { // Edit existing test. $result = executeQuery("select t.totalquestions,t.duration,t.testid,t.testname,t.testdesc,t.subid,s.subname,DECODE(t.testcode,'oespass') as tcode,DATE_FORMAT(t.testfrom,'%Y-%m-%d') as testfrom,DATE_FORMAT(t.testto,'%Y-%m-%d') as testto from test as t,subject as s where t.subid=s.subid and t.testname='" . htmlspecialchars($_REQUEST['edit'], ENT_QUOTES) . "';"); if (mysql_num_rows($result) == 0) { header('Location: testmng.php'); } else if ($r = mysql_fetch_array($result)) { //editing components ?> <!--Form to edit existing tests--> <table class="loginf"> <tr> <td>Subject Name</td> <td> <select name="subject"> <?php $result = executeQuery("select subid,subname from subject;"); while ($r1 = mysql_fetch_array($result)) { if (strcmp($r['subname'], $r1['subname']) == 0) echo "<option value=\"" . $r1['subid'] . "\" selected>" . htmlspecialchars_decode($r1['subname'], ENT_QUOTES) . "</option>"; else echo "<option value=\"" . $r1['subid'] . "\">" . htmlspecialchars_decode($r1['subname'], ENT_QUOTES) . "</option>"; } closedb(); ?> </select> </td> </tr> <tr> <td>Test Name</td> <td><input type="hidden" name="testid" value="<?php echo $r['testid']; ?>"/><input type="text" name="testname" value="<?php echo htmlspecialchars_decode($r['testname'], ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)" /></td> <td><div class="help"><b>Note:</b><br/>Test Name must be Unique<br/> in order to identify different<br/> tests on same subject.</div></td> </tr> <tr> <td>Test Description</td> <td><textarea name="testdesc" cols="20" rows="3" ><?php echo htmlspecialchars_decode($r['testdesc'], ENT_QUOTES); ?></textarea></td> <td><div class="help"><b>Describe here:</b><br/>What the test is all about?</div></td> </tr> <tr> <td>Total Questions</td> <td><input type="text" name="totalqn" value="<?php echo htmlspecialchars_decode($r['totalquestions'], ENT_QUOTES); ?>" size="16" onKeyUp="isnum(this)" /></td> </tr> <tr> <td>Duration(Mins)</td> <td><input type="text" name="duration" value="<?php echo htmlspecialchars_decode($r['duration'], ENT_QUOTES); ?>" size="16" onKeyUp="isnum(this)" /></td> </tr> <tr> <td>Test From </td> <td><input id="testfrom" type="text" name="testfrom" value="<?php echo $r['testfrom']; ?>" size="16" readonly /></td> </tr> <tr> <td>Test To </td> <td><input id="testto" type="text" name="testto" value="<?php echo $r['testto']; ?>" size="16" readonly /></td> </tr> <tr> <td>Test Secret Code</td> <td><input type="text" name="testcode" value="<?php echo htmlspecialchars_decode($r['tcode'], ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)" /></td> <td><div class="help"><b>Note:</b><br/>Candidates must enter<br/>this code in order to <br/> take the test</div></td> </tr> <!--For Edit option--> <?php } if (isset($_REQUEST['edit'])) { ?> <tr> <td><input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savem" class="subbtn" onClick="validateform('testmng')" title="Save"/></td> </tr> </table> <?php closedb(); } } else { // Defualt Mode: Displays the Existing Test/s. $result = executeQuery("select t.testid,t.testname,t.testdesc,s.subname,DECODE(t.testcode,'oespass') as tcode,DATE_FORMAT(t.testfrom,'%d-%M-%Y') as testfrom,DATE_FORMAT(t.testto,'%d-%M-%Y %H:%i:%s %p') as testto from test as t,subject as s where t.subid=s.subid order by t.testdate desc,t.testtime desc;"); if (mysql_num_rows($result) == 0) { echo "<h3 style=\"color:#0000cc;text-align:center;\">No Tests Yet..!</h3>"; } else { $i = 0; ?> <table class="dashboards" cellspacing="10"> <tr> <th>&nbsp;</th> <th>Test Description</th> <th>Subject Name</th> <th>Test Secret Code</th> <th>Validity</th> <th>Edit</th> <th style="text-align:center;">Manage<br/>Questions</th> </tr> <?php while ($r = mysql_fetch_array($result)) { $i = $i + 1; if ($i % 2 == 0) echo "<tr class=\"alt\">"; else echo "<tr>"; echo "<td style=\"text-align:center;\"><input type=\"checkbox\" name=\"d$i\" value=\"" . $r['testid'] . "\" /></td><td> " . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . " : " . htmlspecialchars_decode($r['testdesc'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['subname'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['tcode'], ENT_QUOTES) . "</td><td>" . $r['testfrom'] . " To " . $r['testto'] . "</td>" . "<td class=\"tddata\"><a title=\"Edit " . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . "\"href=\"testmng.php?edit=" . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . "\"><img src=\"../images/edit.png\" height=\"30\" width=\"40\" alt=\"Edit\" /></a></td>" . "<td class=\"tddata\"><a title=\"Manage Questions of " . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . "\"href=\"testmng.php?manageqn=" . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . "\"><img src=\"../images/mngqn.png\" height=\"30\" width=\"40\" alt=\"Manage Questions\" /></a></td></tr>"; } ?> </table> <?php } closedb(); } } ?> <?php } } ?> </div> </form> </div> </body> </html>

oexam/admin/usermng.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if (!isset($_SESSION['admname'])) { $_GLOBALS['message'] = "Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if (isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['admname']); header('Location: index.php'); } else if (isset($_REQUEST['dashboard'])) { //redirect to home header('Location: admwelcome.php'); } else if (isset($_REQUEST['tcmng'])) { //redirect to home header('Location: tcmng.php'); } else if (isset($_REQUEST['delete'])) { //deleting the selected rows unset($_REQUEST['delete']); $hasvar = false; foreach ($_REQUEST as $variable) { if (is_numeric($variable)) { //some session values are also passed with request $hasvar = true; if (!@executeQuery("delete from student where stdid=$variable")) { if (mysql_errno () == 1451) //Children are dependent value $_GLOBALS['message'] = "System will not allow propagated deletions.<br/><b>Help:</b> If you still want to delete this user, manually delete all the records that are associated with this user first."; else $_GLOBALS['message'] = mysql_errno(); } } } if (!isset($_GLOBALS['message']) && $hasvar == true) $_GLOBALS['message'] = "Selected user/s deleted"; else if (!$hasvar) { $_GLOBALS['message'] = "First select the users to be deleted."; } } else if (isset($_REQUEST['savem'])) { //update modified values if (empty($_REQUEST['cname']) || empty($_REQUEST['password']) || empty($_REQUEST['email'])) { $_GLOBALS['message'] = "Some fields are empty.No updates made"; } else { $query = "update student set stdname='" . htmlspecialchars($_REQUEST['cname'], ENT_QUOTES) . "', stdpassword=ENCODE('" . htmlspecialchars($_REQUEST['password']) . "','oespass'),emailid='" . htmlspecialchars($_REQUEST['email'], ENT_QUOTES) . "',contactno='" . htmlspecialchars($_REQUEST['contactno'], ENT_QUOTES) . "',address='" . htmlspecialchars($_REQUEST['address'], ENT_QUOTES) . "',city='" . htmlspecialchars($_REQUEST['city'], ENT_QUOTES) . "',pincode='" . htmlspecialchars($_REQUEST['pin'], ENT_QUOTES) . "' where stdid='" . htmlspecialchars($_REQUEST['student'], ENT_QUOTES) . "';"; if (!@executeQuery($query)) $_GLOBALS['message'] = mysql_error(); else $_GLOBALS['message'] = "User information updated."; } closedb(); } else if (isset($_REQUEST['savea'])) { //Insert the user information in the database $result = executeQuery("select max(stdid) as std from student"); $r = mysql_fetch_array($result); if (is_null($r['std'])) $newstd = 1; else $newstd=$r['std'] + 1; $result = executeQuery("select stdname as std from student where stdname='" . htmlspecialchars($_REQUEST['cname'], ENT_QUOTES) . "';"); if (empty($_REQUEST['cname']) || empty($_REQUEST['password']) || empty($_REQUEST['email'])) { $_GLOBALS['message'] = "Some of the required Fields are Empty"; } else if (mysql_num_rows($result) > 0) { $_GLOBALS['message'] = "User already exists."; } else { $query = "insert into student values($newstd,'" . htmlspecialchars($_REQUEST['cname'], ENT_QUOTES) . "',ENCODE('" . htmlspecialchars($_REQUEST['password'], ENT_QUOTES) . "','oespass'),'" . htmlspecialchars($_REQUEST['email'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['contactno'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['address'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['city'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['pin'], ENT_QUOTES) . "')"; if (!@executeQuery($query)) { if (mysql_errno () == 1062) //duplicate value $_GLOBALS['message'] = "The username provided voilates some constraints, please try another username."; else $_GLOBALS['message'] = mysql_error(); } else $_GLOBALS['message'] = "New user created."; } closedb(); } ?> <html> <head> <title>Manage Students</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form name="usermng" action="usermng.php" method="post"> <?php if (isset($_SESSION['admname'])) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <li><input type="submit" value="Teachers" name="tcmng" title="Manage Teachers"/></li> <!-- For default add or delete functions--> <li><input type="submit" value="Add New" name="add" title="Add new records"/></li> <li><input type="submit" value="Delete Selected" name="delete" title="Delete Selected records"/></li> <!-- log out function--> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to perform administrative duties on students data. You can edit student data where changes are required. </p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Manage Students</h1> <p> <div id="content"> <?php if (isset($_SESSION['admname'])) { if (isset($_REQUEST['add'])) { ?> <!--Form for the new student--> <table class="loginf"> <tr> <td>Username</td> <td><input type="text" name="cname" value="" onKeyUp="isalphanum(this)"/></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" value="" onKeyUp="isalphanum(this)" /></td> </tr> <tr> <td>Retype Password</td> <td><input type="password" name="repass" value="" onKeyUp="isalphanum(this)" /></td> </tr> <tr> <td>E mail</td> <td><input type="text" name="email" value="" /></td> </tr> <tr> <td>Phone No</td> <td><input type="text" name="contactno" value="" onKeyUp="isnum(this)"/></td> </tr> <tr> <td>Address</td> <td><textarea name="address" cols="20" rows="3"></textarea></td> </tr> <tr> <td>Town</td> <td><input type="text" name="city" value="" onKeyUp="isalpha(this)"/></td> </tr> <tr> <td>REG No</td> <td><input type="text" name="pin" value="" onKeyUp="isnum(this)" /></td> </tr> <!--For Add option--> <?php if (isset($_REQUEST['add'])) { ?> <tr> <td> <input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savea" class="subbtn" onClick="validateform('usermng')" title="Save"/></td> </tr> <?php } ?> </table> <?php } else if (isset($_REQUEST['edit'])) { //Edit existing student information $result = executeQuery("select stdid,stdname,DECODE(stdpassword,'oespass') as stdpass ,emailid,contactno,address,city,pincode from student where stdname='" . htmlspecialchars($_REQUEST['edit'], ENT_QUOTES) . "';"); if (mysql_num_rows($result) == 0) { header('Location: usermng.php'); } else if ($r = mysql_fetch_array($result)) { //editing components ?> <!--Form to edit existing students--> <table class="loginf"> <tr> <td>Username</td> <td><input type="text" name="cname" value="<?php echo htmlspecialchars_decode($r['stdname'], ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)"/></td> </tr> <tr> <td>Password</td> <td><input type="text" name="password" value="<?php echo htmlspecialchars_decode($r['stdpass'], ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)" /></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" value="<?php echo htmlspecialchars_decode($r['emailid'], ENT_QUOTES); ?>" size="16" /></td> </tr> <tr> <td>Phone No</td> <td><input type="text" name="contactno" value="<?php echo htmlspecialchars_decode($r['contactno'], ENT_QUOTES); ?>" size="16" onKeyUp="isnum(this)"/></td> </tr> <tr> <td>Address</td> <td><textarea name="address" cols="20" rows="3"><?php echo htmlspecialchars_decode($r['address'], ENT_QUOTES); ?></textarea></td> </tr> <tr> <td>Town</td> <td><input type="text" name="city" value="<?php echo htmlspecialchars_decode($r['city'], ENT_QUOTES); ?>" size="16" onKeyUp="isalpha(this)"/></td> </tr> <tr> <td>Reg No</td> <td><input type="hidden" name="student" value="<?php echo htmlspecialchars_decode($r['stdid'], ENT_QUOTES); ?>"/><input type="text" name="pin" value="<?php echo $r['pincode']; ?>" size="16" onKeyUp="isnum(this)" /></td> </tr> <!--For Edit option--> <?php } if (isset($_REQUEST['edit'])) { ?> <tr> <td><input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savem" class="subbtn" onClick="validateform('usermng')" title="Save"/></td> </tr> </table> <?php closedb(); } } else { // Default: displays the existing students. $result = executeQuery("select * from student order by stdid;"); if (mysql_num_rows($result) == 0) { echo "<h3 style=\"color:#0000cc;text-align:center;\">No existing students.</h3>"; } else { $i = 0; ?> <table class="dashboards" cellspacing="10"> <tr> <th>&nbsp;</th> <th>USERNAME</th> <th>E MAIL</th> <th>PHONE NO</th> <th>EDIT</th> </tr> <?php while ($r = mysql_fetch_array($result)) { $i = $i + 1; if ($i % 2 == 0) echo "<tr class=\"alt\">"; else echo "<tr>"; echo "<td style=\"text-align:center;\"><input type=\"checkbox\" name=\"d$i\" value=\"" . $r['stdid'] . "\" /></td><td>" . htmlspecialchars_decode($r['stdname'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['emailid'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['contactno'], ENT_QUOTES) . "</td>" . "<td class=\"tddata\"><a title=\"Edit " . htmlspecialchars_decode($r['stdname'], ENT_QUOTES) . "\"href=\"usermng.php?edit=" . htmlspecialchars_decode($r['stdname'], ENT_QUOTES) . "\"><img src=\"../images/edit.png\" height=\"30\" width=\"40\" alt=\"Edit\" /></a></td></tr>"; } ?> </table> <?php } closedb(); } } ?> </div> </form> </div> </body> </html>

oexam/calendar/example.html

JsDatePick's Javascript Calendar usage example

Look at the comments on the HTML source to fully understand how this very simple example works.

oexam/calendar/img/aqua_dayDown.gif

oexam/calendar/img/aqua_dayNormal.gif

oexam/calendar/img/aqua_dayOver.gif

oexam/calendar/img/armygreen_dayDown.gif

oexam/calendar/img/armygreen_dayNormal.gif

oexam/calendar/img/armygreen_dayOver.gif

oexam/calendar/img/bananasplit_dayDown.gif

oexam/calendar/img/bananasplit_dayNormal.gif

oexam/calendar/img/bananasplit_dayOver.gif

oexam/calendar/img/beige_dayDown.gif

oexam/calendar/img/beige_dayNormal.gif

oexam/calendar/img/beige_dayOver.gif

oexam/calendar/img/boxBottomLeftCorner.png

oexam/calendar/img/boxBottomRightCorner.png

oexam/calendar/img/boxSideWallPx.gif

oexam/calendar/img/boxSideWallPx.png

oexam/calendar/img/boxTopLeftCorner.png

oexam/calendar/img/boxTopPx.gif

oexam/calendar/img/boxTopPx.png

oexam/calendar/img/boxTopRightCorner.png

oexam/calendar/img/closeButton_down.gif

oexam/calendar/img/closeButton_normal.gif

oexam/calendar/img/closeButton_over.gif

oexam/calendar/img/deepblue_dayDown.gif

oexam/calendar/img/deepblue_dayNormal.gif

oexam/calendar/img/deepblue_dayOver.gif

oexam/calendar/img/greenish_dayDown.gif

oexam/calendar/img/greenish_dayNormal.gif

oexam/calendar/img/greenish_dayOver.gif

oexam/calendar/img/lightgreen_dayDown.gif

oexam/calendar/img/lightgreen_dayNormal.gif

oexam/calendar/img/lightgreen_dayOver.gif

oexam/calendar/img/monthBackward_down.gif

oexam/calendar/img/monthBackward_normal.gif

oexam/calendar/img/monthBackward_over.gif

oexam/calendar/img/monthForward_down.gif

oexam/calendar/img/monthForward_normal.gif

oexam/calendar/img/monthForward_over.gif

oexam/calendar/img/ocean_blue_dayDown.gif

oexam/calendar/img/ocean_blue_dayNormal.gif

oexam/calendar/img/ocean_blue_dayOver.gif

oexam/calendar/img/orange_dayDown.gif

oexam/calendar/img/orange_dayNormal.gif

oexam/calendar/img/orange_dayOver.gif

oexam/calendar/img/peppermint_dayDown.gif

oexam/calendar/img/peppermint_dayNormal.gif

oexam/calendar/img/peppermint_dayOver.gif

oexam/calendar/img/pink_dayDown.gif

oexam/calendar/img/pink_dayNormal.gif

oexam/calendar/img/pink_dayOver.gif

oexam/calendar/img/purple_dayDown.gif

oexam/calendar/img/purple_dayNormal.gif

oexam/calendar/img/purple_dayOver.gif

oexam/calendar/img/Thumbs.db

oexam/calendar/img/torqoise_dayDown.gif

oexam/calendar/img/torqoise_dayNormal.gif

oexam/calendar/img/torqoise_dayOver.gif

oexam/calendar/img/yearBackward_down.gif

oexam/calendar/img/yearBackward_normal.gif

oexam/calendar/img/yearBackward_over.gif

oexam/calendar/img/yearForward_down.gif

oexam/calendar/img/yearForward_normal.gif

oexam/calendar/img/yearForward_over.gif

oexam/calendar/jsDatePick.css

/* Copyright 2009 Itamar Arjuan jsDatePick is distributed under the terms of the GNU General Public License. */ .JsDatePickBox { position:relative; width:212px; font-family:Arial; } .JsDatePickBox .jsDatePickCloseButton { cursor:pointer; position:absolute; z-index:1; top:1px; right:10px; width:33px; height:13px; background:url(img/closeButton_normal.gif) left top no-repeat; } .JsDatePickBox .jsDatePickCloseButtonOver { cursor:pointer; position:absolute; z-index:1; top:1px; right:10px; width:33px; height:13px; background:url(img/closeButton_over.gif) left top no-repeat; } .JsDatePickBox .jsDatePickCloseButtonDown { cursor:pointer; position:absolute; z-index:1; top:1px; right:10px; width:33px; height:13px; background:url(img/closeButton_down.gif) left top no-repeat; } .JsDatePickBox .boxLeftWall { float:left; width:7px; margin:0; padding:0; } .JsDatePickBox .boxLeftWall .leftTopCorner{ margin:0; padding:0; width:7px; height:8px; background:url(img/boxTopLeftCorner.png) left top no-repeat; overflow:hidden; } .JsDatePickBox .boxLeftWall .leftBottomCorner{ margin:0; padding:0; width:7px; height:8px; background:url(img/boxBottomLeftCorner.png) left top no-repeat; overflow:hidden; } .JsDatePickBox .boxLeftWall .leftWall{ margin:0; padding:0; width:7px; background:url(img/boxSideWallPx.gif) #ffffff left top repeat-y; overflow:hidden; } .JsDatePickBox .boxRightWall { float:left; width:7px; margin:0; padding:0;} .JsDatePickBox .boxRightWall .rightTopCorner{ margin:0; padding:0; width:7px; height:8px; background:url(img/boxTopRightCorner.png) left top no-repeat; overflow:hidden; } .JsDatePickBox .boxRightWall .rightBottomCorner{ margin:0; padding:0; width:7px; height:8px; background:url(img/boxBottomRightCorner.png) left top no-repeat; overflow:hidden; } .JsDatePickBox .boxRightWall .rightWall{ margin:0; padding:0; width:7px; background:url(img/boxSideWallPx.gif) #ffffff right top repeat-y; overflow:hidden; } .JsDatePickBox .topWall { position:absolute; overflow:hidden; top:0px; left:7px; width:198px; height:4px; background:url(img/boxTopPx.gif) #ffffff left top repeat-x; } .JsDatePickBox .bottomWall { position:absolute; overflow:hidden; bottom:-1px; left:7px; width:198px; height:4px; background:url(img/boxTopPx.gif) #ffffff left top repeat-x; } .JsDatePickBox .hiddenBoxLeftWall { float:left; width:0px; overflow:hidden; overflow:hidden;} .JsDatePickBox .hiddenBoxRightWall { float:left; width:0px; overflow:hidden; overflow:hidden;} .JsDatePickBox .boxMain { float:left; background-color:#ffffff; margin:0; padding:15px 0 5px 0; } .JsDatePickBox .boxMainStripped { background:#ffffff; border:none; } .JsDatePickBox .tooltip { height:12px; line-height:11px; overflow:hidden; font-size:10px; color:#666666; text-align:left; padding:0px; margin:2px 0 2px 0; } .JsDatePickBox .weekDaysRow { height:12px; overflow:hidden; line-height:11px; font-size:10px; color:#666666; text-align:center; padding:0px; margin:2px 0 0 0; } .JsDatePickBox .weekDaysRow .weekDay { float:left; height:14px; overflow:hidden; width:24px; margin:0 5px 0 0; padding:0; } .JsDatePickBox .boxMainInner { background:#ffffff; width:198px; float:left; margin:5px 0 0 0; padding:0; } .JsDatePickBox .boxMainCellsContainer { background-color:#ffffff; margin:0; padding:0; } .JsDatePickBox .boxMainInner .controlsBar { overflow:hidden; height:20px; position:relative; } .JsDatePickBox .boxMainInner .controlsBarText { overflow:hidden; height:20px; line-height:20px; color:#000000; font-size:12px; text-align:center; } .JsDatePickBox .boxMainInner .monthForwardButton { overflow:hidden; cursor:pointer; width:20px; height:20px; position:absolute; top:0px; right:22px; background:url(img/monthForward_normal.gif) left top no-repeat; } .JsDatePickBox .boxMainInner .monthForwardButtonOver { overflow:hidden; cursor:pointer; width:20px; height:20px; position:absolute; top:0px; right:22px; background:url(img/monthForward_over.gif) left top no-repeat; } .JsDatePickBox .boxMainInner .monthForwardButtonDown { overflow:hidden; cursor:pointer; width:20px; height:20px; position:absolute; top:0px; right:22px; background:url(img/monthForward_down.gif) left top no-repeat; } .JsDatePickBox .boxMainInner .monthBackwardButton { overflow:hidden; cursor:pointer; width:20px; height:20px; position:absolute; top:0px; left:22px; background:url(img/monthBackward_normal.gif) left top no-repeat; } .JsDatePickBox .boxMainInner .monthBackwardButtonOver { overflow:hidden; cursor:pointer; width:20px; height:20px; position:absolute; top:0px; left:22px; background:url(img/monthBackward_over.gif) left top no-repeat; } .JsDatePickBox .boxMainInner .monthBackwardButtonDown { overflow:hidden; cursor:pointer; width:20px; height:20px; position:absolute; top:0px; left:22px; background:url(img/monthBackward_down.gif) left top no-repeat; } .JsDatePickBox .boxMainInner .yearForwardButton { overflow:hidden; cursor:pointer; width:20px; height:20px; position:absolute; top:0px; right:0px; background:url(img/yearForward_normal.gif) left top no-repeat; } .JsDatePickBox .boxMainInner .yearForwardButtonOver { overflow:hidden; cursor:pointer; width:20px; height:20px; position:absolute; top:0px; right:0px; background:url(img/yearForward_over.gif) left top no-repeat; } .JsDatePickBox .boxMainInner .yearForwardButtonDown { overflow:hidden; cursor:pointer; width:20px; height:20px; position:absolute; top:0px; right:0px; background:url(img/yearForward_down.gif) left top no-repeat; } .JsDatePickBox .boxMainInner .yearBackwardButton { overflow:hidden; cursor:pointer; width:20px; height:20px; position:absolute; top:0px; left:0px; background:url(img/yearBackward_normal.gif) left top no-repeat; } .JsDatePickBox .boxMainInner .yearBackwardButtonOver { overflow:hidden; cursor:pointer; width:20px; height:20px; position:absolute; top:0px; left:0px; background:url(img/yearBackward_over.gif) left top no-repeat; } .JsDatePickBox .boxMainInner .yearBackwardButtonDown { overflow:hidden; cursor:pointer; width:20px; height:20px; position:absolute; top:0px; left:0px; background:url(img/yearBackward_down.gif) left top no-repeat; } .JsDatePickBox .boxMainInner .skipDay { cursor:default; overflow:hidden; width:24px; height:25px; float:left; margin:4px 5px 0 0; padding:0; } .JsDatePickBox .boxMainInner .dayNormal { -khtml-user-select: none; font-size:12px; cursor:pointer; overflow:hidden; color:#4c4c4c; width:24px; height:25px; float:left; margin:4px 5px 0 0; padding:0; text-align:center; line-height:25px; /*background:url(img/dayNormal.gif) left top no-repeat;*/ } .JsDatePickBox .boxMainInner .dayNormalToday { -khtml-user-select: none; font-size:12px; cursor:pointer; overflow:hidden; color:#f40f0f; font-weight:bold; width:24px; height:25px; float:left; margin:4px 5px 0 0; padding:0; text-align:center; line-height:25px; /*background:url(img/dayNormal.gif) left top no-repeat;*/ } .JsDatePickBox .boxMainInner .dayDisabled { -khtml-user-select: none; cursor:default; font-size:12px; overflow:hidden; color:#999999; width:24px; height:25px; float:left; margin:4px 5px 0 0; padding:0; text-align:center; line-height:25px; /*background:url(img/dayNormal.gif) left top no-repeat;*/ } .JsDatePickBox .boxMainInner .dayOver { -khtml-user-select: none; cursor:pointer; font-size:12px; overflow:hidden; color:#4c4c4c; width:24px; height:25px; float:left; margin:4px 5px 0 0; padding:0; text-align:center; line-height:25px; /*background:url(img/dayOver.gif) left top no-repeat;*/ } .JsDatePickBox .boxMainInner .dayOverToday { -khtml-user-select: none; cursor:pointer; font-size:12px; overflow:hidden; font-weight:bold; color:#f40f0f; width:24px; height:25px; float:left; margin:4px 5px 0 0; padding:0; text-align:center; line-height:25px; /*background:url(img/dayOver.gif) left top no-repeat;*/ } .JsDatePickBox .boxMainInner .dayDown { -khtml-user-select: none; cursor:pointer; font-size:12px; overflow:hidden; color:#F9F9F9; width:24px; height:25px; float:left; margin:4px 5px 0 0; padding:0; text-align:center; line-height:25px; /*background:url(img/dayDown.gif) left top no-repeat; */ } .JsDatePickBox .boxMainInner .dayDownToday { -khtml-user-select: none; cursor:pointer; font-size:12px; overflow:hidden; color:#f40f0f; font-weight:bold; width:24px; height:25px; float:left; margin:4px 5px 0 0; padding:0; text-align:center; line-height:25px; /* background:url(img/dayDown.gif) left top no-repeat;*/ }

oexam/calendar/jsDatePick.full.1.1.js

/* Copyright 2009 Itamar Arjuan jsDatePick is distributed under the terms of the GNU General Public License. */ g_arrayOfUsedJsDatePickCalsGlobalNumbers = new Array(); g_currentDateObject = new Object(); g_currentDateObject.dateObject = new Date(); g_currentDateObject.day = g_currentDateObject.dateObject.getDate(); g_currentDateObject.month = g_currentDateObject.dateObject.getMonth() + 1; g_currentDateObject.year = g_currentDateObject.dateObject.getFullYear(); $ = function(id){ return document.getElementById(id); }; String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); }; String.prototype.ltrim = function() { return this.replace(/^\s+/,""); }; String.prototype.rtrim = function() { return this.replace(/\s+$/,""); }; JsDatePick = function(configurationObject){ this.oConfiguration = new Object(); this.oCurrentDay = g_currentDateObject; this.monthsTextualRepresentation = new Array("Janaury","February","March","April","May","June","July","August","September","October","November","December"); this.lastPostedDay = null; this.initialZIndex = 2; this.globalNumber = this.getUnUsedGlobalNumber(); eval ("gRef_"+this.globalNumber+"=this;"); this.setConfiguration(configurationObject); this.makeCalendar(); }; JsDatePick.prototype.getUnUsedGlobalNumber = function(){ var aNum = Math.floor(Math.random()*1000); while ( ! this.isUnique_GlobalNumber(aNum) ){ aNum = Math.floor(Math.random()*1000); } return aNum; }; JsDatePick.prototype.isUnique_GlobalNumber = function(aNum){ var i; for (i=0; i<g_arrayOfUsedJsDatePickCalsGlobalNumbers.length; i++){ if (g_arrayOfUsedJsDatePickCalsGlobalNumbers[i] == aNum){ return false; } } return true; }; JsDatePick.prototype.addOnSelectedDelegate = function(aDelegatedFunction){ if (typeof(aDelegatedFunction) == "function"){ this.addonSelectedDelegate = aDelegatedFunction; } return false; }; JsDatePick.prototype.setOnSelectedDelegate = function(aDelegatedFunction){ if (typeof(aDelegatedFunction) == "function"){ this.onSelectedDelegate = aDelegatedFunction; return true; } return false; }; JsDatePick.prototype.executeOnSelectedDelegateIfExists = function(){ if (typeof(this.onSelectedDelegate) == "function"){ this.onSelectedDelegate(); } if (typeof(this.addonSelectedDelegate) == "function"){ this.addonSelectedDelegate(); } }; JsDatePick.prototype.setRepopulationDelegate = function(aDelegatedFunction){ if (typeof(aDelegatedFunction) == "function"){ this.repopulationDelegate = aDelegatedFunction; return true; } return false; }; JsDatePick.prototype.setConfiguration = function(aConf){ this.oConfiguration.isStripped = (aConf["isStripped"] != null) ? aConf["isStripped"] : false; this.oConfiguration.useMode = (aConf["useMode"] != null) ? aConf["useMode"] : 1; this.oConfiguration.selectedDate = (aConf["selectedDate"] != null) ? aConf["selectedDate"] : null; this.oConfiguration.target = (aConf["target"] != null) ? aConf["target"] : null; this.oConfiguration.yearsRange = (aConf["yearsRange"] != null) ? aConf["yearsRange"] : new Array(1971,2100); this.oConfiguration.limitToToday = (aConf["limitToToday"] != null) ? aConf["limitToToday"] : false; this.oConfiguration.field = (aConf["field"] != null) ? aConf["field"] : false; this.oConfiguration.cellColorScheme = (aConf["cellColorScheme"] != null) ? aConf["cellColorScheme"] : "ocean_blue"; this.selectedDayObject = new Object(); this.flag_DayMarkedBeforeRepopulation = false; this.flag_aDayWasSelected = false; this.lastMarkedDayObject = null; if (this.oConfiguration.selectedDate != null){ if (typeof(this.oConfiguration.selectedDate) == "object"){ if (!isNaN(this.oConfiguration.selectedDate.day) && !isNaN(this.oConfiguration.selectedDate.month) && !isNaN(this.oConfiguration.selectedDate.year)){ this.currentDay = this.oCurrentDay.day; this.selectedDayObject.day = this.oConfiguration.selectedDate.day; this.currentMonth = this.selectedDayObject.month = this.oConfiguration.selectedDate.month; this.currentYear = this.selectedDayObject.year = this.oConfiguration.selectedDate.year; this.flag_aDayWasSelected = true; } else { alert("The initial selected date object is not complete or invalid!"); } } else { alert("the initial selected date is wrong! you need to supply an object containing 3 properties (day,month,year)"); } } else { this.currentYear = this.oCurrentDay.year; this.currentMonth = this.oCurrentDay.month; this.currentDay = this.oCurrentDay.day; } }; JsDatePick.prototype.resizeCalendar = function(){ this.leftWallStrechedElement.style.height = "0px"; this.rightWallStrechedElement.style.height = "0px"; var totalHeight = this.JsDatePickBox.offsetHeight; var newStrechedHeight = totalHeight-16; if (newStrechedHeight < 0){ return; } this.leftWallStrechedElement.style.height = newStrechedHeight+"px"; this.rightWallStrechedElement.style.height = newStrechedHeight+"px"; return true; }; JsDatePick.prototype.closeCalendar = function(){ this.JsDatePickBox.style.display = "none"; }; JsDatePick.prototype.populateFieldWithSelectedDate = function(){ $(this.oConfiguration.target).value = this.getSelectedDayFormatted(); this.closeCalendar(); }; JsDatePick.prototype.makeCalendar = function(){ var d = document; var JsDatePickBox = d.createElement("div"); var clearfix = d.createElement("div"); var closeButton = d.createElement("div"); JsDatePickBox.setAttribute("class","JsDatePickBox"); clearfix.setAttribute("class","clearfix"); closeButton.setAttribute("class","jsDatePickCloseButton"); closeButton.setAttribute("globalNumber",this.globalNumber); closeButton.onmouseover = function(){ this.setAttribute("class","jsDatePickCloseButtonOver"); var globalRef = "gRef_"+this.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Close the calendar\");"); }; closeButton.onmouseout = function(){ this.setAttribute("class","jsDatePickCloseButton"); var globalRef = "gRef_"+this.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"\");"); }; closeButton.onmousedown = function(){ this.setAttribute("class","jsDatePickCloseButtonDown"); var globalRef = "gRef_"+this.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Close the calendar\");"); }; closeButton.onmouseup = function(){ this.setAttribute("class","jsDatePickCloseButton"); var globalRef = "gRef_"+this.getAttribute("globalNumber"); eval("gRef_"+this.getAttribute("globalNumber")+".closeCalendar();"); eval(globalRef + ".setTooltipText(\"\");"); }; this.JsDatePickBox = JsDatePickBox; var leftWall = d.createElement("div"); var rightWall = d.createElement("div"); var topWall = d.createElement("div"); var bottomWall = d.createElement("div"); topWall.setAttribute("class","topWall"); bottomWall.setAttribute("class","bottomWall"); var topCorner = d.createElement("div"); var bottomCorner = d.createElement("div"); var wall = d.createElement("div"); topCorner.setAttribute("class","leftTopCorner"); bottomCorner.setAttribute("class","leftBottomCorner"); wall.setAttribute("class","leftWall"); this.leftWallStrechedElement = wall; this.leftWall = leftWall; this.rightWall = rightWall; leftWall.appendChild(topCorner); leftWall.appendChild(wall); leftWall.appendChild(bottomCorner); topCorner = d.createElement("div"); bottomCorner = d.createElement("div"); wall = d.createElement("div"); topCorner.setAttribute("class","rightTopCorner"); bottomCorner.setAttribute("class","rightBottomCorner"); wall.setAttribute("class","rightWall"); this.rightWallStrechedElement = wall; rightWall.appendChild(topCorner); rightWall.appendChild(wall); rightWall.appendChild(bottomCorner); if (this.oConfiguration.isStripped){ leftWall.setAttribute("class","hiddenBoxLeftWall"); rightWall.setAttribute("class","hiddenBoxRightWall"); } else { leftWall.setAttribute("class","boxLeftWall"); rightWall.setAttribute("class","boxRightWall"); } JsDatePickBox.appendChild(leftWall); JsDatePickBox.appendChild(this.getDOMCalendarStripped()); JsDatePickBox.appendChild(rightWall); JsDatePickBox.appendChild(clearfix); if (!this.oConfiguration.isStripped){ JsDatePickBox.appendChild(closeButton); JsDatePickBox.appendChild(topWall); JsDatePickBox.appendChild(bottomWall); } if (this.oConfiguration.useMode == 2){ if (this.oConfiguration.target != false){ if (typeof($(this.oConfiguration.target)) != null){ var inputElement = $(this.oConfiguration.target); var aSpan = document.createElement("span"); if(inputElement!=null) { inputElement.parentNode.replaceChild(aSpan,inputElement); aSpan.appendChild(inputElement); inputElement.setAttribute("globalNumber",this.globalNumber); inputElement.onclick = function(){ eval("gRef_"+this.getAttribute("globalNumber")+".showCalendar();"); }; aSpan.style.position = "relative"; this.initialZIndex++; JsDatePickBox.style.zIndex = this.initialZIndex.toString(); JsDatePickBox.style.position = "absolute"; JsDatePickBox.style.top = "18px"; JsDatePickBox.style.left = "0px"; JsDatePickBox.style.display = "none"; aSpan.appendChild(JsDatePickBox); var aFunc = new Function("gRef_"+this.globalNumber+".populateFieldWithSelectedDate();"); this.setOnSelectedDelegate(aFunc); } } else { alert("There is no element with such an ID!"); } } } else { if (this.oConfiguration.target != null){ $(this.oConfiguration.target).appendChild(JsDatePickBox); $(this.oConfiguration.target).style.position = "relative"; JsDatePickBox.style.position = "absolute"; JsDatePickBox.style.top = "0px"; JsDatePickBox.style.left = "0px"; this.resizeCalendar(); this.executePopulationDelegateIfExists(); } else { alert("No element ID to put this calendar on! check JsDatePick configuration"); } } }; JsDatePick.prototype.determineFieldDate = function(){ var aField = $(this.oConfiguration.target); if (aField.value.trim().length == 0){ this.unsetSelection(); return; } else { if (aField.value.trim().length > 7){ var array = aField.value.trim().split("-"); this.setSelectedDay({ year:parseInt(array[0]), month:parseInt(array[1],10), day:parseInt(array[2],10) }); return; } else { this.unsetSelection(); return; } } }; JsDatePick.prototype.showCalendar = function(){ if (this.JsDatePickBox.style.display == "none"){ this.determineFieldDate(); this.JsDatePickBox.style.display = "block"; this.resizeCalendar(); this.executePopulationDelegateIfExists(); } else { return; } }; JsDatePick.prototype.isAvailable = function(y, m, d){ if (y > this.oCurrentDay.year){ return false; } if (m > this.oCurrentDay.month && y == this.oCurrentDay.year){ return false; } if (d > this.oCurrentDay.day && m == this.oCurrentDay.month && y == this.oCurrentDay.year ){ return false; } return true; }; JsDatePick.prototype.getDOMCalendarStripped = function(){ var d = document; var boxMain = d.createElement("div"); if (this.oConfiguration.isStripped){ boxMain.setAttribute("class","boxMainStripped"); } else { boxMain.setAttribute("class","boxMain"); } this.boxMain = boxMain; var boxMainInner = d.createElement("div"); var clearfix = d.createElement("div"); var boxMainCellsContainer = d.createElement("div"); var tooltip = d.createElement("div"); var weekDaysRow = d.createElement("div"); var clearfix2 = d.createElement("div"); clearfix.setAttribute("class","clearfix"); clearfix2.setAttribute("class","clearfix"); boxMainInner.setAttribute("class","boxMainInner"); boxMainCellsContainer.setAttribute("class","boxMainCellsContainer"); tooltip.setAttribute("class","tooltip"); weekDaysRow.setAttribute("class","weekDaysRow"); this.tooltip = tooltip; boxMain.appendChild(boxMainInner); this.controlsBar = this.getDOMControlBar(); this.makeDOMWeekDays(weekDaysRow); boxMainInner.appendChild(this.controlsBar); boxMainInner.appendChild(clearfix); boxMainInner.appendChild(tooltip); boxMainInner.appendChild(weekDaysRow); boxMainInner.appendChild(boxMainCellsContainer); boxMainInner.appendChild(clearfix2); this.boxMainCellsContainer = boxMainCellsContainer; this.populateMainBox(boxMainCellsContainer); return boxMain; }; JsDatePick.prototype.makeDOMWeekDays = function(aWeekDaysRow){ var i=0; var d = document; var weekDaysArray = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); var textNode; var weekDay; for (i=0; i<7; i++){ weekDay = d.createElement("div"); textNode = d.createTextNode(weekDaysArray[i]); weekDay.setAttribute("class","weekDay"); if (weekDaysArray[i] == "Sat"){ weekDay.style.marginRight = "0px"; } weekDay.appendChild(textNode); aWeekDaysRow.appendChild(weekDay); } }; JsDatePick.prototype.repopulateMainBox = function(){ while (this.boxMainCellsContainer.firstChild){ this.boxMainCellsContainer.removeChild(this.boxMainCellsContainer.firstChild); } this.populateMainBox(this.boxMainCellsContainer); this.resizeCalendar(); this.executePopulationDelegateIfExists(); }; JsDatePick.prototype.executePopulationDelegateIfExists = function(){ if (typeof(this.repopulationDelegate) == "function"){ this.repopulationDelegate(); } }; JsDatePick.prototype.populateMainBox = function(aMainBox){ var d = document; var aDayDiv; var aTextNode; var columnNumber = 1; var disabledDayFlag = false; var cmpMonth = this.currentMonth-1; var oDay = new Date(this.currentYear, cmpMonth, 1,1,0,0); var iStamp = oDay.getTime(); this.flag_DayMarkedBeforeRepopulation = false; this.setControlBarText(this.monthsTextualRepresentation[cmpMonth] + ", " + this.currentYear); var skipDays = parseInt(oDay.getDay()); var i=0; for (i=0; i<skipDays; i++){ aDayDiv = d.createElement("div"); aDayDiv.setAttribute("class","skipDay"); aMainBox.appendChild(aDayDiv); if (columnNumber == 7){ columnNumber = 1; } else { columnNumber++; } } while (oDay.getMonth() == cmpMonth){ disabledDayFlag = false; aDayDiv = d.createElement("div"); if (this.lastPostedDay){ if (this.lastPostedDay == oDay.getDate()){ aTextNode = parseInt(this.lastPostedDay,10)+1; } else { aTextNode = d.createTextNode(oDay.getDate()); } } else { aTextNode = d.createTextNode(oDay.getDate()); } aDayDiv.appendChild(aTextNode); aMainBox.appendChild(aDayDiv); aDayDiv.setAttribute("globalNumber",this.globalNumber); if (columnNumber == 7){ aDayDiv.style.marginRight = "0px"; } if (this.isToday(oDay)){ aDayDiv.setAttribute("isToday",1); } if (this.oConfiguration.limitToToday){ if ( ! this.isAvailable(this.currentYear, this.currentMonth, parseInt(oDay.getDate()) ) ){ disabledDayFlag = true; aDayDiv.setAttribute("isJsDatePickDisabled",1); } } aDayDiv.onmouseover = function(){ var globalRef = "gRef_"+this.getAttribute("globalNumber"); var currentColorScheme = eval(globalRef + ".getCurrentColorScheme()"); if (parseInt(this.getAttribute("isSelected")) == 1){ return; } if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } if (parseInt(this.getAttribute("isToday")) == 1){ this.setAttribute("class","dayOverToday"); this.style.background = "url(img/" + currentColorScheme + "_dayOver.gif) left top no-repeat"; } else { this.setAttribute("class","dayOver"); this.style.background = "url(img/" + currentColorScheme + "_dayOver.gif) left top no-repeat"; } }; aDayDiv.onmouseout = function(){ var globalRef = "gRef_"+this.getAttribute("globalNumber"); var currentColorScheme = eval(globalRef + ".getCurrentColorScheme()"); if (parseInt(this.getAttribute("isSelected")) == 1){ return; } if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } if (parseInt(this.getAttribute("isToday")) == 1){ this.setAttribute("class","dayNormalToday"); this.style.background = "url(img/" + currentColorScheme + "_dayNormal.gif) left top no-repeat"; } else { this.setAttribute("class","dayNormal"); this.style.background = "url(img/" + currentColorScheme + "_dayNormal.gif) left top no-repeat"; } }; aDayDiv.onmousedown = function(){ var globalRef = "gRef_"+this.getAttribute("globalNumber"); var currentColorScheme = eval(globalRef + ".getCurrentColorScheme()"); if (parseInt(this.getAttribute("isSelected")) == 1){ return; } if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } if (parseInt(this.getAttribute("isToday")) == 1){ this.setAttribute("class","dayDownToday"); this.style.background = "url(img/" + currentColorScheme + "_dayDown.gif) left top no-repeat"; } else { this.setAttribute("class","dayDown"); this.style.background = "url(img/" + currentColorScheme + "_dayDown.gif) left top no-repeat"; } }; aDayDiv.onmouseup = function(){ var globalRef = "gRef_"+this.getAttribute("globalNumber"); var currentColorScheme = eval(globalRef + ".getCurrentColorScheme()"); if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } if (parseInt(this.getAttribute("isToday")) == 1){ this.setAttribute("class","dayNormalToday"); this.style.background = "url(img/" + currentColorScheme + "_dayNormal.gif) left top no-repeat"; } else { this.setAttribute("class","dayNormal"); this.style.background = "url(img/" + currentColorScheme + "_dayNormal.gif) left top no-repeat"; } eval(globalRef + ".setDaySelection(this);"); eval(globalRef + ".executeOnSelectedDelegateIfExists();"); }; if (this.isSelectedDay(oDay.getDate())){ aDayDiv.setAttribute("isSelected",1); this.flag_DayMarkedBeforeRepopulation = true; this.lastMarkedDayObject = aDayDiv; if (parseInt(aDayDiv.getAttribute("isToday")) == 1){ aDayDiv.setAttribute("class","dayDownToday"); aDayDiv.style.background = "url(img/" + this.oConfiguration.cellColorScheme + "_dayDown.gif) left top no-repeat"; } else { aDayDiv.setAttribute("class","dayDown"); aDayDiv.style.background = "url(img/" + this.oConfiguration.cellColorScheme + "_dayDown.gif) left top no-repeat"; } } else { var globalRef = "gRef_"+aDayDiv.getAttribute("globalNumber"); var currentColorScheme = eval(globalRef + ".getCurrentColorScheme()"); if (parseInt(aDayDiv.getAttribute("isToday")) == 1){ if (disabledDayFlag){ aDayDiv.setAttribute("class","dayDisabled"); aDayDiv.style.background = "url(img/" + this.oConfiguration.cellColorScheme + "_dayNormal.gif) left top no-repeat"; } else { aDayDiv.setAttribute("class","dayNormalToday"); aDayDiv.style.background = "url(img/" + this.oConfiguration.cellColorScheme + "_dayNormal.gif) left top no-repeat"; } } else { if (disabledDayFlag){ aDayDiv.setAttribute("class","dayDisabled"); aDayDiv.style.background = "url(img/" + this.oConfiguration.cellColorScheme + "_dayNormal.gif) left top no-repeat"; } else { aDayDiv.setAttribute("class","dayNormal"); aDayDiv.style.background = "url(img/" + this.oConfiguration.cellColorScheme + "_dayNormal.gif) left top no-repeat"; } } } if (columnNumber == 7){ columnNumber = 1; } else { columnNumber++; } iStamp += 86400000; oDay.setTime(iStamp); } this.lastPostedDay = null; return aMainBox; }; JsDatePick.prototype.unsetSelection = function(){ this.flag_aDayWasSelected = false; this.selectedDayObject = new Object(); this.repopulateMainBox(); }; JsDatePick.prototype.setSelectedDay = function(dateObject){ this.flag_aDayWasSelected = true; this.selectedDayObject.day = parseInt(dateObject.day,10); this.selectedDayObject.month = parseInt(dateObject.month,10); this.selectedDayObject.year = parseInt(dateObject.year); this.currentMonth = dateObject.month; this.currentYear = dateObject.year; this.repopulateMainBox(); }; JsDatePick.prototype.isSelectedDay = function(aDate){ if (this.flag_aDayWasSelected){ if (parseInt(aDate) == this.selectedDayObject.day && this.currentMonth == this.selectedDayObject.month && this.currentYear == this.selectedDayObject.year){ return true; } else { return false; } } return false; }; JsDatePick.prototype.getSelectedDay = function(){ if (this.flag_aDayWasSelected){ return this.selectedDayObject; } else { return false; } }; JsDatePick.prototype.getSelectedDayFormatted = function(){ if (this.flag_aDayWasSelected){ var returnVal = this.selectedDayObject.year+"-"; if (this.selectedDayObject.month >= 1 && this.selectedDayObject.month <= 9){ returnVal += "0"+this.selectedDayObject.month+"-"; } else { returnVal += this.selectedDayObject.month+"-"; } if (this.selectedDayObject.day >= 1 && this.selectedDayObject.day <= 9){ returnVal += "0"+this.selectedDayObject.day; } else { returnVal += this.selectedDayObject.day; } return returnVal; } else { return false; } }; JsDatePick.prototype.setDaySelection = function(anElement){ var globalRef = "gRef_"+anElement.getAttribute("globalNumber"); var currentColorScheme = eval(globalRef + ".getCurrentColorScheme()"); if (this.flag_DayMarkedBeforeRepopulation){ /* Un mark last selected day */ this.lastMarkedDayObject.setAttribute("isSelected",0); if (parseInt(this.lastMarkedDayObject.getAttribute("isToday")) == 1){ this.lastMarkedDayObject.setAttribute("class","dayNormalToday"); this.lastMarkedDayObject.style.background = "url(img/" + currentColorScheme + "_dayNormal.gif) left top no-repeat"; } else { this.lastMarkedDayObject.setAttribute("class","dayNormal"); this.lastMarkedDayObject.style.background = "url(img/" + currentColorScheme + "_dayNormal.gif) left top no-repeat"; } } this.flag_aDayWasSelected = true; this.selectedDayObject.year = this.currentYear; this.selectedDayObject.month = this.currentMonth; this.selectedDayObject.day = parseInt(anElement.innerHTML); this.flag_DayMarkedBeforeRepopulation = true; this.lastMarkedDayObject = anElement; anElement.setAttribute("isSelected",1); if (parseInt(anElement.getAttribute("isToday")) == 1){ anElement.setAttribute("class","dayDownToday"); anElement.style.background = "url(img/" + currentColorScheme + "_dayDown.gif) left top no-repeat"; } else { anElement.setAttribute("class","dayDown"); anElement.style.background = "url(img/" + currentColorScheme + "_dayDown.gif) left top no-repeat"; } }; JsDatePick.prototype.isToday = function(aDateObject){ var cmpMonth = this.oCurrentDay.month-1; if (aDateObject.getDate() == this.oCurrentDay.day && aDateObject.getMonth() == cmpMonth && aDateObject.getFullYear() == this.oCurrentDay.year){ return true; } return false; }; JsDatePick.prototype.setControlBarText = function(aText){ var aTextNode = document.createTextNode(aText); while (this.controlsBarTextCell.firstChild){ this.controlsBarTextCell.removeChild(this.controlsBarTextCell.firstChild); } this.controlsBarTextCell.appendChild(aTextNode); }; JsDatePick.prototype.setTooltipText = function(aText){ while (this.tooltip.firstChild){ this.tooltip.removeChild(this.tooltip.firstChild); } var aTextNode = document.createTextNode(aText); this.tooltip.appendChild(aTextNode); }; JsDatePick.prototype.moveForwardOneYear = function(){ var desiredYear = this.currentYear + 1; if (desiredYear < parseInt(this.oConfiguration.yearsRange[1])){ this.currentYear++; this.repopulateMainBox(); } else { return; } }; JsDatePick.prototype.moveBackOneYear = function(){ var desiredYear = this.currentYear - 1; if (desiredYear > parseInt(this.oConfiguration.yearsRange[0])){ this.currentYear--; this.repopulateMainBox(); } else { return; } }; JsDatePick.prototype.moveForwardOneMonth = function(){ if (this.currentMonth < 12){ this.currentMonth++; } else { this.currentYear++; this.currentMonth = 1; } this.repopulateMainBox(); }; JsDatePick.prototype.moveBackOneMonth = function(){ if (this.currentMonth > 1){ this.currentMonth--; } else { this.currentYear--; this.currentMonth = 12; } this.repopulateMainBox(); }; JsDatePick.prototype.getCurrentColorScheme = function(){ return this.oConfiguration.cellColorScheme; }; JsDatePick.prototype.getDOMControlBar = function(){ var d = document; var controlsBar = d.createElement("div"); var monthForwardButton = d.createElement("div"); var monthBackwardButton = d.createElement("div"); var yearForwardButton = d.createElement("div"); var yearBackwardButton = d.createElement("div"); var controlsBarText = d.createElement("div"); controlsBar.setAttribute("class","controlsBar"); monthForwardButton.setAttribute("class","monthForwardButton"); monthBackwardButton.setAttribute("class","monthBackwardButton"); yearForwardButton.setAttribute("class","yearForwardButton"); yearBackwardButton.setAttribute("class","yearBackwardButton"); controlsBarText.setAttribute("class","controlsBarText"); controlsBar.setAttribute("globalNumber",this.globalNumber); this.controlsBarTextCell = controlsBarText; controlsBar.appendChild(monthForwardButton); controlsBar.appendChild(monthBackwardButton); controlsBar.appendChild(yearForwardButton); controlsBar.appendChild(yearBackwardButton); controlsBar.appendChild(controlsBarText); monthForwardButton.onmouseover = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","monthForwardButtonOver"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Move a month forward\");"); }; monthForwardButton.onmouseout = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","monthForwardButton"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"\");"); }; monthForwardButton.onmousedown = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","monthForwardButtonDown"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Move a month forward\");"); }; monthForwardButton.onmouseup = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","monthForwardButton"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Move a month forward\");"); eval(globalRef + ".moveForwardOneMonth();"); }; /* Month backward button event handlers */ monthBackwardButton.onmouseover = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","monthBackwardButtonOver"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Move a month backward\");"); }; monthBackwardButton.onmouseout = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","monthBackwardButton"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"\");"); }; monthBackwardButton.onmousedown = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","monthBackwardButtonDown"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Move a month backward\");"); }; monthBackwardButton.onmouseup = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","monthBackwardButton"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Move a month backward\");"); eval(globalRef + ".moveBackOneMonth();"); }; /* Year forward button */ yearForwardButton.onmouseover = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","yearForwardButtonOver"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Move a year forward\");"); }; yearForwardButton.onmouseout = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","yearForwardButton"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"\");"); }; yearForwardButton.onmousedown = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","yearForwardButtonDown"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Move a year forward\");"); }; yearForwardButton.onmouseup = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","yearForwardButton"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Move a year forward\");"); eval(globalRef + ".moveForwardOneYear();"); }; /* Year backward button */ yearBackwardButton.onmouseover = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","yearBackwardButtonOver"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Move a year backward\");"); }; yearBackwardButton.onmouseout = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","yearBackwardButton"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"\");"); }; yearBackwardButton.onmousedown = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","yearBackwardButtonDown"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Move a year backward\");"); }; yearBackwardButton.onmouseup = function(){ if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } this.setAttribute("class","yearBackwardButton"); var parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } var globalRef = "gRef_"+parentElement.getAttribute("globalNumber"); eval(globalRef + ".setTooltipText(\"Move a year backward\");"); eval(globalRef + ".moveBackOneYear();"); }; return controlsBar; };

oexam/calendar/jsDatePick.min.1.1.js

g_arrayOfUsedJsDatePickCalsGlobalNumbers=new Array();g_currentDateObject=new Object();g_currentDateObject.dateObject=new Date();g_currentDateObject.day=g_currentDateObject.dateObject.getDate();g_currentDateObject.month=g_currentDateObject.dateObject.getMonth()+1;g_currentDateObject.year=g_currentDateObject.dateObject.getFullYear();$=function(id){ return document.getElementById(id) };String.prototype.trim=function(){ return this.replace(/^\s+|\s+$/g,"") };String.prototype.ltrim=function(){ return this.replace(/^\s+/,"") };String.prototype.rtrim=function(){ return this.replace(/\s+$/,"") };JsDatePick=function(configurationObject){ this.oConfiguration=new Object();this.oCurrentDay=g_currentDateObject;this.monthsTextualRepresentation=new Array("Janaury","February","March","April","May","June","July","August","September","October","November","December");this.lastPostedDay=null;this.initialZIndex=2;this.globalNumber=this.getUnUsedGlobalNumber();eval("gRef_"+this.globalNumber+"=this;");this.setConfiguration(configurationObject);this.makeCalendar() };JsDatePick.prototype.getUnUsedGlobalNumber=function(){ var aNum=Math.floor(Math.random()*1000);while(!this.isUnique_GlobalNumber(aNum)){ aNum=Math.floor(Math.random()*1000) }return aNum };JsDatePick.prototype.isUnique_GlobalNumber=function(aNum){ var i;for(i=0;i<g_arrayOfUsedJsDatePickCalsGlobalNumbers.length;i++){ if(g_arrayOfUsedJsDatePickCalsGlobalNumbers[i]==aNum){ return false } }return true };JsDatePick.prototype.addOnSelectedDelegate=function(aDelegatedFunction){ if(typeof(aDelegatedFunction)=="function"){ this.addonSelectedDelegate=aDelegatedFunction }return false };JsDatePick.prototype.setOnSelectedDelegate=function(aDelegatedFunction){ if(typeof(aDelegatedFunction)=="function"){ this.onSelectedDelegate=aDelegatedFunction;return true }return false };JsDatePick.prototype.executeOnSelectedDelegateIfExists=function(){ if(typeof(this.onSelectedDelegate)=="function"){ this.onSelectedDelegate() }if(typeof(this.addonSelectedDelegate)=="function"){ this.addonSelectedDelegate() } };JsDatePick.prototype.setRepopulationDelegate=function(aDelegatedFunction){ if(typeof(aDelegatedFunction)=="function"){ this.repopulationDelegate=aDelegatedFunction;return true }return false };JsDatePick.prototype.setConfiguration=function(aConf){ this.oConfiguration.isStripped=(aConf.isStripped!=null)?aConf.isStripped:false;this.oConfiguration.useMode=(aConf.useMode!=null)?aConf.useMode:1;this.oConfiguration.selectedDate=(aConf.selectedDate!=null)?aConf.selectedDate:null;this.oConfiguration.target=(aConf.target!=null)?aConf.target:null;this.oConfiguration.yearsRange=(aConf.yearsRange!=null)?aConf.yearsRange:new Array(1971,2100);this.oConfiguration.limitToToday=(aConf.limitToToday!=null)?aConf.limitToToday:false;this.oConfiguration.field=(aConf.field!=null)?aConf.field:false;this.oConfiguration.cellColorScheme=(aConf.cellColorScheme!=null)?aConf.cellColorScheme:"ocean_blue";this.selectedDayObject=new Object();this.flag_DayMarkedBeforeRepopulation=false;this.flag_aDayWasSelected=false;this.lastMarkedDayObject=null;if(this.oConfiguration.selectedDate!=null){ if(typeof(this.oConfiguration.selectedDate)=="object"){ if(!isNaN(this.oConfiguration.selectedDate.day)&&!isNaN(this.oConfiguration.selectedDate.month)&&!isNaN(this.oConfiguration.selectedDate.year)){ this.currentDay=this.oCurrentDay.day;this.selectedDayObject.day=this.oConfiguration.selectedDate.day;this.currentMonth=this.selectedDayObject.month=this.oConfiguration.selectedDate.month;this.currentYear=this.selectedDayObject.year=this.oConfiguration.selectedDate.year;this.flag_aDayWasSelected=true }else{ alert("The initial selected date object is not complete or invalid!") } }else{ alert("the initial selected date is wrong! you need to supply an object containing 3 properties (day,month,year)") } }else{ this.currentYear=this.oCurrentDay.year;this.currentMonth=this.oCurrentDay.month;this.currentDay=this.oCurrentDay.day } };JsDatePick.prototype.resizeCalendar=function(){ this.leftWallStrechedElement.style.height="0px";this.rightWallStrechedElement.style.height="0px";var totalHeight=this.JsDatePickBox.offsetHeight;var newStrechedHeight=totalHeight-16;if(newStrechedHeight<0){ return }this.leftWallStrechedElement.style.height=newStrechedHeight+"px";this.rightWallStrechedElement.style.height=newStrechedHeight+"px";return true };JsDatePick.prototype.closeCalendar=function(){ this.JsDatePickBox.style.display="none" };JsDatePick.prototype.populateFieldWithSelectedDate=function(){ $(this.oConfiguration.target).value=this.getSelectedDayFormatted();this.closeCalendar() };JsDatePick.prototype.makeCalendar=function(){ var d=document;var JsDatePickBox=d.createElement("div");var clearfix=d.createElement("div");var closeButton=d.createElement("div");JsDatePickBox.setAttribute("class","JsDatePickBox");clearfix.setAttribute("class","clearfix");closeButton.setAttribute("class","jsDatePickCloseButton");closeButton.setAttribute("globalNumber",this.globalNumber);closeButton.onmouseover=function(){ this.setAttribute("class","jsDatePickCloseButtonOver");var globalRef="gRef_"+this.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Close the calendar");') };closeButton.onmouseout=function(){ this.setAttribute("class","jsDatePickCloseButton");var globalRef="gRef_"+this.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("");') };closeButton.onmousedown=function(){ this.setAttribute("class","jsDatePickCloseButtonDown");var globalRef="gRef_"+this.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Close the calendar");') };closeButton.onmouseup=function(){ this.setAttribute("class","jsDatePickCloseButton");var globalRef="gRef_"+this.getAttribute("globalNumber");eval("gRef_"+this.getAttribute("globalNumber")+".closeCalendar();");eval(globalRef+'.setTooltipText("");') };this.JsDatePickBox=JsDatePickBox;var leftWall=d.createElement("div");var rightWall=d.createElement("div");var topWall=d.createElement("div");var bottomWall=d.createElement("div");topWall.setAttribute("class","topWall");bottomWall.setAttribute("class","bottomWall");var topCorner=d.createElement("div");var bottomCorner=d.createElement("div");var wall=d.createElement("div");topCorner.setAttribute("class","leftTopCorner");bottomCorner.setAttribute("class","leftBottomCorner");wall.setAttribute("class","leftWall");this.leftWallStrechedElement=wall;this.leftWall=leftWall;this.rightWall=rightWall;leftWall.appendChild(topCorner);leftWall.appendChild(wall);leftWall.appendChild(bottomCorner);topCorner=d.createElement("div");bottomCorner=d.createElement("div");wall=d.createElement("div");topCorner.setAttribute("class","rightTopCorner");bottomCorner.setAttribute("class","rightBottomCorner");wall.setAttribute("class","rightWall");this.rightWallStrechedElement=wall;rightWall.appendChild(topCorner);rightWall.appendChild(wall);rightWall.appendChild(bottomCorner);if(this.oConfiguration.isStripped){ leftWall.setAttribute("class","hiddenBoxLeftWall");rightWall.setAttribute("class","hiddenBoxRightWall") }else{ leftWall.setAttribute("class","boxLeftWall");rightWall.setAttribute("class","boxRightWall") }JsDatePickBox.appendChild(leftWall);JsDatePickBox.appendChild(this.getDOMCalendarStripped());JsDatePickBox.appendChild(rightWall);JsDatePickBox.appendChild(clearfix);if(!this.oConfiguration.isStripped){ JsDatePickBox.appendChild(closeButton);JsDatePickBox.appendChild(topWall);JsDatePickBox.appendChild(bottomWall) }if(this.oConfiguration.useMode==2){ if(this.oConfiguration.target!=false){ if(typeof($(this.oConfiguration.target))!=null){ var inputElement=$(this.oConfiguration.target);var aSpan=document.createElement("span");inputElement.parentNode.replaceChild(aSpan,inputElement);aSpan.appendChild(inputElement);inputElement.setAttribute("globalNumber",this.globalNumber);inputElement.onclick=function(){ eval("gRef_"+this.getAttribute("globalNumber")+".showCalendar();") };aSpan.style.position="relative";this.initialZIndex++;JsDatePickBox.style.zIndex=this.initialZIndex.toString();JsDatePickBox.style.position="absolute";JsDatePickBox.style.top="18px";JsDatePickBox.style.left="0px";JsDatePickBox.style.display="none";aSpan.appendChild(JsDatePickBox);var aFunc=new Function("gRef_"+this.globalNumber+".populateFieldWithSelectedDate();");this.setOnSelectedDelegate(aFunc) }else{ alert("There is no element with such an ID!") } } }else{ if(this.oConfiguration.target!=null){ $(this.oConfiguration.target).appendChild(JsDatePickBox);$(this.oConfiguration.target).style.position="relative";JsDatePickBox.style.position="absolute";JsDatePickBox.style.top="0px";JsDatePickBox.style.left="0px";this.resizeCalendar();this.executePopulationDelegateIfExists() }else{ alert("No element ID to put this calendar on! check JsDatePick configuration") } } };JsDatePick.prototype.determineFieldDate=function(){ var aField=$(this.oConfiguration.target);if(aField.value.trim().length==0){ this.unsetSelection();return }else{ if(aField.value.trim().length>7){ var array=aField.value.trim().split("-");this.setSelectedDay({ year:parseInt(array[0]), month:parseInt(array[1],10), day:parseInt(array[2],10) });return }else{ this.unsetSelection();return } } };JsDatePick.prototype.showCalendar=function(){ if(this.JsDatePickBox.style.display=="none"){ this.determineFieldDate();this.JsDatePickBox.style.display="block";this.resizeCalendar();this.executePopulationDelegateIfExists() }else{ return } };JsDatePick.prototype.isAvailable=function(y,m,d){ if(y>this.oCurrentDay.year){ return false }if(m>this.oCurrentDay.month&&y==this.oCurrentDay.year){ return false }if(d>this.oCurrentDay.day&&m==this.oCurrentDay.month&&y==this.oCurrentDay.year){ return false }return true };JsDatePick.prototype.getDOMCalendarStripped=function(){ var d=document;var boxMain=d.createElement("div");if(this.oConfiguration.isStripped){ boxMain.setAttribute("class","boxMainStripped") }else{ boxMain.setAttribute("class","boxMain") }this.boxMain=boxMain;var boxMainInner=d.createElement("div");var clearfix=d.createElement("div");var boxMainCellsContainer=d.createElement("div");var tooltip=d.createElement("div");var weekDaysRow=d.createElement("div");var clearfix2=d.createElement("div");clearfix.setAttribute("class","clearfix");clearfix2.setAttribute("class","clearfix");boxMainInner.setAttribute("class","boxMainInner");boxMainCellsContainer.setAttribute("class","boxMainCellsContainer");tooltip.setAttribute("class","tooltip");weekDaysRow.setAttribute("class","weekDaysRow");this.tooltip=tooltip;boxMain.appendChild(boxMainInner);this.controlsBar=this.getDOMControlBar();this.makeDOMWeekDays(weekDaysRow);boxMainInner.appendChild(this.controlsBar);boxMainInner.appendChild(clearfix);boxMainInner.appendChild(tooltip);boxMainInner.appendChild(weekDaysRow);boxMainInner.appendChild(boxMainCellsContainer);boxMainInner.appendChild(clearfix2);this.boxMainCellsContainer=boxMainCellsContainer;this.populateMainBox(boxMainCellsContainer);return boxMain };JsDatePick.prototype.makeDOMWeekDays=function(aWeekDaysRow){ var i=0;var d=document;var weekDaysArray=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");var textNode;var weekDay;for(i=0;i<7;i++){ weekDay=d.createElement("div");textNode=d.createTextNode(weekDaysArray[i]);weekDay.setAttribute("class","weekDay");if(weekDaysArray[i]=="Sat"){ weekDay.style.marginRight="0px" }weekDay.appendChild(textNode);aWeekDaysRow.appendChild(weekDay) } };JsDatePick.prototype.repopulateMainBox=function(){ while(this.boxMainCellsContainer.firstChild){ this.boxMainCellsContainer.removeChild(this.boxMainCellsContainer.firstChild) }this.populateMainBox(this.boxMainCellsContainer);this.resizeCalendar();this.executePopulationDelegateIfExists() };JsDatePick.prototype.executePopulationDelegateIfExists=function(){ if(typeof(this.repopulationDelegate)=="function"){ this.repopulationDelegate() } };JsDatePick.prototype.populateMainBox=function(aMainBox){ var d=document;var aDayDiv;var aTextNode;var columnNumber=1;var disabledDayFlag=false;var cmpMonth=this.currentMonth-1;var oDay=new Date(this.currentYear,cmpMonth,1,1,0,0);var iStamp=oDay.getTime();this.flag_DayMarkedBeforeRepopulation=false;this.setControlBarText(this.monthsTextualRepresentation[cmpMonth]+", "+this.currentYear);var skipDays=parseInt(oDay.getDay());var i=0;for(i=0;i<skipDays;i++){ aDayDiv=d.createElement("div");aDayDiv.setAttribute("class","skipDay");aMainBox.appendChild(aDayDiv);if(columnNumber==7){ columnNumber=1 }else{ columnNumber++ } }while(oDay.getMonth()==cmpMonth){ disabledDayFlag=false;aDayDiv=d.createElement("div");if(this.lastPostedDay){ if(this.lastPostedDay==oDay.getDate()){ aTextNode=parseInt(this.lastPostedDay,10)+1 }else{ aTextNode=d.createTextNode(oDay.getDate()) } }else{ aTextNode=d.createTextNode(oDay.getDate()) }aDayDiv.appendChild(aTextNode);aMainBox.appendChild(aDayDiv);aDayDiv.setAttribute("globalNumber",this.globalNumber);if(columnNumber==7){ aDayDiv.style.marginRight="0px" }if(this.isToday(oDay)){ aDayDiv.setAttribute("isToday",1) }if(this.oConfiguration.limitToToday){ if(!this.isAvailable(this.currentYear,this.currentMonth,parseInt(oDay.getDate()))){ disabledDayFlag=true;aDayDiv.setAttribute("isJsDatePickDisabled",1) } }aDayDiv.onmouseover=function(){ var globalRef="gRef_"+this.getAttribute("globalNumber");var currentColorScheme=eval(globalRef+".getCurrentColorScheme()");if(parseInt(this.getAttribute("isSelected"))==1){ return }if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }if(parseInt(this.getAttribute("isToday"))==1){ this.setAttribute("class","dayOverToday");this.style.background="url(img/"+currentColorScheme+"_dayOver.gif) left top no-repeat" }else{ this.setAttribute("class","dayOver");this.style.background="url(img/"+currentColorScheme+"_dayOver.gif) left top no-repeat" } };aDayDiv.onmouseout=function(){ var globalRef="gRef_"+this.getAttribute("globalNumber");var currentColorScheme=eval(globalRef+".getCurrentColorScheme()");if(parseInt(this.getAttribute("isSelected"))==1){ return }if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }if(parseInt(this.getAttribute("isToday"))==1){ this.setAttribute("class","dayNormalToday");this.style.background="url(img/"+currentColorScheme+"_dayNormal.gif) left top no-repeat" }else{ this.setAttribute("class","dayNormal");this.style.background="url(img/"+currentColorScheme+"_dayNormal.gif) left top no-repeat" } };aDayDiv.onmousedown=function(){ var globalRef="gRef_"+this.getAttribute("globalNumber");var currentColorScheme=eval(globalRef+".getCurrentColorScheme()");if(parseInt(this.getAttribute("isSelected"))==1){ return }if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }if(parseInt(this.getAttribute("isToday"))==1){ this.setAttribute("class","dayDownToday");this.style.background="url(img/"+currentColorScheme+"_dayDown.gif) left top no-repeat" }else{ this.setAttribute("class","dayDown");this.style.background="url(img/"+currentColorScheme+"_dayDown.gif) left top no-repeat" } };aDayDiv.onmouseup=function(){ var globalRef="gRef_"+this.getAttribute("globalNumber");var currentColorScheme=eval(globalRef+".getCurrentColorScheme()");if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }if(parseInt(this.getAttribute("isToday"))==1){ this.setAttribute("class","dayNormalToday");this.style.background="url(img/"+currentColorScheme+"_dayNormal.gif) left top no-repeat" }else{ this.setAttribute("class","dayNormal");this.style.background="url(img/"+currentColorScheme+"_dayNormal.gif) left top no-repeat" }eval(globalRef+".setDaySelection(this);");eval(globalRef+".executeOnSelectedDelegateIfExists();") };if(this.isSelectedDay(oDay.getDate())){ aDayDiv.setAttribute("isSelected",1);this.flag_DayMarkedBeforeRepopulation=true;this.lastMarkedDayObject=aDayDiv;if(parseInt(aDayDiv.getAttribute("isToday"))==1){ aDayDiv.setAttribute("class","dayDownToday");aDayDiv.style.background="url(img/"+this.oConfiguration.cellColorScheme+"_dayDown.gif) left top no-repeat" }else{ aDayDiv.setAttribute("class","dayDown");aDayDiv.style.background="url(img/"+this.oConfiguration.cellColorScheme+"_dayDown.gif) left top no-repeat" } }else{ var globalRef="gRef_"+aDayDiv.getAttribute("globalNumber");var currentColorScheme=eval(globalRef+".getCurrentColorScheme()");if(parseInt(aDayDiv.getAttribute("isToday"))==1){ if(disabledDayFlag){ aDayDiv.setAttribute("class","dayDisabled");aDayDiv.style.background="url(img/"+this.oConfiguration.cellColorScheme+"_dayNormal.gif) left top no-repeat" }else{ aDayDiv.setAttribute("class","dayNormalToday");aDayDiv.style.background="url(img/"+this.oConfiguration.cellColorScheme+"_dayNormal.gif) left top no-repeat" } }else{ if(disabledDayFlag){ aDayDiv.setAttribute("class","dayDisabled");aDayDiv.style.background="url(img/"+this.oConfiguration.cellColorScheme+"_dayNormal.gif) left top no-repeat" }else{ aDayDiv.setAttribute("class","dayNormal");aDayDiv.style.background="url(img/"+this.oConfiguration.cellColorScheme+"_dayNormal.gif) left top no-repeat" } } }if(columnNumber==7){ columnNumber=1 }else{ columnNumber++ }iStamp+=86400000;oDay.setTime(iStamp) }this.lastPostedDay=null;return aMainBox };JsDatePick.prototype.unsetSelection=function(){ this.flag_aDayWasSelected=false;this.selectedDayObject=new Object();this.repopulateMainBox() };JsDatePick.prototype.setSelectedDay=function(dateObject){ this.flag_aDayWasSelected=true;this.selectedDayObject.day=parseInt(dateObject.day,10);this.selectedDayObject.month=parseInt(dateObject.month,10);this.selectedDayObject.year=parseInt(dateObject.year);this.currentMonth=dateObject.month;this.currentYear=dateObject.year;this.repopulateMainBox() };JsDatePick.prototype.isSelectedDay=function(aDate){ if(this.flag_aDayWasSelected){ if(parseInt(aDate)==this.selectedDayObject.day&&this.currentMonth==this.selectedDayObject.month&&this.currentYear==this.selectedDayObject.year){ return true }else{ return false } }return false };JsDatePick.prototype.getSelectedDay=function(){ if(this.flag_aDayWasSelected){ return this.selectedDayObject }else{ return false } };JsDatePick.prototype.getSelectedDayFormatted=function(){ if(this.flag_aDayWasSelected){ var returnVal=this.selectedDayObject.year+"-";if(this.selectedDayObject.month>=1&&this.selectedDayObject.month<=9){ returnVal+="0"+this.selectedDayObject.month+"-" }else{ returnVal+=this.selectedDayObject.month+"-" }if(this.selectedDayObject.day>=1&&this.selectedDayObject.day<=9){ returnVal+="0"+this.selectedDayObject.day }else{ returnVal+=this.selectedDayObject.day }return returnVal }else{ return false } };JsDatePick.prototype.setDaySelection=function(anElement){ var globalRef="gRef_"+anElement.getAttribute("globalNumber");var currentColorScheme=eval(globalRef+".getCurrentColorScheme()");if(this.flag_DayMarkedBeforeRepopulation){ this.lastMarkedDayObject.setAttribute("isSelected",0);if(parseInt(this.lastMarkedDayObject.getAttribute("isToday"))==1){ this.lastMarkedDayObject.setAttribute("class","dayNormalToday");this.lastMarkedDayObject.style.background="url(img/"+currentColorScheme+"_dayNormal.gif) left top no-repeat" }else{ this.lastMarkedDayObject.setAttribute("class","dayNormal");this.lastMarkedDayObject.style.background="url(img/"+currentColorScheme+"_dayNormal.gif) left top no-repeat" } }this.flag_aDayWasSelected=true;this.selectedDayObject.year=this.currentYear;this.selectedDayObject.month=this.currentMonth;this.selectedDayObject.day=parseInt(anElement.innerHTML);this.flag_DayMarkedBeforeRepopulation=true;this.lastMarkedDayObject=anElement;anElement.setAttribute("isSelected",1);if(parseInt(anElement.getAttribute("isToday"))==1){ anElement.setAttribute("class","dayDownToday");anElement.style.background="url(img/"+currentColorScheme+"_dayDown.gif) left top no-repeat" }else{ anElement.setAttribute("class","dayDown");anElement.style.background="url(img/"+currentColorScheme+"_dayDown.gif) left top no-repeat" } };JsDatePick.prototype.isToday=function(aDateObject){ var cmpMonth=this.oCurrentDay.month-1;if(aDateObject.getDate()==this.oCurrentDay.day&&aDateObject.getMonth()==cmpMonth&&aDateObject.getFullYear()==this.oCurrentDay.year){ return true }return false };JsDatePick.prototype.setControlBarText=function(aText){ var aTextNode=document.createTextNode(aText);while(this.controlsBarTextCell.firstChild){ this.controlsBarTextCell.removeChild(this.controlsBarTextCell.firstChild) }this.controlsBarTextCell.appendChild(aTextNode) };JsDatePick.prototype.setTooltipText=function(aText){ while(this.tooltip.firstChild){ this.tooltip.removeChild(this.tooltip.firstChild) }var aTextNode=document.createTextNode(aText);this.tooltip.appendChild(aTextNode) };JsDatePick.prototype.moveForwardOneYear=function(){ var desiredYear=this.currentYear+1;if(desiredYear<parseInt(this.oConfiguration.yearsRange[1])){ this.currentYear++;this.repopulateMainBox() }else{ return } };JsDatePick.prototype.moveBackOneYear=function(){ var desiredYear=this.currentYear-1;if(desiredYear>parseInt(this.oConfiguration.yearsRange[0])){ this.currentYear--;this.repopulateMainBox() }else{ return } };JsDatePick.prototype.moveForwardOneMonth=function(){ if(this.currentMonth<12){ this.currentMonth++ }else{ this.currentYear++;this.currentMonth=1 }this.repopulateMainBox() };JsDatePick.prototype.moveBackOneMonth=function(){ if(this.currentMonth>1){ this.currentMonth-- }else{ this.currentYear--;this.currentMonth=12 }this.repopulateMainBox() };JsDatePick.prototype.getCurrentColorScheme=function(){ return this.oConfiguration.cellColorScheme };JsDatePick.prototype.getDOMControlBar=function(){ var d=document;var controlsBar=d.createElement("div");var monthForwardButton=d.createElement("div");var monthBackwardButton=d.createElement("div");var yearForwardButton=d.createElement("div");var yearBackwardButton=d.createElement("div");var controlsBarText=d.createElement("div");controlsBar.setAttribute("class","controlsBar");monthForwardButton.setAttribute("class","monthForwardButton");monthBackwardButton.setAttribute("class","monthBackwardButton");yearForwardButton.setAttribute("class","yearForwardButton");yearBackwardButton.setAttribute("class","yearBackwardButton");controlsBarText.setAttribute("class","controlsBarText");controlsBar.setAttribute("globalNumber",this.globalNumber);this.controlsBarTextCell=controlsBarText;controlsBar.appendChild(monthForwardButton);controlsBar.appendChild(monthBackwardButton);controlsBar.appendChild(yearForwardButton);controlsBar.appendChild(yearBackwardButton);controlsBar.appendChild(controlsBarText);monthForwardButton.onmouseover=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","monthForwardButtonOver");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Move a month forward");') };monthForwardButton.onmouseout=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","monthForwardButton");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("");') };monthForwardButton.onmousedown=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","monthForwardButtonDown");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Move a month forward");') };monthForwardButton.onmouseup=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","monthForwardButton");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Move a month forward");');eval(globalRef+".moveForwardOneMonth();") };monthBackwardButton.onmouseover=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","monthBackwardButtonOver");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Move a month backward");') };monthBackwardButton.onmouseout=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","monthBackwardButton");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("");') };monthBackwardButton.onmousedown=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","monthBackwardButtonDown");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Move a month backward");') };monthBackwardButton.onmouseup=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","monthBackwardButton");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Move a month backward");');eval(globalRef+".moveBackOneMonth();") };yearForwardButton.onmouseover=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","yearForwardButtonOver");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Move a year forward");') };yearForwardButton.onmouseout=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","yearForwardButton");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("");') };yearForwardButton.onmousedown=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","yearForwardButtonDown");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Move a year forward");') };yearForwardButton.onmouseup=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","yearForwardButton");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Move a year forward");');eval(globalRef+".moveForwardOneYear();") };yearBackwardButton.onmouseover=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","yearBackwardButtonOver");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Move a year backward");') };yearBackwardButton.onmouseout=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","yearBackwardButton");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("");') };yearBackwardButton.onmousedown=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","yearBackwardButtonDown");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Move a year backward");') };yearBackwardButton.onmouseup=function(){ if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){ return }this.setAttribute("class","yearBackwardButton");var parentElement=this.parentNode;while(parentElement.className!="controlsBar"){ parentElement=parentElement.parentNode }var globalRef="gRef_"+parentElement.getAttribute("globalNumber");eval(globalRef+'.setTooltipText("Move a year backward");');eval(globalRef+".moveBackOneYear();") };return controlsBar };

oexam/cdtimer.js

function countDown() { sec--; if (sec == -01) { sec = 59; min = min - 1; if(min==-01) { min=59; hour=hour-1; }else { hour=hour; } } else { min = min; } if (sec<=9) { sec = "0" + sec; } time = (hour<=9 ? "0" + hour : hour) + " : " + (min<=9 ? "0" + min : min) + " : " + sec + ""; if (document.getElementById) { document.getElementById('timer').innerHTML = time; } SD=window.setTimeout("countDown();", 1000); if (hour=='00'&& min == '00' && sec == '00') { sec = "00";min="00"; window.clearTimeout(SD); window.location=document.forms[0].action+"?fs=yes";} } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(function() { countDown(); });

oexam/dbsettings.php

<?php $dbserver="localhost"; $dbusername="root"; $dbpassword="445344"; $dbname="oexam"; ?>

oexam/dean/dnwelcome.php

<?php error_reporting(0); session_start(); if(!isset($_SESSION['dname'])){ $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if(isset($_REQUEST['logout'])){ unset($_SESSION['dname']); $_GLOBALS['message']="Logged Out."; header('Location: index.php'); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Dean Home</title> <link rel="stylesheet" type="text/css" href="../oes.css"/> </head> <body> <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <div class="sidebar1"> <form name="dnwelcome" action="dnwelcome.php" method="post"> <?php if(isset($_SESSION['dname'])){ ?> <ul class="nav"> <li><input type="submit" value="Log Out" name="logout" class="linkbutn" title="CAREFUL !! Log Out"/></li> </ul> <?php } ?> </form> <aside> <p> Use this page to do dean administrative role. </p> </aside> <!-- end .sidebar1 --></div> <article class="content"> <section> <h1>Dean Home</h1> <p> <div id="content"> <?php if(isset($_SESSION['dname'])){ ?> <table class="hometable" cellspacing="0"> <tr> <td width="20"> <p title="Manage Users"> <a href="usermng.php"><img src="../images/manageusers.png" name="imags" height="120" width="200" /></a> </p> <p><a href="usermng.php">Manage Students</a></p></td> <td> <p title="Manage Examiners"> <a href="tcmng.php"><img src="../images/managexaminer.png" name="imags" height="120" width="200" /></a></p> <p><a href="tcmng.php">Manage Examiners</a></p></td> <td> <p title="Manage Subjects"> <a href="submng.php"><img src="../images/managesubjects.png" name="imags" height="120" width="200" /></a></p> <p><a href="tcmng.php">Manage Subjects</a></p></td> </tr> </table> <?php }?> </div> </p> </section> <!-- end .content --></article> <!-- end .container --></div> </body> </html>

oexam/dean/index.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if(isset($_REQUEST['dnsubmit'])) { $result=executeQuery("select * from dnlogin where dname='".htmlspecialchars($_REQUEST['name'],ENT_QUOTES)."' and dnpassword='".md5(htmlspecialchars($_REQUEST['password'],ENT_QUOTES))."'"); // $result=mysql_query("select * from dnlogin where dname='".htmlspecialchars($_REQUEST['name'])."' and dnpassword='".md5(htmlspecialchars($_REQUEST['password']))."'"); if(mysql_num_rows($result)>0) { $r=mysql_fetch_array($result); if(strcmp($r['dnpassword'],md5(htmlspecialchars($_REQUEST['password'],ENT_QUOTES)))==0) { $_SESSION['dname']=htmlspecialchars_decode($r['dname'],ENT_QUOTES); unset($_GLOBALS['message']); header('Location: dnwelcome.php'); }else { $_GLOBALS['message']="Check Your user name and Password."; } } else { $_GLOBALS['message']="Check Your user name and Password."; } closedb(); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Dean Log In </title> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <div class="sidebar1"> <ul class="nav"> <li><a href="../index.php" title="Click here to Register">Home</a></li> </ul> <aside> <p> This page allows you to login as the Dean. </p> </aside> <!-- end .sidebar1 --></div> <article class="content"> <section> <h1>Dean Login</h1> <p> <div id="content"> <table class="loginf"> <form id="indexform" action="index.php" method="post"> <tr> <td> Username </td> <td><input type="text" name="name" tabindex="1" value="" placeholder="Username" /></td> </tr> <tr> <td> Password </td><td><input type="password" name="password" value="" placeholder="Password" /></td> </tr> <tr> <td></td> <td><input type="submit" name="dnsubmit" value="Log In" /></td> </tr> </form> </table> </div> </p> </section> <!-- end .content --></article> <!-- end .container --></div> </body> </html>

oexam/dean/submng.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if (!isset($_SESSION['dname'])) { $_GLOBALS['message'] = "Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if (isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['dname']); header('Location: index.php'); } else if (isset($_REQUEST['dashboard'])) { //redirect to home header('Location: dnwelcome.php'); } else if (isset($_REQUEST['delete'])) { //delete selected subjects unset($_REQUEST['delete']); $hasvar = false; foreach ($_REQUEST as $variable) { if (is_numeric($variable)) { //some session values are also passed with request $hasvar = true; if (!@executeQuery("delete from subject where subid=$variable")) { if (mysql_errno () == 1451) //Children are dependent value $_GLOBALS['message'] = "System will not allow propagated deletions.<br/><b>Help:</b> If you still want to delete this subject, manually delete all the records that are dependent on it first."; else $_GLOBALS['message'] = mysql_errno(); } } } if (!isset($_GLOBALS['message']) && $hasvar == true) $_GLOBALS['message'] = "Selected subjects deleted"; else if (!$hasvar) { $_GLOBALS['message'] = "Select the subjects to delete."; } } else if (isset($_REQUEST['savem'])) { //updating the modified values if (empty($_REQUEST['subname']) || empty($_REQUEST['subdesc'])) { $_GLOBALS['message'] = "Some fields are empty.No updates made."; } else { $query = "update subject set subname='" . htmlspecialchars($_REQUEST['subname'], ENT_QUOTES) . "', subdesc='" . htmlspecialchars($_REQUEST['subdesc'], ENT_QUOTES) . "'where subid=" . $_REQUEST['subject'] . ";"; if (!@executeQuery($query)) $_GLOBALS['message'] = mysql_error(); else $_GLOBALS['message'] = "Subject information updated."; } closedb(); } else if (isset($_REQUEST['savea'])) { //Add the new subject information to db $result = executeQuery("select max(subid) as sub from subject"); $r = mysql_fetch_array($result); if (is_null($r['sub'])) $newstd = 1; else $newstd=$r['sub'] + 1; $result = executeQuery("select subname as sub from subject where subname='" . htmlspecialchars($_REQUEST['subname'], ENT_QUOTES) . "';"); // $_GLOBALS['message']=$newstd; if (empty($_REQUEST['subname']) || empty($_REQUEST['subdesc'])) { $_GLOBALS['message'] = "Some required fields are empty"; } else if (mysql_num_rows($result) > 0) { $_GLOBALS['message'] = "Subject already exists."; } else { $query = "insert into subject values($newstd,'" . htmlspecialchars($_REQUEST['subname'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['subdesc'], ENT_QUOTES) . "',NULL)"; if (!@executeQuery($query)) { if (mysql_errno () == 1062) //duplicate value $_GLOBALS['message'] = "The subject name voilates some constraints, try another name."; else $_GLOBALS['message'] = mysql_error(); } else $_GLOBALS['message'] = "Subject created."; } closedb(); } ?> <html> <head> <title>Manage subjects</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form name="submng" action="submng.php" method="post"> <?php if (isset($_SESSION['dname'])) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <!-- For default add or delete functions--> <li><input type="submit" value="Add New" name="add" title="Add new subjects"/></li> <!-- log out function--> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to do administrative work such subjects. </p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Manage subjects</h1> <p> <div id="content"> <?php if (isset($_SESSION['dname'])) { if (isset($_REQUEST['add'])) { ?> <!--Form for the new subject--> <table class="loginf" > <tr> <td>Subject Name</td> <td><input type="text" name="subname" value="" size="16" onKeyUp="isalphanum(this)" onBlur="if(this.value==''){alert('Subject Name is Empty');this.focus();this.value='';}"/></td> </tr> <tr> <td>Subject Description</td> <td><textarea name="subdesc" cols="20" rows="3" onBlur="if(this.value==''){alert('Subject Description is Empty');this.focus();this.value='';}"></textarea></td> </tr> <!--For Add option--> <?php if (isset($_REQUEST['add'])) { ?> <tr> <td> <input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savea" class="subbtn" onClick="validatesubform('submng')" title="Save"/></td> </tr> <?php } ?> </table> <?php } else if (isset($_REQUEST['edit'])) { //Edit existing subjects and their details. $result = executeQuery("select subid,subname,subdesc from subject where subname='" . htmlspecialchars($_REQUEST['edit'], ENT_QUOTES) . "';"); if (mysql_num_rows($result) == 0) { header('submng.php'); } else if ($r = mysql_fetch_array($result)) { //editing components ?> <table class="loginf"> <tr> <td>Subject Name</td> <td><input type="text" name="subname" value="<?php echo htmlspecialchars_decode($r['subname'], ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)"/></td> </tr> <tr> <td>Subject Description</td> <td><textarea name="subdesc" cols="20" rows="3"><?php echo htmlspecialchars_decode($r['subdesc'], ENT_QUOTES); ?></textarea><input type="hidden" name="subject" value="<?php echo $r['subid']; ?>"/></td> </tr> <!--For Edit option--> <?php } if (isset($_REQUEST['edit'])) { ?> <tr> <td><input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savem" class="subbtn" onClick="validatesubform('submng')" title="Save"/></td> </tr> </table> <?php closedb(); } } else { // Default : displays existing subjects. $result = executeQuery("select * from subject order by subid;"); if (mysql_num_rows($result) == 0) { echo "<h3 style=\"color:#0000cc;text-align:center;\">No Subjets Yet..!</h3>"; } else { $i = 0; ?> <table class="dashboards" cellspacing="10"> <tr> <th>&nbsp;</th> <th>Subject Name</th> <th>Subject Description</th> <th>Edit</th> </tr> <?php while ($r = mysql_fetch_array($result)) { $i = $i + 1; if ($i % 2 == 0) { echo "<tr class=\"alt\">"; } else { echo "<tr>"; } echo "<td style=\"text-align:center;\"><input type=\"checkbox\" name=\"d$i\" value=\"" . $r['subid'] . "\" /></td><td>" . htmlspecialchars_decode($r['subname'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['subdesc'], ENT_QUOTES) . "</td>" . "<td class=\"tddata\"><a title=\"Edit " . htmlspecialchars_decode($r['stdname'], ENT_QUOTES) . "\"href=\"submng.php?edit=" . htmlspecialchars_decode($r['subname'], ENT_QUOTES) . "\"><img src=\"../images/edit.png\" height=\"30\" width=\"40\" alt=\"Edit\" /></a></td></tr>"; } ?> </table> <?php } closedb(); } } ?> </div> </form> </div> </body> </html>

oexam/dean/tcmng.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if (!isset($_SESSION['dname'])) { $_GLOBALS['message'] = "Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if (isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['dname']); header('Location: index.php'); } else if (isset($_REQUEST['dashboard'])) { //redirect to home header('Location: dnwelcome.php'); } else if (isset($_REQUEST['delete'])) { //deleting the selected teachers records unset($_REQUEST['delete']); $hasvar = false; foreach ($_REQUEST as $variable) { if (is_numeric($variable)) { //some session values are also passed with request $hasvar = true; if (!@executeQuery("delete from testconductor where tcid=$variable")){ if (mysql_errno () == 1451) //Children are dependent value $_GLOBALS['message'] = "System will not allow cascading deleting.<br/><b>Help:</b> Delete all records that are associated with this user first."; else $_GLOBALS['message'] = mysql_errno(); } // $_GLOBALS['message']=$_GLOBALS['message'].$variable; } } if (!isset($_GLOBALS['message']) && $hasvar == true) $_GLOBALS['message'] = "Selected teacher/s records deleted"; else if (!$hasvar) { $_GLOBALS['message'] = "Select teacher/s records to delete."; } } else if (isset($_REQUEST['savem'])) { /* * ************************ Step 2 - Case 4 ************************ */ //updating the modified values if (empty($_REQUEST['cname']) || empty($_REQUEST['password']) || empty($_REQUEST['email'])) { $_GLOBALS['message'] = "Some fields are empty.No updates made."; } else { $query = "update testconductor set tcname='" . htmlspecialchars($_REQUEST['cname'],ENT_QUOTES) . "', tcpassword=ENCODE('" . htmlspecialchars($_REQUEST['password'],ENT_QUOTES) . "','oespass'),emailid='" . htmlspecialchars($_REQUEST['email'],ENT_QUOTES) . "',contactno='" . htmlspecialchars($_REQUEST['contactno'],ENT_QUOTES) . "',address='" .htmlspecialchars($_REQUEST['address'],ENT_QUOTES) . "',city='" . htmlspecialchars($_REQUEST['city'],ENT_QUOTES) . "',pincode='" . htmlspecialchars($_REQUEST['pin'],ENT_QUOTES) . "' where tcid='" . $_REQUEST['tc'] . "';"; if (!@executeQuery($query)) $_GLOBALS['message'] = mysql_error(); else $_GLOBALS['message'] = "Teacher information updated."; } closedb(); } else if (isset($_REQUEST['savea'])) { //Add the new test teacher information to the db $result = executeQuery("select max(tcid) as tc from testconductor"); $r = mysql_fetch_array($result); if (is_null($r['tc'])) $newstd = 1; else $newstd=$r['tc'] + 1; $result = executeQuery("select tcname as tc from testconductor where tcname='" . htmlspecialchars($_REQUEST['cname'],ENT_QUOTES) . "';"); if (empty($_REQUEST['cname']) || empty($_REQUEST['password']) || empty($_REQUEST['email'])) { $_GLOBALS['message'] = "Some required fields are empty"; } else if (mysql_num_rows($result) > 0) { $_GLOBALS['message'] = "User already exists."; } else { $query = "insert into testconductor values($newstd,'" . htmlspecialchars($_REQUEST['cname'],ENT_QUOTES) . "',ENCODE('" . htmlspecialchars($_REQUEST['password'],ENT_QUOTES) . "','oespass'),'" . htmlspecialchars($_REQUEST['email'],ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['contactno'],ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['address'],ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['city'],ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['pin'],ENT_QUOTES) . "')"; if (!@executeQuery($query)) { if(mysql_errno ()==1062) //duplicate value $_GLOBALS['message'] = "The teacher name voilates some constraints, try another name."; else $_GLOBALS['message'] = mysql_error(); } else $_GLOBALS['message'] = "Teacher record created."; } closedb(); } ?> <html> <head> <title>Manage Teachers</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form name="tcmng" action="tcmng.php" method="post"> <?php if (isset($_SESSION['dname'])) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <!-- For default add or delete functions--> <li><input type="submit" value="Add New" name="add" title="Add new Examiner"/></li> <li><input type="submit" value="Delete Selected" name="delete" title="Delete Selected records"/></li> <!-- log out function--> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to perform administrative duties on teachers data. You can edit teachers data where changes are required.</p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Manage Examiners</h1> <p> <div id="content"> <?php if (isset($_SESSION['dname'])) { if (isset($_REQUEST['add'])) { ?> <!--Form for the new teacher--> <table class="loginf" > <tr> <td>Username</td> <td><input type="text" name="cname" value="" size="16" onKeyUp="isalphanum(this)"/></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" value="" size="16" onKeyUp="isalphanum(this)" /></td> </tr> <tr> <td>Retype Password</td> <td><input type="password" name="repass" value="" size="16" onKeyUp="isalphanum(this)" /></td> </tr> <tr> <td>E mail</td> <td><input type="text" name="email" value="" size="16" /></td> </tr> <tr> <td>Phone No</td> <td><input type="number" pattern=".{9}" maxlength="12" required title="Enter enough digits" name="contactno" value="" size="16" onKeyUp="isnum(this)"/></td> </tr> <tr> <td>Address</td> <td><textarea name="address" cols="20" rows="3"></textarea></td> </tr> <tr> <td>Town</td> <td><input type="text" name="city" value="" size="16" onKeyUp="isalpha(this)"/></td> </tr> <tr> <td>PIN No</td> <td><input type="text" name="pin" value="" size="16" onKeyUp="isnum(this)" /></td> </tr> <!--For Add option--> <?php if (isset($_REQUEST['add'])) { ?> <tr> <td><input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savea" class="subbtn" onClick="validateform('usermng')" title="Save"/></td> </tr> <?php } ?> </table> <?php } else if (isset($_REQUEST['edit'])) { //Edit existing teacher information $result = executeQuery("select tcid,tcname,DECODE(tcpassword,'oespass') as tcpass ,emailid,contactno,address,city,pincode from testconductor where tcname='" . htmlspecialchars($_REQUEST['edit'],ENT_QUOTES) . "';"); if (mysql_num_rows($result) == 0) { header('Location: tcmng.php'); } else if ($r = mysql_fetch_array($result)) { //editing components ?> <!--Form to edit existing teachers--> <table class="loginf"> <tr> <td>Username</td> <td><input type="text" name="cname" value="<?php echo htmlspecialchars_decode($r['tcname'],ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)"/></td> </tr> <tr> <td>Password</td> <td><input type="text" name="password" value="<?php echo htmlspecialchars_decode($r['tcpass'],ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)" /></td> </tr> <tr> <td>E mail</td> <td><input type="text" name="email" value="<?php echo htmlspecialchars_decode($r['emailid'],ENT_QUOTES); ?>" size="16" /></td> </tr> <tr> <td>Phone No</td> <td><input type="text" name="contactno" value="<?php echo htmlspecialchars_decode($r['contactno'],ENT_QUOTES); ?>" size="16" onKeyUp="isnum(this)"/></td> </tr> <tr> <td>Address</td> <td><textarea name="address" cols="20" rows="3"><?php echo htmlspecialchars_decode($r['address'],ENT_QUOTES); ?></textarea></td> </tr> <tr> <td>Town</td> <td><input type="text" name="city" value="<?php echo htmlspecialchars_decode($r['city'],ENT_QUOTES); ?>" size="16" onKeyUp="isalpha(this)"/></td> </tr> <tr> <td>PIN Code</td> <td><input type="hidden" name="tc" value="<?php echo htmlspecialchars_decode($r['tcid'],ENT_QUOTES); ?>"/><input type="text" name="pin" value="<?php echo htmlspecialchars_decode($r['pincode'],ENT_QUOTES); ?>" size="16" onKeyUp="isnum(this)" /></td> </tr> <!--For Edit option--> <?php } else if (isset($_REQUEST['edit'])) { ?> <tr> <td><input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savem" class="subbtn" onClick="validateform('usermng')" title="Save"/></td> </tr> </table> <?php closedb(); } } else { // Default: displays the existing teachers. $result = executeQuery("select * from testconductor order by tcid;"); if (mysql_num_rows($result) == 0) { echo "<h3 style=\"color:#0000cc;text-align:center;\">No Test Conductors Yet..!</h3>"; } else { $i = 0; ?> <table class="dashboards" cellspacing="10"> <tr> <th>&nbsp;</th> <th>Teacher name</th> <th>Email-ID</th> <th>Contact Number</th> <th>Edit</th> </tr> <?php while ($r = mysql_fetch_array($result)) { $i = $i + 1; if ($i % 2 == 0) echo "<tr class=\"alt\">"; else echo "<tr>"; echo "<td style=\"text-align:center;\"><input type=\"checkbox\" name=\"d$i\" value=\"" . $r['tcid'] . "\" /></td><td>" . htmlspecialchars_decode($r['tcname'],ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['emailid'],ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['contactno'],ENT_QUOTES) . "</td>" . "<td class=\"tddata\"><a title=\"Edit " . htmlspecialchars_decode($r['tcname'],ENT_QUOTES) . "\"href=\"tcmng.php?edit=" . htmlspecialchars_decode($r['tcname'],ENT_QUOTES) . "\"><img src=\"../images/edit.png\" height=\"30\" width=\"40\" alt=\"Edit\" /></a></td></tr>"; } ?> </table> <?php } closedb(); } } ?> </div> </form> </div> </body> </html>

oexam/dean/usermng.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if (!isset($_SESSION['dname'])) { $_GLOBALS['message'] = "Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if (isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['dname']); header('Location: index.php'); } else if (isset($_REQUEST['dashboard'])) { //redirect to home header('Location: dnwelcome.php'); } else if (isset($_REQUEST['tcmng'])) { //redirect to home header('Location: tcmng.php'); } else if (isset($_REQUEST['delete'])) { //deleting the selected rows unset($_REQUEST['delete']); $hasvar = false; foreach ($_REQUEST as $variable) { if (is_numeric($variable)) { //some session values are also passed with request $hasvar = true; if (!@executeQuery("delete from student where stdid=$variable")) { if (mysql_errno () == 1451) //Children are dependent value $_GLOBALS['message'] = "System will not allow cascading deleting.<br/><b>Help:</b> If you still want to delete this user, manually delete all the records that are associated with this user first."; else $_GLOBALS['message'] = mysql_errno(); } } } if (!isset($_GLOBALS['message']) && $hasvar == true) $_GLOBALS['message'] = "Selected user/s deleted"; else if (!$hasvar) { $_GLOBALS['message'] = "First select the users to be deleted."; } } else if (isset($_REQUEST['savem'])) { //update modified values if (empty($_REQUEST['cname']) || empty($_REQUEST['password']) || empty($_REQUEST['email'])) { $_GLOBALS['message'] = "Some fields are empty.No updates made"; } else { $query = "update student set stdname='" . htmlspecialchars($_REQUEST['cname'], ENT_QUOTES) . "', stdpassword=ENCODE('" . htmlspecialchars($_REQUEST['password']) . "','oespass'),emailid='" . htmlspecialchars($_REQUEST['email'], ENT_QUOTES) . "',contactno='" . htmlspecialchars($_REQUEST['contactno'], ENT_QUOTES) . "',address='" . htmlspecialchars($_REQUEST['address'], ENT_QUOTES) . "',city='" . htmlspecialchars($_REQUEST['city'], ENT_QUOTES) . "',pincode='" . htmlspecialchars($_REQUEST['pin'], ENT_QUOTES) . "' where stdid='" . htmlspecialchars($_REQUEST['student'], ENT_QUOTES) . "';"; if (!@executeQuery($query)) $_GLOBALS['message'] = mysql_error(); else $_GLOBALS['message'] = "User information updated."; } closedb(); } else if (isset($_REQUEST['savea'])) { //Insert the user information in the database $result = executeQuery("select max(stdid) as std from student"); $r = mysql_fetch_array($result); if (is_null($r['std'])) $newstd = 1; else $newstd=$r['std'] + 1; $result = executeQuery("select stdname as std from student where stdname='" . htmlspecialchars($_REQUEST['cname'], ENT_QUOTES) . "';"); if (empty($_REQUEST['cname']) || empty($_REQUEST['password']) || empty($_REQUEST['email'])) { $_GLOBALS['message'] = "Some of the required Fields are Empty"; } else if (mysql_num_rows($result) > 0) { $_GLOBALS['message'] = "User already exists."; } else { $query = "insert into student values($newstd,'" . htmlspecialchars($_REQUEST['cname'], ENT_QUOTES) . "',ENCODE('" . htmlspecialchars($_REQUEST['password'], ENT_QUOTES) . "','oespass'),'" . htmlspecialchars($_REQUEST['email'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['contactno'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['address'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['city'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['pin'], ENT_QUOTES) . "')"; if (!@executeQuery($query)) { if (mysql_errno () == 1062) //duplicate value $_GLOBALS['message'] = "The username provided voilates some constraints, please try another username."; else $_GLOBALS['message'] = mysql_error(); } else $_GLOBALS['message'] = "New user created."; } closedb(); } ?> <html> <head> <title>Manage Students</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form name="usermng" action="usermng.php" method="post"> <?php if (isset($_SESSION['dname'])) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Dean Home" name="dashboard" title="Dean Home"/></li> <li><input type="submit" value="Examiners" name="tcmng" title="Manage Examiners"/></li> <!-- For default add or delete functions--> <!-- <li><input type="submit" value="Add New" name="add" title="Add new records"/></li> <li><input type="submit" value="Suspend Selected" name="delete" title="This suspends Selected records"/></li> --> <!-- log out function--> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to perform administrative duties on students data. You can suspend or lift suspension on student accounts. You can also view a specific student entire result history. </p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Manage Students</h1> <p> <div id="content"> <?php if (isset($_SESSION['dname'])) { if (isset($_REQUEST['add'])) { ?> <!--Form for the new student--> <!-- form removed --> <!--we want this form to return all the results of a student --> <?php } else if (isset($_REQUEST['edit'])) { //Edit existing student information $result = executeQuery("select stdid,stdname ,contactno,address,city,stdactive from student where stdname='" . htmlspecialchars($_REQUEST['edit'], ENT_QUOTES) . "';"); if (mysql_num_rows($result) == 0) { header('Location: usermng.php'); } else if ($r = mysql_fetch_array($result)) { //editing components ?> <!--Form to edit existing students--> <table class="loginf"> <tr> <td>Username</td> <td><input type="text" name="cname" value="<?php echo htmlspecialchars_decode($r['stdname'], ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)"/></td> </tr> <tr> <td>Phone No</td> <td><input type="text" name="contactno" value="<?php echo htmlspecialchars_decode($r['contactno'], ENT_QUOTES); ?>" size="16" onKeyUp="isnum(this)"/></td> </tr> <tr> <td>Address</td> <td><textarea name="address" cols="20" rows="3"><?php echo htmlspecialchars_decode($r['address'], ENT_QUOTES); ?></textarea></td> </tr> <tr> <td>Town</td> <td><input type="text" name="city" value="<?php echo htmlspecialchars_decode($r['city'], ENT_QUOTES); ?>" size="16" onKeyUp="isalpha(this)"/></td> </tr> <!--For Edit option--> <?php } if (isset($_REQUEST['edit'])) { ?> <tr> <td><input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savem" class="subbtn" onClick="validateform('usermng')" title="Save"/></td> </tr> </table> <?php closedb(); } } else { // Default: displays the existing students. $result = executeQuery("select stdname, pincode, stdactive from student order by stdid;"); if (mysql_num_rows($result) == 0) { echo "<h3 style=\"color:#0000cc;text-align:center;\">No existing students.</h3>"; } else { $i = 0; ?> <table class="dashboards" cellspacing="10"> <tr> <th>&nbsp;</th> <th>USERNAME</th> <th>REG No</th> <th>Active</th> <th>MORE..</th> <th>SUSPEND</th> </tr> <?php while ($r = mysql_fetch_array($result)) { $i = $i + 1; if ($i % 2 == 0) echo "<tr class=\"alt\">"; else echo "<tr>"; echo "<td style=\"text-align:center;\"><input type=\"checkbox\" name=\"d$i\" value=\"" . $r['stdid'] . "\" /></td><td>" . htmlspecialchars_decode($r['stdname'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['pincode'], ENT_QUOTES) . "</td>" . "</td><td>" . htmlspecialchars_decode($r['stdactive'], ENT_QUOTES) . "</td>" . "<td class=\"tddata\"><a title=\"More details on " . htmlspecialchars_decode($r['stdname'], ENT_QUOTES) . "\"href=\"usermng.php?edit=" . htmlspecialchars_decode($r['stdname'], ENT_QUOTES) . "\"><img src=\"../images/edit.png\" height=\"30\" width=\"40\" alt=\"Edit\" /></a></td> if($row['user_status']=='active') { echo "<td><a href='update_status.php?userid=$row[id]' class='btn btn-success'>".$row['user_status']."</a></td>"; }else{ echo "<td><a href='update_status.php?userid=$row[id]' class='btn btn-warning'>".$row['user_status']."</a></td>"; } </tr>"; } ?> </table> <?php } closedb(); } } ?> </div> </form> </div> </body> </html>

oexam/editprofile.php

<?php error_reporting(0); session_start(); include_once 'oesdb.php'; if(!isset($_SESSION['stdname'])) { $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if(isset($_REQUEST['logout'])) { //Log out and redirect index.php unset($_SESSION['stdname']); header('Location: index.php'); } else if(isset($_REQUEST['dashboard'])){ //redirect to home header('Location: stdwelcome.php'); }else if(isset($_REQUEST['savem'])) { //update changes if(empty($_REQUEST['cname'])||empty ($_REQUEST['password'])||empty ($_REQUEST['email'])) { $_GLOBALS['message']="Some Fields are Empty.No updates made"; } else { $query="update student set stdname='".htmlspecialchars($_REQUEST['cname'],ENT_QUOTES)."', stdpassword=ENCODE('".htmlspecialchars($_REQUEST['password'],ENT_QUOTES)."','oespass'),emailid='".htmlspecialchars($_REQUEST['email'],ENT_QUOTES)."',contactno='".htmlspecialchars($_REQUEST['contactno'],ENT_QUOTES)."',address='".htmlspecialchars($_REQUEST['address'],ENT_QUOTES)."',city='".htmlspecialchars($_REQUEST['city'],ENT_QUOTES)."',pincode='".htmlspecialchars($_REQUEST['pin'],ENT_QUOTES)."' where stdid='".$_REQUEST['student']."';"; if(!@executeQuery($query)) $_GLOBALS['message']=mysql_error(); else $_GLOBALS['message']="Changes saved."; } closedb(); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Profile</title> <link rel="stylesheet" type="text/css" href="oes.css"/> <script type="text/javascript" src="validate.js" ></script> </head> <body> <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <!-- put menu content here --> <div class="sidebar1"> <form id="editprofile" action="editprofile.php" method="post"> <?php if(isset($_SESSION['stdname'])) { ?> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" class="linkbutn" title="Home"/></li> <li><input type="submit" value="Log out" name="logout" class="linkbutn" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to edit your existing information. </p> </aside> <!-- end .sidebar1 --></div> <article class="content"> <section> <h1>Change Profile</h1> <p> <div id="content"> <?php // Display the saved information. $result=executeQuery("select stdid,stdname,DECODE(stdpassword,'oespass') as stdpass ,emailid,contactno,address,city,pincode from student where stdname='".$_SESSION['stdname']."';"); if(mysql_num_rows($result)==0) { header('Location: stdwelcome.php'); } else if($r=mysql_fetch_array($result)) { //editing fields ?> <table class="loginf"> <tr> <td>Username</td> <td><input type="text" name="cname" value="<?php echo htmlspecialchars_decode($r['stdname'],ENT_QUOTES); ?>" size="16" onkeyup="isalphanum(this)"/></td> </tr> <tr> <td>Password </td> <td><input type="password" name="password" value="<?php echo htmlspecialchars_decode($r['stdpass'],ENT_QUOTES); ?>" size="16" onkeyup="isalphanum(this)" /></td> </tr> <tr> <td>E mail</td> <td><input type="email" name="email" value="<?php echo htmlspecialchars_decode($r['emailid'],ENT_QUOTES); ?>" size="16" /></td> </tr> <tr> <td>Phone No</td> <td><input type="number" name="contactno" value="<?php echo htmlspecialchars_decode($r['contactno'],ENT_QUOTES); ?>" size="16" onkeyup="isnum(this)" pattern=".{10,12}" required title="Enter enough digits"/></td> </tr> <tr> <td>Address</td> <td><textarea name="address" cols="20" rows="3"><?php echo htmlspecialchars_decode($r['address'],ENT_QUOTES); ?></textarea></td> </tr> <tr> <td>Town</td> <td><input type="text" name="city" value="<?php echo htmlspecialchars_decode($r['city'],ENT_QUOTES); ?>" size="16" onkeyup="isalpha(this)"/></td> </tr> <tr> <td>REG No</td> <td><input type="hidden" name="student" value="<?php echo $r['stdid']; ?>"/><input type="text" name="pin" value="<?php echo htmlspecialchars_decode($r['pincode'],ENT_QUOTES); ?>" size="16" onkeyup="isnum(this)" /></td> </tr> <tr> <td> </td> <td><input type="submit" value="Save" name="savem" onclick="validateform('editprofile')" title="Save"/></td> </tr> </table> <?php closedb(); } } ?> </div> </form> </div> </div> </p> </section> <!-- end .content --></article> <!-- end .container --></div> </body> </html>

oexam/images/continue.png

oexam/images/correct.png

oexam/images/detail.png

oexam/images/edit.png

oexam/images/editprofile.png

oexam/images/examlogo.png

oexam/images/logout.png

oexam/images/manageexams.png

oexam/images/manageresults.png

oexam/images/managesubjects.png

oexam/images/manageusers.png

oexam/images/managexaminer.png

oexam/images/mngqn.png

oexam/images/practice.png

oexam/images/preparequest.png

oexam/images/results.png

oexam/images/starttest.png

oexam/images/taketest.png

oexam/images/wrong.png

oexam/index.php

0) { $r=mysql_fetch_array($result); if(strcmp(htmlspecialchars_decode($r['std'],ENT_QUOTES),(htmlspecialchars($_REQUEST['password'],ENT_QUOTES)))==0) { $_SESSION['stdname']=htmlspecialchars_decode($r['stdname'],ENT_QUOTES); $_SESSION['stdid']=$r['stdid']; unset($_GLOBALS['message']); header('Location: stdwelcome.php'); }else { $_GLOBALS['message']="Check Your user name and Password."; } } else { $_GLOBALS['message']="Check Your user name and Password."; } closedb(); } ?> [removed] ".$_GLOBALS['message'].""; } ?> Insert Logo Here

This page allows you to login as a student. It allows you to register as a student if you do not have an account.

Student Login

Username
Password
No account? Register here

oexam/oes.css

@charset "utf-8"; body { font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif; background-color: #D1D0CE; margin: 0; padding: 0; color: #000; } ul, ol, dl { padding: 0; margin: 0; } h1, h2, h3, h4, h5, h6, p { margin-top: 0; padding-right: 15px; padding-left: 15px; } a img { border: none; } a:link { color: #42413C; text-decoration: underline; } a:visited { color: #6E6C64; text-decoration: underline; } a:hover, a:active, a:focus { text-decoration: none; } .container { width: 1100px; background-color: #FFFFFF; margin: 0 auto; } header { background-color: #CCC49F; } .sidebar1 { float: left; width: 200px; background-color: #CCC49F; padding-bottom: 10px; } .content { padding: 10px 0; width: 850px; float: right; } #content .hometable { height:100px; text-align:center; font-size:16px; } #content .hometable td { width:50; height:50; } #content .dashboards { width:750px; height:50px; text-align:center; font-size:16px; } #content .loginf input[type=text]{ width:200px; height:30px; font-size:16px; } #content .loginf input[type=password]{ width:200px; height:30px; font-size:16px; } #content .loginf input[type=submit]{ width:200px; height:30px; font-size:16px; } #content .loginf [name=address]{ width:200px; height:60px; font-size:16px; } #content .loginf input[type=submit]:hover{ color:white; background:#03F; } #content .loginf input[type=reset]{ width:100px; height:30px; font-size:16px; } #content .loginf input[type=reset]:hover{ color:white; background:#F00; } #content .loginf a:hover { color:#FFF; background:#03F; } .content ul, .content ol { padding: 0 15px 15px 40px; } ul.nav { list-style: none; border-top: 1px solid #666; margin-bottom: 15px; } ul.nav li, input[type=submit] { border-bottom: 1px solid #666; font-size:16px; width: 200px; } ul.nav a, ul.nav a:visited, input[type=submit] { padding: 5px 5px 5px 15px; display: block; text-decoration: none; background-color: #CCC49F; text-align:left; font-size:16px; } ul.nav a:hover, ul.nav a:active, ul.nav a:focus, input[type=submit]:hover { background-color: #CCC49F; color: #FFF; font-size:20px; } header, section, aside, article, figure { display: block; } .message { width: 1100px; margin: 0 auto; background:#FFFF00; text-align:center; color:#ff0000; font-size:1.5em; padding:3px 0px 2px 0px; } aside { float: left; width: 200px; background-color: #CCC49F; padding: 10px 0; } .fltrt { float: right; margin-left: 8px; } .fltlft { float: left; margin-right: 8px; } .clearfloat { clear:both; height:0; font-size: 1px; line-height: 0px; } .logform { position: relative; background: #D1D0CE; max-width: 400px; margin: 0 auto 0px; padding: 20px; text-align: center; box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24); } .logform input { font-family: "Roboto", sans-serif; outline: 0; background: #ffffff; width: 100%; border: 0; margin: 0 0 15px; padding: 15px; box-sizing: border-box; font-size: 14px; } .logform button { font-family: "Roboto", sans-serif; text-transform: uppercase; outline: 0; background: #4CAF50; width: 100%; border: 0; padding: 15px; color: #FFFFFF; font-size: 14px; -webkit-transition: all 0.3 ease; transition: all 0.3 ease; cursor: pointer; } .logform button:hover,.form button:active,.form button:focus { background: #43A047; } .logform .message { margin: 15px 0 0; color: #b3b3b3; font-size: 12px; } .logform .message a { color: #4CAF50; text-decoration: none; } .logform .register-form { display: none; } .form button { font-family: "Roboto", sans-serif; text-transform: uppercase; outline: 0; background: #4CAF50; width: 100%; border: 0; padding: 15px; color: #FFFFFF; font-size: 14px; transition: all 0.3 ease; cursor: pointer; } .login-page { width: 360px; padding: 0 0 0 0; margin: auto; } .form { position: relative; background: #616D7E; max-width: 360px; margin: 0 auto 100px; padding: 20px; text-align: center; box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24); } .form input { font-family: "Roboto", sans-serif; outline: 0; background: #f2f2f2; width: 100%; border: 0; margin: 0 0 15px; padding: 15px; box-sizing: border-box; font-size: 14px; } .form button:hover,.form button:active,.form button:focus { background: #43A047; } .form .message { margin: 15px 0 0; color: #b3b3b3; font-size: 12px; } .form .message a { color: #4CAF50; text-decoration: none; } .form .register-form { display: none; }

oexam/oesdb.php

<?php include_once 'dbsettings.php'; $conn=false; function executeQuery($query) { global $conn,$dbserver,$dbname,$dbpassword,$dbusername; global $message; if (!($conn = @mysql_connect ($dbserver,$dbusername,$dbpassword))) $message="Cannot connect to server"; if (!@mysql_select_db ($dbname, $conn)) $message="Cannot select database"; $result=mysql_query($query,$conn); if(!$result) $message="Error while executing query.<br/>Mysql Error: ".mysql_error(); else return $result; } function closedb() { global $conn; if(!$conn) mysql_close($conn); } ?>

oexam/practicetest.php

<?php error_reporting(0); session_start(); include_once 'oesdb.php'; $final = false; if (!isset($_SESSION['stdname'])) { $_GLOBALS['message'] = "Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if (isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['stdname']); unset($_SESSION['stdid']); header('Location: index.php'); } else if (isset($_REQUEST['dashboard'])) { //redirect to home header('Location: stdwelcome.php'); } else if (isset($_REQUEST['next']) || isset($_REQUEST['fsum'])) { //Process first question if (isset($_REQUEST['markreview'])) { $_SESSION['q1status'] = 'review'; $_SESSION['q1stdans'] = $_REQUEST['answer']; } else { $_SESSION['q1status'] = 'answered'; $_SESSION['q1stdans'] = $_REQUEST['answer']; } $_SESSION['curqnid'] = 2; if (isset($_REQUEST['fsum'])) { $_REQUEST['summary'] = "summary"; } } else if (isset($_REQUEST['viewsummary']) || isset($_REQUEST['summary'])) { //Process Second question if (isset($_REQUEST['markreview'])) { $_SESSION['q2status'] = 'review'; $_SESSION['q2stdans'] = $_REQUEST['answer']; } else { $_SESSION['q2status'] = 'answered'; $_SESSION['q2stdans'] = $_REQUEST['answer']; } $_SESSION['curqnid'] = 0; } else if (!isset($_SESSION['starttime']) && !isset($_REQUEST['finalsubmit'])) { //firsttime entry $_SESSION['starttime'] = time(); $_SESSION['curqnid'] = 1; $_SESSION['q1status'] = "unanswered"; $_SESSION['q1stdans'] = "unanswered"; $_SESSION['q2status'] = "unanswered"; $_SESSION['q2stdans'] = "unanswered"; } else if (isset($_REQUEST['change'])) { //redirect to examiner $_SESSION['curqnid'] = substr($_REQUEST['change'], 7); // header('Location: practicetest.php'); } else if (isset($_REQUEST['previous'])) { if (isset($_REQUEST['markreview'])) { $_SESSION['q2status'] = 'review'; $_SESSION['q2stdans'] = $_REQUEST['answer']; } else { $_SESSION['q2status'] = 'answered'; $_SESSION['q2stdans'] = $_REQUEST['answer']; } $_SESSION['curqnid'] = 1; } else if (isset($_REQUEST['summary'])) { // nothing to do } else if (isset($_REQUEST['finalsubmit'])) { // nothing to do } else if (isset($_REQUEST['fs'])) { //Final Submission header('Location: practicetest.php?finalsubmit=yes'); } ?> <?php header("Cache-Control: no-cache, must-revalidate"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Practice Test</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="CACHE-CONTROL" content="NO-CACHE"/> <meta http-equiv="PRAGMA" content="NO-CACHE"/> <meta name="ROBOTS" content="NONE"/> <link rel="stylesheet" type="text/css" href="oes.css"/> <script type="text/javascript" src="validate.js" ></script> <script type="text/javascript" src="cdtimer.js" ></script> <script type="text/javascript" > <!-- <?php if (!isset($_REQUEST['finalsumbit']) && isset($_SESSION['starttime'])) { $elapsed = (time() - $_SESSION['starttime']); if (($elapsed / 60) < 2) { echo "var hour=00;"; if ($elapsed == 0) $elapsed = 1; echo "min=" . (int) (2 - ($elapsed / 60)) . ";"; if ($elapsed > 60) echo "sec=" . (60 - ($elapsed - 60)) . ";"; else echo "sec=" . (60 - $elapsed) . ";"; } else { echo "var hour=0;var min=0;sec=01;"; unset($_SESSION['starttime']); } } ?> --> </script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form id="practicetest" action="practicetest.php" method="post"> <?php if (isset($_SESSION['stdname'])) { if ($_REQUEST['finalsubmit']) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> </div> <?php } ?> <article class="content"> <section> <div id="content"> <?php if (isset($_REQUEST['summary']) || isset($_REQUEST['viewsummary'])) { $_SESSION['curqnid'] = 0; //summary ?> <table border="0" width="100%" class="ntab"> <tr> <th style="width:40%;"><h3><span id="timer" class="timerclass"></span></h3></th> </tr> </table> <table class="dashboards" cellspacing="10"> <tr> <th>Question No</th> <th>Status</th> <th>Change Your Answer</th> </tr> <tr> <td>1</td> <td <?php if (strcmp($_SESSION['q1status'], "review") == 0 || strcmp($_SESSION['q1status'], "unanswered") == 0) { echo "style=\"color:#ff0000;\""; } ?> > <?php echo $_SESSION['q1status']; ?></td> <td><?php echo "<input type=\"submit\" value=\"Change 1 \" name=\"change\" class=\"ssubbtn\" />"; ?></td> </tr> <tr> <td>2</td> <td <?php if (strcmp($_SESSION['q2status'], "review") == 0 || strcmp($_SESSION['q2status'], "unanswered") == 0) { echo "style=\"color:#ff0000;\""; } ?> > <?php echo $_SESSION['q2status']; ?></td> <td><?php echo "<input type=\"submit\" value=\"Change 2 \" name=\"change\" class=\"ssubbtn\" />"; ?></td> </tr> <tr> <td colspan="3" style="text-align:center;"><input type="submit" name="finalsubmit" value="Final Submit" class="subbtn"/></td> </tr> </table> <?php } else if (isset($_REQUEST['finalsubmit'])) { ?> <table class="loginf"> <tr> <td colspan="2"><h3 style="color:#0000cc;text-align:center;">Test Summary</h3></td> </tr> <tr> </tr> <tr> <td>Student Name</td> <td><?php echo $_SESSION['stdname']; ?></td> </tr> <tr> <td>Test</td> <td>Sample Test</td> </tr> <tr> <td>Subject</td> <td>General Knowledge</td> </tr> <tr> <td>Test Duration</td> <td>00:02:00</td> </tr> <tr> <td>Max. Marks</td> <td>2</td> </tr> <tr> <td>Obtained Marks</td> <td><?php $marks = 0; if (strcmp($_SESSION['q1stdans'], "Spain") == 0) $marks = $marks + 1; if (strcmp($_SESSION['q2stdans'], "DennisRitchie") == 0) $marks = $marks + 1; echo $marks; ?></td> </tr> <tr> <td>Percentage</td> <td><?php echo (($marks / 2) * 100) . " %"; ?></td> </tr> <tr> <td> </td> </tr> <tr> <td colspan="2"><h3 style="color:#0000cc;text-align:center;">Test Information in Detail</h3></td> </tr> <tr> </tr> </table> <table cellpadding="30" cellspacing="10" class="datatable"> <tr> <th>Q. No</th> <th>Question</th> <th>Correct Answer</th> <th>Your Answer</th> <th>Score</th> <th>&nbsp;</th> </tr> <tr> <td>1</td> <td>Who won the FIFA World-cup 2010 Championship?</td> <td>Spain</td> <td><?php echo $_SESSION['q1stdans']; ?></td> <?php if (strcmp($_SESSION['q1stdans'], "Spain") == 0) { echo "<td>1</td><td class=\"tddata\"><img src=\"images/correct.png\" title=\"Correct Answer\" height=\"30\" width=\"40\" alt=\"Correct Answer\" /></td>"; } else { echo "<td>0</td><td class=\"tddata\"><img src=\"images/wrong.png\" title=\"Wrong Answer\" height=\"30\" width=\"40\" alt=\"Wrong Answer\" /></td>"; } ?> </tr> <tr> <td>2</td> <td>Who is the creator of "C Programming Language"?</td> <td>Dennis Ritchie</td> <td><?php echo $_SESSION['q2stdans']; ?></td> <?php if (strcmp($_SESSION['q2stdans'], "DennisRitchie") == 0) { echo "<td>1</td><td class=\"tddata\"><img src=\"images/correct.png\" title=\"Correct Answer\" height=\"30\" width=\"40\" alt=\"Correct Answer\" /></td>"; } else { echo "<td>0</td><td class=\"tddata\"><img src=\"images/wrong.png\" title=\"Wrong Answer\" height=\"30\" width=\"40\" alt=\"Wrong Answer\" /></td>"; } ?> </tr> <?php unset($_SESSION['starttime']); unset($_SESSION['curqnid']); unset($_SESSION['q1status']); unset($_SESSION['q1stdans']); unset($_SESSION['q2status']); unset($_SESSION['q2stdans']); ?> </table> <?php }if ($_SESSION['curqnid'] == 2) { ?> <div class="tc"> <table border="0" width="100%" class="ntab"> <tr> <th style="width:40%;"><h3><span id="timer" class="timerclass"></span></h3></th> <th style="width:40%;"><h4 style="color: #af0a36;">Question No: 2 </h4></th> <th style="width:20%;"><h4 style="color: #af0a36;"><input type="checkbox" name="markreview" value="mark"> Mark for Review</input></h4></th> </tr> </table> <textarea cols="100" rows="8" name="question" readonly style="width:96.8%;text-align:left;margin-left:2%;margin-top:2px;font-size:120%;font-weight:bold;margin-bottom:0;color:#0000ff;padding:2px 2px 2px 2px;">Who is the creator of "C Programming Language"?</textarea> <table border="0" width="100%" class="ntab"> <tr><td>&nbsp;</td></tr> <tr><td >1. <input type="radio" name="answer" value="DennisRitchie" <?php if ((strcmp($_SESSION['q2status'], "review") == 0 || strcmp($_SESSION['q2status'], "answered") == 0) && strcmp($_SESSION['q2stdans'], "DennisRitchie") == 0) { echo "checked"; } ?>> Dennis Ritchie</input></td></tr> <tr><td >2. <input type="radio" name="answer" value="Bjarne" <?php if ((strcmp($_SESSION['q2status'], "review") == 0 || strcmp($_SESSION['q2status'], "answered") == 0) && strcmp($_SESSION['q2stdans'], "Bjarne") == 0) { echo "checked"; } ?>> Bjarne Stroustrup</input></td></tr> <tr><td >3. <input type="radio" name="answer" value="JamesGosling" <?php if ((strcmp($_SESSION['q2status'], "review") == 0 || strcmp($_SESSION['q2status'], "answered") == 0) && strcmp($_SESSION['q2stdans'], "JamesGosling") == 0) { echo "checked"; } ?>> James Gosling</input></td></tr> <tr><td >4. <input type="radio" name="answer" value="KenThompson" <?php if ((strcmp($_SESSION['q2status'], "review") == 0 || strcmp($_SESSION['q2status'], "answered") == 0) && strcmp($_SESSION['q2stdans'], "KenThompson") == 0) { echo "checked"; } ?>> Ken Thompson</input></td></tr> <tr><td>&nbsp;</td></tr> <tr> <th style="width:80%;"><h4><input type="submit" name="viewsummary" value="View Summary" class="subbtn"/></h4></th> <th style="width:12%;text-align:right;"><h4><input type="submit" name="previous" value="Previous" class="subbtn"/></h4></th> <th style="width:8%;text-align:right;"><h4><input type="submit" name="summary" value="Summary" class="subbtn" /></h4></th> </tr> </table> </div> <?php } else if ($_SESSION['curqnid'] == 1) { ?> <div class="tc"> <table border="0" width="100%" class="ntab"> <tr> <th style="width:40%;"><h3><span id="timer" class="timerclass"></span></h3></th> <th style="width:40%;"><h4 style="color: #af0a36;">Question No: 1 </h4></th> <th style="width:20%;"><h4 style="color: #af0a36;"><input type="checkbox" name="markreview" value="mark"> Mark for Review</input></h4></th> </tr> </table> <textarea cols="100" rows="8" name="question" readonly style="width:96.8%;text-align:left;margin-left:2%;margin-top:2px;font-size:120%;font-weight:bold;margin-bottom:0;color:#0000ff;padding:2px 2px 2px 2px;">Who won the FIFA World-cup 2010 Championship?</textarea> <table border="0" width="100%" class="ntab"> <tr><td>&nbsp;</td></tr> <tr><td >1. <input type="radio" name="answer" value="Spain" <?php if ((strcmp($_SESSION['q1status'], "review") == 0 || strcmp($_SESSION['q1status'], "answered") == 0) && strcmp($_SESSION['q1stdans'], "Spain") == 0) { echo "checked"; } ?>> Spain</input></td></tr> <tr><td >2. <input type="radio" name="answer" value="Netherlands" <?php if ((strcmp($_SESSION['q1status'], "review") == 0 || strcmp($_SESSION['q1status'], "answered") == 0) && strcmp($_SESSION['q1stdans'], "Netherlands") == 0) { echo "checked"; } ?>> Netherlands</input></td></tr> <tr><td >3. <input type="radio" name="answer" value="Germany" <?php if ((strcmp($_SESSION['q1status'], "review") == 0 || strcmp($_SESSION['q1status'], "answered") == 0) && strcmp($_SESSION['q1stdans'], "Germany") == 0) { echo "checked"; } ?>> Germany</input></td></tr> <tr><td >4. <input type="radio" name="answer" value="Uruguay" <?php if ((strcmp($_SESSION['q1status'], "review") == 0 || strcmp($_SESSION['q1status'], "answered") == 0) && strcmp($_SESSION['q1stdans'], "Uruguay") == 0) { echo "checked"; } ?>> Uruguay</input></td></tr> <tr><td>&nbsp;</td></tr> <tr> <th style="width:80%;"><h4><input type="submit" name="next" value="Next" class="subbtn"/></h4></th> <th style="width:8%;text-align:right;"><h4><input type="submit" name="fsum" value="Summary" class="subbtn" /></h4></th> </tr> </table> </div> <?php } closedb(); } ?> </div> </form> </div> </body> </html>

oexam/register.php

<?php error_reporting(0); session_start(); include_once 'oesdb.php'; if(isset($_REQUEST['stdsubmit'])) { //insert new user information in the database $result=executeQuery("select max(stdid) as std from student"); $r=mysql_fetch_array($result); if(is_null($r['std'])) $newstd=1; else $newstd=$r['std']+1; $result=executeQuery("select stdname as std from student where stdname='".htmlspecialchars($_REQUEST['cname'],ENT_QUOTES)."';"); // $_GLOBALS['message']=$newstd; if(empty($_REQUEST['cname'])||empty ($_REQUEST['password'])||empty ($_REQUEST['email'])) { $_GLOBALS['message']="Some of the required Fields are Empty"; }else if(mysql_num_rows($result)>0) { $_GLOBALS['message']="Sorry the User Name is Not Available Try with Some Other name."; } else { $query="insert into student values($newstd,'".htmlspecialchars($_REQUEST['cname'],ENT_QUOTES)."',ENCODE('".htmlspecialchars($_REQUEST['password'],ENT_QUOTES)."','oespass'),'".htmlspecialchars($_REQUEST['email'],ENT_QUOTES)."','".htmlspecialchars($_REQUEST['contactno'],ENT_QUOTES)."','".htmlspecialchars($_REQUEST['address'],ENT_QUOTES)."','".htmlspecialchars($_REQUEST['city'],ENT_QUOTES)."','".htmlspecialchars($_REQUEST['pin'],ENT_QUOTES)."')"; if(!@executeQuery($query)) $_GLOBALS['message']=mysql_error(); else { $success=true; $_GLOBALS['message']="Successfully Your Account is Created.Click <a href=\"index.php\">Here</a> to LogIn"; // header('Location: index.php'); } } closedb(); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Log In </title> <link rel="stylesheet" type="text/css" href="oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <div class="sidebar1"> <ul class="nav"> <li><a href="index.php" title="Go back home">Cancel</a></li> <?php if(!$success): ?> <?php endif; ?> </ul> <aside> <p> Use this page to register as new student. Enter all details. </p> </aside> <!-- end .sidebar1 --></div> <article class="content"> <section> <h1>Student Register</h1> <p> <div id="content"> <?php if($success) { echo "<h2 style=\"text-align:center;color:#0000ff;\">Thank You For Registering.<br/><a href=\"index.php\">Login Now</a></h2>"; } else { ?> <table class="loginf"> <form id="admloginform" action="register.php" method="post" onsubmit="return validateform('admloginform');"> <tr> <td>Username</td> <td><input type="text" name="cname" value="" onkeyup="isalphanum(this)"/></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" value="" onkeyup="isalphanum(this)" /></td> </tr> <tr> <td>Re-type Password</td> <td><input type="password" name="repass" value="" onkeyup="isalphanum(this)" /></td> </tr> <tr> <td>E mail</td> <td><input type="text" name="email" value="" /></td> </tr> <tr> <td>Phone No</td> <td><input type="text" name="contactno" value="" onkeyup="isnum(this)"/></td> </tr> <tr> <td>Address</td> <td><textarea name="address" cols="20" rows="3"></textarea></td> </tr> <tr> <td>Town</td> <td><input type="text" name="city" value="" onkeyup="isalpha(this)"/></td> </tr> <tr> <td>Reg No</td> <td><input type="text" name="pin" value="" onkeyup="isnum(this)" /></td> </tr> <tr> <td><input type="reset" name="reset" value="Reset" ></td> <td style="text-align:right;"><input type="submit" name="stdsubmit" value="Register"/></td> </tr> </form> </table> <?php } ?> </div> </p> </section> <!-- end .content --></article> <!-- end .container --></div> </body> </html>

oexam/sql/oexam.sql

-- phpMyAdmin SQL Dump -- version 3.5.2 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Oct 24, 2016 at 07:56 PM -- Server version: 5.5.25a -- PHP Version: 5.4.4 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `oexam` -- -- -------------------------------------------------------- -- -- Table structure for table `adminlogin` -- CREATE TABLE IF NOT EXISTS `adminlogin` ( `admname` varchar(32) NOT NULL, `admpassword` varchar(32) DEFAULT NULL, PRIMARY KEY (`admname`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `adminlogin` -- INSERT INTO `adminlogin` (`admname`, `admpassword`) VALUES ('myadmin', '1200918ab7a05045c0754b03f23b5dbd'), ('root', '63a9f0ea7bb98050796b649e85481845'); -- -------------------------------------------------------- -- -- Table structure for table `dnlogin` -- CREATE TABLE IF NOT EXISTS `dnlogin` ( `dname` varchar(32) NOT NULL, `dnpassword` varchar(32) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `dnlogin` -- INSERT INTO `dnlogin` (`dname`, `dnpassword`) VALUES ('dean', '48767461cb09465362c687ae0c44753b'); -- -------------------------------------------------------- -- -- Table structure for table `question` -- CREATE TABLE IF NOT EXISTS `question` ( `testid` bigint(20) NOT NULL DEFAULT '0', `qnid` int(11) NOT NULL DEFAULT '0', `question` varchar(500) DEFAULT NULL, `optiona` varchar(100) DEFAULT NULL, `optionb` varchar(100) DEFAULT NULL, `optionc` varchar(100) DEFAULT NULL, `optiond` varchar(100) DEFAULT NULL, `correctanswer` enum('optiona','optionb','optionc','optiond') DEFAULT NULL, `marks` int(11) DEFAULT NULL, PRIMARY KEY (`testid`,`qnid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `question` -- INSERT INTO `question` (`testid`, `qnid`, `question`, `optiona`, `optionb`, `optionc`, `optiond`, `correctanswer`, `marks`) VALUES (3, 1, '5 + 1', '6', '7', '51', '15', 'optiona', 1), (3, 2, '10+15', '1015', '25', '225', '51', 'optionb', 2), (3, 3, '8+2', '82', '11', '10', '28', 'optionc', 1), (3, 4, '152 + 856', '1528', '789', '910', '1008', 'optiond', 3), (3, 5, '70 + 30', '100', '703', '730', '37', 'optiona', 1), (4, 1, '8 * 10', '95', '80', '810', '108', 'optionb', 1), (4, 2, '5 * 5', '55', '255', '25', '52', 'optionc', 1), (4, 3, '7 * 7', '77', '70', '94', '49', 'optiond', 1), (5, 1, '2-1', '1', '2', '21', '-1', 'optiona', 1), (5, 2, '20-5', '205', '15', '25', '2005', 'optionb', 1), (6, 1, '10 / 2', '10', '5', '2', '10.2', 'optionb', 1), (6, 2, '100 / 10', '10', '1', '100', '100.10', 'optiona', 1), (7, 1, '1 * 5', '15', '5', '1.5', '4', 'optionb', 1), (7, 2, '5 - 4', '1', '4', '5', '54', 'optiona', 1), (9, 1, 'This is ___ car?', 'an', 'a', 'not', 'yes', 'optionb', 1), (9, 2, 'Find the cup ___ table?', 'on the', 'in the', 'with the', 'away from', 'optiona', 1), (9, 3, 'Calf is to cow?\r\nCub is to ___?', 'camel', 'Chicken', 'Cublet', 'lion', 'optiond', 1), (10, 1, 'what is c++', 'a new language', 'oop languange', 'a hardware', 'a laptop', 'optionb', 1), (10, 2, 'is c++ object oriented', 'no', 'no its a plain lanuage', 'yes', 'its a basic program', 'optionc', 1), (10, 3, 'what is C', 'a programmig language', 'second generation testing', 'a hardware', 'a form of typing', 'optiona', 1); -- -------------------------------------------------------- -- -- Table structure for table `student` -- CREATE TABLE IF NOT EXISTS `student` ( `stdid` bigint(20) NOT NULL, `stdname` varchar(40) DEFAULT NULL, `stdpassword` varchar(40) DEFAULT NULL, `emailid` varchar(40) DEFAULT NULL, `contactno` varchar(20) DEFAULT NULL, `address` varchar(40) DEFAULT NULL, `city` varchar(40) DEFAULT NULL, `pincode` varchar(20) DEFAULT NULL, `stdactive` varchar(20) NOT NULL, PRIMARY KEY (`stdid`), UNIQUE KEY `stdname` (`stdname`), UNIQUE KEY `emailid` (`emailid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `student` -- INSERT INTO `student` (`stdid`, `stdname`, `stdpassword`, `emailid`, `contactno`, `address`, `city`, `pincode`, `stdactive`) VALUES (1, 'jose', 'Úï�‚T?', '[email protected]', '713816887', '15734', 'Nakuru', '1234', ''); -- -------------------------------------------------------- -- -- Table structure for table `studentquestion` -- CREATE TABLE IF NOT EXISTS `studentquestion` ( `stdid` bigint(20) NOT NULL DEFAULT '0', `testid` bigint(20) NOT NULL DEFAULT '0', `qnid` int(11) NOT NULL DEFAULT '0', `answered` enum('answered','unanswered','review') DEFAULT NULL, `stdanswer` enum('optiona','optionb','optionc','optiond') DEFAULT NULL, PRIMARY KEY (`stdid`,`testid`,`qnid`), KEY `testid` (`testid`,`qnid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `studentquestion` -- INSERT INTO `studentquestion` (`stdid`, `testid`, `qnid`, `answered`, `stdanswer`) VALUES (1, 3, 1, 'answered', 'optiona'), (1, 3, 2, 'answered', 'optionb'), (1, 3, 3, 'answered', 'optionc'), (1, 3, 4, 'answered', 'optionc'), (1, 3, 5, 'answered', 'optiona'), (1, 5, 1, 'answered', 'optiona'), (1, 5, 2, 'answered', 'optionc'), (1, 6, 1, 'answered', 'optionb'), (1, 6, 2, 'answered', 'optiona'), (1, 7, 1, 'answered', 'optionb'), (1, 7, 2, 'answered', 'optionb'), (1, 9, 1, 'unanswered', NULL), (1, 9, 2, 'unanswered', NULL), (1, 9, 3, 'unanswered', NULL), (1, 10, 1, 'answered', 'optiond'), (1, 10, 2, 'answered', 'optiona'), (1, 10, 3, 'answered', 'optiona'); -- -------------------------------------------------------- -- -- Table structure for table `studenttest` -- CREATE TABLE IF NOT EXISTS `studenttest` ( `stdid` bigint(20) NOT NULL DEFAULT '0', `testid` bigint(20) NOT NULL DEFAULT '0', `starttime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `endtime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `correctlyanswered` int(11) DEFAULT NULL, `status` enum('over','inprogress') DEFAULT NULL, PRIMARY KEY (`stdid`,`testid`), KEY `testid` (`testid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `studenttest` -- INSERT INTO `studenttest` (`stdid`, `testid`, `starttime`, `endtime`, `correctlyanswered`, `status`) VALUES (1, 3, '2016-08-03 19:07:34', '2016-08-03 19:17:34', 0, 'over'), (1, 5, '2016-08-03 21:38:39', '2016-08-03 21:42:39', 0, 'over'), (1, 6, '2016-08-03 21:51:14', '2016-08-03 21:56:14', 0, 'over'), (1, 7, '2016-08-05 05:19:40', '2016-08-05 05:22:40', 0, 'over'), (1, 9, '2016-08-05 08:16:38', '2016-08-05 08:26:38', 0, 'over'), (1, 10, '2016-10-19 08:30:40', '2016-10-19 08:38:40', 0, 'over'); -- -------------------------------------------------------- -- -- Table structure for table `subject` -- CREATE TABLE IF NOT EXISTS `subject` ( `subid` int(11) NOT NULL, `subname` varchar(40) DEFAULT NULL, `subdesc` varchar(100) DEFAULT NULL, `tcid` bigint(20) DEFAULT NULL, PRIMARY KEY (`subid`), UNIQUE KEY `subname` (`subname`), KEY `subject_fk1` (`tcid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `subject` -- INSERT INTO `subject` (`subid`, `subname`, `subdesc`, `tcid`) VALUES (1, 'HTML', 'Tests on the basic uses of html 5.', NULL), (2, 'English', 'Tests basic english skills.', NULL), (3, 'swahili', 'tests on use of swahili', NULL), (4, 'maths', 'test basic maths', NULL); -- -------------------------------------------------------- -- -- Table structure for table `test` -- CREATE TABLE IF NOT EXISTS `test` ( `testid` bigint(20) NOT NULL, `testname` varchar(30) NOT NULL, `testdesc` varchar(100) DEFAULT NULL, `testdate` date DEFAULT NULL, `testtime` time DEFAULT NULL, `subid` int(11) DEFAULT NULL, `testfrom` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `testto` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `duration` int(11) DEFAULT NULL, `totalquestions` int(11) DEFAULT NULL, `attemptedstudents` bigint(20) DEFAULT NULL, `testcode` varchar(40) NOT NULL, `tcid` bigint(20) DEFAULT NULL, PRIMARY KEY (`testid`), UNIQUE KEY `testname` (`testname`), KEY `test_fk1` (`subid`), KEY `test_fk2` (`tcid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `test` -- INSERT INTO `test` (`testid`, `testname`, `testdesc`, `testdate`, `testtime`, `subid`, `testfrom`, `testto`, `duration`, `totalquestions`, `attemptedstudents`, `testcode`, `tcid`) VALUES (1, 'BasicHtml', 'Examine basic questions about html', '2016-08-03', '12:10:37', 1, '2016-08-03 08:10:36', '2016-08-03 20:59:59', 10, 5, 0, '.J', NULL), (2, 'cbvx', 'gfbvxvb', '2016-08-03', '12:42:30', 1, '2016-08-10 08:42:29', '2016-08-11 20:59:59', 8, 4, 0, '.»', NULL), (3, 'Addition', 'Test basic addition', '2016-08-03', '22:00:20', 4, '2016-08-03 18:00:19', '2016-08-03 20:59:59', 10, 5, 0, '.»Å', 4), (4, 'Multiplication', 'Tests on basic multlipication', '2016-08-03', '23:41:50', 4, '2016-08-03 19:41:49', '2016-08-03 20:59:59', 7, 3, 0, '.»Å�', 4), (5, 'Subtraction', 'test basic subtraction', '2016-08-04', '00:37:26', 4, '2016-08-04 20:37:25', '2016-08-04 20:59:59', 4, 2, 0, '.Jm', 4), (6, 'Division', 'Tests basic division.', '2016-08-04', '00:48:45', 4, '2016-08-04 20:48:44', '2016-08-04 20:59:59', 5, 2, 0, '›N', 4), (7, 'random', 'ask random maths questions', '2016-08-05', '08:16:45', 4, '2016-08-05 04:16:44', '2016-08-05 20:59:59', 3, 2, 0, '.', 4), (8, 'English', 'Tests basic English skills', '2016-08-05', '10:59:35', 2, '2016-08-05 06:59:34', '2016-08-05 20:59:59', 8, 3, 0, '.»Å', 4), (9, 'EnglishTest', 'Test basic english', '2016-08-05', '11:04:30', 2, '2016-08-05 07:04:29', '2016-08-05 20:59:59', 10, 3, 0, '.»Å', 4), (10, 'programming', 'prog test', '2016-10-19', '11:25:04', 1, '2016-10-19 07:25:03', '2016-10-19 20:59:59', 8, 3, 0, '.»Å', 4); -- -------------------------------------------------------- -- -- Table structure for table `testconductor` -- CREATE TABLE IF NOT EXISTS `testconductor` ( `tcid` bigint(20) NOT NULL, `tcname` varchar(40) DEFAULT NULL, `tcpassword` varchar(40) DEFAULT NULL, `emailid` varchar(40) DEFAULT NULL, `contactno` varchar(20) DEFAULT NULL, `address` varchar(40) DEFAULT NULL, `city` varchar(40) DEFAULT NULL, `pincode` varchar(20) DEFAULT NULL, PRIMARY KEY (`tcid`), UNIQUE KEY `stdname` (`tcname`), UNIQUE KEY `emailid` (`emailid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `testconductor` -- INSERT INTO `testconductor` (`tcid`, `tcname`, `tcpassword`, `emailid`, `contactno`, `address`, `city`, `pincode`) VALUES (3, 'testtwo', 'gnýbùjð', '[email protected]', '024586647', '585', 'Nak', '5452'), (4, 'myexamin', 'c��ˆxÜíW', 'myexamin', '254770589589', '57816', 'Nakuru', '201'), (5, 'randomexamin', ']Šö�©ÂÝ(zÀ›)', 'rando', '52', '1520', 'Nakuru', '125'); -- -- Constraints for dumped tables -- -- -- Constraints for table `question` -- ALTER TABLE `question` ADD CONSTRAINT `question_ibfk_1` FOREIGN KEY (`testid`) REFERENCES `test` (`testid`); -- -- Constraints for table `studentquestion` -- ALTER TABLE `studentquestion` ADD CONSTRAINT `studentquestion_ibfk_1` FOREIGN KEY (`stdid`) REFERENCES `student` (`stdid`), ADD CONSTRAINT `studentquestion_ibfk_2` FOREIGN KEY (`testid`, `qnid`) REFERENCES `question` (`testid`, `qnid`); -- -- Constraints for table `studenttest` -- ALTER TABLE `studenttest` ADD CONSTRAINT `studenttest_ibfk_1` FOREIGN KEY (`stdid`) REFERENCES `student` (`stdid`), ADD CONSTRAINT `studenttest_ibfk_2` FOREIGN KEY (`testid`) REFERENCES `test` (`testid`); -- -- Constraints for table `subject` -- ALTER TABLE `subject` ADD CONSTRAINT `subject_fk1` FOREIGN KEY (`tcid`) REFERENCES `testconductor` (`tcid`); -- -- Constraints for table `test` -- ALTER TABLE `test` ADD CONSTRAINT `test_fk1` FOREIGN KEY (`subid`) REFERENCES `subject` (`subid`), ADD CONSTRAINT `test_fk2` FOREIGN KEY (`tcid`) REFERENCES `testconductor` (`tcid`); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

oexam/stdtest.php

<?php error_reporting(0); session_start(); include_once 'oesdb.php'; if (!isset($_SESSION['stdname'])) { $_GLOBALS['message'] = "Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if (isset($_SESSION['starttime'])) { header('Location: testconducter.php'); } else if (isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['stdname']); header('Location: index.php'); } else if (isset($_REQUEST['dashboard'])) { //redirect to home header('Location: stdwelcome.php'); } else if (isset($_REQUEST['starttest'])) { //Prepare the parameters needed for the examiner and redirect to examiner if (!empty($_REQUEST['tc'])) { $result = executeQuery("select DECODE(testcode,'oespass') as tcode from test where testid=" . $_SESSION['testid'] . ";"); if ($r = mysql_fetch_array($result)) { if (strcmp(htmlspecialchars_decode($r['tcode'], ENT_QUOTES), htmlspecialchars($_REQUEST['tc'], ENT_QUOTES)) != 0) { $display = true; $_GLOBALS['message'] = "You have entered an Invalid Test Code.Try again."; } else { //now prepare parameters for Test Conducter and redirect to it. //first step: Insert the questions into table $result = executeQuery("select * from question where testid=" . $_SESSION['testid'] . " order by qnid;"); if (mysql_num_rows($result) == 0) { $_GLOBALS['message'] = "Tests questions cannot be selected.Please Try after some time!"; } else { // executeQuery("COMMIT"); $error = false; // executeQuery("delimiter |"); /* if (!executeQuery("create event " . $_SESSION['stdname'] . time() . " ON SCHEDULE AT (select endtime from studenttest where stdid=" . $_SESSION['stdid'] . " and testid=" . $_SESSION['testid'] . ") + INTERVAL (select duration from test where testid=" . $_SESSION['testid'] . ") MINUTE DO update studenttest set correctlyanswered=(select count(*) from studentquestion as sq,question as q where sq.qnid=q.qnid and sq.testid=q.testid and sq.answered='answered' and sq.stdanswer=q.correctanswer and sq.stdid=" . $_SESSION['stdid'] . " and sq.testid=" . $_SESSION['testid'] . "),status='over' where stdid=" . $_SESSION['stdid'] . " and testid=" . $_SESSION['testid'] . "|")) $_GLOBALS['message'] = "error" . mysql_error(); executeQuery("delimiter ;");*/ if (!executeQuery("insert into studenttest values(" . $_SESSION['stdid'] . "," . $_SESSION['testid'] . ",(select CURRENT_TIMESTAMP),date_add((select CURRENT_TIMESTAMP),INTERVAL (select duration from test where testid=" . $_SESSION['testid'] . ") MINUTE),0,'inprogress')")) $_GLOBALS['message'] = "error" . mysql_error(); else { while ($r = mysql_fetch_array($result)) { if (!executeQuery("insert into studentquestion values(" . $_SESSION['stdid'] . "," . $_SESSION['testid'] . "," . $r['qnid'] . ",'unanswered',NULL)")) { $_GLOBALS['message'] = "Failure while preparing questions for you.Try again"; $error = true; } } if ($error == true) { // executeQuery("rollback;"); } else { $result = executeQuery("select totalquestions,duration from test where testid=" . $_SESSION['testid'] . ";"); $r = mysql_fetch_array($result); $_SESSION['tqn'] = htmlspecialchars_decode($r['totalquestions'], ENT_QUOTES); $_SESSION['duration'] = htmlspecialchars_decode($r['duration'], ENT_QUOTES); $result = executeQuery("select DATE_FORMAT(starttime,'%Y-%m-%d %H:%i:%s') as startt,DATE_FORMAT(endtime,'%Y-%m-%d %H:%i:%s') as endt from studenttest where testid=" . $_SESSION['testid'] . " and stdid=" . $_SESSION['stdid'] . ";"); $r = mysql_fetch_array($result); $_SESSION['starttime'] = $r['startt']; $_SESSION['endtime'] = $r['endt']; $_SESSION['qn'] = 1; header('Location: testconducter.php'); } } } } } else { $display = true; $_GLOBALS['message'] = "You have entered an Invalid Test Code.Try again."; } } else { $display = true; $_GLOBALS['message'] = "Enter the Test Code First!"; } } else if (isset($_REQUEST['testcode'])) { //test code preparation if ($r = mysql_fetch_array($result = executeQuery("select testid from test where testname='" . htmlspecialchars($_REQUEST['testcode'], ENT_QUOTES) . "';"))) { $_SESSION['testname'] = $_REQUEST['testcode']; $_SESSION['testid'] = $r['testid']; } } else if (isset($_REQUEST['savem'])) { //updating the modified values if (empty($_REQUEST['cname']) || empty($_REQUEST['password']) || empty($_REQUEST['email'])) { $_GLOBALS['message'] = "Some of the required Fields are Empty.Therefore Nothing is Updated"; } else { $query = "update student set stdname='" . htmlspecialchars($_REQUEST['cname'], ENT_QUOTES) . "', stdpassword=ENCODE('" . htmlspecialchars($_REQUEST['password'], ENT_QUOTES) . "','oespass'),emailid='" . htmlspecialchars($_REQUEST['email'], ENT_QUOTES) . "',contactno='" . htmlspecialchars($_REQUEST['contactno'], ENT_QUOTES) . "',address='" . htmlspecialchars($_REQUEST['address'], ENT_QUOTES) . "',city='" . htmlspecialchars($_REQUEST['city'], ENT_QUOTES) . "',pincode='" . htmlspecialchars($_REQUEST['pin'], ENT_QUOTES) . "' where stdid='" . $_REQUEST['student'] . "';"; if (!@executeQuery($query)) $_GLOBALS['message'] = mysql_error(); else $_GLOBALS['message'] = "Profile updated."; } closedb(); } ?> <html> <head> <title>Available Tests</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="CACHE-CONTROL" content="NO-CACHE"/> <meta http-equiv="PRAGMA" content="NO-CACHE"/> <meta name="ROBOTS" content="NONE"/> <link rel="stylesheet" type="text/css" href="oes.css"/> <script type="text/javascript" src="validate.js" ></script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form id="stdtest" action="stdtest.php" method="post"> <?php if (isset($_SESSION['stdname'])) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to tests that available for you to take.</p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Available Tests</h1> <p> <div id="content"> <?php if (isset($_REQUEST['testcode'])) { echo "<div class=\"pmsg\" style=\"text-align:center;\">What is the Code of " . $_SESSION['testname'] . " ? </div>"; } else { echo "<div class=\"pmsg\" style=\"text-align:center;\">Offered Tests</div>"; } ?> <?php if (isset($_REQUEST['testcode']) || $display == true) { ?> <table class="loginf"> <tr> <td>Enter Test Code</td> <td><input type="text" tabindex="1" name="tc" value="" size="16" /></td> <td><div class="help"><b>Note:</b><br/>Once you press start test<br/>button timer will be started</div></td> </tr> <tr> <td colspan="3"> <input type="submit" tabindex="3" value="Start Test" name="starttest" class="subbtn" /> </td> </tr> </table> <?php } else { $result = executeQuery("select t.*,s.subname from test as t, subject as s where s.subid=t.subid and CURRENT_TIMESTAMP<t.testto and t.totalquestions=(select count(*) from question where testid=t.testid) and NOT EXISTS(select stdid,testid from studenttest where testid=t.testid and stdid=" . $_SESSION['stdid'] . ");"); if (mysql_num_rows($result) == 0) { echo"<h3 style=\"color:#0000cc;text-align:center;\">You have no available tests to take.</h3>"; } else { //editing components ?> <table class="dashboards" cellspacing="10"> <tr> <th>Test Name</th> <th>Test Description</th> <th>Subject Name</th> <th>Duration</th> <th>Total Questions</th> <th>Take Test</th> </tr> <?php while ($r = mysql_fetch_array($result)) { $i = $i + 1; if ($i % 2 == 0) { echo "<tr class=\"alt\">"; } else { echo "<tr>"; } echo "<td>" . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['testdesc'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['subname'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['duration'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['totalquestions'], ENT_QUOTES) . "</td>" . "<td class=\"tddata\"><a title=\"Start Test\" href=\"stdtest.php?testcode=" . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . "\"><img src=\"images/starttest.png\" height=\"30\" width=\"40\" alt=\"Start Test\" /></a></td></tr>"; } ?> </table> <?php } closedb(); } ?> </div> </form> </div> </body> </html>

oexam/stdwelcome.php

<?php error_reporting(0); session_start(); if(!isset($_SESSION['stdname'])){ $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if(isset($_REQUEST['logout'])){ unset($_SESSION['stdname']); $_GLOBALS['message']="You are Loggged Out Successfully."; header('Location: index.php'); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Student Home</title> <link rel="stylesheet" type="text/css" href="oes.css"/> </head> <body> <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <div class="sidebar1"> <form name="stdwelcome" action="stdwelcome.php" method="post"> <?php if(isset($_SESSION['stdname'])){ ?> <ul class="nav"> <li><input type="submit" value="Log Out" name="logout" class="linkbutn" title="CAREFUL !! Log Out"/></li> </ul> <?php } ?> </form> <aside> <p> Use this page to manage your profile, take mock exams, and mainly do your exams. </p> </aside> <!-- end .sidebar1 --></div> <article class="content"> <section> <h1>Student Home</h1> <p> <div id="content"> <?php if(isset($_SESSION['stdname'])){ ?> <table class="dashboards"> <tr> <td> <p title="Click to View Results"> <a href="viewresult.php"><img src="images/results.png" name="imags" height="120" width="200" /></a> </p> <p><a href="viewresult.php">View Results</a></p></td> <td> <p title="Click to View edit info"> <a href="editprofile.php"><img src="images/editprofile.png" name="imags" height="120" width="200" /></a></p> <p><a href="editprofile.php">Edit Profile</a></p></td> <td> <p title="Click to do exams"><strong> <a href="stdtest.php"><img src="images/taketest.png" name="imags" height="120" width="200" /></a></strong></p> <p><a href="stdtest.php">Take Exams</a></p></td> </tr> <tr> <td> <p title="Click to do a practice test"> <a href="practicetest.php"><img src="images/practice.png" name="imags" height="120" width="200" /></a> </p> <p ><a href="practicetest.php">Practice Test</a></p></td> <td> <p title="Click to do exams"><strong> <a href="stdtest.php"><img src="images/logout.png" name="imags" height="120" width="200" /></a></strong></p> <p><a href="stdtest.php">Log Out</a></p></td> <td> </td> </tr> </table> <?php }?> </div> </p> </section> <!-- end .content --></article> <!-- end .container --></div> </body> </html>

oexam/summary.php

<?php error_reporting(0); session_start(); include_once 'oesdb.php'; if(!isset($_SESSION['stdname'])) { $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if(isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['stdname']); header('Location: index.php'); } else if(isset($_REQUEST['dashboard'])){ //redirect to dashboard // header('Location: stdwelcome.php'); } else if(isset($_REQUEST['change'])) { //redirect to testconducter $_SESSION['qn']=substr($_REQUEST['change'],7); header('Location: testconducter.php'); } else if(isset($_REQUEST['finalsubmit'])){ //redirect to dashboard // header('Location: testack.php'); } else if(isset($_REQUEST['fs'])){ //redirect to dashboard // header('Location: testack.php'); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>OES-Summary</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="CACHE-CONTROL" content="NO-CACHE"/> <meta http-equiv="PRAGMA" content="NO-CACHE"/> <meta name="ROBOTS" content="NONE"/> <link rel="stylesheet" type="text/css" href="oes.css"/> <script type="text/javascript" src="validate.js" ></script> <script type="text/javascript" src="cdtimer.js" ></script> <script type="text/javascript" > <!-- <?php $elapsed=time()-strtotime($_SESSION['starttime']); if(((int)$elapsed/60)<(int)$_SESSION['duration']) { $result=executeQuery("select TIME_FORMAT(TIMEDIFF(endtime,CURRENT_TIMESTAMP),'%H') as hour,TIME_FORMAT(TIMEDIFF(endtime,CURRENT_TIMESTAMP),'%i') as min,TIME_FORMAT(TIMEDIFF(endtime,CURRENT_TIMESTAMP),'%s') as sec from studenttest where stdid=".$_SESSION['stdid']." and testid=".$_SESSION['testid'].";"); if($rslt=mysql_fetch_array($result)) { echo "var hour=".$rslt['hour'].";"; echo "var min=".$rslt['min'].";"; echo "var sec=".$rslt['sec'].";"; } else { $_GLOBALS['message']="Try Again"; } closedb(); } else { echo "var sec=01;var min=00;var hour=00;"; } ?> --> </script> </head> <body > <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form id="summary" action="summary.php" method="post"> <div class="menubar"> <?php if(isset($_SESSION['stdname'])) { // Navigations ?> </div> <div class="page"> <table border="0" width="100%" class="ntab"> <tr> <th style="width:40%;"><h3><span id="timer" class="timerclass"></span></h3></th> </tr> </table> <?php $result=executeQuery("select * from studentquestion where testid=".$_SESSION['testid']." and stdid=".$_SESSION['stdid']." order by qnid ;"); if(mysql_num_rows($result)==0) { echo"<h3 style=\"color:#0000cc;text-align:center;\">Please Try Again.</h3>"; } else { //editing components ?> <table cellpadding="30" cellspacing="10" class="datatable"> <tr> <th>Question No</th> <th>Status</th> <th>Change Your Answer</th> </tr> <?php while($r=mysql_fetch_array($result)) { $i=$i+1; if($i%2==0) { echo "<tr class=\"alt\">"; } else{ echo "<tr>";} echo "<td>".$r['qnid']."</td>"; if(strcmp(htmlspecialchars_decode($r['answered'],ENT_QUOTES),"unanswered")==0 ||strcmp(htmlspecialchars_decode($r['answered'],ENT_QUOTES),"review")==0) { echo "<td style=\"color:#ff0000\">".htmlspecialchars_decode($r['answered'],ENT_QUOTES)."</td>"; } else { echo "<td>".htmlspecialchars_decode($r['answered'],ENT_QUOTES)."</td>"; } echo"<td><input type=\"submit\" value=\"Change ".$r['qnid']."\" name=\"change\" class=\"ssubbtn\" /></td></tr>"; } ?> <tr> <td colspan="3" style="text-align:center;"><input type="submit" name="finalsubmit" value="Final Submit" class="subbtn"/></td> </tr> </table> <?php } closedb(); } ?> </div> </form> </div> </body> </html>

oexam/tc/editprofile.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if(!isset($_SESSION['tcname'])) { $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if(isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['tcname']); header('Location: index.php'); } else if(isset($_REQUEST['dashboard'])){ //redirect to home header('Location: tcwelcome.php'); }else if(isset($_REQUEST['savem'])) { //updating the modified values if(empty($_REQUEST['cname'])||empty ($_REQUEST['password'])||empty ($_REQUEST['email'])) { $_GLOBALS['message']="Some Fields are Empty.No updates made"; } else { $query="update testconductor set tcname='".htmlspecialchars($_REQUEST['cname'],ENT_QUOTES)."', tcpassword=ENCODE('".htmlspecialchars($_REQUEST['password'],ENT_QUOTES)."','oespass'),emailid='".htmlspecialchars($_REQUEST['email'],ENT_QUOTES)."',contactno='".htmlspecialchars($_REQUEST['contactno'],ENT_QUOTES)."',address='".htmlspecialchars($_REQUEST['address'],ENT_QUOTES)."',city='".htmlspecialchars($_REQUEST['city'],ENT_QUOTES)."',pincode='".htmlspecialchars($_REQUEST['pin'],ENT_QUOTES)."' where tcid='".$_REQUEST['tc']."';"; if(!@executeQuery($query)) $_GLOBALS['message']=mysql_error(); else $_GLOBALS['message']="Changes saved."; } closedb(); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Profile </title> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <!-- put menu content here --> <div class="sidebar1"> <form id="editprofile" action="editprofile.php" method="post"> <?php if(isset($_SESSION['tcname'])) { ?> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" class="linkbutn" title="Home"/></li> <li><input type="submit" value="Log out" name="logout" class="linkbutn" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to edit your existing information. </p> </aside> <!-- end .sidebar1 --></div> <article class="content"> <section> <h1>Change Profile</h1> <p> <div id="content"> <?php // Display the saved information. $result=executeQuery("select tcid,tcname,DECODE(tcpassword,'oespass') as tcpass ,emailid,contactno,address,city,pincode from testconductor where tcname='".$_SESSION['tcname']."';"); if(mysql_num_rows($result)==0) { header('Location: tcwelcome.php'); } else if($r=mysql_fetch_array($result)) { //editing fields ?> <table class="loginf"> <tr> <td>User Name</td> <td><input type="text" name="cname" value="<?php echo htmlspecialchars_decode($r['tcname'],ENT_QUOTES); ?>" size="16" onkeyup="isalphanum(this)"/></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" value="<?php echo htmlspecialchars_decode($r['tcpass'],ENT_QUOTES); ?>" size="16" onkeyup="isalphanum(this)" /></td> </tr> <tr> <td>E mail</td> <td><input type="mail" name="email" required title="enter a correct email format" value="<?php echo htmlspecialchars_decode($r['emailid'],ENT_QUOTES); ?>" size="16" /></td> </tr> <tr> <td>Phone No</td> <td><input type="text" name="contactno" value="<?php echo htmlspecialchars_decode($r['contactno'],ENT_QUOTES); ?>" size="16" onkeyup="isnum(this)" pattern=".{10,12}" required title="Enter enough digits" /></td> </tr> <tr> <td>Address</td> <td><textarea name="address" cols="20" rows="3"><?php echo htmlspecialchars_decode($r['address'],ENT_QUOTES); ?></textarea></td> </tr> <tr> <td>Town</td> <td><input type="text" name="city" value="<?php echo htmlspecialchars_decode($r['city'],ENT_QUOTES); ?>" size="16" onkeyup="isalpha(this)"/></td> </tr> <tr> <td>Examiner No</td> <td><input type="hidden" name="tc" value="<?php echo $r['tcid']; ?>"/><input type="text" name="pin" value="<?php echo htmlspecialchars_decode($r['pincode'],ENT_QUOTES); ?>" size="16" onkeyup="isnum(this)" /></td> </tr> <tr> <td> </td> <td> <input type="submit" value="Save" name="savem" onclick="validateform('editprofile')" title="Save"/></td> </tr> </table> <?php closedb(); } } ?> </div> </form> </div> </div> </p> </section> <!-- end .content --></article> <!-- end .container --></div> </body> </html>

oexam/tc/index.php

0) { $r=mysql_fetch_array($result); if(strcmp(htmlspecialchars_decode($r['tc'],ENT_QUOTES),(htmlspecialchars($_REQUEST['password'],ENT_QUOTES)))==0) { $_SESSION['tcname']=htmlspecialchars_decode($r['tcname'],ENT_QUOTES); $_SESSION['tcid']=$r['tcid']; unset($_GLOBALS['message']); header('Location: tcwelcome.php'); }else { $_GLOBALS['message']="Check Your user name and Password."; } } else { $_GLOBALS['message']="Check Your user name and Password."; } closedb(); } ?> [removed] ".$_GLOBALS['message'].""; } ?> Insert Logo Here

This page allows you to login as a teacher with an existing account.

Create a new account if you do not have one.

Examiner Login

Username
Password

oexam/tc/newaccount.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if(isset($_REQUEST['trsubmit'])) { //insert new user information in the database $result=executeQuery("select max(tcid) as trd from testconductor"); $r=mysql_fetch_array($result); if(is_null($r['trd'])) $newtrd=1; else $newtrd=$r['trd']+1; $result=executeQuery("select tcname as trd from testconductor where tcname='".htmlspecialchars($_REQUEST['cname'],ENT_QUOTES)."';"); // $_GLOBALS['message']=$newtrd; if(empty($_REQUEST['cname'])||empty ($_REQUEST['password'])||empty ($_REQUEST['email'])) { $_GLOBALS['message']="Some of the required Fields are Empty"; }else if(mysql_num_rows($result)>0) { $_GLOBALS['message']="Sorry the User Name is Not Available Try with Some Other name."; } else { $query="insert into testconductor values($newtrd,'".htmlspecialchars($_REQUEST['cname'],ENT_QUOTES)."',ENCODE('".htmlspecialchars($_REQUEST['password'],ENT_QUOTES)."','oespass'),'".htmlspecialchars($_REQUEST['email'],ENT_QUOTES)."','".htmlspecialchars($_REQUEST['contactno'],ENT_QUOTES)."','".htmlspecialchars($_REQUEST['address'],ENT_QUOTES)."','".htmlspecialchars($_REQUEST['city'],ENT_QUOTES)."','".htmlspecialchars($_REQUEST['pin'],ENT_QUOTES)."')"; if(!@executeQuery($query)) $_GLOBALS['message']=mysql_error(); else { $success=true; $_GLOBALS['message']="Successfully Your Account is Created.Click <a href=\"index.php\">Here</a> to Log In"; // header('Location: index.php'); } } closedb(); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Log In </title> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <div class="sidebar1"> <ul class="nav"> <li><a href="index.php" title="Go back home">Cancel</a></li> <?php if(!$success): ?> <?php endif; ?> </ul> <aside> <p> Use this page to create a new teacher account. Enter all details. </p> </aside> <!-- end .sidebar1 --></div> <article class="content"> <section> <h1>Teacher Register</h1> <p> <div id="content"> <?php if($success) { echo "<h2 style=\"text-align:center;color:#0000ff;\">Thank You For Registering.<br/><a href=\"index.php\">Login Now</a></h2>"; } else { ?> <table class="loginf"> <form id="admloginform" action="newaccount.php" method="post" onsubmit="return validateform('admloginform');"> <tr> <td>Username</td> <td><input type="text" name="cname" value="" onkeyup="isalphanum(this)"/></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" value="" onkeyup="isalphanum(this)" /></td> </tr> <tr> <td>Re-type Password</td> <td><input type="password" name="repass" value="" onkeyup="isalphanum(this)" /></td> </tr> <tr> <td>E mail</td> <td><input type="text" name="email" value="" /></td> </tr> <tr> <td>Phone No</td> <td><input type="text" name="contactno" value="" onkeyup="isnum(this)"/></td> </tr> <tr> <td>Address</td> <td><textarea name="address" cols="20" rows="3"></textarea></td> </tr> <tr> <td>Town</td> <td><input type="text" name="city" value="" onkeyup="isalpha(this)"/></td> </tr> <tr> <td>Teacher No</td> <td><input type="text" name="pin" value="" onkeyup="isnum(this)" /></td> </tr> <tr> <td><input type="reset" name="reset" value="Reset" ></td> <td style="text-align:right;"><input type="submit" name="trsubmit" value="Register"/></td> </tr> </form> </table> <?php } ?> </div> </p> </section> <!-- end .content --></article> <!-- end .container --></div> </body> </html>

oexam/tc/prepqn.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if (!isset($_SESSION['tcname']) || !isset($_SESSION['testqn'])) { $_GLOBALS['message'] = "Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if (isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['tcname']); header('Location: index.php'); } else if (isset($_REQUEST['managetests'])) { //redirect to Manage Tests Section header('Location: testmng.php'); } else if (isset($_REQUEST['delete'])) { //deleting the selected questions unset($_REQUEST['delete']); $hasvar = false; $count = 1; foreach ($_REQUEST as $variable) { if (is_numeric($variable)) { //some session values are also passed with request $hasvar = true; if (!@executeQuery("delete from question where testid=" . $_SESSION['testqn'] . " and qnid=$variable")) $_GLOBALS['message'] = mysql_error(); } } //reordering questions $result = executeQuery("select qnid from question where testid=" . $_SESSION['testqn'] . " order by qnid;"); while ($r = mysql_fetch_array($result)) if (!@executeQuery("update question set qnid=" . ($count++) . " where testid=" . $_SESSION['testqn'] . " and qnid=" . $r['qnid'] . ";")) $_GLOBALS['message'] = mysql_error(); // if (!isset($_GLOBALS['message']) && $hasvar == true) $_GLOBALS['message'] = "Selected questions deleted"; else if (!$hasvar) { $_GLOBALS['message'] = "First select questions to delete."; } } else if (isset($_REQUEST['savem'])) { //updating the modified values // $_GLOBALS['message']=$newstd; if (strcmp($_REQUEST['correctans'], "<Choose the Correct Answer>") == 0 || empty($_REQUEST['question']) || empty($_REQUEST['optiona']) || empty($_REQUEST['optionb']) || empty($_REQUEST['optionc']) || empty($_REQUEST['optiond']) || empty($_REQUEST['marks'])) { $_GLOBALS['message'] = "Some of the required Fields are Empty"; } else if (strcasecmp($_REQUEST['optiona'], $_REQUEST['optionb']) == 0 || strcasecmp($_REQUEST['optiona'], $_REQUEST['optionc']) == 0 || strcasecmp($_REQUEST['optiona'], $_REQUEST['optiond']) == 0 || strcasecmp($_REQUEST['optionb'], $_REQUEST['optionc']) == 0 || strcasecmp($_REQUEST['optionb'], $_REQUEST['optiond']) == 0 || strcasecmp($_REQUEST['optionc'], $_REQUEST['optiond']) == 0) { $_GLOBALS['message'] = "Two or more options are representing same answers.Verify Once again"; } else { $query = "update question set question='" . htmlspecialchars($_REQUEST['question'], ENT_QUOTES) . "',optiona='" . htmlspecialchars($_REQUEST['optiona'], ENT_QUOTES) . "',optionb='" . htmlspecialchars($_REQUEST['optionb'], ENT_QUOTES) . "',optionc='" . htmlspecialchars($_REQUEST['optionc'], ENT_QUOTES) . "',optiond='" . htmlspecialchars($_REQUEST['optiond'], ENT_QUOTES) . "',correctanswer='" . htmlspecialchars($_REQUEST['correctans'], ENT_QUOTES) . "',marks=" . htmlspecialchars($_REQUEST['marks'], ENT_QUOTES) . " where testid=" . $_SESSION['testqn'] . " and qnid=" . $_REQUEST['qnid'] . " ;"; if (!@executeQuery($query)) $_GLOBALS['message'] = mysql_error(); else $_GLOBALS['message'] = "Question updated."; } closedb(); } else if (isset($_REQUEST['savea'])) { //Add the new Question $cancel = false; $result = executeQuery("select max(qnid) as qn from question where testid=" . $_SESSION['testqn'] . ";"); $r = mysql_fetch_array($result); if (is_null($r['qn'])) $newstd = 1; else $newstd=$r['qn'] + 1; $result = executeQuery("select count(*) as q from question where testid=" . $_SESSION['testqn'] . ";"); $r2 = mysql_fetch_array($result); $result = executeQuery("select totalquestions from test where testid=" . $_SESSION['testqn'] . ";"); $r1 = mysql_fetch_array($result); if (!is_null($r2['q']) && (int) htmlspecialchars_decode($r1['totalquestions'], ENT_QUOTES) == (int) $r2['q']) { $cancel = true; $_GLOBALS['message'] = "Maximum questions already created for this Test.<br /><b>Help:</b> If you want to add some more questions then edit the test settings."; } else $cancel=false; $result = executeQuery("select * from question where testid=" . $_SESSION['testqn'] . " and question='" . htmlspecialchars($_REQUEST['question'], ENT_QUOTES) . "';"); if (!$cancel && $r1 = mysql_fetch_array($result)) { $cancel = true; $_GLOBALS['message'] = "You trying to enter same question for same test"; } else if (!$cancel) $cancel = false; // $_GLOBALS['message']=$newstd; if (strcmp($_REQUEST['correctans'], "<Choose the Correct Answer>") == 0 || empty($_REQUEST['question']) || empty($_REQUEST['optiona']) || empty($_REQUEST['optionb']) || empty($_REQUEST['optionc']) || empty($_REQUEST['optiond']) || empty($_REQUEST['marks'])) { $_GLOBALS['message'] = "Some fields are empty"; } else if (strcasecmp($_REQUEST['optiona'], $_REQUEST['optionb']) == 0 || strcasecmp($_REQUEST['optiona'], $_REQUEST['optionc']) == 0 || strcasecmp($_REQUEST['optiona'], $_REQUEST['optiond']) == 0 || strcasecmp($_REQUEST['optionb'], $_REQUEST['optionc']) == 0 || strcasecmp($_REQUEST['optionb'], $_REQUEST['optiond']) == 0 || strcasecmp($_REQUEST['optionc'], $_REQUEST['optiond']) == 0) { $_GLOBALS['message'] = "Two or more options are representing same answers.Verify Once again"; } else if (!$cancel) { $query = "insert into question values(" . $_SESSION['testqn'] . ",$newstd,'" . htmlspecialchars($_REQUEST['question'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['optiona'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['optionb'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['optionc'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['optiond'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['correctans'], ENT_QUOTES) . "'," . htmlspecialchars($_REQUEST['marks'], ENT_QUOTES) . ")"; if (!@executeQuery($query)) $_GLOBALS['message'] = mysql_error(); else $_GLOBALS['message'] = "New question is created."; } closedb(); } ?> <html> <head> <title>Manage Questions</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if ($_GLOBALS['message']) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form name="prepqn" action="prepqn.php" method="post"> <?php if (isset($_SESSION['tcname']) && isset($_SESSION['testqn'])) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Manage Tests" name="managetests" title="Manage Tests"/></li> <!-- For default add or delete functions--> <li><input type="submit" value="Add New" name="add" title="Add new questions"/></li> <li><input type="submit" value="Delete Selected" name="delete" title="Delete Selected records"/></li> <!-- log out function--> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to do add questions. </p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Prepare Questions</h1> <p> <div id="content"> <?php if (isset($_SESSION['tcname']) && isset($_SESSION['testqn'])) { if (isset($_REQUEST['add'])) { //Form for the new Question ?> <table cellpadding="20" cellspacing="20" style="text-align:left;" > <tr> <td>Question</td> <td><textarea name="question" cols="40" rows="3" ></textarea></td> </tr> <tr> <td>Option A</td> <td><input type="text" name="optiona" value="" size="30" /></td> </tr> <tr> <td>Option B</td> <td><input type="text" name="optionb" value="" size="30" /></td> </tr> <tr> <td>Option C</td> <td><input type="text" name="optionc" value="" size="30" /></td> </tr> <tr> <td>Option D</td> <td><input type="text" name="optiond" value="" size="30" /></td> </tr> <tr> <td>Correct Answer</td> <td> <select name="correctans"> <option value="<Choose the Correct Answer>" selected>&lt;Choose the Correct Answer&gt;</option> <option value="optiona">Option A</option> <option value="optionb">Option B</option> <option value="optionc">Option C</option> <option value="optiond">Option D</option> </select> </td> </tr> <tr> <td>Marks</td> <td><input type="text" name="marks" value="1" size="30" onKeyUp="isnum(this)" /></td> </tr> <!--For Add option--> <?php if (isset($_REQUEST['add'])) { ?> <tr> <td> <input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savea" class="subbtn" onClick="validateqnform('prepqn')" title="Save"/></td> </tr> <?php } ?> </table> <?php } else if (isset($_REQUEST['edit'])) { // To allow Editing Existing Question. $result = executeQuery("select * from question where testid=" . $_SESSION['testqn'] . " and qnid=" . $_REQUEST['edit'] . ";"); if (mysql_num_rows($result) == 0) { header('Location: prepqn.php'); } else if ($r = mysql_fetch_array($result)) { //editing components ?> <table class="loginf"> <tr> <td>Question<input type="hidden" name="qnid" value="<?php echo $r['qnid']; ?>" /></td> <td><textarea name="question" cols="40" rows="3" ><?php echo htmlspecialchars_decode($r['question'], ENT_QUOTES); ?></textarea></td> </tr> <tr> <td>Option A</td> <td><input type="text" name="optiona" value="<?php echo htmlspecialchars_decode($r['optiona'], ENT_QUOTES); ?>" size="30" /></td> </tr> <tr> <td>Option B</td> <td><input type="text" name="optionb" value="<?php echo htmlspecialchars_decode($r['optionb'], ENT_QUOTES); ?>" size="30" /></td> </tr> <tr> <td>Option C</td> <td><input type="text" name="optionc" value="<?php echo htmlspecialchars_decode($r['optionc'], ENT_QUOTES); ?>" size="30" /></td> </tr> <tr> <td>Option D</td> <td><input type="text" name="optiond" value="<?php echo htmlspecialchars_decode($r['optiond'], ENT_QUOTES); ?>" size="30" /></td> </tr> <tr> <td>Correct Answer</td> <td> <select name="correctans"> <option value="optiona" <?php if (strcmp(htmlspecialchars_decode($r['correctanswer'], ENT_QUOTES), "optiona") == 0) echo "selected"; ?>>Option A</option> <option value="optionb" <?php if (strcmp(htmlspecialchars_decode($r['correctanswer'], ENT_QUOTES), "optionb") == 0) echo "selected"; ?>>Option B</option> <option value="optionc" <?php if (strcmp(htmlspecialchars_decode($r['correctanswer'], ENT_QUOTES), "optionc") == 0) echo "selected"; ?>>Option C</option> <option value="optiond" <?php if (strcmp(htmlspecialchars_decode($r['correctanswer'], ENT_QUOTES), "optiond") == 0) echo "selected"; ?>>Option D</option> </select> </td> </tr> <tr> <td>Marks</td> <td><input type="text" name="marks" value="<?php echo htmlspecialchars_decode($r['marks'], ENT_QUOTES); ?>" size="30" onKeyUp="isnum(this)" /></td> </tr> <!--For Edit option--> <?php } if (isset($_REQUEST['edit'])) { ?> <tr> <td><input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savem" class="subbtn" onClick="validatesubform('prepqn')" title="Save"/></td> </tr> </table> <?php closedb(); } } else { // Default : displays existing questions. $result = executeQuery("select * from question where testid=" . $_SESSION['testqn'] . " order by qnid;"); if (mysql_num_rows($result) == 0) { echo "<h3 style=\"color:#0000cc;text-align:center;\">No questions.</h3>"; } else { $i = 0; ?> <table class="dashboards" cellspacing="10"> <tr> <th>&nbsp;</th> <th>Qn.No</th> <th>Question</th> <th>Correct Answer</th> <th>Marks</th> <th>Edit</th> </tr> <?php while ($r = mysql_fetch_array($result)) { $i = $i + 1; if ($i % 2 == 0) echo "<tr class=\"alt\">"; else echo "<tr>"; echo "<td style=\"text-align:center;\"><input type=\"checkbox\" name=\"d$i\" value=\"" . $r['qnid'] . "\" /></td><td> " . $i . "</td><td>" . htmlspecialchars_decode($r['question'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r[htmlspecialchars_decode($r['correctanswer'], ENT_QUOTES)], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['marks'], ENT_QUOTES) . "</td>" . "<td class=\"tddata\"><a title=\"Edit " . $r['qnid'] . "\"href=\"prepqn.php?edit=" . $r['qnid'] . "\"><img src=\"../images/edit.png\" height=\"30\" width=\"40\" alt=\"Edit\" /></a>" . "</td></tr>"; } ?> </table> <?php } closedb(); } } ?> </div> </form> </div> </body> </html>

oexam/tc/rsltmng.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if(!isset($_SESSION['tcname'])) { $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if(isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['tcname']); header('Location: index.php'); } else if(isset($_REQUEST['dashboard'])) { //redirect to home header('Location: tcwelcome.php'); } else if(isset($_REQUEST['back'])) { //redirect to Result Management Section header('Location: rsltmng.php'); } ?> <html> <head> <title>Manage Results</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form name="rsltmng" action="rsltmng.php" method="post"> <div class="sidebar1"> <ul class="nav"> <?php if(isset($_REQUEST['testid'])) { ?> <li><input type="submit" value="Back" name="back" class="subbtn" title="Manage Results"/></li> <?php }else { ?> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <?php if(isset($_SESSION['tcname'])) { ?> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> <?php } ?> </ul> <aside> <p> Use this page to perform administrative duties on results data.</p> </aside> <!-- end .sidebar1 --></div> <article class="content"> <section> <h1>Manage Results</h1> <p> <div id="content"> </div> <div class="page"> <?php if(isset($_REQUEST['testid'])) { /************************** Step 3 - Case 2 *************************/ // Displays the Existing Test Results in detail, If any. $result=executeQuery("select t.testname,DATE_FORMAT(t.testfrom,'%d %M %Y') as fromdate,DATE_FORMAT(t.testto,'%d %M %Y %H:%i:%S') as todate,sub.subname,IFNULL((select sum(marks) from question where testid=".$_REQUEST['testid']."),0) as maxmarks from test as t, subject as sub where sub.subid=t.subid and t.testid=".$_REQUEST['testid'].";") ; if(mysql_num_rows($result)!=0) { $r=mysql_fetch_array($result); ?> <table cellpadding="20" cellspacing="30" border="0" style="background:#ffffff url(../images/page.gif);text-align:left;line-height:20px;"> <tr> <td colspan="2"><h3 style="color:#0000cc;text-align:center;">Test Summary</h3></td> </tr> <tr> <td colspan="2" ><hr style="color:#ff0000;border-width:4px;"/></td> </tr> <tr> <td>Test Name</td> <td><?php echo htmlspecialchars_decode($r['testname'],ENT_QUOTES); ?></td> </tr> <tr> <td>Subject Name</td> <td><?php echo htmlspecialchars_decode($r['subname'],ENT_QUOTES); ?></td> </tr> <tr> <td>Validity</td> <td><?php echo $r['fromdate']." To ".$r['todate']; ?></td> </tr> <tr> <td>Max. Marks</td> <td><?php echo $r['maxmarks']; ?></td> </tr> <tr><td colspan="2"><hr style="color:#ff0000;border-width:2px;"/></td></tr> <tr> <td colspan="2"><h3 style="color:#0000cc;text-align:center;">Attempted Students</h3></td> </tr> <tr> <td colspan="2" ><hr style="color:#ff0000;border-width:4px;"/></td> </tr> </table> <?php $result1=executeQuery("select s.stdname,s.emailid,IFNULL((select sum(q.marks) from studentquestion as sq,question as q where q.qnid=sq.qnid and sq.testid=".$_REQUEST['testid']." and sq.stdid=st.stdid and sq.stdanswer=q.correctanswer),0) as om from studenttest as st, student as s where s.stdid=st.stdid and st.testid=".$_REQUEST['testid'].";" ); if(mysql_num_rows($result1)==0) { echo"<h3 style=\"color:#0000cc;text-align:center;\">No Students Yet Attempted this Test!</h3>"; } else { ?> <table class="dashboards" cellspacing="10"> <tr> <th>Student Name</th> <th>Email-ID</th> <th>Obtained Marks</th> <th>Result(%)</th> </tr> <?php while($r1=mysql_fetch_array($result1)) { ?> <tr> <td><?php echo htmlspecialchars_decode($r1['stdname'],ENT_QUOTES); ?></td> <td><?php echo htmlspecialchars_decode($r1['emailid'],ENT_QUOTES); ?></td> <td><?php echo $r1['om']; ?></td> <td><?php echo ($r1['om']/$r['maxmarks']*100)." %"; ?></td> </tr> <?php } } } else { echo"<h3 style=\"color:#0000cc;text-align:center;\">Something went wrong. Please logout and Try again.</h3>"; } ?> </table> <?php } else { // default Displays existing teste results. $result=executeQuery("select t.testid,t.testname,DATE_FORMAT(t.testfrom,'%d %M %Y') as fromdate,DATE_FORMAT(t.testto,'%d %M %Y %H:%i:%S') as todate,sub.subname,(select count(stdid) from studenttest where testid=t.testid) as attemptedstudents from test as t, subject as sub where sub.subid=t.subid and t.tcid=".$_SESSION['tcid'].";"); if(mysql_num_rows($result)==0) { echo "<h3 style=\"color:#0000cc;text-align:center;\">No Tests Results</h3>"; } else { $i=0; ?> <table class="dashboards" cellspacing="10"> <tr> <th>Test Name</th> <th>Validity</th> <th>Subject Name</th> <th>Attempted Students</th> <th>Details</th> </tr> <?php while($r=mysql_fetch_array($result)) { $i=$i+1; if($i%2==0) { echo "<tr class=\"alt\">"; } else { echo "<tr>";} echo "<td>".htmlspecialchars_decode($r['testname'],ENT_QUOTES)."</td><td>".$r['fromdate']." To ".$r['todate']." PM </td>" ."<td>".htmlspecialchars_decode($r['subname'],ENT_QUOTES)."</td><td>".$r['attemptedstudents']."</td>" ."<td class=\"tddata\"><a title=\"Details\" href=\"rsltmng.php?testid=".$r['testid']."\"><img src=\"../images/detail.png\" height=\"30\" width=\"40\" alt=\"Details\" /></a></td></tr>"; } ?> </table> <?php } } closedb(); } ?> </div> </form> </div> </body> </html>

oexam/tc/submng.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if (!isset($_SESSION['admname'])) { $_GLOBALS['message'] = "Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if (isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['admname']); header('Location: index.php'); } else if (isset($_REQUEST['dashboard'])) { //redirect to home header('Location: tcwelcome.php'); } else if (isset($_REQUEST['delete'])) { //deleting the selected Subjects unset($_REQUEST['delete']); $hasvar = false; foreach ($_REQUEST as $variable) { if (is_numeric($variable)) { //some session values are also passed with request $hasvar = true; if (!@executeQuery("delete from subject where subid=$variable")) { if (mysql_errno () == 1451) //Children are dependent value $_GLOBALS['message'] = "System will not allow propagated deletions.<br/><b>Help:</b> If you still want to delete this subject, manually delete all the records that are associated with this subject first."; else $_GLOBALS['message'] = mysql_errno(); } } } if (!isset($_GLOBALS['message']) && $hasvar == true) $_GLOBALS['message'] = "Selected subject/s deleted"; else if (!$hasvar) { $_GLOBALS['message'] = "First select the subject/s to delete."; } } else if (isset($_REQUEST['savem'])) { //update modified values if (empty($_REQUEST['subname']) || empty($_REQUEST['subdesc'])) { $_GLOBALS['message'] = "Some fields are empty.No updates made"; } else { $query = "update subject set subname='" . htmlspecialchars($_REQUEST['subname'], ENT_QUOTES) . "', subdesc='" . htmlspecialchars($_REQUEST['subdesc'], ENT_QUOTES) . "'where subid=" . $_REQUEST['subject'] . ";"; if (!@executeQuery($query)) $_GLOBALS['message'] = mysql_error(); else $_GLOBALS['message'] = "Subject information updated."; } closedb(); } else if (isset($_REQUEST['savea'])) { //Add the new subject information to db $result = executeQuery("select max(subid) as sub from subject"); $r = mysql_fetch_array($result); if (is_null($r['sub'])) $newstd = 1; else $newstd=$r['sub'] + 1; $result = executeQuery("select subname as sub from subject where subname='" . htmlspecialchars($_REQUEST['subname'], ENT_QUOTES) . "';"); // $_GLOBALS['message']=$newstd; if (empty($_REQUEST['subname']) || empty($_REQUEST['subdesc'])) { $_GLOBALS['message'] = "Some of the required Fields are Empty"; } else if (mysql_num_rows($result) > 0) { $_GLOBALS['message'] = "Subject already exists."; } else { $query = "insert into subject values($newstd,'" . htmlspecialchars($_REQUEST['subname'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['subdesc'], ENT_QUOTES) . "',NULL)"; if (!@executeQuery($query)) { if (mysql_errno () == 1062) //duplicate value $_GLOBALS['message'] = "The subject name provided voilates some constraints, please try another name."; else $_GLOBALS['message'] = mysql_error(); } else $_GLOBALS['message'] = "New subject created."; } closedb(); } ?> <html> <head> <title>Manage Subjects</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form name="submng" action="submng.php" method="post"> <?php if (isset($_SESSION['tcname'])) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <!-- For default add or delete functions--> <li><input type="submit" value="Add New" name="add" title="Add new records"/></li> <li><input type="submit" value="Delete Selected" name="delete" title="Delete Selected records"/></li> <!-- log out function--> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to perform administrative duties on subjects management. </p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Manage Subjects</h1> <p> <div id="content"> <?php if (isset($_SESSION['tcname'])) { if (isset($_REQUEST['add'])) { ?> <!--Form for the new student--> <table class="loginf"> <tr> <td>Subject Name</td> <td><input type="text" name="subname" value="" size="16" onKeyUp="isalphanum(this)" onBlur="if(this.value==''){alert('Subject Name is Empty');this.focus();this.value='';}"/></td> </tr> <tr> <td>Subject Description</td> <td><textarea name="subdesc" cols="20" rows="3" onBlur="if(this.value==''){alert('Subject Description is Empty');this.focus();this.value='';}"></textarea></td> </tr> <!--For Add option--> <?php if (isset($_REQUEST['add'])) { ?> <tr> <td> <input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savea" class="subbtn" onClick="validateform('submng')" title="Save"/></td> </tr> <?php } ?> </table> <?php } else if (isset($_REQUEST['edit'])) { //Edit existing Subject. $result = executeQuery("select subid,subname,subdesc from subject where subname='" . htmlspecialchars($_REQUEST['edit'], ENT_QUOTES) . "';"); if (mysql_num_rows($result) == 0) { header('submng.php'); } else if ($r = mysql_fetch_array($result)) { //editing components ?> <!--Form to edit existing subjects--> <table class="loginf"> <tr> <td>Subject Name</td> <td><input type="text" name="subname" value="<?php echo htmlspecialchars_decode($r['subname'], ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)"/></td> </tr> <tr> <td>Subject Description</td> <td><textarea name="subdesc" cols="20" rows="3"><?php echo htmlspecialchars_decode($r['subdesc'], ENT_QUOTES); ?></textarea><input type="hidden" name="subject" value="<?php echo $r['subid']; ?>"/></td> </tr> <!--For Edit option--> <?php } if (isset($_REQUEST['edit'])) { ?> <tr> <td><input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savem" class="subbtn" onClick="validateform('submng')" title="Save"/></td> </tr> </table> <?php closedb(); } } else { // Default : displays existing subjects. $result = executeQuery("select * from subject order by subid;"); if (mysql_num_rows($result) == 0) { echo "<h3 style=\"color:#0000cc;text-align:center;\">No Subjets Yet..!</h3>"; } else { $i = 0; ?> <table class="dashboards" cellspacing="10"> <tr> <th>&nbsp;</th> <th>Subject Name</th> <th>Subject Description</th> <th>Edit</th> </tr> <?php while ($r = mysql_fetch_array($result)) { $i = $i + 1; if ($i % 2 == 0) { echo "<tr class=\"alt\">"; } else { echo "<tr>"; } echo "<td style=\"text-align:center;\"><input type=\"checkbox\" name=\"d$i\" value=\"" . $r['subid'] . "\" /></td><td>" . htmlspecialchars_decode($r['subname'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['subdesc'], ENT_QUOTES) . "</td>" . "<td class=\"tddata\"><a title=\"Edit " . htmlspecialchars_decode($r['stdname'], ENT_QUOTES) . "\"href=\"submng.php?edit=" . htmlspecialchars_decode($r['subname'], ENT_QUOTES) . "\"><img src=\"../images/edit.png\" height=\"30\" width=\"40\" alt=\"Edit\" /></a></td></tr>"; } ?> </table> <?php } closedb(); } } ?> </div> </form> </div> </body> </html>

oexam/tc/tcwelcome.php

<?php error_reporting(0); session_start(); if(!isset($_SESSION['tcname'])){ $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if(isset($_REQUEST['logout'])){ unset($_SESSION['tcname']); $_GLOBALS['message']="Loggged Out."; header('Location: index.php'); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Examiner Home</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> </head> <body> <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <div class="sidebar1"> <form name="tcwelcome" action="tcwelcome.php" method="post"> <?php if(isset($_SESSION['tcname'])){ ?> <ul class="nav"> <li><input type="submit" value="Log Out" name="logout" class="linkbutn" title="CAREFUL !! Log Out"/></li> </ul> <?php } ?> </form> <aside> <p> Use this page to perform examiner related functions. </p> </aside> <!-- end .sidebar1 --></div> <article class="content"> <section> <h1>Examiner Home</h1> <p> <div id="content"> <?php if(isset($_SESSION['tcname'])){ ?> <table class="hometable" cellspacing="0"> <tr> <td> <p title="Manage Tests"> <a href="testmng.php"><img src="../images/manageexams.png" name="imags" height="120" width="200" /></a></p> <p><a href="testmng.php">Manage Tests</a></p></td> <td> <p title="Prepare Questions"> <a href="testmng.php?forpq=true"><img src="../images/preparequest.png" name="imags" height="120" width="200" /></a> </p> <p ><a href="testmng.php?forpq=true">Prepare Questions</a></p></td> <td> <p title="Manage Results"><strong> <a href="rsltmng.php"><img src="../images/manageresults.png" name="imags" height="120" width="200" /></a></strong></p> <p><a href="rsltmng.php">Manage Results</a></p></td> </tr> <tr> <td width="20"> <p title="Edit Profile"> <a href="editprofile.php"><img src="../images/manageusers.png" name="imags" height="120" width="200" /></a> </p> <p><a href="editprofile.php">Edit Profile</a></p></td> <td> </td> <td> </td> </tr> </table> <?php }?> </div> </p> </section> <!-- end .content --></article> <!-- end .container --></div> </body> </html>

oexam/tc/testmng.php

<?php error_reporting(0); session_start(); include_once '../oesdb.php'; if (!isset($_SESSION['tcname'])) { $_GLOBALS['message'] = "Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if (isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['tcname']); header('Location: index.php'); } else if (isset($_REQUEST['dashboard'])) { //redirect to dashboard header('Location: tcwelcome.php'); } else if (isset($_REQUEST['delete'])) { //deleting the selected tests unset($_REQUEST['delete']); $hasvar = false; foreach ($_REQUEST as $variable) { if (is_numeric($variable)) { //some session values are also passed with request $hasvar = true; if (!@executeQuery("delete from test where testid=$variable and tcid=" . $_SESSION['tcid'] . ";")) { if (mysql_errno () == 1451) //Children are dependent value $_GLOBALS['message'] = "System will not allow propagated deletions.<br/><b>Help:</b> If you still want to delete this test, manually delete all the records that are associated with this test first."; else $_GLOBALS['message'] = mysql_errno(); } } } if (!isset($_GLOBALS['message']) && $hasvar == true) $_GLOBALS['message'] = "Selected test/s deleted"; else if (!$hasvar) { $_GLOBALS['message'] = "First select the test/s to delete."; } } else if (isset($_REQUEST['savem'])) { //update modified values $fromtime = $_REQUEST['testfrom'] . " " . date("H:i"); $totime = $_REQUEST['testto'] . " 23:59"; $_GLOBALS['message'] = strtotime($totime) . " " . strtotime($fromtime) . " " . time(); if (strtotime($fromtime) > strtotime($totime) || strtotime($totime) < time()) $_GLOBALS['message'] = "Start date of test is less than end date or last date of test is less than today's date.<br/>Therefore Nothing is Updated"; else if (empty($_REQUEST['testname']) || empty($_REQUEST['testdesc']) || empty($_REQUEST['totalqn']) || empty($_REQUEST['duration']) || empty($_REQUEST['testfrom']) || empty($_REQUEST['testto']) || empty($_REQUEST['testcode'])) { $_GLOBALS['message'] = "Some fields are empty.No updates made"; } else { $query = "update test set testname='" . htmlspecialchars($_REQUEST['testname'], ENT_QUOTES) . "',testdesc='" . htmlspecialchars($_REQUEST['testdesc'], ENT_QUOTES) . "',subid=" . $_REQUEST['subject'] . ",testfrom='" . $fromtime . "',testto='" . $totime . "',duration=" . htmlspecialchars($_REQUEST['duration'], ENT_QUOTES) . ",totalquestions=" . htmlspecialchars($_REQUEST['totalqn'], ENT_QUOTES) . ",testcode=ENCODE('" . htmlspecialchars($_REQUEST['testcode'], ENT_QUOTES) . "','oespass') where testid=" . $_REQUEST['testid'] . " and tcid=" . $_SESSION['tcid'] . ";"; if (!@executeQuery($query)) $_GLOBALS['message'] = mysql_error(); else $_GLOBALS['message'] = "Test information updated."; } closedb(); } else if (isset($_REQUEST['savea'])) { //Add the new test information in the database $noerror = true; $fromtime = $_REQUEST['testfrom'] . " " . date("H:i"); $totime = $_REQUEST['testto'] . " 23:59"; if (strtotime($fromtime) > strtotime($totime) || strtotime($fromtime) < (time() - 3600)) { $noerror = false; $_GLOBALS['message'] = "Start date of test is either less than today's date or greater than last date of test."; } else if ((strtotime($totime) - strtotime($fromtime)) <= 3600 * 24) { $noerror = true; $_GLOBALS['message'] = "Note:<br/>The test is valid upto " . date(DATE_RFC850, strtotime($totime)); } //$_GLOBALS['message']="time".date_format($first, DATE_ATOM)."<br/>time ".date_format($second, DATE_ATOM); $result = executeQuery("select max(testid) as tst from test"); $r = mysql_fetch_array($result); if (is_null($r['tst'])) $newstd = 1; else $newstd=$r['tst'] + 1; // $_GLOBALS['message']=$newstd; if (strcmp($_REQUEST['subject'], "<Choose the Subject>") == 0 || empty($_REQUEST['testname']) || empty($_REQUEST['testdesc']) || empty($_REQUEST['totalqn']) || empty($_REQUEST['duration']) || empty($_REQUEST['testfrom']) || empty($_REQUEST['testto']) || empty($_REQUEST['testcode'])) { $_GLOBALS['message'] = "Some of the required Fields are Empty"; } else if ($noerror) { $query = "insert into test values($newstd,'" . htmlspecialchars($_REQUEST['testname'], ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['testdesc'], ENT_QUOTES) . "',(select curDate()),(select curTime())," . $_REQUEST['subject'] . ",'" . $fromtime . "','" . $totime . "'," . htmlspecialchars($_REQUEST['duration'], ENT_QUOTES) . "," . htmlspecialchars($_REQUEST['totalqn'], ENT_QUOTES) . ",0,ENCODE('" . htmlspecialchars($_REQUEST['testcode'], ENT_QUOTES) . "','oespass')," . $_SESSION['tcid'] . ")"; if (!@executeQuery($query)) { if (mysql_errno () == 1062) //duplicate value $_GLOBALS['message'] = "The test name violates some constraints, please try another name."; else $_GLOBALS['message'] = mysql_error(); } else $_GLOBALS['message'] = $_GLOBALS['message'] . "<br/>New test created."; } closedb(); } else if (isset($_REQUEST['manageqn'])) { //Store the Test identity in session varibles and redirect to prepare question section. //$tempa=explode(" ",$_REQUEST['testqn']); // $testname=substr($_REQUEST['manageqn'],0,-10); $testname = $_REQUEST['manageqn']; $result = executeQuery("select testid from test where testname='$testname' and tcid=" . $_SESSION['tcid'] . ";"); if ($r = mysql_fetch_array($result)) { $_SESSION['testname'] = $testname; $_SESSION['testqn'] = $r['testid']; // $_GLOBALS['message']=$_SESSION['testname']; header('Location: prepqn.php'); } } ?> <html> <head> <title>Manage Tests</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="../oes.css"/> <link rel="stylesheet" type="text/css" media="all" href="../calendar/jsDatePick.css" /> <script type="text/javascript" src="../calendar/jsDatePick.full.1.1.js"></script> <script type="text/javascript"> window.onload = function(){ new JsDatePick({ useMode:2, target:"testfrom" //limitToToday:true <-- Add this should you want to limit the calendar until today. }); new JsDatePick({ useMode:2, target:"testto" //limitToToday:true <-- Add this should you want to limit the calendar until today. }); }; </script> <script type="text/javascript" src="../validate.js" ></script> </head> <body> <?php if ($_GLOBALS['message']) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="../images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form name="testmng" action="testmng.php" method="post"> <?php if (isset($_SESSION['tcname'])) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <!-- For default add or delete functions--> <li><input type="submit" value="Add New" name="add" title="Add new test"/></li> <li><input type="submit" value="Delete Selected" name="delete" title="Delete Selected records"/></li> <!-- log out function--> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> Use this page to manage tests. </p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Manage Tests</h1> <p> <div id="content"> <?php if (isset($_SESSION['tcname'])) { if (isset($_REQUEST['add'])) { ?> <!--Form for the new subject--> <table class="loginf" > <tr> <td>Subject Name</td> <td> <select name="subject"> <option selected value="<Choose the Subject>">&lt;Choose the Subject&gt;</option> <?php $result = executeQuery("select subid,subname from subject;"); while ($r = mysql_fetch_array($result)) { echo "<option value=\"" . $r['subid'] . "\">" . htmlspecialchars_decode($r['subname'], ENT_QUOTES) . "</option>"; } closedb(); ?> </select> </td> </tr> <tr> <td>Test Name</td> <td><input type="text" name="testname" value="" size="16" onKeyUp="isalphanum(this)" /></td> <td><div class="help"><b>Note:</b><br/>Test Name must be Unique<br/> in order to identify different<br/> tests on same subject.</div></td> </tr> <tr> <td>Test Description</td> <td><textarea name="testdesc" cols="20" rows="3" ></textarea></td> <td><div class="help"><b>Describe here:</b><br/>What the test is all about?</div></td> </tr> <tr> <td>Total Questions</td> <td><input type="text" name="totalqn" value="" size="16" onKeyUp="isnum(this)" /></td> </tr> <tr> <td>Duration(Mins)</td> <td><input type="text" name="duration" value="" size="16" onKeyUp="isnum(this)" /></td> </tr> <tr> <td>Test From </td> <td><input id="testfrom" type="text" name="testfrom" value="" size="16" readonly /></td> </tr> <tr> <td>Test To </td> <td><input id="testto" type="text" name="testto" value="" size="16" readonly /></td> </tr> <tr> <td>Test Secret Code</td> <td><input type="text" name="testcode" value="" size="16" onKeyUp="isalphanum(this)" /></td> <td><div class="help"><b>Note:</b><br/>Candidates must enter<br/>this code in order to <br/> take the test</div></td> </tr> <!--For Add option--> <?php if (isset($_REQUEST['add'])) { ?> <tr> <td> <input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savea" class="subbtn" onClick="validatesubform('testmng')" title="Save"/></td> </tr> <?php } ?> </table> <?php } else if (isset($_REQUEST['edit'])) { // Edit existing subjects and their details $result = executeQuery("select t.totalquestions,t.duration,t.testid,t.testname,t.testdesc,t.subid,s.subname,DECODE(t.testcode,'oespass') as tcode,DATE_FORMAT(t.testfrom,'%Y-%m-%d') as testfrom,DATE_FORMAT(t.testto,'%Y-%m-%d') as testto from test as t,subject as s where t.subid=s.subid and t.testname='" . htmlspecialchars($_REQUEST['edit'], ENT_QUOTES) . "' and t.tcid=" . $_SESSION['tcid'] . ";"); if (mysql_num_rows($result) == 0) { header('Location: testmng.php'); } else if ($r = mysql_fetch_array($result)) { //editing components ?> <table class="loginf" > <tr> <td>Subject Name</td> <td> <select name="subject"> <?php $result = executeQuery("select subid,subname from subject where tcid=" . $_SESSION['tcid'] . ";"); while ($r1 = mysql_fetch_array($result)) { if (strcmp(htmlspecialchars_decode($r['subname'], ENT_QUOTES), htmlspecialchars_decode($r1['subname'], ENT_QUOTES)) == 0) echo "<option value=\"" . $r1['subid'] . "\" selected>" . htmlspecialchars_decode($r1['subname'], ENT_QUOTES) . "</option>"; else echo "<option value=\"" . $r1['subid'] . "\">" . htmlspecialchars_decode($r1['subname'], ENT_QUOTES) . "</option>"; } closedb(); ?> </select> </td> </tr> <tr> <td>Test Name</td> <td><input type="hidden" name="testid" value="<?php echo $r['testid']; ?>"/><input type="text" name="testname" value="<?php echo htmlspecialchars_decode($r['testname'], ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)" /></td> <td><div class="help"><b>Note:</b><br/>Test Name must be Unique<br/> in order to identify different<br/> tests on same subject.</div></td> </tr> <tr> <td>Test Description</td> <td><textarea name="testdesc" cols="20" rows="3" ><?php echo htmlspecialchars_decode($r['testdesc'], ENT_QUOTES); ?></textarea></td> <td><div class="help"><b>Describe here:</b><br/>What the test is all about?</div></td> </tr> <tr> <td>Total Questions</td> <td><input type="text" name="totalqn" value="<?php echo htmlspecialchars_decode($r['totalquestions'], ENT_QUOTES); ?>" size="16" onKeyUp="isnum(this)" /></td> </tr> <tr> <td>Duration(Mins)</td> <td><input type="text" name="duration" value="<?php echo htmlspecialchars_decode($r['duration'], ENT_QUOTES); ?>" size="16" onKeyUp="isnum(this)" /></td> </tr> <tr> <td>Test From </td> <td><input id="testfrom" type="text" name="testfrom" value="<?php echo $r['testfrom']; ?>" size="16" readonly /></td> </tr> <tr> <td>Test To </td> <td><input id="testto" type="text" name="testto" value="<?php echo $r['testto']; ?>" size="16" readonly /></td> </tr> <tr> <td>Test Secret Code</td> <td><input type="text" name="testcode" value="<?php echo htmlspecialchars_decode($r['tcode'], ENT_QUOTES); ?>" size="16" onKeyUp="isalphanum(this)" /></td> <td><div class="help"><b>Note:</b><br/>Candidates must enter<br/>this code in order to <br/> take the test</div></td> </tr> <!--For Edit option--> <?php } else if (isset($_REQUEST['edit'])) { ?> <tr> <td><input type="submit" value="Cancel" name="cancel" class="subbtn" title="Cancel"/></td> <td><input type="submit" value="Save" name="savem" class="subbtn" onClick="validatetestform('testmng')" title="Save the changes"/></td> </tr> </table> <?php closedb(); } } else { // Default: Displays the existing tests. $result = executeQuery("select t.testid,t.testname,t.testdesc,s.subname,DECODE(t.testcode,'oespass') as tcode,DATE_FORMAT(t.testfrom,'%d-%M-%Y') as testfrom,DATE_FORMAT(t.testto,'%d-%M-%Y %H:%i:%s %p') as testto from test as t,subject as s where t.subid=s.subid and t.tcid=" . $_SESSION['tcid'] . " order by t.testdate desc,t.testtime desc;"); if (mysql_num_rows($result) == 0) { echo "<h3 style=\"color:#0000cc;text-align:center;\">No Tests.</h3>"; } else { $i = 0; ?> <table class="dashboards" cellspacing="10"> <tr> <th>&nbsp;</th> <th>Test Description</th> <th>Subject Name</th> <th>Secret Code</th> <th>Validity</th> <th>Edit</th> <th style="text-align:center;">Manage<br/>Questions</th> </tr> <?php while ($r = mysql_fetch_array($result)) { $i = $i + 1; if ($i % 2 == 0) echo "<tr class=\"alt\">"; else echo "<tr>"; echo "<td style=\"text-align:center;\"><input type=\"checkbox\" name=\"d$i\" value=\"" . $r['testid'] . "\" /></td><td> " . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . " : " . htmlspecialchars_decode($r['testdesc'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['subname'], ENT_QUOTES) . "</td><td>" . htmlspecialchars_decode($r['tcode'], ENT_QUOTES) . "</td><td>" . $r['testfrom'] . " To " . $r['testto'] . "</td>" . "<td class=\"tddata\"><a title=\"Edit " . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . "\"href=\"testmng.php?edit=" . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . "\"><img src=\"../images/edit.png\" height=\"30\" width=\"40\" alt=\"Edit\" /></a></td>" . "<td class=\"tddata\"><a title=\"Manage Questions of " . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . "\"href=\"testmng.php?manageqn=" . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . "\"><img src=\"../images/mngqn.png\" height=\"30\" width=\"40\" alt=\"Manage Questions\" /></a></td></tr>"; } ?> </table> <?php } closedb(); } } ?> </div> </form> </div> </body> </html>

oexam/testack.php

<?php error_reporting(0); session_start(); include_once 'oesdb.php'; if(!isset($_SESSION['stdname'])) { $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if(isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['stdname']); header('Location: index.php'); } else if(isset($_REQUEST['dashboard'])){ //redirect to home header('Location: stdwelcome.php'); } if(isset($_SESSION['starttime'])) { unset($_SESSION['starttime']); unset($_SESSION['endtime']); unset($_SESSION['tqn']); unset($_SESSION['qn']); unset($_SESSION['duration']); executeQuery("update studenttest set status='over' where testid=".$_SESSION['testid']." and stdid=".$_SESSION['stdid'].";"); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Log In </title> <link rel="stylesheet" type="text/css" href="oes.css"/> <script type="text/javascript" src="validate.js" ></script> </head> <body> <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form id="editprofile" action="editprofile.php" method="post"> <div class="sidebar1"> <ul class="nav"> <?php if(isset($_SESSION['stdname'])) { ?> <li><input type="submit" value="Home" name="dashboard" class="subbtn" title="Home"/></li> <li><input type="submit" value="Log Out" name="logout" class="linkbutn" title="CAREFUL !! Log Out"/></li> </ul> <aside> <p> </p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <article class="content"> <section> <h1>Finished Test</h1> <p> <div id="content"> <h3 text-align:center;">Your answers are Successfully Submitted. To view the Results <b><a href="viewresult.php">Click Here</a></b> </h3> </div> </form> </div> </body> </html>

oexam/testconducter.php

<?php error_reporting(0); session_start(); include_once 'oesdb.php'; $final=false; if(!isset($_SESSION['stdname'])) { $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if(isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['stdname']); header('Location: index.php'); } else if(isset($_REQUEST['dashboard'])){ //redirect to home header('Location: stdwelcome.php'); }else if(isset($_REQUEST['next']) || isset($_REQUEST['summary']) || isset($_REQUEST['viewsummary'])) { //next question $answer='unanswered'; if(time()<strtotime($_SESSION['endtime'])) { if(isset($_REQUEST['markreview'])) { $answer='review'; } else if(isset($_REQUEST['answer'])) { $answer='answered'; } else { $answer='unanswered'; } if(strcmp($answer,"unanswered")!=0) { if(strcmp($answer,"answered")==0) { $query="update studentquestion set answered='answered',stdanswer='".htmlspecialchars($_REQUEST['answer'],ENT_QUOTES)."' where stdid=".$_SESSION['stdid']." and testid=".$_SESSION['testid']." and qnid=".$_SESSION['qn'].";"; } else { $query="update studentquestion set answered='review',stdanswer='".htmlspecialchars($_REQUEST['answer'],ENT_QUOTES)."' where stdid=".$_SESSION['stdid']." and testid=".$_SESSION['testid']." and qnid=".$_SESSION['qn'].";"; } if(!executeQuery($query)) { // to do $_GLOBALS['message']="Your previous answer is not updated.Please answer once again"; } closedb(); } if(isset($_REQUEST['viewsummary'])) { header('Location: summary.php'); } if(isset($_REQUEST['summary'])) { //summary page header('Location: summary.php'); } } if((int)$_SESSION['qn']<(int)$_SESSION['tqn']) { $_SESSION['qn']=$_SESSION['qn']+1; } if((int)$_SESSION['qn']==(int)$_SESSION['tqn']) { $final=true; } } else if(isset($_REQUEST['previous'])) { // Perform the changes for current question $answer='unanswered'; if(time()<strtotime($_SESSION['endtime'])) { if(isset($_REQUEST['markreview'])) { $answer='review'; } else if(isset($_REQUEST['answer'])) { $answer='answered'; } else { $answer='unanswered'; } if(strcmp($answer,"unanswered")!=0) { if(strcmp($answer,"answered")==0) { $query="update studentquestion set answered='answered',stdanswer='".htmlspecialchars($_REQUEST['answer'],ENT_QUOTES)."' where stdid=".$_SESSION['stdid']." and testid=".$_SESSION['testid']." and qnid=".$_SESSION['qn'].";"; } else { $query="update studentquestion set answered='review',stdanswer='".htmlspecialchars($_REQUEST['answer'],ENT_QUOTES)."' where stdid=".$_SESSION['stdid']." and testid=".$_SESSION['testid']." and qnid=".$_SESSION['qn'].";"; } if(!executeQuery($query)) { // to do $_GLOBALS['message']="Your previous answer is not updated.Please answer once again"; } closedb(); } } //previous question if((int)$_SESSION['qn']>1) { $_SESSION['qn']=$_SESSION['qn']-1; } } else if(isset($_REQUEST['fs'])) { //Final Submission header('Location: testack.php'); } ?> <?php header("Cache-Control: no-cache, must-revalidate"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Active Test</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="CACHE-CONTROL" content="NO-CACHE"/> <meta http-equiv="PRAGMA" content="NO-CACHE"/> <meta name="ROBOTS" content="NONE"/> <link rel="stylesheet" type="text/css" href="oes.css"/> <script type="text/javascript" src="validate.js" ></script> <script type="text/javascript" src="cdtimer.js" ></script> <script type="text/javascript" > <!-- <?php $elapsed=time()-strtotime($_SESSION['starttime']); if(((int)$elapsed/60)<(int)$_SESSION['duration']) { $result=executeQuery("select TIME_FORMAT(TIMEDIFF(endtime,CURRENT_TIMESTAMP),'%H') as hour,TIME_FORMAT(TIMEDIFF(endtime,CURRENT_TIMESTAMP),'%i') as min,TIME_FORMAT(TIMEDIFF(endtime,CURRENT_TIMESTAMP),'%s') as sec from studenttest where stdid=".$_SESSION['stdid']." and testid=".$_SESSION['testid'].";"); if($rslt=mysql_fetch_array($result)) { echo "var hour=".$rslt['hour'].";"; echo "var min=".$rslt['min'].";"; echo "var sec=".$rslt['sec'].";"; } else { $_GLOBALS['message']="Try Again"; } closedb(); } else { echo "var sec=01;var min=00;var hour=00;"; } ?> --> </script> </head> <body > <?php if($_GLOBALS['message']) { echo "<div class=\"message\">".$_GLOBALS['message']."</div>"; } ?> <div class="container"> <header> <a href="#"><img src="images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <article class="content"> <section> <div id="content"> <form id="testconducter" action="testconducter.php" method="post"> <div style="text-align:center;"> <h2 style="font-family:helvetica,sans-serif;font-weight:bolder;font-size:120%;color:#f50000;padding-top:0.3em;letter-spacing:1px;">Active Test Session</h2> </div> <div class="page"> <?php if(isset($_SESSION['stdname'])) { $result=executeQuery("select stdanswer,answered from studentquestion where stdid=".$_SESSION['stdid']." and testid=".$_SESSION['testid']." and qnid=".$_SESSION['qn'].";"); $r1=mysql_fetch_array($result); $result=executeQuery("select * from question where testid=".$_SESSION['testid']." and qnid=".$_SESSION['qn'].";"); $r=mysql_fetch_array($result); ?> <div class="tc"> <table border="0" width="100%" class="ntab"> <tr> <th style="width:40%;"><h3><span id="timer" class="timerclass"></span></h3></th> <th style="width:40%;"><h4 style="color: #af0a36;">Question No: <?php echo $_SESSION['qn']; ?> </h4></th> <th style="width:20%;"><h4 style="color: #af0a36;"><input type="checkbox" name="markreview" value="mark"> Mark for Review</input></h4></th> </tr> </table> <textarea cols="100" rows="8" name="question" readonly style="width:96.8%;text-align:left;margin-left:2%;margin-top:2px;font-size:120%;font-weight:bold;margin-bottom:0;color:#0000ff;padding:2px 2px 2px 2px;"><?php echo htmlspecialchars_decode($r['question'],ENT_QUOTES); ?></textarea> <table border="0" width="100%" class="ntab"> <tr><td>&nbsp;</td></tr> <tr><td >1. <input type="radio" name="answer" value="optiona" <?php if((strcmp(htmlspecialchars_decode($r1['answered'],ENT_QUOTES),"review")==0 ||strcmp(htmlspecialchars_decode($r1['answered'],ENT_QUOTES),"answered")==0)&& strcmp(htmlspecialchars_decode($r1['stdanswer'],ENT_QUOTES),"optiona")==0 ){echo "checked";} ?>> <?php echo htmlspecialchars_decode($r['optiona'],ENT_QUOTES); ?></input></td></tr> <tr><td >2. <input type="radio" name="answer" value="optionb" <?php if((strcmp(htmlspecialchars_decode($r1['answered'],ENT_QUOTES),"review")==0 ||strcmp(htmlspecialchars_decode($r1['answered'],ENT_QUOTES),"answered")==0)&& strcmp(htmlspecialchars_decode($r1['stdanswer'],ENT_QUOTES),"optionb")==0 ){echo "checked";} ?>> <?php echo htmlspecialchars_decode($r['optionb'],ENT_QUOTES); ?></input></td></tr> <tr><td >3. <input type="radio" name="answer" value="optionc" <?php if((strcmp(htmlspecialchars_decode($r1['answered'],ENT_QUOTES),"review")==0 ||strcmp(htmlspecialchars_decode($r1['answered'],ENT_QUOTES),"answered")==0)&& strcmp(htmlspecialchars_decode($r1['stdanswer'],ENT_QUOTES),"optionc")==0 ){echo "checked";} ?>> <?php echo htmlspecialchars_decode($r['optionc'],ENT_QUOTES); ?></input></td></tr> <tr><td >4. <input type="radio" name="answer" value="optiond" <?php if((strcmp(htmlspecialchars_decode($r1['answered'],ENT_QUOTES),"review")==0 ||strcmp(htmlspecialchars_decode($r1['answered'],ENT_QUOTES),"answered")==0)&& strcmp(htmlspecialchars_decode($r1['stdanswer'],ENT_QUOTES),"optiond")==0 ){echo "checked";} ?>> <?php echo htmlspecialchars_decode($r['optiond'],ENT_QUOTES); ?></input></td></tr> <tr><td>&nbsp;</td></tr> <tr> <th style="width:80%;"><h4><input type="submit" name="<?php if($final==true){ echo "viewsummary" ;}else{ echo "next";} ?>" value="<?php if($final==true){ echo "View Summary" ;}else{ echo "Next";} ?>" class="subbtn"/></h4></th> <th style="width:12%;text-align:right;"><h4><input type="submit" name="previous" value="Previous" class="subbtn"/></h4></th> <th style="width:8%;text-align:right;"><h4><input type="submit" name="summary" value="Summary" class="subbtn" /></h4></th> </tr> </table> </div> <?php closedb(); } ?> </div> </form> </div> </body> </html>

oexam/validate.js

function isalphanum(ele) { var r=/\W$/i; if(r.test(ele.value)) { alert("This Field allows alpha numeric characters only."); ele.value=""; ele.focus(); } } function isalpha(ele) { var r=/[^a-zA-Z]+/i; if(r.test(ele.value)) { alert("This Field allows alphabets only."); ele.value=""; ele.focus(); } } function isnum(ele) { var r=/\D$/i; if(r.test(ele.value)) { alert("This Field allows numbers only."); ele.value=""; ele.focus(); } } function validateform(mmyform) { var em=/[a-zA-Z0-9]+@[a-zA-Z0-9]+.[a-zA-Z]+/; myform=document.forms[mmyform]; if(myform.cname.value=="" || myform.password.value=="" || myform.repass.value=="" || myform.email.value=="" || myform.contactno.value=="" || myform.address.value=="" || myform.city.value=="" || myform.pin.value=="") { alert("Some of the fields are Empty."); return false; // myform.onsubmit=false; } else if(myform.password.value!=myform.repass.value) { alert("Passwords Dont Match!"); // myform.onsubmit=false; return false; } else if(!em.test(myform.email.value)) { alert("Enter the E-mail Correctly!"); // myform.onsubmit=false; return false; } } function validatesubform(mmyform) { myform=document.forms[mmyform]; if(myform.subname.value=="" || myform.subdesc.value=="") { alert("Some of the fields are Empty."); myform.onSubmit=false; } } function validatetestform(mmyform) { /* myform=document.forms[mmyform]; if(myform.subname.value=="" || myform.subdesc.value=="") { alert("Some of the fields are Empty."); myform.onSubmit=false; } */ }

oexam/viewresult.php

<?php error_reporting(0); session_start(); include_once 'oesdb.php'; if(!isset($_SESSION['stdname'])) { $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Log In</a>"; } else if(isset($_REQUEST['logout'])) { //Log out and redirect login page unset($_SESSION['stdname']); header('Location: index.php'); } else if(isset($_REQUEST['back'])) { //redirect to View Result header('Location: viewresult.php'); } else if(isset($_REQUEST['dashboard'])) { //redirect to dashboard header('Location: stdwelcome.php'); } ?> <html> <head> <title>View Results</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="CACHE-CONTROL" content="NO-CACHE"/> <meta http-equiv="PRAGMA" content="NO-CACHE"/> <meta name="ROBOTS" content="NONE"/> <link rel="stylesheet" type="text/css" href="oes.css"/> <script type="text/javascript" src="validate.js" ></script> </head> <body> <?php if (isset($_GLOBALS['message'])) { echo "<div class=\"message\">" . $_GLOBALS['message'] . "</div>"; } ?> <div class="container"> <header> <a href="#"><img src="images/examlogo.png" alt="Insert Logo Here" width="200" height="90" id="Insert_logo" style="background-color: #FFFFFF; display:block;" /></a> </header> <form id="summary" action="viewresult.php" method="post"> <?php if (isset($_SESSION['stdname'])) { if(isset($_REQUEST['details'])) { ?> <div class="sidebar1"> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <li><input type="submit" value="Back" name="delete" title="View Results"/></li> <!-- log out function--> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <?php } else { ?> <ul class="nav"> <li><input type="submit" value="Home" name="dashboard" title="Home"/></li> <li><input type="submit" value="Log out" name="logout" title="CAREFUL !! Log Out"/></li> </ul> <?php } ?> <aside> <p> Use this page to view your previous tests results summary. </p> </aside> <!-- end .sidebar1 --></div> <?php } ?> <div id="content"> <?php if(isset($_REQUEST['details'])) { $result=executeQuery("select s.stdname,t.testname,sub.subname,DATE_FORMAT(st.starttime,'%d %M %Y %H:%i:%s') as stime,TIMEDIFF(st.endtime,st.starttime) as dur,(select sum(marks) from question where testid=".$_REQUEST['details'].") as tm,IFNULL((select sum(q.marks) from studentquestion as sq, question as q where sq.testid=q.testid and sq.qnid=q.qnid and sq.answered='answered' and sq.stdanswer=q.correctanswer and sq.stdid=".$_SESSION['stdid']." and sq.testid=".$_REQUEST['details']."),0) as om from student as s,test as t, subject as sub,studenttest as st where s.stdid=st.stdid and st.testid=t.testid and t.subid=sub.subid and st.stdid=".$_SESSION['stdid']." and st.testid=".$_REQUEST['details'].";") ; if(mysql_num_rows($result)!=0) { $r=mysql_fetch_array($result); ?> <table class="dashboards"> <tr> <td colspan="2"><h3 style="color:#0000cc;text-align:center;">Test Summary</h3></td> </tr> <tr> <td colspan="2" ><hr style="color:#ff0000;border-width:4px;"/></td> </tr> <tr> <td>Student Name</td> <td><?php echo htmlspecialchars_decode($r['stdname'],ENT_QUOTES); ?></td> </tr> <tr> <td>Test</td> <td><?php echo htmlspecialchars_decode($r['testname'],ENT_QUOTES); ?></td> </tr> <tr> <td>Subject</td> <td><?php echo htmlspecialchars_decode($r['subname'],ENT_QUOTES); ?></td> </tr> <tr> <td>Date and Time</td> <td><?php echo $r['stime']; ?></td> </tr> <tr> <td>Test Duration</td> <td><?php echo $r['dur']; ?></td> </tr> <tr> <td>Max. Marks</td> <td><?php echo $r['tm']; ?></td> </tr> <tr> <td>Obtained Marks</td> <td><?php echo $r['om']; ?></td> </tr> <tr> <td>Percentage</td> <td><?php echo (($r['om']/$r['tm'])*100)." %"; ?></td> </tr> <tr> <td colspan="2" ><hr style="color:#ff0000;border-width:2px;"/></td> </tr> <tr> <td colspan="2"><h3 style="color:#0000cc;text-align:center;">Test information details</h3></td> </tr> <tr> <td colspan="2" ><hr style="color:#ff0000;border-width:4px;"/></td> </tr> </table> <?php $result1=executeQuery("select q.qnid as questionid,q.question as quest,q.correctanswer as ca,sq.answered as status,sq.stdanswer as sa from studentquestion as sq,question as q where q.qnid=sq.qnid and sq.testid=q.testid and sq.testid=".$_REQUEST['details']." and sq.stdid=".$_SESSION['stdid']." order by q.qnid;" ); if(mysql_num_rows($result1)==0) { echo"<h3 style=\"color:#0000cc;text-align:center;\">1.Some individual questions cannot be displayed.</h3>"; } else { ?> <table class="dashboards" cellspacing="10"> <tr> <th>Q. No</th> <th>Question</th> <th>Correct Answer</th> <th>Your Answer</th> <th>Score</th> <th>&nbsp;</th> </tr> <?php while($r1=mysql_fetch_array($result1)) { if(is_null($r1['sa'])) $r1['sa']="question"; //any valid field of question $result2=executeQuery("select ".$r1['ca']." as corans,IF('".$r1['status']."'='answered',(select ".$r1['sa']." from question where qnid=".$r1['questionid']." and testid=".$_REQUEST['details']."),'unanswered') as stdans, IF('".$r1['status']."'='answered',IFNULL((select q.marks from question as q, studentquestion as sq where q.qnid=sq.qnid and q.testid=sq.testid and q.correctanswer=sq.stdanswer and sq.stdid=".$_SESSION['stdid']." and q.qnid=".$r1['questionid']." and q.testid=".$_REQUEST['details']."),0),0) as stdmarks from question where qnid=".$r1['questionid']." and testid=".$_REQUEST['details'].";"); if($r2=mysql_fetch_array($result2)) { ?> <tr> <td><?php echo $r1['questionid']; ?></td> <td><?php echo htmlspecialchars_decode($r1['quest'],ENT_QUOTES); ?></td> <td><?php echo htmlspecialchars_decode($r2['corans'],ENT_QUOTES); ?></td> <td><?php echo htmlspecialchars_decode($r2['stdans'],ENT_QUOTES); ?></td> <td><?php echo $r2['stdmarks']; ?></td> <?php if($r2['stdmarks']==0) { echo"<td class=\"tddata\"><img src=\"images/wrong.png\" title=\"Wrong Answer\" height=\"30\" width=\"40\" alt=\"Wrong Answer\" /></td>"; } else { echo"<td class=\"tddata\"><img src=\"images/correct.png\" title=\"Correct Answer\" height=\"30\" width=\"40\" alt=\"Correct Answer\" /></td>"; } ?> </tr> <?php } else { echo"<h3 style=\"color:#0000cc;text-align:center;\">Some individual questions cannot be displayed.</h3>".mysql_error(); } } } } else { echo"<h3 style=\"color:#0000cc;text-align:center;\">Something went wrong. Logout and Try again.</h3>".mysql_error(); } ?> </table> <?php } else { $result=executeQuery("select st.*,t.testname,t.testdesc,DATE_FORMAT(st.starttime,'%d %M %Y %H:%i') as startt from studenttest as st,test as t where t.testid=st.testid and st.stdid=".$_SESSION['stdid']." and st.status='over' order by st.testid;"); if(mysql_num_rows($result)==0) { echo"<h3 style=\"color:#0000cc;text-align:center;\">You have not attempted any exams yet.</h3>"; } else { //editing components ?> <table class="dashboards" cellspacing="10"> <tr> <th>Date and Time</th> <th>Test Name</th> <th>Max. Marks</th> <th>Obtained Marks</th> <th>Percentage</th> <th>Details</th> </tr> <?php while($r=mysql_fetch_array($result)) { $i=$i+1; $om=0; $tm=0; $result1=executeQuery("select sum(q.marks) as om from studentquestion as sq, question as q where sq.testid=q.testid and sq.qnid=q.qnid and sq.answered='answered' and sq.stdanswer=q.correctanswer and sq.stdid=".$_SESSION['stdid']." and sq.testid=".$r['testid']." order by sq.testid;"); $r1=mysql_fetch_array($result1); $result2=executeQuery("select sum(marks) as tm from question where testid=".$r['testid'].";"); $r2=mysql_fetch_array($result2); if($i%2==0) { echo "<tr class=\"alt\">"; } else { echo "<tr>";} echo "<td>".$r['startt']."</td><td>".htmlspecialchars_decode($r['testname'],ENT_QUOTES)." : ".htmlspecialchars_decode($r['testdesc'],ENT_QUOTES)."</td>"; if(is_null($r2['tm'])) { $tm=0; echo "<td>$tm</td>"; } else { $tm=$r2['tm']; echo "<td>$tm</td>"; } if(is_null($r1['om'])) { $om=0; echo "<td>$om</td>"; } else { $om=$r1['om']; echo "<td>$om</td>"; } if($tm==0) { echo "<td>0</td>"; } else { echo "<td>".(($om/$tm)*100)." %</td>"; } echo"<td class=\"tddata\"><a title=\"Details\" href=\"viewresult.php?details=".$r['testid']."\"><img src=\"images/detail.png\" height=\"30\" width=\"40\" alt=\"Details\" /></a></td></tr>"; } ?> </table> <?php } } closedb(); ?> </div> </form> </div> </body> </html>

I need the following changes to be made to this online exam system.docx

I need the following changes to be made to this online exam system.

1) The dean module.

The dean should be able to suspend or lift suspension of student accounts.

The dean should be able to view all the results of a student.

The dean should be the only one to create a subject and assign it to examiners.

2) Student module

The student should be able to register for an exam

The student should be able to defer an exam.

3) Examiner module

The examiner should be able to view how many students have registered for an exam.

The examiner must only add questions and tests for the subject they are allocated by the dean.

N.B: The results should be displayed in the format A, B, C, D and F where A= 80% - 100%, B = 65% - 79%

C= 50% - 64% , D= 40% - 49% and F = 0% - 39%

Details to use in the database:

Database name: oexam

examiner:

username: myexamin

password: myexamin

student:

username: jose

password: 445344

admin:

username: root

password: root