Help : Réalisation d'un quizz

cs_mag16 Messages postés 1 Date d'inscription lundi 12 avril 2004 Statut Membre Dernière intervention 27 novembre 2004 - 27 nov. 2004 à 17:00
cs_ae2olivier Messages postés 2 Date d'inscription mardi 26 octobre 2004 Statut Membre Dernière intervention 14 février 2005 - 1 déc. 2004 à 22:21
J'ai un quiz avec 6 questions et pour chacunes, 2 réponses possibles par un système de bouton radio.

Comment récupérer les infos pour afficher le résultat avec le nombre de bonne réponses?

Merci pour votre aide

6 réponses

Blacknight91titi Messages postés 1732 Date d'inscription jeudi 17 juin 2004 Statut Membre Dernière intervention 9 mars 2015 2
27 nov. 2004 à 17:42
Il faut que ut utilise une incrémentation d'une variable pour chaque réponse bonne
a chauqe fois que une bonne réponse a été valider incrémente la variable de 1
si la réponse est fausse rien ne se passe le quizz se rend a al prochaine question
a la fin il te suffit d'afficher cette variable

8-) Bl@cknight91Titi :-p
0
cs_alise Messages postés 2203 Date d'inscription lundi 12 juillet 2004 Statut Membre Dernière intervention 26 janvier 2010
30 nov. 2004 à 14:38
Voilà un script de Moock à placer sur la première image de ton anim :/* * Multiple-Choice Quiz * Version: 1.0.1 * Author: Colin Moock */// ========================================// LOAD CLASSES// ========================================// Notice that the filenames match the// namespace used. This is not required, but is a useful// convention.#include "textes/org.moock.Quiz.as"#include "textes/org.moock.QuizGUI.as"#include "textes/org.moock.Question.as"// ========================================// START APPLICATION// ========================================main();// Function: main()// Desc: The entry point for the quiz application.function main () { // Create a new quiz. The Quiz class manages the data (i.e., it's // the Model in the Model-View-Controller design pattern). var asQuiz = new org.moock.Quiz(); // Create a QuizGUI instance to display the quiz and receive user input. // The QuizGUI instance will: // -respond to changes in the Quiz instance's data // -create UI elements that change the Quiz instance's data // (Hence, the QuizGUI class is the View and Controller in the MVC triad). var asQuizGUI = new org.moock.QuizGUI(this, asQuiz); // Now tell the Quiz instance which QuizGUI instance will be used // to render the quiz to screen. The QuizGUI wants to be notified of // changes in the quiz data so that the display can be updated. // In Observer pattern terms, the QuizGUI is the Observer and // the Quiz is the Observable. asQuiz.setQuizGUI(asQuizGUI); // All ready to start. Load the quiz data from an XML file. asQuiz.loadQuizData("asQuiz.xml"); // The quiz could also be created manually here instead of // being loaded from an XML file. To create the quiz manually, // use Quiz.setTitle(), Quiz.setDescription(), and Quiz.addQuestion(). // When the quiz is ready, we then call QuizGUI.displaySplashScreen().}et le xml externe avec les questions bien sûr: Ile Dauphine Ile Bourbon Ile de France 1638 1793 1946 L'?©glise de Saint-Louis L'?©glise de Sainte-Marie L'?©glise de Sainte-Anne L'?©glise de Saint-Leu Saint-Denis Saint-Pierre Saint-Paul 1920 1929 1933 Saint-Philippe Le Port Sainte-Rose Sainte-Suzanne le fichier AS externe nommé org.moock.Question.as à créer :// Define namespace.if(_global.org == undefined) { _global.org = new Object();} if(_global.org.moock == undefined) { _global.org.moock = new Object();} // =============================================================// Question Class// --------------// This class stores the data for a single question, including:// the question, the answers, the correct answer, and the// user's answer.// =============================================================/** * Question Constructor * * @param questionXML An XML object that contains the question data. * @param correctAnswer An optional zero-based integer indicating the * question's correct answer. * @param questionText An optional string specifying the text of * the question. * @param answers An optional array of strings specifying the * possible answers for the question. */_global.org.moock.Question = function (questionXML, correctAnswer, questionText, answers) { // Instance Properties this.questionText = ""; this.answers = new Array(); this.correctAnswer = 0; this.userAnswer = null; // Initialization. // If there's only one argument and it's an XMLnode object... var answerList = new Array(); if (arguments.length == 1 && questionXML instanceof XMLnode) { // ...construct the question using the XML. this.setCorrectAnswer(questionXML.attributes.ANSWER); this.setQuestionText(questionXML.attributes.TEXT); for (var i=0; i < questionXML.childNodes.length; i++) { answerList[i] = questionXML.childNodes[i].firstChild.nodeValue; } this.setAnswers(answerList); } else { // ...otherwise assume the correctAnswer, questionText, answers format. this.setCorrectAnswer(correctAnswer); this.setQuestionText(questionText); this.setAnswers(answers); }}/** * Method: QuizGUI.setQuestionText() * Desc: Sets the question itself. For example "How old is Canada?" * * @param text The question's text. */org.moock.Question.prototype.setQuestionText = function (text) { this.questionText = text;}/** * Method: QuizGUI.getQuestionText() * Desc: Returns the question's text. */org.moock.Question.prototype.getQuestionText = function () { return this.questionText;}/** * Method: QuizGUI.setAnswers() * Desc: Sets the answers to the question as an array. * * @param answerList An array of string answers. */org.moock.Question.prototype.setAnswers = function (answerList) { this.answers = answerList;}/** * Method: QuizGUI.getAnswers() * Desc: Returns the answers to this question as an array. */org.moock.Question.prototype.getAnswers = function () { return this.answers;}/** * Method: QuizGUI.setCorrectAnswer() * Desc: Sets the correct answer for this question. * * @param index The zero-based position of the correct answer * in the answer list returned by getAnswers(). */org.moock.Question.prototype.setCorrectAnswer = function (index) { // Could add type and bounds checking here, but we're keeping things // simple. this.correctAnswer = index;}/** * Method: QuizGUI.getCorrectAnswer() * Desc: Returns the correct answer to this question as an index in * the array returned by getAnswers(). */org.moock.Question.prototype.getCorrectAnswer = function () { return this.correctAnswer;}/** * Method: QuizGUI.setUserAnswer() * Desc: Sets the user's guess for this question. * * @param index The zero-based position of the user's answer * in the answer list returned by getAnswers(). */org.moock.Question.prototype.setUserAnswer = function (index) { // Could add type and bounds checking here, but we're keeping things // simple. this.userAnswer = index;}/** * Method: QuizGUI.getUserAnswer() * Desc: Returns the user's answer to this question as an index in * the array returned by getAnswers(). */org.moock.Question.prototype.getUserAnswer = function () { return this.userAnswer;}le fichier externe en As à créer, appelé org.moock.Quiz.as :// Define namespace.if(_global.org == undefined) { _global.org = new Object();} if(_global.org.moock == undefined) { _global.org.moock = new Object();} // =============================================================// Question Class// --------------// This class stores the data for a single question, including:// the question, the answers, the correct answer, and the// user's answer.// =============================================================/** * Question Constructor * * @param questionXML An XML object that contains the question data. * @param correctAnswer An optional zero-based integer indicating the * question's correct answer. * @param questionText An optional string specifying the text of * the question. * @param answers An optional array of strings specifying the * possible answers for the question. */_global.org.moock.Question = function (questionXML, correctAnswer, questionText, answers) { // Instance Properties this.questionText = ""; this.answers = new Array(); this.correctAnswer = 0; this.userAnswer = null; // Initialization. // If there's only one argument and it's an XMLnode object... var answerList = new Array(); if (arguments.length == 1 && questionXML instanceof XMLnode) { // ...construct the question using the XML. this.setCorrectAnswer(questionXML.attributes.ANSWER); this.setQuestionText(questionXML.attributes.TEXT); for (var i=0; i < questionXML.childNodes.length; i++) { answerList[i] = questionXML.childNodes[i].firstChild.nodeValue; } this.setAnswers(answerList); } else { // ...otherwise assume the correctAnswer, questionText, answers format. this.setCorrectAnswer(correctAnswer); this.setQuestionText(questionText); this.setAnswers(answers); }}/** * Method: QuizGUI.setQuestionText() * Desc: Sets the question itself. For example "How old is Canada?" * * @param text The question's text. */org.moock.Question.prototype.setQuestionText = function (text) { this.questionText = text;}/** * Method: QuizGUI.getQuestionText() * Desc: Returns the question's text. */org.moock.Question.prototype.getQuestionText = function () { return this.questionText;}/** * Method: QuizGUI.setAnswers() * Desc: Sets the answers to the question as an array. * * @param answerList An array of string answers. */org.moock.Question.prototype.setAnswers = function (answerList) { this.answers = answerList;}/** * Method: QuizGUI.getAnswers() * Desc: Returns the answers to this question as an array. */org.moock.Question.prototype.getAnswers = function () { return this.answers;}/** * Method: QuizGUI.setCorrectAnswer() * Desc: Sets the correct answer for this question. * * @param index The zero-based position of the correct answer * in the answer list returned by getAnswers(). */org.moock.Question.prototype.setCorrectAnswer = function (index) { // Could add type and bounds checking here, but we're keeping things // simple. this.correctAnswer = index;}/** * Method: QuizGUI.getCorrectAnswer() * Desc: Returns the correct answer to this question as an index in * the array returned by getAnswers(). */org.moock.Question.prototype.getCorrectAnswer = function () { return this.correctAnswer;}/** * Method: QuizGUI.setUserAnswer() * Desc: Sets the user's guess for this question. * * @param index The zero-based position of the user's answer * in the answer list returned by getAnswers(). */org.moock.Question.prototype.setUserAnswer = function (index) { // Could add type and bounds checking here, but we're keeping things // simple. this.userAnswer = index;}/** * Method: QuizGUI.getUserAnswer() * Desc: Returns the user's answer to this question as an index in * the array returned by getAnswers(). */org.moock.Question.prototype.getUserAnswer = function () { return this.userAnswer;}Et le dernier fichier en AS à créer appelé org.moock.QuizGUI.as :// Define namespace.if(_global.org == undefined) { _global.org = new Object();} if(_global.org.moock == undefined) { _global.org.moock = new Object();} // =============================================================// QuizGUI Class// -------------// This class displays the data in a Quiz instance and creates// user interface elements that let the user take the quiz.// =============================================================/** * QuizGUI Constructor * * @param quizClip The clip used to display the quiz. * @param quizObject The Quiz instance we're displaying. */_global.org.moock.QuizGUI = function (quizClip, quizObject) { // Instance Properties. this.quizClip = quizClip; // The clip used for quiz GUI display. this.quizObj = quizObject; // The Quiz instance (quiz data object). this.depthCounter = 0; // A unique depth for onscreen assets (clips and text fields). // Initialization. // Set movie scale mode and aligment. Stage.scaleMode = "noScale"; Stage.align = "TL";};/** * Method: QuizGUI.displaySplashScreen() * Desc: Displays the quiz title screen. Users begin the quiz here. * If the quiz data is loaded from an XML file, this method is * invoked automatically by Quiz.loadQuizData(). Otherwise, it should * be called manually when the questions of the quiz are ready. */org.moock.QuizGUI.prototype.displaySplashScreen = function () { // Store a convenient reference to the display clip and the quiz object. var quizClip = this.quizClip; var quizObj = this.quizObj; // Create the title. this.displayTitle(quizObj.getTitle(), "top"); // Create the description. quizClip.createTextField("desc_txt", ++this.depthCounter, 0, 0, 0, 0); quizClip.desc_txt.autoSize = true; quizClip.desc_txt.text = quizObj.getDescription(); quizClip.desc_txt.selectable = false; quizClip.desc_txt.setTextFormat(new TextFormat("Verdana", 14, 0x333333)); quizClip.desc_txt._x = Stage.width/2 - quizClip.desc_txt._width/2; quizClip.desc_txt._y = quizClip.title_txt._y + quizClip.title_txt._height+20; // Create the Begin button. var begin_mc = this.createNavButton("En avant !"); begin_mc._x = Stage.width/2 - begin_mc._width/2; begin_mc._y = quizClip.desc_txt._y + quizClip.desc_txt._height + 20; begin_mc.onPress = function () { quizObj.startNewQuiz(); };};/** * Method: QuizGUI.displayQuestion() * Desc: Displays a question on screen. Draws the entire UI from scratch. */org.moock.QuizGUI.prototype.displayQuestion = function () { // Store convenient references to the quizClip, quizObj, and quizGUI objects. var quizGUI = this; var quizClip = this.quizClip; var quizObj = this.quizObj; // Determine the current question. var currentQuestionIdx = quizObj.getCurrentQuestion(); // Set the margins for question display. var questionLeftMargin = 70; var questionRightMargin = 70; // Create the question text field in the quizClip. quizClip.createTextField("q_txt", ++this.depthCounter, 0, 0, 0, 0); quizClip.q_txt._width = Stage.width - questionLeftMargin - questionRightMargin; quizClip.q_txt.multiline = true; quizClip.q_txt.wordWrap = true; quizClip.q_txt.autoSize = "left"; quizClip.q_txt.text = "Question " + (currentQuestionIdx + 1) + "\n" + quizObj.getQuestionAt(currentQuestionIdx).getQuestionText(); quizClip.q_txt.selectable = false; // Set the overall format for the question. quizClip.q_txt.setTextFormat(new TextFormat("Verdana", 12)); // Make the word "Question" bold and red. quizClip.q_txt.setTextFormat(0, 10, new TextFormat("Verdana", 12, 0x000099, true)); quizClip.q_txt._x = questionLeftMargin; quizClip.q_txt._y = quizClip.title_txt._y + quizClip.title_txt._height + 40; // Create the quiz status text field in the quizClip. quizClip.createTextField("status_txt", ++this.depthCounter, 0, 0, 0, 0); quizClip.status_txt.autoSize = true; quizClip.status_txt.text = "Réponses : " + quizObj.getNumUserAnswers() + "/" + quizObj.getNumQuestions() + "." quizClip.status_txt.selectable = false; quizClip.status_txt.setTextFormat(new TextFormat("Verdana", 12)); quizClip.status_txt._x = questionLeftMargin; quizClip.status_txt._y = Stage.height - quizClip.status_txt._height - 150; // Now the heavy lifting...create the answer buttons and answer text fields. // Note that it would probably be wise to create an answer button component // or class that handles all this work outside of the displayQuestion() // method. We make the buttons inline here simply to keep the focus on the // quiz, not the generation of UI libraries. // Determine where to place the answers (below the question). var questionBottomBound = quizClip.q_txt._y + quizClip.q_txt._height; // Retrieve the answers for this question from the Quiz object. var answers = this.quizObj.getQuestionAt(currentQuestionIdx).getAnswers(); // For each answer to this question... for (var i = 0; i < answers.length; i++) { // ...make a button clip. var aBut_mc = this.quizClip.createEmptyMovieClip("aBut_mc" + i, ++this.depthCounter); // Draw a checkbox in the button clip. aBut_mc.lineStyle(0); aBut_mc.moveTo(0, 4); aBut_mc.lineTo(10, 4); aBut_mc.lineTo(10, 14); aBut_mc.lineTo(0, 14); aBut_mc.lineTo(0, 4); // If the user already has made a choice for this question, fill // the checkbox with red. (The user might have returned to a question // in order to change an answer). var userAnswer = quizObj.getQuestionAt(currentQuestionIdx).getUserAnswer(); if (userAnswer != null && userAnswer == i) { aBut_mc.createEmptyMovieClip("choice_mc", ++this.depthCounter); aBut_mc.choice_mc.lineStyle(0); aBut_mc.choice_mc.moveTo(0, 4); aBut_mc.choice_mc.beginFill(0x000099); aBut_mc.choice_mc.lineTo(10, 4); aBut_mc.choice_mc.lineTo(10, 14); aBut_mc.choice_mc.lineTo(0, 14); aBut_mc.choice_mc.lineTo(0, 4); aBut_mc.choice_mc.endFill(); } // Place the button in line with the question text, a little // right of the question text field's left border. aBut_mc._x = questionLeftMargin + 4; // Create the answer text field in the button clip. aBut_mc.createTextField("a_txt" + i, 1, 0, 0, 0, 0); var rightTextBorder = {x:Stage.width, y:0}; aBut_mc.globalToLocal(rightTextBorder); aBut_mc["a_txt" + i]._width = rightTextBorder.x - questionRightMargin; aBut_mc["a_txt" + i].multiline = true; aBut_mc["a_txt" + i].wordWrap = true; aBut_mc["a_txt" + i].autoSize = "left"; aBut_mc["a_txt" + i].text = answers[i]; aBut_mc["a_txt" + i].selectable = false; aBut_mc["a_txt" + i].setTextFormat(new TextFormat("Verdana", 12)); aBut_mc["a_txt" + i]._x = 20; // Position the text field in from the checkbox. // If we're making the first answer button, then position it // below the question text. Otherwise, position it below the previous button. if (i == 0) { aBut_mc._y = questionBottomBound + 2; } else { aBut_mc._y = quizClip["aBut_mc" + (i-1)].getBounds(quizClip).yMax; } // Now that the text field is made, make the button's hit area // to match its size. The hit area is another programmatically // drawn movie clip. aBut_mc.createEmptyMovieClip("hit_mc", 2); var hitAreaRightEdge = 20 + aBut_mc["a_txt" + i]._width; var hitAreaBottomEdge = aBut_mc["a_txt" + i]._height; aBut_mc.hit_mc.lineStyle(1); aBut_mc.hit_mc.beginFill(0x00FF00); aBut_mc.hit_mc.lineTo(hitAreaRightEdge, 0); aBut_mc.hit_mc.lineTo(hitAreaRightEdge, hitAreaBottomEdge); aBut_mc.hit_mc.lineTo(0, hitAreaBottomEdge); aBut_mc.hit_mc.lineTo(0, 0); aBut_mc.hit_mc.endFill(); // Don't display the hit area on screen. aBut_mc.hit_mc._visible = false; // Assign the hit area clip as the button's hit area. aBut_mc.hitArea = aBut_mc.hit_mc; // Assign the button click behavior. aBut_mc.onPress = function () { quizObj.setUserAnswer(currentQuestionIdx, parseInt(this._name.substring(7))); } // On rollover, draw the button's "on" state. aBut_mc.onRollOver = function () { this.moveTo(0, 4); this.lineTo(10, 14); this.moveTo(10, 4); this.lineTo(0, 14); } // On rollout, draw the button's "off" state. aBut_mc.onRollOut = function () { this.clear(); this.lineStyle(0); this.moveTo(0, 4); this.lineTo(10, 4); this.lineTo(10, 14); this.lineTo(0, 14); this.lineTo(0, 4); } } // We're done making the answer buttons. // Now create the "Next" button, which the user clicks to // move to the next question. var next_mc = this.createNavButton(" Suivante "); // Position the Next button on the right edge of the Stage, // vertically above the status movie clip. next_mc._x = Stage.width - next_mc._width - 70; next_mc._y = Stage.height - quizClip.status_txt._height - 150; // If we're not on the last question... if (currentQuestionIdx < quizObj.getNumQuestions() - 1) { // ...activate the next button. next_mc.onPress = function () { quizObj.setCurrentQuestion(quizObj.getCurrentQuestion() + 1); }; } else { // ...otherwise, fade out the button. new Color(next_mc).setRGB(0x999999); } // Create the "Back" button. var back_mc = this.createNavButton(" Précédente "); // Position the Back button beside the Next button. back_mc._x = next_mc.getBounds(quizClip).xMin - back_mc._width - 10; back_mc._y = Stage.height - quizClip.status_txt._height - 150; // If we're not on the first question... if (currentQuestionIdx > 0) { // ...activate the back button. back_mc.onPress = function () { quizObj.setCurrentQuestion(quizObj.getCurrentQuestion() - 1); }; } else { // ...otherwise, fade out the button. new Color(back_mc).setRGB(0x999999); } // If all the questions have been answered, create a "Grade" button. // Note that the first time the questions are all answered, // the Quiz class automatically invokes QuizGUI.onQuizComplete(). if (quizObj.isComplete()) { var grade_mc = this.createNavButton(" Score ", 0x000099); // Position the Grade button beside the Back button. grade_mc._x = back_mc.getBounds(quizClip).xMin - grade_mc._width - 30; grade_mc._y = Stage.height - quizClip.status_txt._height - 150; // When the grade button is pressed, show the quiz end screen. grade_mc.onPress = function () { quizGUI.displayQuizEnd(); }; }};/** * Method: QuizGUI.displayQuizEnd() * Desc: Displays the user's score on screen, and offers a Try Again button. */org.moock.QuizGUI.prototype.displayQuizEnd = function () { // Need a reference to the quizGUI for use in the Continue button. var quizGUI = this; var quizClip = this.quizClip; // Clear the current question. this.clearScreen(); // Display the quiz title. this.displayTitle(this.quizObj.getTitle(), "top"); // Create a text field to hold the user's score. quizClip.createTextField("info_txt", ++this.depthCounter, 0, 0, 0, 0); quizClip.info_txt._width = Math.floor(Stage.width/2); quizClip.info_txt.multiline = true; quizClip.info_txt.wordWrap = true; quizClip.info_txt.autoSize = "left"; quizClip.info_txt.text = "Merci d'avoir répondu."+ newline + "Votre score final est de : " + this.quizObj.getScore() + "/" + this.quizObj.getNumQuestions(); quizClip.info_txt.selectable = false; quizClip.info_txt.setTextFormat(new TextFormat("Verdana", 12, null, null, null, null, null, null, "center")); quizClip.info_txt._x = Stage.width/2 - quizClip.info_txt._width / 2; quizClip.info_txt._y = Stage.height/2 - quizClip.info_txt._height; // Create a button to let the user try again. var tryAgain_mc = this.createNavButton(" Recommencer "); tryAgain_mc._x = Stage.width/2 - tryAgain_mc._width/2; tryAgain_mc._y = quizClip.info_txt._y + quizClip.info_txt._height + 20; tryAgain_mc.onPress = function () { quizGUI.quizObj.startNewQuiz(); };};/** * Method: QuizGUI.displayTitle() * Desc: Draws the title to screen. * * @param align The alignment of the title, either "middle" or "top". */org.moock.QuizGUI.prototype.displayTitle = function (title, align) { var quizClip = this.quizClip; // Create the title text field. quizClip.createTextField("title_txt", ++this.depthCounter, 0, 0, 0, 0); quizClip.title_txt.autoSize = true; // If the title argument is supplied, use it, otherwise, default to // the title set for the Quiz object. quizClip.title_txt.text = title != undefined ? title : this.quizObj.getTitle(); quizClip.title_txt.selectable = false; quizClip.title_txt.setTextFormat(new TextFormat("Verdana", 14, 0x000099, true)); quizClip.title_txt._alpha=0; // Position the title text field. quizClip.title_txt._x = Stage.width/2 - quizClip.title_txt._width/2; if (align == "middle") { quizClip.title_txt._y = Stage.height/2 - quizClip.title_txt._height/2; } else if (align == "top") { quizClip.title_txt._y = 200; }};/** * Method: QuizGUI.createNavButton() * Desc: Creates a new navigation button (e.g., "Next", "Back"), and * returns a reference to it. * * @param text The text on the button. * @param col The color of the button border and text. */org.moock.QuizGUI.prototype.createNavButton = function (text, col) { // Set button color to black if none is supplied. col = col ? col : 0x000000; this.depthCounter++; var navBut_mc = this.quizClip.createEmptyMovieClip("navBut_mc" + this.depthCounter, this.depthCounter); navBut_mc.createTextField("but_txt", ++this.depthCounter, 0, 0, 0, 0); navBut_mc.but_txt.autoSize = true; navBut_mc.but_txt.text = text; navBut_mc.but_txt.selectable = false; navBut_mc.but_txt.border = false; navBut_mc.but_txt.borderColor = col; navBut_mc.but_txt.setTextFormat(new TextFormat("Verdana", 12, col)); return navBut_mc;};/** * Method: QuizGUI.clearScreen() * Desc: Wipes the entire screen blank by removing all movie clips * and text fields from the target quiz clip. */org.moock.QuizGUI.prototype.clearScreen = function () { for (var p in this.quizClip) { if (typeof this.quizClip[p] == "movieclip") { this.quizClip[p].removeMovieClip(); } else if (this.quizClip[p] instanceof TextField) { this.quizClip[p].removeTextField(); } }};// #############################################// Event handlers// #############################################/** * Method: QuizGUI.onQuizStart() * Desc: Invoked when the user presses "begin" on the quiz splash screen. * When invoked, we display the first question. */org.moock.QuizGUI.prototype.onQuizStart = function () { this.clearScreen(); this.displayTitle(this.quizObj.getTitle(), "top"); this.displayQuestion();};/** * Method: QuizGUI.onQuestionUpdate() * Desc: Invoked when the current question changes or the data for a * question changes (such as when the user submits an answer). * When invoked, we display the current question. */org.moock.QuizGUI.prototype.onQuestionUpdate = function () { this.clearScreen(); this.displayTitle(this.quizObj.getTitle(), "top"); this.displayQuestion();};/** * Method: QuizGUI.onQuizComplete() * Desc: Invoked when the user has answered ever question in the quiz. * When invoked, we display a screen that offers the user the choice * to Grade or Continue the quiz. */org.moock.QuizGUI.prototype.onQuizComplete = function () { // Need a reference to the quizGUI for use in the Continue button. var quizGUI = this; var quizClip = this.quizClip; // Clear the current question. this.clearScreen(); // Display the quiz title. this.displayTitle(this.quizObj.getTitle(), "top"); // Create a text field explaining that the quiz is finished. quizClip.createTextField("info_txt", ++this.depthCounter, 0, 0, 0, 0); quizClip.info_txt._width = Math.floor(Stage.width); quizClip.info_txt.multiline = true; quizClip.info_txt.wordWrap = true; quizClip.info_txt.autoSize = "left"; quizClip.info_txt.text = "Vous avez répondu à toutes les questions."+ newline + "Pour connaître votre résultat, cliquez sur Score."+ newline + "Pour revenir en arrière et changer vos réponses, cliquez sur \"Continuer\"."+ newline + "En cliquant sur \"Score\", vous pouvez arrêter le quiz quand vous le désirez." quizClip.info_txt.selectable = false; quizClip.info_txt.setTextFormat(new TextFormat("Verdana", 12, null, null, null, null, null, null, "center")); quizClip.info_txt._x = Stage.width/2 - quizClip.info_txt._width / 2; quizClip.info_txt._y = Stage.height/2 - quizClip.info_txt._height; // Create a "Grade" button. var grade_mc = this.createNavButton(" Score "); grade_mc._x = Stage.width/2 - grade_mc._width - 10; grade_mc._y = quizClip.info_txt._y + quizClip.info_txt._height + 20; grade_mc.onPress = function () { quizGUI.displayQuizEnd(); }; // Create a "Continue" button. var continue_mc = this.createNavButton(" Continuer "); continue_mc._x = Stage.width/2 + 10; continue_mc._y = quizClip.info_txt._y + quizClip.info_txt._height + 20; continue_mc.onPress = function () { // Force the current question to display. quizGUI.quizObj.setCurrentQuestion(quizGUI.quizObj.getCurrentQuestion()); };};voilà avec ça, en épluchant un peu tu devrait t'en tirer pour ton Quizz, on l'a tester puisqu'il nous a servit à en faire un pour notre Ile.A+Alisefrom RunIsland
0
cs_alise Messages postés 2203 Date d'inscription lundi 12 juillet 2004 Statut Membre Dernière intervention 26 janvier 2010
30 nov. 2004 à 14:43
attention, on avait placé tous ces scripts dans un répertoire texte, donc si tu les veux au premier plan, lire :

// LOAD CLASSES
// ========================================
// Notice that the filenames match the
// namespace used. This is not required, but is a useful
// convention.
#include "org.moock.Quiz.as"
#include "org.moock.QuizGUI.as"
#include "org.moock.Question.as"

Alise
from RunIsland
0
trouble magma Messages postés 15 Date d'inscription mercredi 8 septembre 2004 Statut Membre Dernière intervention 11 août 2005
30 nov. 2004 à 18:07
Juste pour proposer une solution plus simple car apparement ton problème est assez simple vu que tu as un quiz précis (pas de xml a moins que je me trompe...)

donc en gros faut juste que tu créé une variable de type array();
dans laquelle tu enregistre le resutat de chaque question au fur et a mesure (array(i)=1 ou 0 suivant si la réponse est bonne ou fausse)
en imaginant bien sur que tu as un moyen de savoir quelle reponse a été cochée mais logiquement oui vu que tu as mis des boutons radio...

et a la fin sois tu additionne toutes les valeurs avec une boucle for soit tu fais un affichage du score par réponse... a toi de voir ce que tu veux.

Simz
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_alise Messages postés 2203 Date d'inscription lundi 12 juillet 2004 Statut Membre Dernière intervention 26 janvier 2010
30 nov. 2004 à 19:37
t'as raison trouble magma, bien sûr on peut faire bien plus simple, mais il y a des gens comme C.Moock qui se cassent le C? à développer des trucs pour les partager et les enseigner autant se servir de leurs bases pour développer nos API, les comprendre et les adapter, (c'est ce qui contribue en fin de compte à apprendre l'AS) !!!

Alise
from RunIsland
0
cs_ae2olivier Messages postés 2 Date d'inscription mardi 26 octobre 2004 Statut Membre Dernière intervention 14 février 2005
1 déc. 2004 à 22:21
%-6 ae2olivier
J'ai fait un petit Quiz ou j'incrémente les bonnes réponses directement après chaque résultat, je crois que c'est ce que tu veux faire. le tuto de C.MOOCK ne m'a pas aidé car beaucoup trop compliqué pour moi.
J'ai mis des conditions sur chaque boutons et en fonction de la bonne réponse on gagne 1 ou 0.
Mais je l'ai fait avec une base de données via php.
http://ae2olivier.free.fr/flash_quizz.php
0
Rejoignez-nous