Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Setting cmi.comments (SCORM variable) with Javascript in Captivate 8?

Engaged ,
Dec 16, 2014 Dec 16, 2014

Hi folks,

A long, long time ago, way back in Captivate 5.5, I managed to "save" some data in a SCORM 1.2 course as part of a convoluted randomization thingy (https://forums.adobe.com/thread/1176710). I wrote the data to cmi.comments using this little snippet:

g_objAPI.LMSSetValue('cmi.comments', 'whateverDataHere');

I'd like to do something similar again in Captivate 8 (not the whole convoluted randomization thingy-- I just want to save some data to comments so it'll be easily readable by someone who looks at the SCORM data). I'm assuming that things have changed since then. I've tried googling, but the closest I can find is the general JavaScript tutorial for Captivate 8, and that seems to be about interacting with Captivate, not SCORM.

Any hints/suggestions? I feel like this should be relatively simple, but without the proper "wording," I'm stuck. (It's also been a while since I dabbled in JavaScript, so that might be hindering me, too )

Thanks!

TOPICS
Advanced
4.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Dec 16, 2014 Dec 16, 2014

You'll want to use something like this for SCORM 1.2 content:

SCORM_CallLMSSetValue('cmi.comments', 'Hello');

For SCORM 2004, you can use the cmi.comments_from_learner collection (an array):

SCORM2004_CallSetValue('cmi.comments_from_learner.0.comment', 'Hello');

see section 4.2.2 of the SCORM 2004 Run-Time Environment manual for more details.


Jim Leichliter

Translate
Advisor ,
Dec 16, 2014 Dec 16, 2014

You'll want to use something like this for SCORM 1.2 content:

SCORM_CallLMSSetValue('cmi.comments', 'Hello');

For SCORM 2004, you can use the cmi.comments_from_learner collection (an array):

SCORM2004_CallSetValue('cmi.comments_from_learner.0.comment', 'Hello');

see section 4.2.2 of the SCORM 2004 Run-Time Environment manual for more details.


Jim Leichliter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 17, 2014 Dec 17, 2014

Thank you! (I was hoping you'd see this, and I really appreciate your quick and concise reply-- regulars like you and Lieve are awesome )

It's working perfectly for me in SCORM Cloud (as well as SCORM_CallLMSGetValue which I tried on a whim). Now it just needs testing on our LMS, so fingers crossed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 20, 2016 Dec 20, 2016

I understand this is an old post, but maybe one of you can help me out.
I want to send text that the user would enter in a text entry box to api cmi.comments.
Some people have told me this should automatically happen but I have not been able to get this to work at all.

I used this snippit:

SCORM_CallLMSSetValue('cmi.comments', 'Hello'); and changed hello to box1 (the name of my variable attached to a text entry box)

It looked like this

SCORM_CallLMSSetValue('cmi.comments', 'box1');

I attached the javascript to a button via advanced actions.

In my report from the LMS- cmi.comments returned the value 'box1' - which makes sense based on the javascript.

(At this point I am happy to return anything in cmi.comments because I have tried so many things that haven't worked- This is the first script that returned anything to cmi.comments)

Now, my question is- how do I make it return the text the user has entered in the text entry box instead of the variable name?

ElaKat​

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 21, 2016 Dec 21, 2016

When you put quotes around a variable, it's no longer a variable.

If this is html5 use:

SCORM_CallLMSSetValue("cmi.comments", window.box1);

Also you should note that cmi.comments are appended to whatever is there so you may want to use a delimiter so the you can see the last comment clearly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 21, 2016 Dec 21, 2016

Thank you for your response.

I just tested this- The value I got back in the LMS was 'undefined'.

I found a work around by using short answer quiz questions in Captivate. I am able to report on that using cmi.interactions.student_response (no javascript needed). But I would really like to be able to do this with a TEB as well.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 21, 2016 Dec 21, 2016

You created the variable in Captivate?

Is this HTML5?

Undefined means that the variable wasn't created, not that it wasn't populated.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 21, 2016 Dec 21, 2016

HTML5 was the issue. I published to SWF and HTML5. When I published to HTML5 only, I was able to get the value. Thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 21, 2016 Dec 21, 2016

If you want it to work for both:

SCORM_CallLMSSetValue("cmi.comments",window.cpAPIInterface.getVariableValue("box1"));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 21, 2016 Dec 21, 2016

Awesome. I will try that out.


What if I want to include a / after each, or some way to separate box1 input from box2 input? Right now it includes them all with no space between box1 entry and box2 entry if I have more than one variable value going to cmi.comments.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 21, 2016 Dec 21, 2016

SCORM_CallLMSSetValue("cmi.comments"," / "+window.cpAPIInterface.getVariableValue("box1"));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 21, 2016 Dec 21, 2016

Thank you for your help! You're a lifesaver.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 11, 2017 Oct 11, 2017

Does anyone if you can clear the cmi.comments?

Currently if I were to do:

SCORM_CallLMSSetValue('cmi.comments', 'Hello'); 

and then

SCORM_CallLMSSetValue('cmi.comments', 'World');

The cmi.comments would read "HelloWorld" and actually I want to be able to clear it out so that I can start from scratch. Any ideas?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 11, 2017 Oct 11, 2017

The concatenation may be due to the behavior of your LMS provider's implementation of SCORM... or the version of SCORM you are using.  You can read here for more info.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Oct 11, 2017 Oct 11, 2017
LATEST

You cannot clear comment in SCORM 1.2. You need to use a special character to separate the comments when writing them, say an "*".

Then you need to turn the comments into an array when reading and get the last comment.

So something like this to read:

var getComments = SCORM_CallLMSGetValue('cmi.comments').split("*");

var myComment = getComments[getComments.length);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources