Files
qcmmaker/current_version/.svn/text-base/qcmReader.php.svn-base
2013-08-07 14:41:29 +02:00

60 lines
2.2 KiB
Plaintext

<?php
/* Displays the selected QCM and check for previous results */
if(!isset($_GET['qcm']) || !is_numeric($_GET['qcm']) || $_GET['qcm']<=0)
{
echo getError(array('Qcm inconnu', 'Qcm n&deg;'.$_GET['qcm']));
}
else
{
$iQcmId = $_GET['qcm'];
$asQcm = getQcm($iQcmId);
$sQcmName = $asQcm[QCM_TABLE];
//check if the user had already played this QCM
$bplayed = checkPreviousResults($_SESSION['user'], $iQcmId);
echo $bplayed?getWarning('Vous avez d&eacute;j&agrave; r&eacute;pondu &agrave; ce QCM. Les r&eacute;sultats ne seront pas compt&eacute;s'):'';
//display the questions
$iNbQuestions = 0;
foreach(shuffle_assoc($asQcm[QUESTION_TABLE]) as $iQuestionId => $asAnswers)
{
$asDisplayAnswers = $asDisplayRightAnswers = array();
$iNbAnswers = 0;
$iNbQuestions++;
foreach($asAnswers[ANSWER_TABLE] as $iAnswerId => $asAnswer)
{
$iNbAnswers++;
$asDisplayAnswers[$iAnswerId] = '<p class="question">'.$iNbAnswers.'. '.$asAnswer[ANSWER_TABLE].'</p>';
$asDisplayRightAnswers[$iAnswerId] = getInputHtml('RightAnswer', array($iQuestionId, $iAnswerId, '', ''));
}
$sImage = ($asAnswers['image']!='')?getHtml(getImage(IMAGE_FOLDER.$asAnswers['image']), 'div', 'qcmReader'):'';
$asDisplayQuestions[$iQuestionId] = '<tr>
<td width="10%">'.$iNbQuestions.'.</td>
<td width="60%">'.$asAnswers[QUESTION_TABLE].'<br />'.$sImage.'</td>
<td>'.implode("\n", $asDisplayAnswers).'</td>
<td>'.implode("\n", $asDisplayRightAnswers).'</td>
</tr>';
}
}
?>
<form action="?page=qcmResults" method="post">
<table class="maxWidth">
<tr>
<th colspan="4" class="top-left-rounded top-right-rounded"><p class="tresimportant"><?php echo $sQcmName; ?></p></th>
</tr>
<?php
echo implode("\n", $asDisplayQuestions);
?>
<tr>
<td colspan="4" class="bottom-left-rounded bottom-right-rounded">
<input type="hidden" name="qcm" value="<?php echo $iQcmId; ?>" />
<input type="hidden" name="user" value="<?php echo $_SESSION['user']; ?>" />
<input style="margin:10px;font-size:large;" type="submit" value="R&eacute;sultats" />
</td>
</tr>
</table>
</form>