i have quiz app but i dont know how to matches my anwser with correct answer and catch my answer without insert to database
here the controller.
public function hasilKuis()
{
$check = $this->kuisModel->find('id_quiz');
$data = [
'title' => 'Hasil Kuis',
'hasil' => $this->kuisModel->findAll(),
'checks' => $this->request->getVar($check)
];
return view('user/kuis/hasil', $data);
}
when i diedump the controller get my answer but i still not get the answer to result quiz
the view quiz to choice the answer
<?php $i = 1; ?>
<?php foreach($soal as $s) : ?>
<?php $ans_array = [
$s['choice1'], $s['choice2'], $s['choice3'], $s['answer']
]; shuffle($ans_array); ?>
<div class="soal mb-3">
<p><?= $i++; ?>. <?= $s['pertanyaan']; ?></p>
<div class="form-check">
<input class="form-check-input" type="radio" name="<?= $s['id_quiz']; ?>" value="<?= $ans_array[0] ?>">
<label class="form-check-label">
A. <?= $ans_array[0] ?>
</label>
</div>
...
</div>
<?php endforeach; ?>
view result quiz after answer the quiz
<?php $i = 1; ?>
<?php foreach($hasil as $s) : ?>
<div class="soal mb-3">
<p><?= $i++; ?>. <?= $s['question']; ?></p>
<?php if ($checks == $s['answer']) : ?>
<div class="form-check" style="background-color: aquamarine;">
<input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioCheckedDisabled"
value="<?= $s['answer'] ?>" checked disabled>
<label class="form-check-label" for="flexRadioCheckedDisabled">
<?= $s['answer']; ?>
</label>
</div>
<?php else : ?>
<div class="form-check" style="background-color: palevioletred;">
<input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioCheckedDisabled"
value="" checked disabled>
<label class="form-check-label" for="flexRadioCheckedDisabled">
wrong answer
</label>
</div>
<div class="form-check" style="background-color: aquamarine;">
<input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioDisabled" disabled>
<label class="form-check-label" for="flexRadioDisabled">
<?= $s['answer']; ?>
</label>
</div>
<?php endif ?>
</div>
<?php endforeach; ?>
i dont know how to fix this. can anyone help me how to do this.. Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire