Forum Discussion
Retrieve LMS User Name as Variable
Is anyone able to share a .story file example where it pulls in a users profile photo from an LMS also? The name comes through perfectly but I don't currently don't have the expertise to re-purpose this and pull in a users photo also. Many thanks everyone, this is the best resource community by far.
I don’t see how you can pull in a users photo there is nowhere in the scorm standard for this. It maybe you can pull a unique I’d from thee LMS you can compare against a company database and pull the picture from there, but you would need to use a web object as Storyline variables are finite and a base64 image would be too large.
Sent from my iPhone
- DarrenCampbell-2 years agoCommunity Member
Ahh thanks Phil, I asked chat GPT which gave me hope here, this is what it recommended
---------------------
// Get the LMS API object
var lmsAPI = parent.GetAPI();// Check if the LMS API is available
if (lmsAPI) {
// Get the current user's ID
var userID = lmsAPI.GetStudentID();// Use the user ID to retrieve the profile photo URL
var profilePhotoURL = getProfilePhotoURL(userID);// Update the profile photo in the Storyline content
updateProfilePhoto(profilePhotoURL);
} else {
console.error("LMS API is not available.");
}// Function to retrieve the profile photo URL for the given user ID
function getProfilePhotoURL(userID) {
// Add your code here to retrieve the profile photo URL from the LMS for the given user ID
// Example:
// return "https://example.com/profile-photos/" + userID + ".jpg";return "";
}// Function to update the profile photo in the Storyline content
function updateProfilePhoto(profilePhotoURL) {
// Add your code here to update the profile photo in the Storyline content
// Example:
// document.getElementById("profile-photo").src = profilePhotoURL;
}----------------
If anyone else or even I do get a working version going I'll add to this thread.