Skip to main content
KariMueller
Inspiring
November 30, 2016
Question

Javascript for Text Entry Box to API for reporting

  • November 30, 2016
  • 3 replies
  • 256 views

Would someone be able to advise on writing javascript to report user input text from a text entry box to API for reporting?
Disclaimer: I do no know much about javascript.


What I do know:- I am using SCORM 1.2
- My LMS allows me to call the following API
     cmi.comments (SCORM 1.2)
     cmi.interactions.student_response (SCORM 1.2)

     cmi.interactions.id (SCORM 1.2)
     cmi.objectives.id (SCORM 1.2)

My TEB for my test are creatively named

     text_entry_box_1

     text_entry_box_2

What I do not know:

How do I send the value entered in text entry box to an API to report on this?

If more than one Text Entry Box, how does this effect the javascript?

Where do I execute the Javascript (upon entering slide, exiting slide, clicking submit button?)

I found something on one of the forums that looked close:

           SCORM_CallLMSSetValue('cmi.comments', 'Hello');
To me, this looks like it would set the value of cmi.comments to Hello by default. I would need that to be the value of text_entry_box_1

Any help is appreciated!

This topic has been closed for replies.

3 replies

KariMueller
Inspiring
December 2, 2016

Hmmmm. I already have interaction data checked.

I will try both of these.
Thanks so much!

TLCMediaDesign
Inspiring
December 1, 2016

If you validate the TEB and set it to be included in the quiz and also check Publish Settings > Quiz > And check the "Interaction Data" check box, it will report for you automatically.

SauravGhosh
Adobe Employee
Adobe Employee
December 1, 2016

Hi,

Here is what you could do (to get started):

1. Text>Text Entry Box and create a variable myCustomMessage

2. On Success > Execute JavaScript

3.Enter  var message=window.cpAPIInterface.getVariableValue("myCustomMessage");

4. Text>Text Caption and assign variable returnMessage to the caption.

5. Select text entry box and add the following lines to the JavaScript code already there:

newMessage=message;

window.cpAPIInterface.setVariableValue("returnMessage",newMessage);

6. Preview the project in HTML5 in browser. Enter a name in the text entry box and when you click Submit, you will see the name appear below, what is actually in a text caption container.

You can extend this to your LMS and assign variables and passing value to the variables, like above.

Thanks,

Saurav