13 Replies Latest reply on Apr 27, 2010 6:10 AM by Michael V Baker

    Captivate JavaScript


      We have recently bought captivate and I have to say that I am very disappointed by the documentation.


      I am totally horrified by the JavaScript that is generated.


      The browser checks are looking for Netscape and it is generating VBScript for the client.


      This obviously has not been updated for some time and is of a very poor quality.


      I also have had no answers to my questions in these forums.


      The only example I can find of communicating with the flash movie is in this link which is in cold fusion of all thngs:




      In the above link, it tells you to fudge the generated JavaScript to get it to work by and I quote

      The first area is to force a variable g_objAPI to some value. This tells the  content that the SCORM-API has been found. In the example

      Is this really what is required?

      How would anyone of known this.


      This product is a disgrace.

        • 1. Re: Captivate JavaScript
          Captiv8r Adobe Community Professional & MVP

          Hi there


          Many folks are using Captivate quite successfully.


          Did you acquire it so you could have a fancy JavaScript generator or did you acquire it to provide eLearning?


          I'm confused about your issues with JavaScript because probably 98% of Captivate authors have no need whatsoever to look beyond the files it creates and tweak the script. Yet it just seems to work.


          What are you attempting to do that requires deep knowledge of JavaScript? If you have posted before and seen no responses, odds are you are trying to do something way beyond the scope of knowledge of most of us here and as a result we have no clue how to help.


          Cheers... Rick


          Helpful and Handy Links

          Captivate Wish Form/Bug Reporting Form

          Adobe Certified Captivate Training

          SorcerStone Blog

          Captivate eBooks

          • 2. Re: Captivate JavaScript
            Michael V Baker Level 3

            Sorry I didn't see this sooner (and your other one about ASP.NET). I may have some of the answers you're looking for.


            The other post about ASP.NET suggests that you want send quiz info to a database (not necessarily ASP.NET - something SOAP compatible). You can do this with an action that calls JavaScript. Write your JavaScript that does the soap call and modify the html template so that it loads your JS. Include the JS file with your output of course. Then call the JS function from the Captivate file using CallJavascript action.


            A developer name Phillip Hutchinson has some info on www.pipwerks.com that outlines the contents of different variables inside the Captivate Quiz. You can get some quiz specific info at the end of the quiz or you can get some question specific info as the questions progress. What I found in my project is that you can't wait until the end of the quiz and 'loop through' all the questions to aggregate the info. I had to capture the variables and store them in the JS. The system I built would send the data to the database one question at a time or all at the end.


            This post is looking for info on SCORM. Are you looking for this because you couldn't find info on storing it to the database? Are you familiar with the SCORM spec and API or are you only interested in getting the data to the databse?



            • 3. Re: Captivate JavaScript
              dagda1970 Level 1

              Hi and thanks for the reply, I was starting to despair.


              My requirements are as follows:


              1.  Allow different users to take many quizzes

              2.  Record the score of the user taking the test.

              3.  Allow the user to suspend the test and complete the test at a later date

              by starting where they suspended the test,


              I would be over the moon if I could get the scores into JavaScript variables

              or interact with captivate in any way.  At the moment I am lost and I am not

              having much fun with the guidance.


              The only thing about SCORM I know is that it is one of the options I chose

              when creating the quiz.


              All I care about is getting the data into the database.  I have written a

              lot of AJAX and javascript so just knowing how to retrieve the scores is all

              I need to know.  Whether that is at the end of the quiz or during is not

              important.  I will find a way.


              I need to know how I interact with the API to retrieve the scores.


              The guidance is absolutely shocking on this.




              Paul Cowan


              Cutting-Edge Solutions (Scotland)



              • 4. Re: Captivate JavaScript
                Michael V Baker Level 3

                What you describe is very often done through the use of an LMS. There are many choices out there for LMS vendors some will host your content and run the whole show - you just create the content and post it to their LMS. They'll provide you with a number of various reports and they'll maintain the database for you and they keep updating the software. Some can be very expensive and only appropriate if you have tens of thousands of users.


                SCORM (Shareable Content Object Reference Model) is a protocol. A specification for communication between content and LMS (whether it's a commercially provided LMS or something you write yourself). It defines a certain set of data to be maintained and the API for the communication. You can find the details for that at www.adlnet.gov. It includes a set of canned JS that follows the protocol for persisting the quiz data to database. Captivate's an excellent tool for people who want to have this all done for them without having to code anything. Cp can implement an interactive training piece that submits the data to a SCORM compatible LMS without any code by the user at all.


                Here's some of the nitty gritty stuff you'll need to do in order to customize the data storage. When you create the Cp project and build the HTML file will contain an object.




                so = new SWFObject(....);


                so.addParam("name", "Captivate");


                You can use this name in your own JS to set and retrieve variables in the Captivate movie


                // returns the choice the user made



                Some of the troubles you'll find is that there's no variable that exposes the correct choice. You'll have to create a custom variable and set it to the correct answer whenever you enter the question. This has a bad smell to it because you can forget to change the correct answer in your own variable when you change the correct answer for the question. It's unfortunate duplication, but necessary AFAIK. I couldn't get the the text of the qestion or the type of question (m/c, t/f, fill in) through variables either - I had to create custom variables.


                Since you're just getting started (or appear to be) and you have coding experience, perhaps it would be better to build a custom tool in Flash Pro / Flash Developer.




                • 5. Re: Captivate JavaScript
                  www.cpguru.com Level 4

                  Just a little heads up:


                  3.  Allow the user to suspend the test and complete the test at a later date by starting where they suspended the test.


                  That is not possible with Captivate. A started quiz needs to be finished in order for it to score properly. Creating a "resume" feature that will return the user to the question where they left off will leave all previous questions unanswered and therefore result in a fail in the quiz. It is not possible to "inject" results from previously answered questions into Captivate again if you are resuming a project.


                  I'm not a JavaScript ninja but what you are after is definetely possible. If you don't need the SCORM API then I see no reason to use it at all. The SCORM API is intended to be used when deploying a course in an LMS. Modifying this to work with a database is probably possible but will be a pain.


                  I recently created a Flash widget that will grab quiz results and send these to a PHP script. The Captivate project is just published to web without any SCORM or other fancy stuff but simply uses the Captivate system variables to retireve the relevant information. The Flash widget is inserted on the quiz summary page and then sends the results to the PHP script. I'm sure that it would be possible to use ASP.NET instead of PHP.


                  I know that others have been "hacking" the "Send to email" reporting method. The standard Send to email functionality is flawed in Captivate, but some people have been rewriting the JavaScript that Captivate creates to handle the Send to email stuff and made it work with PHP etc.


                  As Michael said - Phillips site is an excellent resource on Captivate / JavaScript interaction so hopefully you will be able to find some explanations there.


                  James also have an article about Captivate/PHP/MySql integration here that you might find useful: http://wheatblog.com/2010/01/cp2db-adobe-captivate-quiz-reporting-with-phpmysql-version-2/


                  Good luck ;o)



                  Visit my Captivate blog with tips & tricks, tutorials and Widgets.

                  • 6. Re: Captivate JavaScript
                    dagda1970 Level 1

                    Thanks for the replies guys and I now have some good links for some research.


                    What I am not getting is why does the application expect to be running in an LMS by default?


                    Is this the common usage?


                    All I want is to be able to record the user's scores in the database.


                    Why would I want to use an LMS?  Why would I concern myself with SCORM?


                    Also the JavaScript generated is really old and is doing user agent tests for netscape 4.


                    THis is not filling me with much confidence about the product.

                    • 7. Re: Captivate JavaScript
                      www.cpguru.com Level 4

                      SCORM is a framework that is used only when deploying courses to an LMS so unless that you actually want to deploy your courses in an LMS there is no need to worry about it.


                      An LMS (Learning Management System) is essentially a database, which keeps track of your students, your courses, students scores etc. In my work we use an LMS to keep track of more than 30.000 students / employees, who have access to 100+ courses. The LMS manages access control, security, assigns relevant courses to different types of learner groups etc. Furthermore it keeps track of students track record in terms of courses passed, failed, not attempted, scores in the quizzes, certifications achieved bla bla bla.


                      Using Captivate to deploy courses to an LMS is a breeze and that is what the SCORM framework is for.


                      Whether or not SCORM / LMS deployment for Captivate content is the common usage or not I cannot answer. It depends greatly on what your needs are. For my company Captivate fills our needs very well since we deliver content through an LMS. A lot of users are producing Captivate content that run directly on the web or on CD/DVDs so I guess it fills their needs too.


                      What you are trying to do is to make Captivate do something that is not what it was designed to do originally. Captivate offers a variety of differerent publishing / reporting options and with these Captivate works just fine (with exception of the email reporting stuff). What you are looking to do is possible, but is not part of the standard package. If Adobe were to describe all possible uses and modifications that could be done then they wouldn't even have released Captivate 2 yet ;o)


                      Adobe has managed to create a tool with which newcommers to the e-learning world quickly can get started on producing content. Furthermore they have made it possible for a non-tech person to actually produce a SCORM package that can be run from a SCORM compatible LMS. This has always been notoriusly difficult and geeky but Captivate allows you to do it easily. Naturally it still requires that you have knowledge about what an LMS is and what it does.


                      I don't know how, why and where you want to deploy your content, but an LMS is of course the best choice available to do this. It has the framework in place already so there is no reason to reinvent the wheel. LMS's comes in many different sizes and types. Free LMS's like Moodle, Claroline, Efront Learning etc will most likely suit your needs. They are free and relatively easy to install and maintain.




                      Visit my Captivate blog with tips & tricks, tutorials and Widgets.

                      • 8. Re: Captivate JavaScript
                        dagda1970 Level 1

                        Thanks for the info:


                        THis article allows me to get the scores in JavaScript:




                        It is a hack but it works.


                        My next choice is whether to go LMS or not.




                        Paul Cowan


                        Cutting-Edge Solutions (Scotland)



                        • 9. Re: Captivate JavaScript
                          dagda1970 Level 1

                          If I use an LMS, can I suspend and restart the test at a later date with the

                          answers that have already taken place saved?




                          Paul Cowan


                          Cutting-Edge Solutions (Scotland)



                          • 10. Re: Captivate JavaScript
                            www.cpguru.com Level 4

                            No that will still not be possible unfortunately. Regardless of deployment method a started quiz needs to be finished in one go. If you really need to have this feature then you need to look into a custom-made quiz developed in Flash or similar.



                            Visit my Captivate blog with tips & tricks, tutorials and Widgets.

                            • 11. Re: Captivate JavaScript
                              Michael V Baker Level 3

                              3.  Allow the user to suspend the test and complete the test at a later date by starting where they suspended the test.


                              That is not possible with Captivate. A started quiz needs to be finished in order for it to score properly. Creating a "resume" feature that will return the user to the question where they left off will leave all previous questions unanswered and therefore result in a fail in the quiz.


                              What Michael's saying is correct if you're depending on the Captivate internal variables for quiz tracking. I was able to resume a quiz in the middle by tracking the results in the JS. These results were persisted to SQL Server via SOAP web service with an ASP.NET back end. When the quiz was resumed the previous results were re-loaded. The quiz results page was replaced by a custom results page that displayed the content we wanted (set into Captivate with document.Captivate.SetVariable(varName, varValue)) Naturally the ability to resume a quiz was an option that was set in the SQL server description of the quiz.


                              A word of caution here... there are a number of things that are undocumented in the way the quiz works. Undocumented because they're internal, not intended to be customized in any way by end-users of Captivate. In some cases just knowledge of the settings makes a difference. For instance the quiz we built can deliver questions in random order. We had problems using the navigation part of Phillip's Captivate Controller until we realized that we had not set the 'allow backward movement' flag. Even though we were telling the Cp movie to go to slide N through a JS call, it would not obey that navigation command if the slide we wanted resulted in backwards movement and that flag wasn't checked.

                              I recall another case where we couldn't find a setting to correct the problem and were forced to re-work a lot of material. The problem was cpQuizInfoAnswerChoice and the feedback box. When the question was over we read cpQuizInfoAnswerChoice in the JS to see what they chose. If we opted to display the feedback box then there was a 50/50 chance that variable would be blank when the JS was called. Needless to say that set of conditions was difficult to locate. Once we did find that the feedback box was the controlling variable in the problem, we tried for days to figure out a fix. We eventually had to drop feedback boxes and instead make a feedback slide that we could jump to.

                              The point here is that this is an exercise in putting a square peg in a round hole. Yes it can work but there are pitfalls. It's also possible that it won't work with the next version of Captivate if the internals are changed. Using the LMS with the SCORM option is a safer choice because the API is already well defined.



                              • 12. Re: Captivate JavaScript
                                dagda1970 Level 1

                                Sober advice Michael.


                                Thanks for the comments guys.


                                The road is now 1000 times clearer than 24 hours ago.




                                Paul Cowan


                                Cutting-Edge Solutions (Scotland)



                                • 13. Re: Captivate JavaScript
                                  Michael V Baker Level 3

                                  As Michael said Captivate files don't support this out of the box. You could look at this issue from the instructional design perspective. "Teaching to the test" is regarded by many as being the worst way to handle eLearning. You might as well build static pages and a web page form for the students to select the answers. A different approach is to break the content down into smaller chunks... teach the content and quiz the students simultaneously. You can put scored questions in the middle of the learning or have a short quiz at the very end to help encode the content (or both), especially if they have to apply the material in a different context. A SCORM conformant LMS can manage a group of several Cp files as a unit. This is where the "cotent object" part comes in. Each of these can have their own quiz, which cannot be resumed, however the content as a whole has the appearance of being resumed since it's broken up into chunks. Some say 10-15 minutes is ideal.