LTI Launch Tester

Whenever a launch is triggered, the configuration parameters are applied, new nonce and timestamp values are obtained, and a new OAuth signature is calculated. The "Refresh" button does the same, without triggering a launch. Current support is for LTI 1.0/1.1 Adapted from Lance's implementation and customized for testing dashboards

by prakgarnly

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/hmac-sha1.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/components/enc-base64.js"></script>
<p><em>Remember to click on "Refresh" at the bottom of the form before launching!!</em>

</p>

<h2>LTI configuration parameters</h2>

<form id="ltiConfigurationForm" onsubmit="updateLtiLaunchForm(); return false;">
    <ul>http://jsfiddle.net/prakgarnly/sd20tL6b/56/#run
        <li>
            <label>Launch URL:
                <input id="launchUrl" value="" type="text" />
            </label>
        </li>
        <li>
            <label>View ID:
                <input id="viewId" value="" type="text" />
            </label>
        </li>
        <li>
            <label>Key:
                <input id="key" value="" type="text" size="80" />
            </label>
        </li>
        <li>
            <label>Secret:
                <input id="secret" value="" type="text" size="80" />
            </label>
        </li>
    </ul>
    <button type="submit" style="display: none;"></button>
</form>

<h2>LTI launch parameters</h2>

<form id="ltiLaunchForm" name="ltiLaunchForm" method="POST" action="" onsubmit="updateLtiLaunchForm()">
    <ul>
        <li>
            <label>user_id:
                <input type="text" name="user_id" value="0ae836b9-7fc9-4060-006f-27b2066ac545">
            </label>
        </li>
        <li>
            <label>roles:
                <input type="text" name="roles" value="urn:lti:role:ims/lis/Instructor">
            </label>
        </li>
        <li>
            <label>custom_action:
                <input type="text" name="custom_action" value="view_url"/>
            </label>
        </li>
        <li>
            <label>resource_link_id:
                <input type="text" name="resource_link_id" value="88391-e1919-bb3456">
            </label>
        </li>
        <li>
            <label>resource_link_title:
                <input type="text"...

CSS

input:read-only {
    background-color: #D6D6D6;
}
input#launchUrl {
    width: 90%
}
input{
    width: 60%;
}

JavaScript

(function () {
    window.onload = function () {
        
        // Local testing (Instructor Only Dashbaord)
        $('#launchUrl').val('http://77fa04f4.ngrok.com/ltilaunch/');
        $('#viewId').val('55a7e1d83004e82fbf3007dd');
        $('#key').val('btAOEeZ0Qx-DeKA7BMiddA');
        $('#secret').val('863feef1-519e-4768-ac0b-646312eb907e');

//rtw simple        
//$('#launchUrl').val('http://77fa04f4.ngrok.com/ltilaunch/55500e1330049af4c9a6ce57');
//        $('#key').val('btAOEeZ0Qx-DeKA7BMiddA');
//        $('#secret').val('fe0bfe47-e343-43c8-a626-9d56ef26ddba');
        
        // Local testing (Learner Only Dashbaord)
        //$('#launchUrl').val('http://56ee95b0.ngrok.com/ltilaunch/559ed69b3004b603a9baaf95');//
        //$('#key').val('SHMaOmepTgaMWKrCWR0ZVw');
        //$('#secret').val('11604152-fcbb-421b-b829-4de672d03fee');
        
        // Local testing (Student Only Dashbaord)
        //$('#launchUrl').val('http://56ee95b0.ngrok.com/ltilaunch/559e9fba300482f8d20f7df0');
        //$('#key').val('SHMaOmepTgaMWKrCWR0ZVw');
        //$('#secret').val('a811b294-84a3-455c-a98e-a27acd195092');
        
        // Dev1 testing - Edu Instructor Dashboard
        //$('#launchUrl').val('http://dev1.intellifylearning.com/ltilaunch/559a832c0cf2cd674051df5d');
        //$('#key').val('qiSc1cZ3RDWr-FsGCerXbQ');
        //$('#secret').val('62bc0ae5-6dab-4551-87b3-c4af4822b2e7');
        
        // Dev1 testing - Student Dashboard
        //$('#launchUrl').val('http://dev1.intellifylearning.com/ltilaunch/559a823f0cf23bb9f81c0929');
        //$('#key').val('qiSc1cZ3RDWr-FsGCerXbQ');
        //$('#secret').val('5ced4122-8a9f-4930-a620-90c3f9120f38');
        
        updateLtiLaunchForm();
    };

    this.updateLtiLaunchForm = function () {
        var launchUrl = $('#launchUrl').val() + $('#viewId').val();
        var encodedSecret = encodeURIComponent($('#secret').val()) + '&';
        var $ltiLaunchForm = $('#ltiLaunchForm');

       ...