Best practice forum (Archived)

Access to course custom fields in External Tool (LTI) custom parameters?

 
Matt Williams
Access to course custom fields in External Tool (LTI) custom parameters?
by Matt Williams - Thursday, 9 May 2019, 12:47 PM

I am using the LTI External Tool plugin on our totara environment. Today I learned I could add to custom parameters for the external tool something like 'thisuser=$User.username' and the LTI will see thisuser=adminuser. Great. So what else can I access like this. Is there a listing of other variables I can see???

The thing I really want is access to custom fields set on the course. Is this possible?

Wesley Holden
Re: access to course custom fields in lti custom parameters?
by Wesley Holden - Thursday, 2 May 2019, 2:45 PM

Hi Matt, 
Apologies for not responding sooner. The docs for the tool are here:  https://help.totaralearning.com/display/TLE/Enrolment#Enrolment-PublishasLTItool(experimental) 

I've poked around to see what is available and haven't found a list of variables. I'm also posting the question to the support team to see if they have additional details.


Thanks!

Wes

Jonathan Newman
Re: access to course custom fields in lti custom parameters?
by Jonathan Newman - Wednesday, 8 May 2019, 4:35 PM

Hi Matt,

Thanks for raising your question. We're working to add the information below to the help docs, but in the meantime, the supported parameters are:

Variable Source
$Context.id Course id (system generated)
$Context.title Course fullname
$Context.label Course shortname
$Context.sourcedId Course idnumber
$Context.longDescription Course summary
$Context.timeFrame.begin Course start date
$CourseSection.title Course fullname
$CourseSection.label Course shortname
$CourseSection.sourcedId Course idnumber
$CourseSection.longDescription Course summary
$CourseSection.timeFrame.begin Course start date
$User.id User id (system generated)
$User.username User profile username
$Person.name.full User profile first name + surname
$Person.name.given User profile first name
$Person.name.family User profile surname
$Person.email.primary User profile email address
$Person.sourcedId User profile idnumber
$Person.name.middle User profile middle name
$Person.address.street1 User profile street
$Person.address.locality User profile city
$Person.address.country User profile country
$Person.address.timezone User profile timezone
$Person.phone.primary User profile phone 1
$Person.phone.mobile User profile phone 2
$Person.webaddress User profile URL
$Membership.role Comma separated list of roles (if the user has the capability 'mod/lti:manage' in the activity, then 'Instructor' is returned. Otherwise, 'Learner' is returned. Also, if the user is a Site Admin, then full URN or URI values are added to the list, depending on the version of LTI tool used).


Also, here is an example that provides three parameters:

----

acme_tool_user_fullname = $Person.name.full

acme_tool_course_id = $Context.sourcedId

acme_tool_user_roles = $Membership.role

----

It would be awesome if you could share the results as you add them to the activities you're working on.

Matt Williams
Re: access to course custom fields in lti custom parameters?
by Matt Williams - Wednesday, 8 May 2019, 5:25 PM

This is super useful. Thank you. What I was hoping to see was an ability to get course custom fields out as well. I guess I can do that via rest, but eliminating the need for another round trip call would be nice. 


Thanks again for this great answer. 

Matt Williams
Re: access to course custom fields in lti custom parameters?
by Matt Williams - Wednesday, 8 May 2019, 5:55 PM

For context, here is what I am doing. I run the learning environment in our company and we have a number of hands-on sections where folks can try working with the product. When they complete the section, the LTI service that I wrote will assess whether they have completed the tasks by interrogating their account using our API. The LTI service uses AWS Lambda and Step Functions and has been the topic of a couple of my talks at AWS re:Invent and other conferences. 

So recently we started implementing a hosted lab environment. The labs have a lab id based on an account name and specific scenario id. But I develop the course on my personal Github account, and then when it's complete, move it over to the company Github org. So a course might have 6 or so labs and that means when I move it over, I have to change the lab id 6 times or more. Chances are I am going to miss one. So, I want a way to store the first part of the lab id in the course info, such as a custom field, then the scenario id is in the custom parameters. If I have access to those custom fields then when I move from the personal account to the company org, I only have to change the value once. With all that info passed to the LTI, I then generate an embed code that is the contents of the iframe for the External Tool. Then when the student finishes that section, they run a command in the hosted lab environment that again uses the LTI to assess their progress and returns a grade to Totara. 

It works really well, I just want to solve this lab ID issue without a second call via the REST api. 

Jonathan Newman
Re: access to course custom fields in lti custom parameters?
by Jonathan Newman - Thursday, 9 May 2019, 1:47 PM

Hi Matt,

Apologies, before writing my previous post, I should have picked up on the word 'custom' when you described course fields. 

Unfortunately, course custom fields values are not yet supported by the activity's custom parameters field. I've just added the user story to the product backlog (ID TL-20942)This improvement currently has a relatively low priority and is unlikely to be implemented by the Totara team in the near future. 

In the meantime, some questions to better understand what you're trying to achieve:

  1. When you say "labs have a lab id based on an account name and specific scenario id", what does the 'account name' represent? Is it a specific customer organization going through the training, or something else?
  2. Do you plan to deliver the same labs through multiple courses (e.g., one course--with all six labs--per customer)?

Also, some questions based on possible workarounds. Could you store...

  1. the first part of the lab id as the course id number (which can be passed as  $Context.sourcedId, per my last post)? 
  2. both parts of the lab id in the External Tool instance's custom parameters? You already have to add the scenario id, so why not add the account name as well? I suppose that would be lots of work if you're wanting to duplicate the Totara course.
  3. a map in the LTI of either the course id number, course shortname, or course id (system generated) to the account name, pass which ever one as a custom parameter, and resolve the lab id on the LTI end?

Matt Williams
Re: access to course custom fields in lti custom parameters?
by Matt Williams - Thursday, 9 May 2019, 6:19 PM

So the lab environment is provided by Katacoda. Each scenario is pushed to GitHub which then triggers a hook that pushes it to katacoda. I test each scenario on my personal GitHub account, the. When it goes live, I move it over to the Datadog organization on GitHub. So the account ids are technovangelist and datadog. I’m putting the whole thing in the custom parameters now, but I was hoping to make configuration a little easier. Each lab is only used in a single course. Right now I am building a course on monitoring Kubernetes with datadog. And so as I test it out, the katacoda ID is for one of the scenarios is technovangelist/k8s1-install, but when it goes live it will be datadog/k8s1-install. But then there are times when we do in person courses and we have katacoda provision a bunch of extra machines for us. The course would have a slightly different ID for those labs.

The lab config is identical for all all users, but one of the functions of the lti is to generate a datadog account for the user, gather api keys for the user, and generate the embed code for the katacoda labs with those api keys and other things which then get injected into the lab scenario.

As an org we really like tools that can be store the config in GitHub. A little off topic, but it would be super amazing if there was a way to push a course config and all content to GitHub and have a job in Jenkins or even the new GitHub actions to push it to our Totara instance. 

Jonathan Newman
Re: access to course custom fields in lti custom parameters?
by Jonathan Newman - Monday, 13 May 2019, 3:44 PM

Hi Matt,

Thanks for describing what you're trying to achieve. 

I can see how support for course custom fields values within the External Tool activity's custom parameters field would help here. It probably won't be too much work to improve the module to expose the custom field values, it's just a low priority.

Regarding the need to push to an LTI module's course config from a hosted service (like GitHub) to Totara, that's also an interesting scenario that makes sense but probably not something we'll address soon.

In the meantime would be great to hear from others in the community about situations in which these needs come up, to help us gauge the level of interest.


Jussi Tuominen
Re: access to course custom fields in lti custom parameters?
by Jussi Tuominen - Thursday, 4 February 2021, 9:06 AM

Hello Matt,

My customer wants to build similar arrangement for their training labs. Any possibility that you would share your details with us?

What LTI solution you used? Did you considered implementing with REST API?

/jussi