Initial commit
This commit is contained in:
60
current_version/qcmReader.php
Normal file
60
current_version/qcmReader.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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°'.$_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éjà répondu à ce QCM. Les résultats ne seront pas compté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ésultats" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
Reference in New Issue
Block a user