Picture of Jason Chui
Display user LMS name in Adapt?
by Jason Chui - Tuesday, 23 April 2019, 10:14 AM
 

Hi,

In https://adaptlearning.github.io/v4demo/#/id/co-05 it is mentioned that 

"In addition, if your course is being launched from an LMS or LRS, you can personalise the course content by having the learner's name dynamically displayed in the body, instruction or feedback text."

I have updated my authoring tool to v0.7.1, and framework to 4.1.1, but I can't find the way to do it. 

Please help.

Picture of Simon Date
Re: Display user LMS name in Adapt?
by Simon Date - Tuesday, 23 April 2019, 10:45 AM
 

Hi Adam,

The variable name that comes with the Framework when installed is {{_globals._learnerInfo.firstname}}

It's generated by the Spoor plugin. If that doesn't work your LMS may use a different variable for learner name. For more information or other variable names read the comments in the extension code here.

Simon

Picture of Matt Leathes
Re: Display user LMS name in Adapt?
by Matt Leathes - Tuesday, 23 April 2019, 11:12 AM
 

https://github.com/adaptlearning/adapt_framework/blob/master/src/course/en/components.json#L12

FYI this feature has been available since Adapt FW v2.1.0 (with spoor v2.1.0)

I'll see about getting some better documentation sorted out though.

Picture of Jason Chui
Re: Display user LMS name in Adapt?
by Jason Chui - Wednesday, 24 April 2019, 12:16 AM
 

Thanks for the replies.

How can I use this feature in the Authoring tool though? I need to minimise coding as my users have no programming background

 

Picture of Jason Chui
Re: Display user LMS name in Adapt?
by Jason Chui - Wednesday, 24 April 2019, 9:15 AM
 

This is my full intention. I want to send data out from individual plugins to a free online database survey.js.

I am using a textconfirmation plugin, and the javascript file I am modifying is shown in the picture attached.

The code you are seeing in the picture is working i.e. when I check the checkbox in the lesson, the event will be triggered and data will be posted to surveyJS.

Instead of hardcoding the name to be sent, I wish to send the LMS user name.

How can I do that inside a plugin?


Picture of Matt Leathes
Re: Display user LMS name in Adapt?
by Matt Leathes - Wednesday, 24 April 2019, 9:19 AM
 

As per the code that Simon linked to in an earlier reply:

Adapt.offlineStorage.getLearnerInfo()

Returns an object with the properties:

  • id
  • name
  • firstname
  • lastname
Picture of Matt Leathes
Re: Display user LMS name in Adapt?
by Matt Leathes - Wednesday, 24 April 2019, 9:15 AM
 

You just put {{_globals._learnerInfo.firstname}} wherever you want the user's first name to be displayed.

Calling it 'coding' is a bit of a stretch! It's just copy-and-paste...

Picture of Jason Chui
Re: Display user LMS name in Adapt?
by Jason Chui - Thursday, 25 April 2019, 9:13 AM
 

Thanks a lot Matt, I was unsure where to paste the code. I initially pasted it in the JavaScript but it failed. Managed to get it working by pasting {{_globals._learnerInfo.firstname}}  into the Authoring Tool:

 

However, I still can't get Adapt.offlineStorage.getLearnerInfo() to work.

I tried to call it in a plugin's JavaScript, but I get the following error:

 

The code is attached (the plugin is the core adapt-contrib-textInput-master), and I've screenshot the relevant parts below.

Front part of code:

Main part that fails:

Please help. Thanks!

Picture of Matt Leathes
Re: Display user LMS name in Adapt?
by Matt Leathes - Thursday, 25 April 2019, 10:14 AM
 

Sorry that's my mistake, the getLearnerInfo function isn't intended to be accessed directly.

You should use this instead:

Adapt.course.get('_globals')._learnerInfo.name;

Picture of Matt Leathes
Re: Display user LMS name in Adapt?
by Matt Leathes - Thursday, 25 April 2019, 10:19 AM
 

BTW it would be neater to require Adapt like this:

define([
    'core/js/adapt',
    'core/js/models/questionModel'
], function(Adapt, QuestionModel) {
    var TextInputModel = QuestionModel.extend({
Picture of Jason Chui
Re: Display user LMS name in Adapt?
by Jason Chui - Friday, 26 April 2019, 3:04 PM
 

Thanks! It works now! Great support as always!