cmi.core.student_name

205 views
Skip to first unread message

baldTrainer

unread,
May 15, 2012, 3:04:05 PM5/15/12
to elearning-technolo...@googlegroups.com
This may have been covered previously, but I can't seem to find it.  I've got a Flash-based certificate on a Moodle LMS.  The cert pulls the student's name using cmi.core.student_name.  It works just fine, but the name is pushed out as 'Last Name, First Name'.  Is there a simple way to flip the name so it shows 'First Name, Last Name'? Thanks!

Henry Ryng

unread,
May 15, 2012, 3:22:18 PM5/15/12
to elearning-technolo...@googlegroups.com

Without syntax details.

 

 

Myarray()  = name.split(",")

 

Newnname = MyArray(1) + " " + MyArray(0)



On Tue, May 15, 2012 at 12:04 PM, baldTrainer <baldt...@gmail.com> wrote:
This may have been covered previously, but I can't seem to find it.  I've got a Flash-based certificate on a Moodle LMS.  The cert pulls the student's name using cmi.core.student_name.  It works just fine, but the name is pushed out as 'Last Name, First Name'.  Is there a simple way to flip the name so it shows 'First Name, Last Name'? Thanks!

--
You received this message because you are subscribed to the Google Groups "eLearning Technology and Development" group.
To view this discussion on the web visit https://groups.google.com/d/msg/elearning-technology-and-development/-/zc0knCH5hrcJ.
To post to this group, send email to elearning-technolo...@googlegroups.com.
To unsubscribe from this group, send email to elearning-technology-and...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/elearning-technology-and-development?hl=en.

Philip Hutchison

unread,
May 15, 2012, 3:45:56 PM5/15/12
to elearning-technolo...@googlegroups.com
SCORM doesn't specify the formatting of the name, and leaves it up to the LMS. Some do "Family Name, Given Name", some do "Given Name Family Name", etc.

If you know your LMS is sending you "Family Name, Given Name", you can use a bit of JavaScript to rearrange.

function reverseNameOrder(namestr){
var name = "Smith, John";
var arr = name.split(", ");
name = arr[1] + " " + arr[0];

Of course this doesn't account for names that might contain additional commas, such as "Davis, Sammy, Jr.", but it will work in most cases.

Here are some other approaches:

function reverseNameOrder(namestr){
var arr = namestr.split(", ");
if(arr.length > 1){
namestr = arr.reverse().join(" ");
}
return namestr;
}

console.log(reverseNameOrder("Smith, John"));  // John Smith
console.log(reverseNameOrder("Davis, Sammy Jr.")); // Sammy Jr. Davis
console.log(reverseNameOrder("Howser, Doogie, MD")); // MD Doogie Howser


function reverseNameOrder2(namestr){
var arr = namestr.split(", ");
if(arr.length > 1){
var family = arr.splice(0,1);
var remainder = arr.join(", ");
namestr = remainder + " " + family;
}
return namestr;
}

console.log(reverseNameOrder2("Smith, John")); //John Smith
console.log(reverseNameOrder2("Davis, Sammy Jr.")); // Sammy Jr. Davis
console.log(reverseNameOrder2("Howser, Doogie, MD")); // Doogie, MD Howser



None are perfect, but them's the breaks!  :)

- philip


On Tue, May 15, 2012 at 12:04 PM, baldTrainer <baldt...@gmail.com> wrote:
This may have been covered previously, but I can't seem to find it.  I've got a Flash-based certificate on a Moodle LMS.  The cert pulls the student's name using cmi.core.student_name.  It works just fine, but the name is pushed out as 'Last Name, First Name'.  Is there a simple way to flip the name so it shows 'First Name, Last Name'? Thanks!

--

Philip Hutchison

unread,
May 15, 2012, 3:46:50 PM5/15/12
to elearning-technolo...@googlegroups.com
oops, ignore the first "function reverseNameOrder(namestr){", it was a typo

rsug...@pivotpointelearning.com

unread,
May 15, 2012, 3:48:43 PM5/15/12
to elearning-technolo...@googlegroups.com

Here’s a function I use:

 

function getName()

{

                var locComma = sUserName.indexOf(",")

                var learnerLen = sUserName.length

                sUserLast = sUserName.substring(0,locComma)

                sUserFirst = sUserName.substring(locComma + 2,learnerLen)

                sUserName = sUserFirst + " " + sUserLast

}

 

sUserName initially holds the value returned by GetValue(“cmi.core.student_name”)

 

Raymond Sugel Sr
cid:image001.png@01CA9746.34805150
eLearning Consultant
224-293-4135 (O)

847-370-6163 (C)
rsug...@pivotpointelearning.com
www.pivotpointelearning.com

--

image001.png

Ryan Wale

unread,
May 16, 2012, 7:44:58 AM5/16/12
to elearning-technolo...@googlegroups.com

Thanks so much for the help!  Got it up and running now…

image001.png
Reply all
Reply to author
Forward
0 new messages