How can i correct a multiple choice question with multiple correct answers?

26 views Asked by At
                if(!empty($meerdereantwoorden)) { // Multiple choice meerdere antwoorden controleren

                        if($_POST['answer'] === 'GET' && $_POST['answer'] === 'POST') {
                            $antwoordmeerdereantwoorden = 'Vraag 4 (meerdere antwoorden): correct';
                        } else {
                            $antwoordmeerdereantwoorden = 'Vraag 4 (meerdere antwoorden): incorrect';
                        }
                    }
                else{}
 <form name="vragen" method="post" action="vijfvragen.php">
                <fieldset>
                    <legend>Vragen</legend>
                        <p><strong>Vraag 1: </strong>Hoe heet de serverside scriptingtaal die we nu aan het leren zijn? <input type = "text" size="18" name ="invulvraag" autocomplete="off" placeholder='Vul hier je antwoord in.'></p>
                        <hr>
                        <p><strong>Vraag 2: </strong>Om sommige stukken code opnieuw te gebruiken, zonder het steeds opnieuw te typen, welke tag is dan het handigst om te gebruiken? </p><select name="combobox">
                            <option> </option>
                            <option>for loop</option>
                            <option>function()</option>
                            <option>array</option>
                            </select>
                    <hr>
                    <p><strong>Vraag 3: </strong>Met welk HTML-element kan je &lt;fieldset&gt; een naam geven?</p>
                        <p><input type="radio" value="<legend>" name="eenantwoord">&lt;legend&gt;<p>
                        <p><input type="radio" value="<br>" name="eenantwoord">&lt;br&gt;<p>
                        <p><input type="radio" value="echo" name="eenantwoord">echo<p>
                        <p><input type="radio" value="<hr>" name="eenantwoord">&lt;hr&gt;<p>
                    <hr>
                    <p><b>Meerdere antwoorden mogelijk!</b></p>
                    <p><strong>Vraag 4: </strong>Welke van deze onderstaande antwoorden worden gebruikt om informatie naar een server te sturen?</p>   
                        <label><input type="checkbox" value="GET" name="answer[]">GET</label><br>
                        <label><input type="checkbox" value="POST" name="answer[]">POST</label><br>
                        <label><input type="checkbox" value="multipass" name="answer[]">Multipass</label><br>
                        <label><input type="checkbox" value="array" name="answer[]">Array</label><br>
                        <br>

                <input type="submit" value="Vragen versturen" name='verstuurd'><br>
               <p><strong><font color="#ff0000">Verstuur je vragen, zodat het nagekeken kan worden!</strong></p>
               <font color='#000000'>
                </fieldset>
            </form>

I tried in_array and array intersect aswell but to no use. The issue is when i select the two correct options that it doesn't correct them. What i mean that it should echo Vraag 4 (meerdere antwoorden) correct.Which it doesn't do for the incorrect and correct questions. This also applies for when you choose one incorrect and one correct option

I tried array intersect and in_array and foreach, but it didn't work. I also tried ChatGPT and Gemini and still no use haha. Sometimes it gave me the correct echo, but not the incorrect echo or the other way around.

0

There are 0 answers