Created
August 8, 2023 17:41
-
-
Save snowfluke/c4808c4fd1659aeaa564230d7cc7a515 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$questions = array( | |
array( | |
'question' => 'Soal 1', | |
'prompt' => 'gitar : ... ≈ ... : pukul', | |
'options' => array( | |
'A' => 'bernyanyi tukang', | |
'B' => 'kayu besi', | |
'C' => 'petik jimbe', | |
'D' => 'musik paku', | |
'E' => 'senar gendang' | |
) | |
), | |
array( | |
'question' => 'Soal 2', | |
'prompt' => 'hard disk : ... ≈ ... : uang', | |
'options' => array( | |
'A' => 'piringan logam', | |
'B' => 'data dompet', | |
'C' => 'piringan kertas', | |
'D' => 'disket barter', | |
'E' => 'komputer penghasilan' | |
) | |
) | |
); | |
foreach ($questions as $index => $question) { | |
$questionNumber = $index + 1; | |
$questionId = 'question' . $questionNumber; | |
echo '<div class="question' . ($index === 0 ? ' active' : '') . '" id="' . $questionId . '">'; | |
echo '<h5>' . $question['question'] . '</h5>'; | |
echo '<p>' . $question['prompt'] . '</p>'; | |
echo '<div class="options">'; | |
foreach ($question['options'] as $optionValue => $optionText) { | |
$dataCorrect = ($optionValue === 'B') ? ' data-correct' : ''; | |
echo '<label>'; | |
echo '<input type="radio" name="answer' . $questionNumber . '" value="' . $optionValue . '"' . $dataCorrect . '> ' . $optionText; | |
echo '</label>'; | |
} | |
echo '</div>'; | |
echo '</div>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment