Forum Discussion
Course Name variable (for SmartSheet)
Goal: Prefill in as many fields as we can for users on a SmartSheet survey form at the end of our University courses (100s of courses will be updated with this new feature).
I am using JS to extract the UserID and UserName. This is working.
QUESTION: Is there already an existing easy way to extract the coursename from already designed courses?
My current (ugh) plan is to edit each course, create a variable where I manually add the course name. Then my already constructed JS will create the smartURL that the user will be given at the end of the course that will prefill in the fields as the form opens.
I would love to just drop in the new javascript without having to manually add in course-specific variables.
Any brilliant paths to that goal? Thanks in advance.
7 Replies
- RussellKillips-Community Member
Try using: document.title
alert(document.title);
- JerryBeaucaireCommunity Member
That works! Thanks for the quick tip.
- JerryBeaucaireCommunity Member
My final code, for your reference:
//Put name of student into variable "username"//Construct a URL with the student's name included in variable "smartURL"
var feedbackform = "https://app.smartsheet.com/b/form/94b1b0fcfe1234567890x"var player = GetPlayer();var docname = document.titlefunction findLMSAPI(win) {if (win.hasOwnProperty("GetStudentID")) return win;else if (win.parent == win) return null;
else return findLMSAPI(win.parent);}
var lmsAPI = findLMSAPI(this);var myName = lmsAPI.GetStudentName();var array = myName.split(',');var newName = array[1] + '%20' + array[0];player.SetVar("username", array[1]);
if (newName) {player.SetVar("smartURL", feedbackform + "?Name=" + newName + "&Course=" + docname);}else{player.SetVar("smartURL", feedbackform + "?Course=" + docname);}
------------------------------------
And here is the JS that is connected to the FEEDBACK button in the course//Open the smartURL link created earliervar player = GetPlayer();var win = window.open(player.GetVar("smartURL")); - SherriSagers1Community Member
Hi Jerry! I'm trying to prefill an embedded Smartsheet form with the learner's quiz score and a few other Storyline variables, which I think is what you're describing here. I'm new to Smartsheet but I've done something very similar with Google Sheets, so I think (hope!) I'm following your explanation. My questions:
1. Where do you put the first set of code? (On the first slide of the Storyline project?)
2. In your first set of code, is the "app.smartsheet.com..." URL the same URL you get to embed the form?
3. (Longshot...) All of my courses are in Rise, with Storyline embedded - sometimes in more than one place. I'm putting the Smartsheet survey forms at the end of the Rise projects. Is there any way to pass the Storyline variables into a Smartsheet form that isn't embedded in the Storyline project itself, but later on in the same Rise course? (... she asks with only the tiniest glimmer of hope...)
Thank you for any help you can give me! <3
- MariaCSStaff
Hi, Sherri.
Jerry might not be subscribed to this discussion, but you're welcome to contact them directly through their profile by clicking on their name and selecting Contact Me.
- JerryBeaucaireCommunity Member
- For me, yes. My code does all the work at the onset because I'm not gathering end-of-course data like scores or metrics.
For you, just remember to put your code that constructs the smartURL with your metrics added to the URL into your course at a point after those metrics have been created. So that could be as the first trigger events on the RESULTS slide, perhaps? - The base URL is the same one I get from SmartSheet to open the form from anywhere. So I think... yes.
- I've only used Rise twice, so not an expert at all on Rise's ability to read/write/pass JS variables. Sorry.
- SherriSagers1Community Member
Thank you Jerry!
- For me, yes. My code does all the work at the onset because I'm not gathering end-of-course data like scores or metrics.
Related Content
- 12 months ago
- 6 months ago
- 12 months ago
- 12 months ago
- 12 months ago