<? 
	include "header.inc";
	include_once "survey.inc";
?>

<?
if (!(isAdmin ()))
{
	print ("<h2>You do not have permission to access this page</h2>");
}
else
{
?>
<h1>The Harvard-MIT Survey of Pig Latin and its Dialects reports</h1>
<h3>Export results to <a href="export.php">CSV</a></h3>

<div id="helptext">
<table width="100%" cellspacing="1">
<?
	$count = showReport ("html");
?>
</table>
<?
	print ("<h5>Total responses: $count</h5>");
?>
<br />
<hr />
<br />
<div id="projectissues" class="app">
<h3>Question/Answer key</h3>
</div>

<br />

<table width="100%" cellspacing="1">
<th>Key</th><th>Question/Answer text</th>
<?
	if (isset ($survey->questions))
	{
		foreach ($survey->questions as $question)
		{
			print ("<tr>");
			print ("<th>".$question->getKey ()."</th>");
			print ("<th>".$question->question."</th>");
			print ("</tr>");

			if (isset ($question->answers))
			{
				foreach ($question->answers as $answer)
				{
					print ("<tr>");
					print ("<td><strong>".$answer->getKey ()."</strong></td>");
					print ("<td>".$answer->answer."</td>");
					print ("</tr>");
				}
			}
		}
	}

?>
</table>

</div>
<?
}
?>

<? include "footer.inc" ?>
