Steven Warwick Part 2 - A Deeper Dive Into Developing Custom Interactions in Adobe Captivate Using JavaScript
Steven Warwick Part 2 - A Deeper Dive Into Developing Custom Interactions in Adobe Captivate Using JavaScript
WITH JAVASCRIPT
ADVANCED TECHNIQUES FROM A WEB DEVELOPER’S PERSPECTIVE
HTTPS://GITHUB.COM/SDWARWICK/CAPTIVATE-DEMOS
Downside
• Steeper learning curve – HTML/CSS/Jquery/Captivate
• Lots of cool stuff is undocumented by Adobe, discovered and published by developers
Downside:
• Files “outside” a module are only accessible when using http:// not file://
• No Captivate “preview” mode - must “publish”
• Use local web server
• Move file inside module - automation
COPYRIGHT (C)2017 ELEARNING OCEAN LLC 11
HOW TO WORK EFFICIENTLY WITH JAVASCRIPT
On enter execute JavaScript + continue playing project
if( !externLoaded ) {
$('body').append('<script src="../multichoice.js" async="false"></script>');
$(fontLink).appendTo("head");
externLoaded = true;
}
• JavaScript file is outside of course module, is not deleted when module is re-
published
• Add to every slide in cases where LMS can jump past first slide
Rules:
No scoring until “Submit” is pressed
True/false toggles correctly
Score for each answer may be different
+25 points for 4/5 right answers
+50 points for 5/5 right answers
Strategy:
All of the user interactions managed by
JavaScript
Over the years, many people have contributed to weeding through the CPM.js code to find these functions
COPYRIGHT (C)2017 ELEARNING OCEAN LLC 18
EXAMPLE CUSTOM QUIZ INTERACTION - SCORING
• The first line triggers the quiz submit function
for the button with the ID “submitButton”
“team”
Drop Target All scoring functions in JavaScript
Each time a “candidate” is dropped, “game1drop()” is called
“team”
Object Actions
“candidates”
Source Pool
“team” correct
Answer pool
CPM.js code is well organized with very descriptive top level function names
• https://helpx.adobe.com/captivate/using/common-js-interface.html
cpAPIInterface.getVariableValue Returns the value of the given variable name.
cpAPIInterface.setVariableValue Sets value of the given variable name
cpAPIInterface.play Plays the movie.
cpAPIInterface.pause Pauses the movie.
cpAPIInterface.stop Stops the movie.
cpAPIInterface.rewind Rewinds and plays the movie.
cpAPIInterface.next Seeks the movie to the next slide.
cpAPIInterface.previous Seeks the movie to the previous slide.
cpAPIInterface.fastForward Increases the movie speed to 2x, then 4x and then back to normal on consecutive calls.
cpAPIInterface.getPlaySpeed Returns movie playback speed in Frames per second (fps).
cpAPIInterface.getDurationInFrames Returns the total number of frames in the movie.
cpAPIInterface.getDurationInSeconds Returns the total duration of the movie in seconds.
cpAPIInterface.getVolume Returns the volume of the movie in percentage.
cpAPIInterface.setVolume Sets the volume of the movie.
cpAPIInterface.navigateToTime Seeks to a particular time (milliseconds) in the movie.
cpAPIInterface.canNavigateToTime Returns a boolean value showing whether you can seek to a particular time in the movie or not.
cpAPIInterface.getCurrentFrame Returns the current frame of the movie.
cpAPIInterface.getCurrentSlideIndex Returns the current slide index of the movie.
cpAPIInterface.getEventEmitter Returns the handle to the cpAPIEventEmitter object.
• https://helpx.adobe.com/captivate/using/common-js-interface.html
cpAPIEventEmitter.addEventListener (event, function )
cpAPIEventEmitter.removeEventListener( event )
CPAPI_SLIDEENTER
CPAPI_SLIDEEXIT
CPAPI_STARTPLAYBARSCRUBBING
CPAPI_ENDPLAYBARSCRUBBING
CPAPI_INTERACTIVEITEMSUBMIT
CPAPI_MOVIEPAUSE
CPAPI_MOVIERESUME
CPAPI_MOVIESTART
CPAPI_MOVIESTOP
CPAPI_QUESTIONSKIP