0

Thank you Brian. Moving my script blocks as you suggested worked and it is now sending statements. Terrific! Unfortunately instead of it capturing the name that someone enters in the form, the statement viewer gives me an actor name of "fullname." Is there something that I can do to the form or the script to fix this? My latest code is below. Many thanks.

<!DOCTYPE html>
<html>
    <head>
    <meta charset="utf-8">
    </head>
    <body>

<form id="frm1" action="">
    Full Name: <input type="text" id="fullNameID" name="fullName"><br>
    Email: <input type="text" id="emailAddressID" name="emailAddress"><br><br>
    <input type="button" id="theButton" value="Submit">
</form>

        <p>
        <code><pre id='output'></pre></code>
        </p>

    <script src="js/xapiwrapper.min.js"></script>
    <script type="text/javascript">


                var button = document.getElementById("theButton"),
                fullName =  button.form.fullNameID.value;
                emailAddress =  button.form.emailAddressID.value;

                button.onclick = function() {

                var stmt = new ADL.XAPIStatement(
                new ADL.XAPIStatement.Agent(ADL.XAPIWrapper.hash('mailto:emailAddress'), 'fullName'),
                new ADL.XAPIStatement.Verb('http://adlnet.gov/expapi/verbs/registered', 'registered'),
                new ADL.XAPIStatement.Activity('act:http://ISO9000Video.html', 'Preparing for the ISO 9000 Audit',
                    'Preparation steps for the upcoming ISO 9000 audit.')
            );
            stmt.generateId();
            stmt.addOtherContextActivity( new ADL.XAPIStatement.Activity('compId:internet_proficiency') );
            stmt.generateRegistration();

            ADL.XAPIWrapper.changeConfig({
                'endpoint': 'https://lrs.adlnet.gov/xapi/',
                'user': 'xapi-tools',
                'password': 'xapi-tools',
            });

            ADL.XAPIWrapper.sendStatement(stmt);

            var o = document.getElementById('output');
            o.innerText = JSON.stringify(stmt, null, '    ');
        }

        </script>



    </body>
    </html>
John M.
  • 347
  • 1
  • 11

1 Answers1

0

You have the values hardcoded in your Agent creation line:

new ADL.XAPIStatement.Agent(ADL.XAPIWrapper.hash('mailto:emailAddress'), 'fullName'),

Rather than using the variables you've set. And to preempt the next likely question, you've set the value of those variables on page load rather than during the click handler which is likely when you'll want them.

Brian J. Miller
  • 2,169
  • 1
  • 12
  • 12