Skip to main content
Participant
May 6, 2014
Answered

Passing variables from web server to HTML5 Captivate File

  • May 6, 2014
  • 1 reply
  • 1350 views

I am publishing a Captivate quiz as HTML5 and hosting them on a website. I would like to know how I can pass data from my site to the HTML5 based Captivate quiz.

So far I have had success getting data out of captivate by having the file POST the results of a finished quiz to a RESTful route. However, I have not had success putting data into the file. I would like to pass information such as User ids and quiz ids, maybe even current slide position so that I can associate the quiz information with my database. I am not specifically looking for a solution to user ids, quiz ids, etc. because I can get creative in that regard, I just want to know if others have been able to set variables on Captivate file load.

I have tried a setting variables in a couple ways:

- Declaring the variables with javascript, then ajax loading the page into a div. This caused dependency issues since the captivate file uses relative paths for its assets folder.

- Modifying the published html file by adding the javascript variables, this returned an error message saying I cannot override the existing captivate variables

- Adding the js variables into the init function, this had no effect.

    This topic has been closed for replies.
    Correct answer Metapod

    To simply pass the username and an id I used the following.

    Note the URL has query string parameters that match the captivate variables

    http://mywebsite/Course/index.html?cpQuizInfoStudentID=IDHere&cpQuizInfoStudentName=StudentNameHere

    Another way to do this to use JavaScript to read the query string, and the assign variable in CP to the query string values. I remember reading some more detail, but cant remember where.

    Hope it helps

    Luke

    1 reply

    MetapodCorrect answer
    Inspiring
    May 7, 2014

    To simply pass the username and an id I used the following.

    Note the URL has query string parameters that match the captivate variables

    http://mywebsite/Course/index.html?cpQuizInfoStudentID=IDHere&cpQuizInfoStudentName=StudentNameHere

    Another way to do this to use JavaScript to read the query string, and the assign variable in CP to the query string values. I remember reading some more detail, but cant remember where.

    Hope it helps

    Luke

    Participant
    May 7, 2014

    Thank you, this worked perfectly!