Captivate | Show instant feedback on selecting an an option in quiz question

Author - Neelam

In Adobe Captivate on a question slide if we want some feedback to be displayed instantly when user clicks radio button to select an option, it will not work. There is no option out of the box to achieve this. But it can be achieved with Javascript.

On entering a new slide we can associate an event handler to the radio button click event which will show the feedback. Initially, feedback text/shape will be hidden on the page. The radio button click handler function will display the feedback.

Sample Code:

correctIndexId = "si39403r_radioInputField"; //id of correct option
correctMsgBoxName = "CB1"; //name of correct feedback shape
incorrectMsgBoxName = "ICB1"; //name of incorrect feedback shape 
waitTime = 1000;
setTimeout(function() {
document.addEventListener('click', function(evt) {
    if (evt.target.type == 'radio') {
    if (evt.target.id == correctIndexId) // check if clicked option is correct answer or not
        {
        cp.show(correctMsgBoxName); //show correct feedback
        cp.hide(incorrectMsgBoxName); //hide incorrect feedback
         } else {
        cp.show(incorrectMsgBoxName); //show incorrect feedback
        cp.hide(correctMsgBoxName); //hide correct feedback
          }
         }
        }, false);
    } //end settimeout function,waitTime);

Note: We have used set timeout function to give sufficient time to the browser to load the page with all its HTML first before trying to attach the event.

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published. Required fields are marked *