A. |
B. |
C. |
D. None of these graphs are correct. |
session_start(); #GLOBAL CONSTANTS include("../mysql.php"); //include all mysql constants (abstracted for ease of migration) $nextQuestionURL = "question6.php"; //location of next question, tutorial, or end-of-test page. $flag=0; #ANSWER SUBMITTED -- Hanndles the case that this question has been answered. if(isset($_POST['answer5'])){ //Connect to db mysql_connect($mysqlURL,$mysqlUser,$mysqlPass); mysql_select_db($mysqlDatabase); //Question Update Database Queries -- $answerKey[questionNumber]=questionAnswer; $answerKey=array(); //create fresh array $answerKey[5]=$_POST['answer5']; #MYSQL -- This checks for existing answers in the database, then adds each of the student's answers. foreach($answerKey as $question=>$answer){ //Check the answer hasn't already been submitted. $testQuery=mysql_query("select count(id) as c from ".$mysqlAnswerTable." where sn=".$_SESSION['sn']." and question=".$question); if(mysql_error()){ echo "Please report this to the administrator: ".mysql_error(); die; } if(mysql_result($testQuery,0,'c')!=0) {mysql_close(); header("location:".$nextQuestionURL); die(); }; $query="insert into ".$mysqlAnswerTable."(sn,course,question,answer,tstamp) values('".mysql_escape_string($_SESSION['sn'])."','".mysql_escape_string($_SESSION['course'])."',".$question.",'".mysql_escape_string($answer)."',".time().")"; mysql_query($query); if(mysql_error()){ echo "Please report this to the administrator: ".mysql_error(); die; } } //Go to the next question. mysql_close(); header("location:".$nextQuestionURL); die(); } else if(isset($_POST['Submit'])) $flag=1; ?>
A. |
B. |
C. |
D. None of these graphs are correct. |