//Page for displaying a quiz
/***********************************************
* Copyright (c) 2003-4 TheGlasgowStory & HATII *
* Written by Brian Aitken *
***********************************************/
//session needed for links & photo album
session_start();
//need to register user's IP address for all logs
//Only need to do this once per user
$isip = session_is_registered("userip");
if (!$isip)
{
session_register("userip");
if (getenv(HTTP_X_FORWARDED_FOR))
$userip=getenv(HTTP_X_FORWARDED_FOR);
else
$userip=getenv(REMOTE_ADDR);
}
include("error.inc");
include("staff/connect.php");
include("session.inc");
include("logon.php");
include("inc.inc");
$isurltp = session_is_registered("urltp");
if ($isurltp)
{
session_unregister("urltp");
}
//assign error stuff
$head = "An error has occurred with TheGlasgowStory";
$back = "index.php";
$backtext = "Either click your browser's 'back' button or click on this link to return to TheGlasgowStory index page";
//get info for quiz
$quizlist = mysql_query("select quizid, name from quiz where active = 'Y' order by quizid desc");
$numquizes = mysql_num_rows($quizlist);
if(!$qsub)
{
if(!$quizid)
{
//echo("No id. ".$quizid."
");
$quiz = mysql_query("select * from quiz where active = 'Y' order by quizid desc limit 0,1");
$quiz = mysql_fetch_array($quiz);
$quest = mysql_query("select * from quiz_q where quiz = '$quiz[quizid]' order by qid");
$quizid = $quiz[quizid];
}
else
{
//echo("Is id. ".$quizid."
");
$quest = mysql_query("select * from quiz_q where quiz = '$quizid' order by qid");
}
$numq = mysql_num_rows($quest);
}
else
{
if($quizid)
{
$urltp = "quiz.php?qsub=99&quizid=".$quizid;
//get all the questions
$quest = mysql_query("select * from quiz_q where quiz = '$quizid' order by qid");
$numq = mysql_num_rows($quest);
$display=array();
$numright=0;
//now see how many were correct and put all answers into array for display
for($i=0;$i<$numq;$i++)
{
$row = mysql_fetch_array($quest);
$display[$i][0] = $row[qid];
$display[$i][1] = $row[question];
$display[$i][2] = $row[image];
$tmp = $row[qid];
$urltp.="&".$tmp."=".$$tmp;
//now get all the answers
$correct = mysql_query("select * from quiz_a where question = '$row[qid]' and correct = 'Y'");
$correct = mysql_fetch_array($correct);
if($$tmp==$correct[letter])
$numright++;
}
$urltp = urlencode($urltp);
}
else
$error = true;
}
format_pre("N", "TheGlasgowStory Quiz", $feature, $_COOKIE);
/*******************************************
* Code to run if submit button not pressed *
*******************************************/
if(!$qsub)
{
/*******************
* Log quiz viewing *
*******************/
$date = date(U);
$log = mysql_query("insert into accesslog set ip = '$userip', uname = '$user', logdate = '$date',
actiontype = 'Quiz Questions', details = 'Quiz ID = ".$quiz[quizid]."'");
$urltp = "quiz.php";
?>
If you can give the correct answers to 4 questions or more, then you must be pure gallus. And if you get 2 or less? You're a tumshie!
You can use the website to find answers - simply go to the search option and type in words that you think might help you to locate the relevant information. Each answer also comes with a link to a relevant captioned image.
echo(""); echo(""); for($i=0;$i<$numquizes;$i++) { $row = mysql_fetch_array($quizlist); if($row[quizid]==$quizid) echo($row[name]." | "); else echo("".$row[name]." | "); } echo("
"); } else { /******************* * Log quiz answers * *******************/ $date = date(U); $log = mysql_query("insert into accesslog set ip = '$userip', uname = '$user', logdate = '$date', actiontype = 'Quiz Answers', details = 'Quiz ID = ".$quizid.", ".$numright." correct'"); ?>There was an error running the quiz.
"); else { echo("You got ".$numright." question"); if($numright!=1) echo("s"); echo(" correct!
"); } for($i=0;$i<$numq;$i++) { $tmp = $i+1; $qid = $display[$i][0]; echo("".$tmp.": ".$display[$i][1]."
");
//now get all the answers
$ans = mysql_query("select * from quiz_a where question = '$qid' order by letter");
$numans = mysql_num_rows($ans);
for($j=0;$j<$numans;$j++)
{
$r = mysql_fetch_array($ans);
echo(" ".$r[letter]." ".$r[answer]."
");
}
echo("
");
if($right==true)
echo("Pure Gallus!");
else
echo("Tumshie!");
echo("
The Answer was ".$rightanswer);
if($display[$i][2])
echo(". Find out more");
echo(".