Student Last name

sirwise23
sirwise23 Community Member Posts: 442 ☆ Roadie ☆
Hey Forum,



I know the AICC_Student_name variable pulls the name as LAST, FIRST.



I was wondering if anyone has any code to drop , FIRST. I am trying to grab ONLY the student Last Name. I have seen stuff on here to switch it to FIRST LAST name... but nothing to just take a Last name.

Comments

  • candaceid
    candaceid Community Member Posts: 14
    I happened here looking for a quick answer, but alas, no one has followed up. So, I dug a little and found this in my files. Might be helpful to someone, but I have not tested it in awhile.
  • sulaimaanrb
    sulaimaanrb Community Member Posts: 7 ☆ Roadie ☆
    I have also been playing with the idea of personalising the learning experience and this is awesome.  Just tested it out and it works perfect. Thank you Candace
  • andrew-robertson
    andrew-robertson Community Member Posts: 184 ☆ Superstar ☆
    edited May 26, 2021
    I created a privacy emodule and the instructional designer wanted to have something like > Use your @server.com e-mail address for all work-related communications. So to make it better, I took the first name and last name from the LMS and made the email address more personable for all users taking the course.

    Method to make it work:
    1. Add two page level actions.
    2. Change the other page level action to OnShowModVar (Trigger: Show; Action Modify Variable).
    3. Change one page level action to be OnShowRunJS (Trigger: Show; Action Run JavaScript).
    Page Level Action #1


    Pagel Level Action #2
    var name = Var_userEmailAddress.getValue();
    var name = name.replace(/\s/g, '');
    var nameArr = name.split(',');
    var emailAddress = nameArr[1] + "." + nameArr[0]+ "@server.com";
    var emailAddress = emailAddress.toLowerCase();
    Var_userEmailAddress.set(emailAddress);

    Page Level Action Hierarchy:


    Once these actions are all configured, I added a text box on screen with my default wording ( Use your @server.com e-mail address for all work-related communications.), and then added an OnPageShowChange action to the text box so that once the text box appeared, it modified the text box contents to include the user's full email address.

    Textbox Action:

    Use your VAR(_userEmailAddress) e-mail address for all work-related communications.

    Also you need to create a variable named _userEmailAddress with the setting to not retain the user's details between sessions in case their name changes.
    Andrew R.
    Developing content since 2010 using a mixed bag of tools.