Picture of Helen Bailey
Pull through SCORM value
by Helen Bailey - Wednesday, 5 October 2016, 4:08 PM
 

Can I get "ScormWrapper::getValue: _property=cmi.core.student_name" and "ScormWrapper::getValue: _property=cmi.core.student_id" that I see in the debugger into my course to be displayed somehow?

Picture of Matt Leathes
Re: Pull through SCORM value
by Matt Leathes - Thursday, 6 October 2016, 9:36 AM
 

Hi Helen

Although we've now amended contrib-spoor so that it can pull through this information, we've not yet made it available more generally in Adapt so there's a bit of manual intervention in the code required still if you wanted to be able to use it.

The eventual plan is to pull information like this into Adapt 'globals' so that you can then use it easily as documented here.

For now, you can pull this information out of SCORM via Adapt.offlineStorage.get('learnerinfo') - this will give you an object with these properties. So if you wanted to output the user's first name that would be  Adapt.offlineStorage.get('learnerinfo').firstname

If you look at the code for assessmentResults you can see how to allow the user to specify dynamic text like this in the .json.

In the meantime I'll see if we can get back on the case with ticket #1040.

Picture of Stephen Harlow
Re: Pull through SCORM value
by Stephen Harlow - Tuesday, 11 October 2016, 4:19 AM
 

Hi Matt Are you able to spell this out more fully for me? Specifically, from where do you call the Adapt.offlineStorage.get('learnerinfo') function? Is the dynamic text in the assessmentResults example.json the variables using handlebars style escaping, e.g., {{scoreAsPercent}}? So once you call the function, can you then use handlebar escaped variables like {{firstname {{lastname}}?

Picture of Matt Leathes
Re: Pull through SCORM value
by Matt Leathes - Tuesday, 11 October 2016, 8:58 AM
 

Hi Stephen

Here's an example I worked through with Helen to allow the user's first name to be included in the 'body' text of any text component.

First, you need to add this code to adapt-contrib-text.js:

replaceText: function() {
    var learnerInfo = Adapt.offlineStorage.get('learnerinfo');
    var fname = "Student";
    if(learnerInfo !== undefined && learnerInfo.firstname !== "") { 
        fname = learnerInfo.firstname; 
    }
    this.model.set('body', this.model.get('body').replace("{{firstname}}", fname)); 
},

Then you need to add a call to that into the preRender function in the same file. Done correctly, you should end up with something like this (note that screenshot has an older version of the replaceText function).

You can then use {{firstname}} in the body of any text component.

Picture of Stephen Harlow
Re: Pull through SCORM value
by Stephen Harlow - Wednesday, 12 October 2016, 3:53 AM
 

Many thanks Matt. I will give this a go and report back.