revised grade user function:
PHP Code:
function gradeUser() {
// Report that we're about to grade the quiz in the Output window.
trace("Quiz complete. Now grading...");
// Create a local variable to track the
// number of questions user answered correctly.
var totalCorrect = 0;
// Count how many questions the user answered correctly.
// For each question...
for (var i=0; i < numQuestions; i++) {
// If the user's answer matches the correct answer.
if(userAnswers[i] == correctAnswers[i]) {
// Give the user a point.
totalCorrect++;
}
// Display the correct answer and the user's answer
// in the Output window for debugging.
trace("Question " + (i + 1)
+ ". Correct answer: " + correctAnswers[i]
+ ". User's answer: " + userAnswers[i]);
}
// Display the final score in the Output window for debugging.
trace("User's score: " + totalCorrect + "/" + numQuestions);
// Create an onscreen text field do display the user's score.
this.createTextField("totalOutput_txt", 50, 25, 60, 400, 80);
if ( totalCorrect > 13){
totalOutput_txt.text = "You answered " + totalCorrect + "/" + numQuestions + " correctly."+newline+" You are a Bordeaux Master!!!";
}else if(totalCorrect > 10 && totalCorrect < 12){
totalOutput_txt.text = "You answered " + totalCorrect + "/" + numQuestions + " correctly."+newline+" You are a Bordeaux Pro.";
}else if(totalCorrect >6 && totalCorrect < 9){
totalOutput_txt.text = "You answered " + totalCorrect + "/" + numQuestions + " correctly."+newline+" You are a Bordeaux Apprentice.";
}else if (totalCorrect >= 0 && totalCorrect < 5){
totalOutput_txt.text = "You answered " + totalCorrect + "/" + numQuestions + " correctly."+newline+" You are a Bordeaux Novice.";
}
// Show the user's score in an onscreen text field.
//totalOutput_txt.text = "You answered " + totalCorrect + "/" + numQuestions + " correctly" ;
// Customize the font face, size, and color of the text field.
var format = new TextFormat();
format.size = 20;
format.color = 0xFFCC00;
format.font = "candara";
format.bold = true;
totalOutput_txt.setTextFormat(format);
}
I added:
PHP Code:
if ( totalCorrect > 13){
totalOutput_txt.text = "You answered " + totalCorrect + "/" + numQuestions + " correctly."+newline+" You are a Bordeaux Master!!!";
}else if(totalCorrect > 10 && totalCorrect < 12){
totalOutput_txt.text = "You answered " + totalCorrect + "/" + numQuestions + " correctly."+newline+" You are a Bordeaux Pro.";
}else if(totalCorrect >6 && totalCorrect < 9){
totalOutput_txt.text = "You answered " + totalCorrect + "/" + numQuestions + " correctly."+newline+" You are a Bordeaux Apprentice.";
}else if (totalCorrect >= 0 && totalCorrect < 5){
totalOutput_txt.text = "You answered " + totalCorrect + "/" + numQuestions + " correctly."+newline+" You are a Bordeaux Novice.";
}
and comment out or delete this line:
PHP Code:
// Show the user's score in an onscreen text field.
totalOutput_txt.text = "You answered " + totalCorrect + "/" + numQuestions + " correctly" ;
IMS