The Review Area.
Some people love it, most people hate it, either way it’s an aspect of Question Widgets, and Question Widgets are what I’m teaching.
What is the Review Area?
In theory, the Review Area is supposed to supply the audience feedback on how they answered the question. When they answer it correctly, the Review Area has the stock response of ‘You answered this correctly!’ It’s when the audience gets the question wrong where things get complicated. The general consensus is that there is only one correct answer and many wrong answers. Not that this is true in real life, but that’s how it works in Captivate. So although you can only have one message for when the answer is correct, which is controlled in the Review Area’s properties…
…You could have potentially unlimited messages for each way the audience can get the question wrong. So Captivate allows the widget to take control of what feedback will be given if the question is incorrect.
This feedback is controlled by WidgetFactory’s Answer objects.
The Review Area and Question Widgets
Here’s the theory: You create an answer object to represent how the audience answered the question. These answers, once created, are added to an answer list. Then after the question has been submitted, Captivate takes the answer list and displays it in the review area.
An answer object has three properties, each of which are Strings:
- answerID: Something to identify this answer object when it is dealt with by compareAnswers (See next section)
- chosenAnswer: What will appear in the ‘Your Answer’ section of the Review Area.
- correctAnswer: What will appear in the ‘Correct Answer’ section of the Review Area.
So here’s what you do:
- Import the Answer class: import widgetfactory.Answer;
- Create an Answer object: var answer:Answer = new Answer();
- The constructor for the Answer class, the () in the new Answer()bit, takes three parameters. These parameters correspond to the three properties above: answerID, chosenAnswer, and correctAnswer. answerID is required, the others are optional. So at the very least, you would have to have something like: new Answer(“answerIdentity”);
- If you don’t define chosenAnswer and correctAnswer in the step above, then use the answer object’s properties to assign them a value. For example: answer.correctAnswer = “Red”; answer.chosenAnswer = “Blue”;
- Add the answer to the answer list with QuestionWidget’s addAnswer() method: addAnswer(answer).
Let’s see how that looks in an example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | package { import widgetfactory.Answer; import widgetfactory.QuestionWidget; public class ReviewAreaExampleOne extends QuestionWidget { override protected function submit():void { var answer:Answer = new Answer("answer1"); answer.chosenAnswer = "User's Answer"; answer.correctAnswer = "Correct Answer"; // You could also write: // var answer:Answer = new Answer("answer1","User's Answer", "Correct Answer"); // That would give you the exact same object. addAnswer(answer); } } } |
Click here to download this widget.Have a play around with the chosenAnswer and correctAnswer values and see how they come up in the Review Area.
You may be wondering what happens if you add multiple answers to the answer list.
1 2 3 4 5 6 7 | override protected function submit():void { var answer1:Answer = new Answer("answer1","User's Answer", "Correct Answer"); var answer2:Answer = new Answer("answer2", "User's Other Answer", "Other Correct answer"); addAnswer(answer1); addAnswer(answer2); } |
In that case, all answers are displayed in the Review Area separated by comas.
Note that Answers have no effect on how the question is scored. If the correctAnswer and chosenAnswer properties don’t match, it’s not going to score the question as incorrect. Scoring is ONLY handled by isCorrectAnswer.
For some Question Widgets, just a static response like “You got it wrong dude” will be fine. With other ones you may have a chance to give valuable feedback. For example, say you built a Question Widget that was a hangman game. If during the game you recorded what letters the audience guessed, then you could assign them to chosenAnswer, while correctAnswer held what the correct letters would have been.
Although this works quite well for hangman, as it is a text based game, it would be much more difficult to give meaningful feedback for a certain Drag and Drop widget.
There is however, another way Answers could come in useful.
Advanced Question Reviewing
Answers work in tandem with the compareAnswers Template Method. Let’s meet that method.
1 2 3 4 |
You may recognize some of those parameters. Yep, they’re the same as Answer class’ properties. When the audience reviews the quiz, compareAnswers() is called for each answer in the answer list. With this information about how the audience answered the question, the widget could provide some visual feedback to show how the question should have been answered. For example, what if we added some code to the Question Widget we made in Part 1 to make the button we pressed glow when we review the question.
All we need to do is add a few lines to the submit method and add the compareAnswers method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | override protected function submit():void { // Create the answer. var answer:Answer = new Answer("AnswerID"); // The correct answer is always going to be the same. answer.correctAnswer = "CorrectButton"; // Unless otherwise stated, the question is complete. isCompleteAnswer = true; // If the correctAnswerButton is selected... if (correctAnswerButton.selected == true) { // ...then the question is answered correctly isCorrectAnswer = true; // Set the chosen answer to be the same as the correct answer. answer.chosenAnswer = answer.correctAnswer; // if the incorrectAnswerButton is selected... } else if (incorrectAnswerButton.selected == true) { // ...then the question is answered incorrectly isCorrectAnswer = false; // Set the chosen answer to be the incorrect button. answer.chosenAnswer = "IncorrectButton"; // If no buttons are selected... } else { // ...then the question hasn't been answered at all isCompleteAnswer = false; } // Add our answer to the answer list. addAnswer(answer); } // Review quiz time override protected function compareAnswers(answerID:String, chosenAnswer:String, correctAnswer:String):void { // If the question was answered correctly... if (chosenAnswer == correctAnswer) { // ...make the correctAnswerButton glow green. correctAnswerButton.filters = [new GlowFilter(0x00FF00,1,6,6,2,3)]; // If the question was answered incorrectly... } else { // ...make the incorrectAnswerButton glow red. incorrectAnswerButton.filters = [new GlowFilter(0xFF0000,1,6,6,2,3)]; } } |
Click here to download this widget.
Of course, in this case it would probably be easier to check the isCorrectAnswer property to see how the question was answered, but don’t rain on my parade.
You can see how if you had multiple answers and just the chosenAnswer and correctAnswer properties to work with in compareAnswers, it could become difficult to determine which answer you’re currently dealing with. This is why we have the answerID.
Sometimes you may just want to use this Template Method to run code when the question is being reviewed. However, compareAnswers() will not be called without any answers to compare! So if make sure you have at least one answer in the answer list.
Here ends the Question Widget Saga. That is unless anyone has any further questions on Questions?


