QCM problème codage
Fermé
Emilien54
-
Modifié le 15 oct. 2019 à 20:48
irongege Messages postés 40847 Date d'inscription jeudi 1 novembre 2007 Statut Modérateur Dernière intervention 29 juin 2023 - 16 oct. 2019 à 14:17
irongege Messages postés 40847 Date d'inscription jeudi 1 novembre 2007 Statut Modérateur Dernière intervention 29 juin 2023 - 16 oct. 2019 à 14:17
A voir également:
- QCM problème codage
- Codage ascii - Guide
- Codage binaire - Guide
- Fichier word illisible codage - Guide
- Qcm électricité afpa - Forum Études / Formation High-Tech
- Application codage - Guide
2 réponses
jordane45
Messages postés
38346
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
16 décembre 2024
4 718
Modifié le 16 oct. 2019 à 14:37
Modifié le 16 oct. 2019 à 14:37
Bonjour,
Tu ne nous indiques pas le souci rencontré...
je suppose que c'est que tu as toujours la fenêtre t'indiquant que tu n'as pas répondu à toutes les questions...
ça me semble normal vu qu'a aucun moment tu ne vas voir les réponses cochées....
Je précise également que faire un qcm en javascript est une énorme erreur...
n'importe qui peut, juste en regardant le code source de ta page, savoir quelles sont les bonnes réponses.
Un qcm ça se fait avec un langage serveur (tel que du PHP par exemple)... jamais uniquement en javascript.
enfin bon...
le code suivant devrait faire ce que tu souhaites
Tu ne nous indiques pas le souci rencontré...
je suppose que c'est que tu as toujours la fenêtre t'indiquant que tu n'as pas répondu à toutes les questions...
ça me semble normal vu qu'a aucun moment tu ne vas voir les réponses cochées....
Je précise également que faire un qcm en javascript est une énorme erreur...
n'importe qui peut, juste en regardant le code source de ta page, savoir quelles sont les bonnes réponses.
Un qcm ça se fait avec un langage serveur (tel que du PHP par exemple)... jamais uniquement en javascript.
enfin bon...
le code suivant devrait faire ce que tu souhaites
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html lang="fr"> <meta charset="utf-8"/> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Quizz Musique</title> <script language="JavaScript"> var key = new Array(0,1,0,1,1,1,0,0,0,1,0,1,0,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,0,0,0,0,1); <!-- tableau contenant les numeros des bonnes réponses --> var tryAgain = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); var numQ = 40; <!-- Nombre de questions --> function remplir(qNumber, answer) { tryAgain[qNumber-1]=answer; } function showGrade() { var missing = " "; var grade = 0; //recup곡tion des r걯nses var reponses = []; var radios = document.getElementsByTagName('input'); for (i = 0; i < radios.length; i++) { if (radios[i].type == 'radio' ) { if(radios[i].checked){ reponses.push({name:radios[i].name,value:radios[i].value,bonnereponse:key[i] == radios[i].value ? true : false}); grade += key[i] == radios[i].value ? 1 : 0 ; }else{ missing+= i+1 + "\n"; } } } console.log(reponses); console.log("bonne reponses :",grade); nbrep = reponses.length; console.log("Nb cochées ",nbrep); if (nbrep == numQ){ alert("Votre r괵ltat est de " + grade + " sur " + numQ + "."); } else{ alert("Vous n'avez pas terminé les questions" + missing + ". Vous pouvez retourner pour y répondre."); } } </script> </head> <body> <form action=""> <div align="center"></div> <table width="80%" border="0" cellspacing="3" cellpadding="0" bgcolor="#000099" align="center"> <tr> <td align="center" valign="middle"> <p> </p> <table width="95%" border="0" cellspacing="3" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td colspan="40"> <p align="center"><font face="Arial, Helvetica, sans-serif">Voulez-vous vous testez sur la musique en passant un petit QCM ?</font></p> <p> </p> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif"></font></td> <td width="10%"> <div align="center"><font face="Arial, Helvetica, sans-serif">OUI</font></div> </td> <td width="10%"> <div align="center"><font face="Arial, Helvetica, sans-serif">NON</font></div> </td> <td> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 1 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton1" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton1" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 2 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton2" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton2" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 3</font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton3" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton3" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 4</font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton4" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton4" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 5 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton5" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton5" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 6 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton6" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton6" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 7 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton7" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton7" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 8 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton8" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton8" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 9 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton9" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton9" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 10 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton10" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton10" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 11 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton11" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton11" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 12 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton12" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton12" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 13 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton13" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton13" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 14 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton14" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton14" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 15 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton15" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton15" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 16 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton16" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton16" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 17 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton17" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton17" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 18 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton18" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton18" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 19</font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton19" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton19" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 20 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton20" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton20" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 21 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton21" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton21" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 22 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton22" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton22" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 23 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton23" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton23" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 24 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton24" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton24" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 25 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton25" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton25" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 26 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton26" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton26" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 27 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton27" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton27" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 28 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton28" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton28" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 29 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton29" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton29" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 30 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton30" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton30" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 31 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton31" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton31" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 32 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton32" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton32" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 33 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton33" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton33" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 34 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton34" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton34" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 35 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton35" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton35" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 36 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton36" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton36" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 37 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton37" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton37" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 38 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton38" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton38" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 39 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton39" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton39" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="60%"><font face="Arial, Helvetica, sans-serif">Question 40 </font></td> <td width="10%" align="center"> <input type="radio" name="radiobutton40" value="0"> </td> <td width="10%" align="center"> <input type="radio" name="radiobutton40" value="1"> </td> <td align="center"> <input type="text" name="textfield"> </td> </tr> </table> </td> </tr> <tr> <td align="center" height="74" valign="middle"> <center> <input TYPE="BUTTON" Value="Afficher mes résultats" name="B1" onClick="showGrade();"> <input type="reset" name="Submit2" value="Recommencer" onClick="reset();clearScreen(this.form);"> </center> </td> </tr> </table> </form> </body> </html>
Salut jordane45 je suis désolé mais ton programme ne fonctionne il ne calcule pas les réponses ca fait tout le temps 0 sur 40
jordane45
Messages postés
38346
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
16 décembre 2024
4 718
16 oct. 2019 à 11:47
16 oct. 2019 à 11:47
jordane45
Messages postés
38346
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
16 décembre 2024
4 718
>
Emilien54
16 oct. 2019 à 14:01
16 oct. 2019 à 14:01
irongege
Messages postés
40847
Date d'inscription
jeudi 1 novembre 2007
Statut
Modérateur
Dernière intervention
29 juin 2023
5 072
>
jordane45
Messages postés
38346
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
16 décembre 2024
16 oct. 2019 à 14:17
16 oct. 2019 à 14:17