Skip to main content
Participant
March 22, 2014
Question

how can i reverse the username sent from Moodle showing on the Captivate Certificate?

  • March 22, 2014
  • 1 reply
  • 687 views

Cap 7. Moodle 2.6.

The certificate always shows surname,firstname. I want it to say firstname surname.

Any Ideas?

Thanks

    This topic has been closed for replies.

    1 reply

    RodWard
    Community Expert
    Community Expert
    March 22, 2014

    The variable displayed on the certificate is just pulling whatever is available from the server.  If the server sends the user as surname/firstname then that's what you'll see.  It doesn't break them up in to separate variables for you to change the order.

    So you'll either need to fix this as the server end, or else use some JavaScript to split out the variables and display them.  Advanced Actions has no default way to address this issue.

    matt9099Author
    Participant
    March 22, 2014

    Hi Rod, Thanks for your help.

    Moodle does send the username out 'Surname, Firstname'. I have had this confirmed by the moodle experts.

    Is there a good Javascript forum for me to souce the code to split and display the name correctly?

    Any help is greatly appreciated.

    TLCMediaDesign
    Inspiring
    March 22, 2014

    Put this JavaScript in the <head> section of your html document:

    <script>

    function swapName()

    {

    var cp = document.Captivate;

    var getName = cp.cpEIGetValue('m_VarHandle.cpQuizInfoStudentName');

    var getName = getName.split(",");

    getName.reverse();

    var newName = getName[0]+" "+getName[1];

    cp.cpEISetValue('m_VarHandle.cpQuizInfoStudentName', newName);

    }

    </script>

    Then execute JavaScript on the enter slide before you reach the certificate.

    swapName();