Copy link to clipboard
Copied
I'm using Captivate CS4 and I've created my own simple question widget in Flash, (using AS2, because I've been asked to add a question to a quiz that is already in AS2). In Flash I've got three keyframes... Frame 1 offers two buttons, pressing button A goes to Frame 2, button B goes to Frame 3. Frame 3 has a "Try Again" button leading back to Frame 1. All of that is working, and there are no compilation errors. When I insert the widget in Captivate it adds a Quiz summary and gets the correct total score. But I can't set or get any variables in the widget...clicking Submit always says "Please answer all the questions"
How do I tell the Quiz that Button A is correct, Button B is incorrect, and "Try Again" should reinitialize myAnswer as an empty string?
Thanks
function answersIncomplete(mustAnswerAll:Boolean):Boolean {
return true;///false; //to force the user to answer completely
}
Please implement this function. accordingly. It should return true if the answers are incomplete and false if they are complete. As the default is true,captivate treats your question as always incomplete.
Copy link to clipboard
Copied
Hi folks,
I should add that I'm using the updated template from Build 1658, and I hope I might also have better luck if I include some code. I know it's primitive, I really thought it'd be an easy self-learning thing, but I already need help, and I'm not too proud to say so!
From template top, just what I've added or changed (in green😞
//..........................Template for Question widget(AS2)....................
//flash construct to use external interface : This is needed to use flash functionality for communication between two swfs
import flash.external.ExternalInterface;
var widgetMode:String = '';
var varHand;
// My Globals
var myAnswer:String = (myAnswer == undefined) ? '' : myAnswer;
var myCorrectAnswer:String = 'A';
var gotItRight:Sound = new Sound();
gotItRight.attachSound("correct");
var gotItWrong:Sound = new Sound();
gotItWrong.attachSound("wrong");
var jeopardy:Sound = new Sound();
jeopardy.attachSound("jeopardy");
//----------------------------
I customized someof the stock functions in the mid section...
function enableAnswers() {
trace("enableAnswers() called.");
btnTheCode.enabled = true;
btnTheLaws.enabled = true;
}
function disableAnswers() {
trace("disableAnswers() called.");
btnTheCode.enabled = false;
btnTheLaws.enabled = false;
}
function clearAnswers() { // This one actually works from the Clear button in the quiz
trace("clearAnswers() called.");
setChosenAnswer(""); gotoAndPlay(1);
}
Everything else I added at the bottom of the template (see below). It all works within the widget, but does not communicate with the Captivate Question Page, so I can't "mark" the students' quiz.
Can anyone tell me what I missed?
// MY STUFF
function setButtonState()
{ // disable buttons if answered correctly
if (evaluateAnswer())
{
disableAnswers();
}
else
{
enableAnswers();
}
}
function setChosenAnswer(a:String):String
{
myAnswer = a;
trace("setChosenAnswer(): set myAnswer = '"+a+"'.");
return myAnswer;
}
function getChosenAnswer():String
{
var answerString:String = "";
answerString = myAnswer;
trace("getChosenAnswer(): answerString is '"+answerString+"'.");
return answerString;
}
function evaluateAnswer():Boolean {
var answerString:String = String(getChosenAnswer());
var retVal:Boolean = (answerString.toUpperCase() == myCorrectAnswer.toUpperCase()) ;
var correctness = (retVal) ? 'correct!' : 'NOT correct.' ;
trace("This answer is "+correctness);
return retVal;
}
function answers():Array{
var answers:Array = new Array();
var ans:Object = new Object();
ans.answerID = "1";
ans.chosenAnswer = getChosenAnswer();
ans.correctAnswer = myCorrectAnswer ;
answers["my_answer"]= ans;
trace("Called answers(): answerID = '"+answers["my_answer"]["answerID"]+"'. chosenAnswer = '"+answers["my_answer"]["chosenAnswer"]+"'. correctAnswer = '"+answers["my_answer"]["correctAnswer"]+"'.");
return answers;
}
// Entering frame...
stop();
btnTheCode.onPress = function () { trace("Pressed btnTheCode."); setChosenAnswer("A"); jeopardy.stop(); gotItRight.start(); answers(); evaluateAnswer(); gotoAndStop(2); }
btnTheLaws.onPress = function () { trace("Pressed btnTheLaws."); setChosenAnswer("B"); jeopardy.stop(); gotItWrong.start(); answers(); evaluateAnswer(); gotoAndStop(3); }
btnSorry_en.onPress = function () { trace("Pressed btnSorry_en."); setChosenAnswer(getChosenAnswer()); answers(); evaluateAnswer(); gotoAndStop(1); }
//
Thanks for any help!
Copy link to clipboard
Copied
function answersIncomplete(mustAnswerAll:Boolean):Boolean {
return true;///false; //to force the user to answer completely
}
Please implement this function. accordingly. It should return true if the answers are incomplete and false if they are complete. As the default is true,captivate treats your question as always incomplete.
Copy link to clipboard
Copied
Thanks Vikram, that got it first try. As I said I had the variables set up and trace() was reporting everything working internally. It should have been obvious, but all that was left to do was to add an IF in the function you indicated:
function answersIncomplete(mustAnswerAll:Boolean):Boolean {
if (myAnswer == "") {
return true;
}
}
Cheers!