Seperate First name from AICC_STUDENT_NAME

sirwise23
sirwise23 Community Member Posts: 441 ☆ Roadie ☆
Hey everyone,



Haven't been on here in a while. I know I have seen notes n this before but I can't find it.



I am trying display the students first name but the AICC_Student_Name only pulls LastName, FirstName.



Is there a way with variables to strip off the LastName, and only display the firstname?



I can probably manage this if I use a flash file to read the AICC_Student_name variable, strip out what I don't need, write the first name to a new variable, and then use Lectora read the variable.



Since I do plan on doing some development for an LMS that uses iPads, I was trying to avoid the flash route though.



Anyone ever manage this?
«1

Comments

  • beeps
    beeps Community Member Posts: 40 ✶ Headliner ✶
    Do you need to pull the name from AIC_Student_Name? What about having the first name be its own variable and then asking them for their name at the start of the course?



    I think how you plan to have the first name show in the course depends on what you are doing with it. If it is just for customization (e.g., a guide says something like "Hi FIRSTNAME, let's learn do something!") then a new variable would work well for that.
  • altarium
    altarium Community Member Posts: 78
    Haven't tried it yet, but using javascript and the split() method.



    It should look something like this (variables aren't correct, just used as an example):




    var studentname = varaicc_studnet_name.split(",");
    var firstname = studentname[1];
    [/CODE]

    the variable "firstname" should then only hold the students first name for you to use anywhere

    hopefully this gives you a starting place, let me know if you have any trouble with it! (someone else on here might be able to give you a better answer too)[CODE]

    var studentname = varaicc_studnet_name.split(",");

    var firstname = studentname[1];

    [/CODE]



    the variable "firstname" should then only hold the students first name for you to use anywhere



    hopefully this gives you a starting place, let me know if you have any trouble with it! (someone else on here might be able to give you a better answer too)
  • timk
    timk Community Member Posts: 1,245 ✭ Legend ✭
    It can be done in three steps:



    1.

    Create a textfield that's initially invisible

    Add an action

    On: Page show

    Action: Change content

    Target: This object

    Value: VAR(AICC_Student_Name)



    2.

    Create two variables

    -> lastname

    -> firstname



    3.

    Add an action on page level



    On: Show

    Action: Run JavaScript

    Javascript:

    var username = VarAICC_Student_Name.getValue().split(", ");

    Varlastname.set(username[0]);

    Varfirstname.set(username[1]);



    "lastname" now contains the users' lastname (i.e. everything before the ", ") "firstname" contains the users' firstname. Both variables can now be used throughout the course.



    Tim
  • altarium
    altarium Community Member Posts: 78
    Thanks, Tim! I was about 1/3 of the way there lol :)
  • sirwise23
    sirwise23 Community Member Posts: 441 ☆ Roadie ☆
    Thanks. This worked great.
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    Hey guys, i need really help, i did exactly the three steps from Tim, but it doesnt work. Has anyone an idea? i have Lectora inspire 17.0.2. The strange thing is, that in Lectora online, the first name appears at beginning but in inspire it doesnt work.

    var username = AICC_Student_Name.getValue().split(",",2);
    Varlastname.set(username[0]);
    Varfirstname.set(username[1]);
    alert(username);

    greetings marcel
  • timk
    timk Community Member Posts: 1,245 ✭ Legend ✭
    If you publish with "Publish for Seamless Play" the code needs to be changed:
    var username = parent.AICC_Student_Name.getValue().split(",");
    parent.Varlastname.set(username[0]);
    parent.Varfirstname.set(username[1]);

    Tim
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    Hey Tim, thx  :-)

    i tried it but its the same like before, is there maybe something false in my variablemanager...
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    sorry it is the first time i work with variables :-)

     
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    i have send you a test title, maybe it helps
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    oh no it didnt work...:-( isnt allowed to send project files
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    second try: i get always both names

    Wellcome Eastwood, Clint

    for my project it will be necessary that only the firstname will appear....

    For example: Wellcome Clint
  • timk
    timk Community Member Posts: 1,245 ✭ Legend ✭
    Ok, here's my title, I tested in moodle 3.0.

    Damit sollte es funktionieren.

    Tim
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    hey Tim, vielen Dank, werde es gleich ausprobieren.

    glg Marcel

     

     

     
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    Hey Tim, super, danke dir :-) ist es aber auch möglich nur den Vornamen anzeigen zu lassen, quasi...."Hi Marcel"....das wäre nämlich genial :-)
  • timk
    timk Community Member Posts: 1,245 ✭ Legend ✭
    Hi Marcel,

    I'll return to English as the community is international.

    The whole sense of the script is to have both parts of the name in two separate variables. The message displays

    "Hi VAR(firstname) VAR(lastname)" If you remove the part about the lastname, it'll show "Hi Marcel".

    There's a German group http://community.trivantis.com/groups/lectora-user-im-deutschsprachigen-raum/forum/

    Tim
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    Hi Tim, thx for your help, i tried it and have again the strange result but with both variables it works.

    "hi 0" is now the message

     
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    and you can see i removed the (Var)lastname.
  • timk
    timk Community Member Posts: 1,245 ✭ Legend ✭
    Hm, did you change anything else? "0" is the initial value of the variable, so the "Display Message" action is working alright. Seems more like the script isn't setting the name. You didn't remove the action to "Modify variable" "username" did you? Did you test in your LMS? Did you uncheck "Publish for Seamless Play" when publishing to Scorm? (Sorry, actually I don't know what it's called in German) These are the three reasons I can think of causing the script to not get the name.

    Here's another sample, I tested in moodle (now 3.1.5). The textfield displays the firstname only, the message still displays both parts.

    Tim
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    Hey Tim, thx, this works, a little bit strange, maybe i forgot something,  i had a lot to do the last days but tomorrow i will work further on my little project :-)  i had last week another little problem, when i pasted a textfield with some text, i had another format result. That means, that the textformat in the editor view is not the same like in the Preview mode. Do you have an idea why? For me its very bad, because i have to place exactly symbols beside terms in my text

    nice greetings, Marcel
  • timk
    timk Community Member Posts: 1,245 ✭ Legend ✭
    The browsers sometimes interpret Lectoras style settings differently. What exactly is different? Position of the textfield? Or formatting of the text itself?
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    Hi Tim,

    thx for your fast answer, yes the formatting of the text itself is different.

    you can see it in the two pictures....really strange
  • mmilo9281
    mmilo9281 Community Member Posts: 155 ☆ Roadie ☆
    and this is how it looks like in the preview mode...
  • mallow76
    mallow76 Community Member Posts: 123
    You'll get better results if you just split your text into separate text boxes.
  • mnotermans5114
    mnotermans5114 Community Member Posts: 916 ☆ Roadie ☆
    Not only will things look different in preview versus editor mode, but even when you publish it might look different in different browsers. Just try and publish, then test in IE, FF, Chrome and Edge ( and if you dare even Safari ). If the look and feel of your texts and formatting is everywhere exact the same, you are very lucky. In most cases there will be differences, and if you need to get them all 100% the same, your in for quite some work. Back to the issue at hand, the difference in preview versus editor mode. I do think you should ignore both. What counts is your final output, being HTML. So publish and test that.... thats what the endresult will be. Preview in browser targetting your favourite browser for me often gives the closest result compared to a publish.

    ~Math