0% found this document useful (0 votes)
107 views

Steven Warwick Part 2 - A Deeper Dive Into Developing Custom Interactions in Adobe Captivate Using JavaScript

Uploaded by

deathvim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views

Steven Warwick Part 2 - A Deeper Dive Into Developing Custom Interactions in Adobe Captivate Using JavaScript

Uploaded by

deathvim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

EXTENDING ADOBE CAPTIVATE

WITH JAVASCRIPT
ADVANCED TECHNIQUES FROM A WEB DEVELOPER’S PERSPECTIVE
HTTPS://GITHUB.COM/SDWARWICK/CAPTIVATE-DEMOS

STEVEN WARWICK, ELEARNINGOCEAN.COM


[email protected]

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 1


AUDIENCE
• Learning interaction designers
• Project managers / Course strategy developers
• Web Developers
• eLearning methodology strategists
• Content Authors

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 2


CONTEXT
• Captivate
• HTML projects
• “Responsive” design
• Windows 10 development environment
• JavaScript ECMA 2015
• Chrome browser
• Notepad++ text editor

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 3


PLAN
• Captivate as a web development platform
• Efficient development of JavaScript/Captivate scripts
• Example Scripts
• Fully custom quiz interactions
• Full-screen mode
• D&D
• Adobe documented vs. undocumented functions
• Bridging between JavaScript and Captivate
• Overview of other possibilities with JavaScript
• Questions

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 4


CAPTIVATE FROM THE WEB DEVELOPERS PERSPECTIVE
• WYSIWYG website builders:
• “Closed” builders generate sites that cannot easily be modified after being generated
• Easy to get started building, limited access to potential of modern design
• Weebly, Wix, Squarespace
• “Open” builders support direct modification of generated sites & continued editing
• Deeper understanding of web technologies needed
• Pinegrow, Bootstrap Studio, Bootply

• Captivate – 90% closed / 10% open


• Custom features valuable for eLearning
• Reasonable strategy given initial target audience

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 5


ANATOMY OF A WEBSITE (CAPTIVATE FILE LAYOUT)

• A module produced by Captivate is structured in a very common website design style


• A zipped module is simply a single-file version of this exact directory structure
• When a captivate module is loaded into an LMS, the zip file is simply uncompressed by the LMS
• Websites typically need to be “served” by a server program (apache/nginx) in case external
content needs to be loaded
• When all content is inside the module directory, a browser can be used to view the website (file://)
COPYRIGHT (C)2017 ELEARNING OCEAN LLC 6
ANATOMY OF A CAPTIVATE WEBSITE
HTML CSS Javascript

• Same structures are seen in Captivate as in all websites


• “CPM.js” file contains
• All content data – shapes, text, timing, placement, quiz
• Captivate JavaScript Library that “runs” the website
• Since the file is compressed, it is hard to decipher
COPYRIGHT (C)2017 ELEARNING OCEAN LLC 7
WHY JAVASCRIPT?
• Most popular programming language – StackOverflow / Github
• Used for both user interaction in browser and business logic on server
• Access all the power of the browser
• Completely free development environment
• All Browsers have powerful, built-in debugging tools
• Very fast design/test cycle - no “publishing/compiling” process
• Most profound change in learning process – learning on demand
• Stackoverflow http://stackoverflow.com/insights/survey/2016
• 2.7Million questions, 3.2Million answers in 2015
• Thousands of tutorials

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 8


WHY USE JAVASCRIPT WITH CAPTIVATE
Upside
• All “Automation” functions in one place – Model/View/Controller Architecture
• JavaScript can control any aspect of UI
• Change shape properties, display notifications, react to any user event
• Create custom quiz interactions, unique animations etc..
• JavaScript functions can be debugged while the presentation is running, unlike advanced actions
• Many online tutorials for using JavaScript with Captivate
• Large subject area, no tutorial is can be comprehensive – point solutions and examples

Downside
• Steeper learning curve – HTML/CSS/Jquery/Captivate
• Lots of cool stuff is undocumented by Adobe, discovered and published by developers

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 9


HOW TO WORK EFFICIENTLY WITH JAVASCRIPT
• Internally supported approach: Use built-in JavaScript script window
• No syntax checking
• Must re-publish module to update
• Hard to maintain, code is sprinkled throughout the modules

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 10


HOW TO WORK EFFICIENTLY WITH JAVASCRIPT
Better approach:
• External file holds all JavaScript functions
• Changes in file will be loaded whenever the module is viewed, no need to re-
publish course – rapid development!

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

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 12


HOW TO WORK EFFICIENTLY WITH JAVASCRIPT

Notepad++ text editor as example

Far easier than built-in script window!


• JavaScript syntax and error highlighting

• Variable name validation

• Multiple windows, spell check etc.

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 13


DEBUGGING JAVASCRIPT WITH CHROME
F12 opens Chrome debugger!

Pauses execution of function,


enables complete debugging
environment in Chrome

Step-by-step debugging – unlike advanced actions

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 14


EXAMPLE – CUSTOM QUIZ INTERACTION
HTTPS://GITHUB.COM/SDWARWICK/CAPTIVATE-DEMOS

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

Quiz will be scored and submitted by JavaScript

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 15


EXAMPLE – CUSTOM QUIZ INTERACTION
• Slide “on enter execute JavaScript”: Add script file and links to fonts
$('body').append('<script src="../multichoice.js" async="false"></script>');

var fontLink = '<link href="https://fonts.googleapis.com/css?family=Calligraffitti" rel="stylesheet">';


$(fontLink).appendTo("head");

• All buttons are simple circle smartshapes


with “use as button”

• Add an additional state called “selected”


• This will be controlled by JavaScript

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 16


EXAMPLE – CUSTOM QUIZ INTERACTION
• The shapes are labeled using a
regular pattern that will be easily
distinguished in the JavaScript
Code

• The hidden answer buttons are all


set to “Include in Quiz” and points
can be assigned to each answer

• Add variables to enable


connection between JavaScript
and Captivate

• That’s it.. no advanced actions


COPYRIGHT (C)2017 ELEARNING OCEAN LLC 17
EXAMPLE CUSTOM QUIZ INTERACTION - TOGGLE
Find all buttons that start with the word
“Question”. When clicked, call
“manageToggleButtons function

Take the name of the button that was


pressed, changes any “_T_” to “_F_”
and any “_F_” to “_T_”

Call an undocumented captivate function


“cp.changeState” to toggle between the
“Normal” view and the “selected” view

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”

• Variables defined in captivate can be


directly used in JavaScript!

• The correct answers are defined by which of


the question buttons were set to state
“selected”

• If the correct answer is selected, which hidden


button should be activated?

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 19


EXAMPLE CUSTOM QUIZ INTERACTION - SCORING
When writing code, try to keep things flexible..

• Determine maximum number of questions,


maximum score, answered questions and score
values on the fly

• Here’s how to get the value of a quiz button

• Here’s how to find the state of a slide object

• If the right button was selected then we call


another undocumented function that signals to
captivate that an answer was given correctly.

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 20


EXAMPLE CUSTOM QUIZ INTERACTION - SCORING
Find quiz value for the bonus points by
looking at the Captivate data

Award points based on some criteria -


here it is at least 4 answers right

Here it is 5 answers right…

After done, signal to move to next slide


by simply setting the “next slide” flag
variable
COPYRIGHT (C)2017 ELEARNING OCEAN LLC 21
EXAMPLE – CUSTOM QUIZ INTERACTION
Why is this example important?
• Other than labeling the buttons, setting question values and loading the external JavaScript
module, no advanced actions or special processing is needed
• The scoring is completely general. Any set of button presses can be used to generate a
specific quiz result
• Scoring doesn’t happen for any of the quizzing until the interaction is complete
• Custom interactions need not be limited to one “slide”
• Although not shown, at any point in the process, additional information can be given to the
user
• Other measures can be made along the way:
• How many times has the user changed their score?
• How long did it take before the user completed the quiz?

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 22


EXAMPLE – “FULL SCREEN” MODE
• Any button that has a name starting in “fullscreen” will activate this code

• Also works for presentations embedded in other applications (IFRAME)

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 23


EXAMPLE – DRAG AND DROP
HTTPS://GITHUB.COM/SDWARWICK/CAPTIVATE-DEMOS

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 24


EXAMPLE – DRAG AND DROP
HTTPS://GITHUB.COM/SDWARWICK/CAPTIVATE-DEMOS

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 25


EXAMPLE – DRAG AND DROP
HTTPS://GITHUB.COM/SDWARWICK/CAPTIVATE-DEMOS

“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

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 26


EXAMPLE – DRAG AND DROP
HTTPS://GITHUB.COM/SDWARWICK/CAPTIVATE-DEMOS

Let JavaScript figure out what source


item was moved

Create scoring based on some criteria


- count of dragged components
- value score for team member

Give feedback by changing colors of


shapes directly using CSS on shapes

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 27


UNDOCUMENTED CAPTIVATE FUNCTIONS AND
DATA STRUCTURES..
The CPM.js library
• 25,000 JavaScript statements in the basic library to “run” a presentation
• 100,000+ statements to define all objects in a large presentation
CPM.js defines 100+ “top level objects/properties”
CP top object - defines 751 objects/properties
CP.D - all of the slide objects and quizzing information
CP.DD - drag/drop interaction data
CP.em - event manger
CP.movie – timing manager

Lots of other things, too much to even begin to describe..


• Animation
• Display timing
• Quiz handling
• Drag/Drop interactions
• LMS Reporting system..

CPM.js code is well organized with very descriptive top level function names

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 28


UNDOCUMENTED CAPTIVATE FUNCTIONS AND
DATA STRUCTURES USED IN THESE TWO EXAMPLES
cp.changeState(targetID, state)
cp.getCurrentStateNameForSlideItem(targetID);
cp.show(targetID) , cp.hide(targetID)
cp.D[targetID].qnq (find question data for targetID)
cp.D[questionID].w (question score value – can read and write!)
cp.SubmitInteractions(targetID, cp.QuestionStatusEnum.CORRECT, 0) (click answer button!)

cp.DD.CurrInteractionManager.getActiveInteraction() (get activeDDInteraction)


activeDDInteraction.m_DsFrameSetDataID; (id of last dropped target)
ActiveDDInteraction.OnResetButtonClicked(); (click DD reset button)
activeDDInteraction.undoAvailable (check if undo is available)
activeDDInteraction.OnUndoButtonClicked();
activeDDInteraction.OnSubmitButtonClicked();

cp.RuntimeMessageBox(document.getElementById("cpDocument"), 1) (create a new message box)

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 29


DOCUMENTED CAPTIVATE/JAVASCRIPT FUNCTIONS

• 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.

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 30


DOCUMENTED CAPTIVATE/JAVASCRIPT EVENTS

• 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

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 31


FAR TOO MUCH TO “FIGURE OUT” IN CPM.JS
What is an efficient custom interaction development strategy?
• Build basic shapes and simple interactions that do not require advanced actions directly
in Captivate
• Use Adobe Documented JavaScript library as starting place

• Developers familiar with HTML/CSS/JAVASCRIPT:


• Build custom interactions decoupled from the Captivate data structures as much as
possible
• Bridge back into Captivate using the CPM.js library functions
• Leverage undocumented features only as needed

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 32


JAVASCRIPT TO CAPTIVATE BRIDGE
• All shape information is found in the object CP.D
• cp.D.shapename
• cp.D.shapenamec
• cp.D.shapenameq0
• Shape name is used as a base to build HTML
<div id=theSquare>
<canvas id=theSquarec>
<div id=theSquare_vTxtHolder>
<div id=re-theSquarec>
<div id=theSquare_vTxtHandlerHolder>
<div id=theSquareaccStr>
• Use these objects to create custom effects

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 33


JAVASCRIPT TO CAPTIVATE BRIDGE
• All variables in captivate are now global JavaScript variables
Example: cpInfoCurrentSlide == cpAPIInterface.getVariableValue("cpInfoCurrentSlide")

• Event-driven JavaScript functions ( mouse clicks.. )


• Indirect: use actions and scripts in captivate (captivate dependency)
• Direct: use JavaScript events tied directly to HTML objects (JavaScript only)
• Captivate monitors all variable values once every frame interval ( 1/30 sec )
• Simply setting timing-control variables to “true” will cause changes in state
• Example: cpCmndNextSlide = 1
• Quiz management has another data structure, too much to describe here

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 34


CPM.JS INTERNALS
Notepad++ JavaScript formatter
Convert compressed CPM.js to readable code
Save formatted version back into project

Enables modification & debugging

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 35


105 “TOP LEVEL” VARIABLES GENERATED BY CPM.JS
cpCmndGotoSlideAndResume _cpInfoPrevSlide cpInfoCurrentDateString cpQuizInfoTotalQuizPoints
cp cpCmndGotoSlideByUIDAndResume cpInfoLastVisitedSlide cpInfoCurrentDateStringDDMMYYYY cpQuizInfoAttempts
cpXHRJSLoader cpCmndResume _cpInfoLastVisitedSlide cpInfoCurrentLocaleDateString cpQuizInfoTotalQuestionsPerProject
cpAPIInterface cpCmndPause cpInfoCurrentSlide cpCmndGotoQuizScopeSlide cpQuizInfoQuestionPartialScoreOn
cpAPIEventEmitter cpCmndExit cpInfoCurrentSlideIndex cpQuizInfoLastSlidePointScored cpQuizScopeSlide
cpCmndVolume cpLockTOC _cpInfoCurrentSlide cpQuizInfoQuestionSlideType cpInQuizScope
cpCmndMute cpCmndInfo cpInfoCurrentSlideLabel cpQuizInfoAnswerChoice cpQuizInfoPassFail
cpCmndCC cpCmndTOCVisible _cpInfoCurrentSlideLabel cpQuizInfoMaxAttemptsOnCurrentQuestion cpInfoCourseID

cpCmndNext cpInfoSlidesInProject cpInfoSlideCount cpQuizInfoPointsPerQuestionSlide cpInfoCourseName


cpCmndNextSlide cpInfoFPS cpInfoIsStandalone cpQuizInfoNegativePointsOnCurrent cpQuizInfoPreTestTotalCorrectAnswers
cpCmndPrevious cpInfoAuthor cpInfoHasPlaybar QuestionSlide cpInReviewMode
cpCmndNextOnReview cpInfoCompany cpInfoCurrentSlideType cpQuizInfoQuestionSlideTiming cpQuizInfoPreTestTotalQuestions
cpCmndPreviousSlide cpInfoEmail cpInfoIsResultSlide cpQuizInfoQuizPassPoints cpQuizInfoPreTestMaxScore
cpCmndPreviousOnReview cpInfoWebsite cpInfoElapsedTimeMS cpQuizInfoQuizPassPercent cpInfoMobileOS
cpCmndPlaybarMoved cpInfoCopyright cpInfoEpochMS cpQuizInfoTotalProjectPoints cpQuizInfoStudentID
cpCmndShowPlaybar cpInfoProjectName cpInfoCurrentMinutes cpQuizInfoTotalUnansweredQuestions cpQuizInfoStudentName
cpCmndFastForward cpInfoDescription cpInfoCurrentHour cpQuizInfoNoQuestionsPerQuiz cpQuizHandledAll
cpCmndRewindAndPlay cpInfoCurrentFrame cpInfoCurrentTime cpQuizInfoPointsscored
cpCmndRewindAndStop _cpInfoCurrentFrame cpInfoCurrentDay cpQuizInfoPretestPointsscored
cpCmndGotoFrame cpInfoPrevFrame cpInfoCurrentYear cpQuizInfoPretestScorePercentage
cpCmndGotoFrameAndResume cpInfoFrameCount cpInfoCurrentMonth cpQuizInfoTotalCorrectAnswers
cpCmndGotoSlide cpInfoPrevSlide cpInfoCurrentDate cpInfoPercentage

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 36


WHAT ELSE DOES JAVASCRIPT OPEN UP?
• References to external content – fonts, libraries
• Real-time, group interactions with backend data sources (AJAX)
• Video game-level animations
• Dynamic Graphing and Charting
• Fine-grained experience measurement
• Pass information between parent/child windows
• Custom reporting to LMS/LRS
• Access to the entire web development community!

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 37


QUESTIONS?

Steven Warwick, eLearningOcean LLC


[email protected]

COPYRIGHT (C)2017 ELEARNING OCEAN LLC 38

You might also like