Skip to main content
ralantess
Known Participant
June 8, 2016
Question

Activating a Button...

  • June 8, 2016
  • 3 replies
  • 1208 views

Hello there,

I added a smart shape button on a question slide. I want it to be active when an answer selection checkbox is clicked, till then I want it to stay deactivated. Is it possible please??

Thank you...

    This topic has been closed for replies.

    3 replies

    TLCMediaDesign
    Inspiring
    June 8, 2016

    If you are using html5 you can include this JavaScript or insert it in the head of the html document.

    There is a function call ed myClick where you can show or enable the button. Just put the smartshape button name in the quotes:

    var interfaceObj, eventEmitterObj;

    window.addEventListener( 'moduleReadyEvent', function ( e )
    {
    interfaceObj = e.Data;
    eventEmitterObj = interfaceObj.getEventEmitter();
    initializeEventListeners();
    });

    function initializeEventListeners()
    {
    if ( interfaceObj )
    {
         if ( eventEmitterObj )
      {
             eventEmitterObj.addEventListener( 'CPAPI_SLIDEENTER', function ( e )
       {    
        if ( window.cpInQuizScope )
        {    
         res = cp.model.data.project_main.slides.split( ',' );
         cSlide = res[ window.cpInfoCurrentSlide - 1 ];    
         thisSlide = cp.model.data[ cSlide ];
     
         for ( var i = 0; i < thisSlide.si.length; i++ )
         {     
          if ( cp.model.data[ thisSlide.si[ i ].n ].hasOwnProperty( 'qdi' ) )
          {
           var temp = cp.model.data[ thisSlide.si[ i ].n ].qdi.toString();      
           document.getElementById( temp ).addEventListener("click", myClick);
          }
         }
        }

       
        function myClick( e )
        {
         cp.show( 'smartshape_btn' );
         cp.enable ( 'smartshape_btn' );    
        }
         
                });  
      }
    }
    }

    ralantess
    ralantessAuthor
    Known Participant
    June 8, 2016

    Thank you very much but I am not that much capable of the program...

    Lilybiri
    Legend
    June 8, 2016

    If you don't want to use JS as TLCMediaDesign suggested, you'll have to change your strict requirement to have this happening when an answer on a default question slides is clicked. Quiz slides have pretty strict rules, there are some workarounds as I describe in several blog posts, but what you want is not possible because clicking on an answer is not an 'event' as both Rod and myself explained. Either you accept that only clicking on the Submit button will make it possible to show the 'correct answer', either using the default Feedback messages, either by using custom objects as I explained in this blog post:

    http://blog.lilybiri.com/question-question-slides-in-captivate

    Another approach is to create custom question slides: you use standard objects like text containers,  buttons/shape buttons, variables and advanced actions. Each answer will be clickable if it is an interactive object, which means you have a Success event and can show/enable whatever you want. Beware: reporting to a LMS will be a little bit more complicated, but it is possible.

    Lilybiri
    Legend
    June 8, 2016

    Each action, and disabling/enabling a shape button is an action, has to be triggered by an event.

    On question slides you only have the On Enter event, and the Success/Last Attempt events. The last events occur after the two-step process for Submitting, not after a selection of an answer.  If you explained the goal of that button, maybe another approach could be possible? I explained some use cases for shape buttons on question/score slide in this article:

    http://blog.lilybiri.com/want-a-button-on-question-slide-in-captivate

    If you want to see a complete list with available events out of the box in Captivate:

    http://blog.lilybiri.com/events-and-advanced-actions

    RodWard
    Community Expert
    Community Expert
    June 8, 2016

    There is no run-time event available from selection of an answer option that you could use to trigger an Advanced Action that SHOWs or ENABLEs a button on the Quiz Slide. 

    You'd need some kind of custom programming or a specialized widget to pull this off, but those quiz answer captions do not have Object Names that can easily be referenced by a widget to trigger an event.

    ralantess
    ralantessAuthor
    Known Participant
    June 8, 2016

    Thank you RodWard. Lilybiri, to be specific, I'm aiming to show the correct answer info text with that button after the selection was made before moving to the next question...

    Thank you both..

    RodWard
    Community Expert
    Community Expert
    June 8, 2016

    Yes it's pretty obvious where you'd be going with this but the fact remains, you don't have an event you can use to make something happen.  Without that you're stuck.