Пример #1
0
function postLaunchHTML($newparms, $endpoint, $debug = false, $iframeattr = false)
{
    global $LastOAuthBodyBaseString;
    $r = "<div id=\"ltiLaunchFormSubmitArea\">\n";
    if ($iframeattr == "_blank") {
        $r = "<form action=\"" . $endpoint . "\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" target=\"_blank\" encType=\"application/x-www-form-urlencoded\">\n";
    } else {
        if ($iframeattr) {
            $r = "<form action=\"" . $endpoint . "\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" target=\"basicltiLaunchFrame\" encType=\"application/x-www-form-urlencoded\">\n";
        } else {
            $r = "<form action=\"" . $endpoint . "\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" encType=\"application/x-www-form-urlencoded\">\n";
        }
    }
    $submit_text = isset($newparms['ext_submit']) ? $newparms['ext_submit'] : 'Submit';
    foreach ($newparms as $key => $value) {
        $key = htmlspec_utf8($key);
        $value = htmlspec_utf8($value);
        if ($key == "ext_submit") {
            $r .= "<input type=\"submit\" name=\"";
        } else {
            $r .= "<input type=\"hidden\" name=\"";
        }
        $r .= $key;
        $r .= "\" value=\"";
        $r .= $value;
        $r .= "\"/>\n";
    }
    if ($debug) {
        $r .= "<script language=\"javascript\"> \n";
        $r .= "  //<![CDATA[ \n";
        $r .= "function basicltiDebugToggle() {\n";
        $r .= "    var ele = document.getElementById(\"basicltiDebug\");\n";
        $r .= "    if(ele.style.display == \"block\") {\n";
        $r .= "        ele.style.display = \"none\";\n";
        $r .= "    }\n";
        $r .= "    else {\n";
        $r .= "        ele.style.display = \"block\";\n";
        $r .= "    }\n";
        $r .= "} \n";
        $r .= "  //]]> \n";
        $r .= "</script>\n";
        $r .= "<a id=\"displayText\" href=\"javascript:basicltiDebugToggle();\">";
        $r .= get_string("toggle_debug_data", "basiclti") . "</a>\n";
        $r .= "<div id=\"basicltiDebug\" style=\"display:none\">\n";
        $r .= "<b>" . get_string("basiclti_endpoint", "basiclti") . "</b><br/>\n";
        $r .= $endpoint . "<br/>\n&nbsp;<br/>\n";
        $r .= "<b>" . get_string("basiclti_parameters", "basiclti") . "</b><br/>\n";
        ksort($newparms);
        foreach ($newparms as $key => $value) {
            $key = htmlspec_utf8($key);
            $value = htmlspec_utf8($value);
            $r .= "{$key} = {$value}<br/>\n";
        }
        $r .= "&nbsp;<br/>\n";
        $r .= "<p><b>" . get_string("basiclti_base_string", "basiclti") . "</b><br/>\n" . $LastOAuthBodyBaseString . "</p>\n";
        $r .= "</div>\n";
    }
    $r .= "</form>\n";
    if ($iframeattr && $iframeattr != '_blank') {
        $r .= "<iframe name=\"basicltiLaunchFrame\"  id=\"basicltiLaunchFrame\" src=\"\"\n";
        $r .= $iframeattr . ">\n<p>" . get_string("frames_required", "basiclti") . "</p>\n</iframe>\n";
    }
    if (!$debug) {
        $ext_submit = "ext_submit";
        $ext_submit_text = $submit_text;
        $r .= " <script type=\"text/javascript\"> \n" . "  //<![CDATA[ \n" . "    document.getElementById(\"ltiLaunchForm\").style.display = \"none\";\n" . "    nei = document.createElement('input');\n" . "    nei.setAttribute('type', 'hidden');\n" . "    nei.setAttribute('name', '" . $ext_submit . "');\n" . "    nei.setAttribute('value', '" . $ext_submit_text . "');\n" . "    document.getElementById(\"ltiLaunchForm\").appendChild(nei);\n" . "    document.ltiLaunchForm.submit(); \n" . "  //]]> \n" . " </script> \n";
    }
    $r .= "</div>\n";
    return $r;
}
Пример #2
0
    /**
     * Emit the text and form fields to support the done option
     */
    public static function done()
    {
        global $USER;
        if (!$USER->instructor) {
            return;
        }
        $done = Settings::linkGet('done', '');
        ?>
        <label for="done">
            This option allows you to control the existance and behavior of a "Done" button for this tool.
            If you leave this blank the tool will assume it is in an iFrame and will not show a Done button.
            If you put a URL here, a Done button will be shown and when pressed the tool will navigate to
            the specified URL.  If you expect to launch this tool in a popup, enter "_close" here and
            the tool will close its window when Done is pressed.<br/>
        <input type="text" class="form-control" value="<?php 
        echo htmlspec_utf8($done);
        ?>
" name="done"></label>
<?php 
    }
Пример #3
0
$iframe = isset($_REQUEST["iframe"]) && $_REQUEST["iframe"] == "true";
$checked = '';
if ($iframe) {
    $checked = 'checked';
}
echo "<br/>Launch in iFrame: <input type=\"checkbox\" name=\"iframe\" {$checked} {$disabled} value=\"true\">\n";
$sha256 = isset($_REQUEST["sha256"]) && $_REQUEST["sha256"] == "true";
if ($sha256) {
    $checked = 'checked';
}
echo "<br/>Sign with SHA256: <input type=\"checkbox\" name=\"sha256\" {$checked} {$disabled} value=\"true\">\n";
echo "</fieldset><p>";
echo "<fieldset><legend>Launch Data</legend>\n";
foreach ($lmsdata as $k => $val) {
    echo $k . ": <input type=\"text\" size=\"60\" name=\"" . $k . "\" value=\"";
    echo htmlspec_utf8($val);
    echo "\"><br/>\n";
}
echo "</fieldset>\n";
echo "</form>\n";
echo "</div>\n";
echo "<hr>";
$parms = $lmsdata;
// Cleanup parms before we sign
foreach ($parms as $k => $val) {
    if (strlen(trim($parms[$k])) < 1) {
        unset($parms[$k]);
    }
}
// Add oauth_callback to be compliant with the 1.0A spec
$parms["oauth_callback"] = "about:blank";
Пример #4
0
 public static function postLaunchHTML($newparms, $endpoint, $debug = false, $iframeattr = false, $endform = false)
 {
     global $LastOAuthBodyBaseString;
     $r = "<div id=\"ltiLaunchFormSubmitArea\">\n";
     if ($iframeattr == "_blank") {
         $r = "<form action=\"" . $endpoint . "\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" target=\"_blank\" encType=\"application/x-www-form-urlencoded\">\n";
     } else {
         if ($iframeattr) {
             $r = "<form action=\"" . $endpoint . "\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" target=\"basicltiLaunchFrame\" encType=\"application/x-www-form-urlencoded\">\n";
         } else {
             $r = "<form action=\"" . $endpoint . "\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" encType=\"application/x-www-form-urlencoded\">\n";
         }
     }
     $submit_text = $newparms['ext_submit'];
     foreach ($newparms as $key => $value) {
         $key = htmlspec_utf8($key);
         $value = htmlspec_utf8($value);
         if ($key == "ext_submit") {
             $r .= "<input type=\"submit\" name=\"";
         } else {
             $r .= "<input type=\"hidden\" name=\"";
         }
         $r .= $key;
         $r .= "\" class=\"btn btn-primary";
         $r .= "\" value=\"";
         $r .= $value;
         $r .= "\"/>\n";
     }
     if ($debug) {
         $r .= "<script language=\"javascript\"> \n";
         $r .= "  //<![CDATA[ \n";
         $r .= "function basicltiDebugToggle() {\n";
         $r .= "    var ele = document.getElementById(\"basicltiDebug\");\n";
         $r .= "    if(ele.style.display == \"block\") {\n";
         $r .= "        ele.style.display = \"none\";\n";
         $r .= "    }\n";
         $r .= "    else {\n";
         $r .= "        ele.style.display = \"block\";\n";
         $r .= "    }\n";
         $r .= "} \n";
         $r .= "  //]]> \n";
         $r .= "</script>\n";
         $r .= "<a id=\"basicltiDebugToggle\" href=\"javascript:basicltiDebugToggle();\">";
         $r .= self::get_string("toggle_debug_data", "basiclti") . "</a>\n";
         $r .= "<div id=\"basicltiDebug\" style=\"display:none\">\n";
         $r .= "<b>" . self::get_string("basiclti_endpoint", "basiclti") . "</b><br/>\n";
         $r .= $endpoint . "<br/>\n&nbsp;<br/>\n";
         $r .= "<b>" . self::get_string("basiclti_parameters", "basiclti") . "</b><br/>\n";
         foreach ($newparms as $key => $value) {
             $key = htmlspec_utf8($key);
             $value = htmlspec_utf8($value);
             $r .= "{$key} = {$value}<br/>\n";
         }
         $r .= "&nbsp;<br/>\n";
         $r .= "<p><b>" . self::get_string("basiclti_base_string", "basiclti") . "</b><br/>\n" . $LastOAuthBodyBaseString . "</p>\n";
         $r .= "</div>\n";
     }
     if ($endform) {
         $r .= $endform;
     }
     $r .= "</form>\n";
     if ($iframeattr && $iframeattr != '_blank') {
         $r .= "<iframe name=\"basicltiLaunchFrame\"  id=\"basicltiLaunchFrame\" src=\"\"\n";
         $r .= $iframeattr . ">\n<p>" . self::get_string("frames_required", "basiclti") . "</p>\n</iframe>\n";
     }
     // Remove session_name (i.e. PHPSESSID) if it was added.
     $r .= " <script type=\"text/javascript\"> \n" . "  //<![CDATA[ \n" . "    var inputs = document.getElementById(\"ltiLaunchForm\").childNodes;\n" . "    for (var i = 0; i < inputs.length; i++)\n" . "    {\n" . "        var thisinput = inputs[i];\n" . "        if ( thisinput.name != '" . session_name() . "' ) continue;\n" . "        thisinput.parentNode.removeChild(thisinput);\n" . "    }\n" . "  //]]> \n" . " </script> \n";
     if (!$debug) {
         $ext_submit = "ext_submit";
         $ext_submit_text = $submit_text;
         $r .= " <script type=\"text/javascript\"> \n" . "  //<![CDATA[ \n" . "    document.getElementById(\"ltiLaunchForm\").style.display = \"none\";\n" . "    nei = document.createElement('input');\n" . "    nei.setAttribute('type', 'hidden');\n" . "    nei.setAttribute('name', '" . $ext_submit . "');\n" . "    nei.setAttribute('value', '" . $ext_submit_text . "');\n" . "    document.getElementById(\"ltiLaunchForm\").appendChild(nei);\n" . "    document.ltiLaunchForm.submit(); \n" . "  //]]> \n" . " </script> \n";
     }
     $r .= "</div>\n";
     return $r;
 }
Пример #5
0
}
$top_tag = str_replace("Request", "Response", $operation);
$body_tag = "\n<" . $top_tag . "/>";
if ($operation == "replaceResultRequest") {
    $score = (string) $parms->resultRecord->result->resultScore->textString;
    $fscore = (double) $score;
    if (!is_numeric($score)) {
        echo sprintf($response, uniqid(), 'failure', "Score must be numeric", $message_ref, $operation, $body_tag);
        exit;
    }
    $fscore = (double) $score;
    if ($fscore < 0.0 || $fscore > 1.0) {
        echo sprintf($response, uniqid(), 'failure', "Score not between 0.0 and 1.0", $message_ref, $operation, $body_tag);
        exit;
    }
    echo sprintf($response, uniqid(), 'success', "Score for " . htmlspec_utf8($sourcedid) . " is now {$score}", $message_ref, $operation, $body_tag);
    $gradebook[$sourcedid] = $score;
} else {
    if ($operation == "readResultRequest") {
        $score = $gradebook[$sourcedid];
        $body = '
    <readResultResponse>
      <result>
        <resultScore>
          <language>en</language>
          <textString>%s</textString>
        </resultScore>
      </result>
    </readResultResponse>';
        $body = sprintf($body, $score);
        echo sprintf($response, uniqid(), 'success', "Score read successfully", $message_ref, $operation, $body);
Пример #6
0
is not running on localhost.
Because these services are server-to-server calls if you are 
running your LMS on "localhost", you must also run this script
on localhost as well.  If your LMS has a real Internet
address you should be OK.  You can get a copy of the test
tools to run locally at 
to test your LMS instance running on localhost.
(<a href="../lti.zip" target="_new">Download</a>) 
</p>
<?php 
}
$oauth_consumer_key = $_REQUEST['key'];
$method = "POST";
$endpoint = $_REQUEST['url'];
$content_type = "application/xml";
$sourcedid = htmlspec_utf8($sourcedid);
if ($_REQUEST['submit'] == "Send Grade" && isset($_REQUEST['grade'])) {
    $operation = 'replaceResultRequest';
    $postBody = str_replace(array('SOURCEDID', 'GRADE', 'OPERATION', 'MESSAGE'), array($sourcedid, $_REQUEST['grade'], $operation, uniqid()), getPOXGradeRequest());
    if (strpos($_REQUEST['accepted'], "text") !== false && strlen($_REQUEST['comment']) > 0) {
        $postBody = str_replace("</resultScore>", "</resultScore>\n<resultData>\n<text>\n" . $_REQUEST['comment'] . "\n</text>\n</resultData>", $postBody);
    }
} else {
    if ($_REQUEST['submit'] == "Read Grade") {
        $operation = 'readResultRequest';
        $postBody = str_replace(array('SOURCEDID', 'OPERATION', 'MESSAGE'), array($sourcedid, $operation, uniqid()), getPOXRequest());
    } else {
        if ($_REQUEST['submit'] == "Delete Grade") {
            $operation = 'deleteResultRequest';
            $postBody = str_replace(array('SOURCEDID', 'OPERATION', 'MESSAGE'), array($sourcedid, $operation, uniqid()), getPOXRequest());
        } else {