Calcul score quiz pourcentage (percent)

Bonjour,

J'ai réalisé un quiz avec des boutons pour chaque réponses. Ils deviennent verts ou rouges lorsque l'on clique dessus.

J'aimerai calculer le score en pourcentage de bonne ou mauvaise réponse au quiz.
Je n'y arrive pas.

Hello

Are you looking for help with the math?

Total questions total
Correctly answered questions correct
Incorrectly answered questions incorrect.

So the Percent correct is calculadted with this formula: correct / total * 100

for example if total questions = 20 and correctly answered questions = 15

                  15/20 * 100 = 75%

are correct.

Use the Math blocks Blocks to do the calculation.

Is that what you want to do?

Merci pour votre réponse.
Dois-je faire des listes pour regrouper les réponses correctes et incorrectes ?
Pouvez-vous me donner le code à réaliser grâce à la capture d'écran que je vous envoie ci-joint ?

Merci encore.

Yes you could. When an answer is correct, add the question number perhaps to a listOfCorrect answers; when the quiz is finished, total the number of items in the List.

Another way to keep track to the number of correct answers might be to create a counter variable. When an answer is correct, add 1 to the variable. For example counterVariable = 1 + counterVariable.

Read and do Taifun's quiz example https://puravidaapps.com/quiz.php and the MIT tutorial QuizMe for App Inventor 2 (it shows how to keep track of correct answers) to get more help and advice.

Find information about Any Component:
http://ai2.appinventor.mit.edu/reference/other/any-component-blocks.html

botones_colores.aia (3.9 KB)

Thank you everyone !!!

J'ai réalisé ces blocs avec vos précieux conseils.

Néanmoins lorsque j'essai de calculer mon résultat suite au quiz, j'obtiens un chiffre avec un virgule. Et le chiffre n'ai pas bon (15,34 au lieu de 50 %). Savez-vous pourquoi le résultat se calcule mal ?

Merci d'avance,
Math

Set the same number of "green" and "red" buttons, for example 8 green and 8 red, in total 16.

You press 3 "green" buttons, then you have 3/16 * 100 of "all buttons" pressed that are green, or 3/8 * 100 of "all green buttons" pressed.