Пример #1
0
function replaceResultRequest($grade, $sourcedid, $endpoint, $oauth_consumer_key, $oauth_consumer_secret)
{
    $method = "POST";
    $content_type = "application/xml";
    $operation = 'replaceResultRequest';
    $postBody = str_replace(array('SOURCEDID', 'GRADE', 'OPERATION', 'MESSAGE'), array($sourcedid, $grade, $operation, uniqid()), getPOXGradeRequest());
    $response = sendOAuthBody($method, $endpoint, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $postBody);
    return parseResponse($response);
}
Пример #2
0
echo "reg_key=" . $reg_key . "\n";
echo "reg_password="******"\n";
echo "</pre>\n";
if (strlen($register_url) < 1 || strlen($reg_key) < 1 || strlen($reg_password) < 1) {
    die("Cannot call register_url - insufficient data...\n");
}
unset($_SESSION['reg_key']);
unset($_SESSION['reg_password']);
$_SESSION['reg_key'] = $reg_key;
$_SESSION['reg_password'] = $reg_password;
togglePre("Registration Request", htmlent_utf8($body));
$more_headers = array();
if ($lti_message_type == "ToolProxyReregistrationRequest") {
    $more_headers[] = 'VND-IMS-CONFIRM-URL: ' . $cur_base . 'tp_commit.php?correlation=49201-48842';
}
$response = sendOAuthBody("POST", $register_url, $reg_key, $reg_password, "application/vnd.ims.lti.v2.toolproxy+json", $body, $more_headers);
togglePre("Registration Request Headers", htmlent_utf8(get_body_sent_debug()));
global $LastOAuthBodyBaseString;
togglePre("Registration Request Base String", $LastOAuthBodyBaseString);
togglePre("Registration Response Headers", htmlent_utf8(get_body_received_debug()));
togglePre("Registration Response", htmlent_utf8(json_indent($response)));
$tc_half_shared_secret = false;
if ($last_http_response == 201 || $last_http_response == 200) {
    if ($oauth_splitsecret && $tp_half_shared_secret) {
        $responseObject = json_decode($response);
        if (isset($responseObject->tc_half_shared_secret)) {
            $tc_half_shared_secret = $responseObject->tc_half_shared_secret;
            echo "<p>tc_half_shared_secret: " . $tc_half_shared_secret . "</p>\n";
            if (strlen($tc_half_shared_secret) != 128) {
                echo '<p style="color: red">Warning secret length of ' . strlen($tc_half_shared_secret) . " should be 128</p>\n";
            }
Пример #3
0
<?php

require_once "util/lti_util.php";
if (isset($_GET['url']) && isset($_GET['r_key']) && isset($_GET['r_secret'])) {
    // All good
} else {
    error_log("tc_commit.php missing url, r_key, or r_secret parameter");
    die('tc_commit.php missing url, r_key, or r_secret parameter');
}
error_log("tp_commit.php sleeping 5 seconds");
sleep(5);
error_log("tp_commit.php back from sleep");
$url = $_GET['url'];
$reg_key = $_GET['r_key'];
$reg_secret = $_GET['r_secret'];
error_log($url);
$accept_type = "application/json";
$body = '{}';
$response = sendOAuthBody("PUT", $url, $reg_key, $reg_secret, "application/vnd.ims.lti.v2.toolproxy+json", $body);
Пример #4
0
        } else {
            if (isset($_REQUEST['set_link'])) {
                $postBody = true;
                $response = sendOAuthBody("PUT", $link_url, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $settings);
                $debugin = get_body_sent_debug();
                $debugout = get_body_received_debug();
            } else {
                if (isset($_REQUEST['set_tool'])) {
                    $postBody = true;
                    $response = sendOAuthBody("PUT", $tool_url, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $settings);
                    $debugin = get_body_sent_debug();
                    $debugout = get_body_received_debug();
                } else {
                    if (isset($_REQUEST['set_proxy'])) {
                        $postBody = true;
                        $response = sendOAuthBody("PUT", $proxy_url, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $settings);
                        $debugin = get_body_sent_debug();
                        $debugout = get_body_received_debug();
                    } else {
                        exit;
                    }
                }
            }
        }
    }
}
global $LastOAuthBodyBaseString;
$lbs = $LastOAuthBodyBaseString;
ltiUtilTogglePre("Sent Headers", $debugin);
if ($postBody !== false) {
    ltiUtilTogglePre("Our Body Data", indent($settings));
Пример #5
0
</p><p>
<input type='submit' name='get' value="Get Result">
<input type='submit' name='set' value="Set Result">
</form>
<?php 
$postBody = false;
$content_type = "application/vnd.ims.lis.v2.result+json";
if (isset($_REQUEST['get'])) {
    $response = sendOAuthGET($result_url, $oauth_consumer_key, $oauth_consumer_secret, "application/vnd.ims.lis.v2.result+json");
    $debugin = get_get_sent_debug();
    $debugout = get_get_received_debug();
} else {
    if (isset($_REQUEST['set'])) {
        $addStructureRequest = getResultJSON($_REQUEST['grade'], $_REQUEST['comment']);
        $postBody = indent(json_encode($addStructureRequest));
        $response = sendOAuthBody("PUT", $result_url, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $postBody);
        $debugin = get_body_sent_debug();
        $debugout = get_body_received_debug();
    } else {
        exit;
    }
}
global $LastOAuthBodyBaseString;
$lbs = $LastOAuthBodyBaseString;
ltiUtilTogglePre("Headers sent", $debugin);
if ($postBody !== false) {
    ltiUtilTogglePre("Our Body Data", indent($postBody));
}
ltiUtilTogglePre("Our Base String", $lbs);
ltiUtilTogglePre("Results and Headers", $debugout);
if (strlen($response) < 1) {
Пример #6
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 {
            exit;
        }
    }
}
$response = sendOAuthBody($method, $endpoint, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $postBody);
global $LastOAuthBodyBaseString;
$lbs = $LastOAuthBodyBaseString;
global $LastPOSTHeader;
$lph = $LastPOSTHeader;
try {
    $retval = parseResponse($response);
} catch (Exception $e) {
    $retval = $e->getMessage();
}
echo "\n<pre>\n";
echo "Service Url:\n";
echo htmlent_utf8($endpoint) . "\n\n";
echo get_body_sent_debug();
print_r($retval);
echo "\n";