<html><head></head><body><blockquote> <?php if ($_SESSION['token']['temp']) { include "canvasapi.php"; $api = new CanvasAPI($_SESSION['token']['temp'], $_COOKIE['domain']); $response = $api->post_canvas("/login/oauth2/token", "DELETE"); //print_r($response); echo 'Your Canvas access token has been deleted. '; } //no, this won't work. Have to get _parent to reload with javascript echo 'You have logged out. Please refresh your browser no reload'; session_start(); session_unset(); session_destroy(); session_write_close(); setcookie(session_name(), '', 0, '/'); session_regenerate_id(true); ?> </blockquote></body></html>
<?php require_once "/home/bkinney/includes/mysessions.php"; mysession_start(); include_once "/www/canvas/canvasapi.php"; if (array_key_exists('csv', $_REQUEST)) { //download header("content-disposition:attachment;filename=rubric_scores_" . $_REQUEST['aid'] . ".csv"); header("content-type:text/csv"); echo $_REQUEST['csv']; exit; } $token = $_SESSION['token']; $access_key = $_SESSION['token']; $domain = $_SESSION['_basic_lti_context']['custom_domain_url']; $api = new CanvasAPI($access_key, $domain); if (get_val($_GET, 'endpoint')) { $endpoint = str_replace('https://' . $domain, '', $_GET['endpoint']); //echo $endpoint; $queueStatus = $api->get_canvas($endpoint, false); echo '<p>status: ' . $queueStatus['workflow_state']; echo '</p><p>percent completed: ' . $queueStatus['completion'] . '</p>'; if ($queueStatus['completion'] * 1 < 100) { echo '<a href="#" onclick="$(\'#success\').load(\'putgrades-beta.php?endpoint=' . $endpoint . '\')">Check again</a>'; } exit; } $endpoint = '/api/v1/courses/' . $_SESSION['_basic_lti_context']['custom_canvas_course_id'] . '/assignments/' . $_POST['aid'] . '/submissions/update_grades?as_user_id=' . $_SESSION['_basic_lti_context']['custom_canvas_user_id']; $args = array(); foreach ($_POST['grades'] as $grade) { //grade
//echo "valid"; //die(); $context_id = $context->info['context_id']; //echo $context_id; //these are used to update db by get_token_domain $isAdmin = $context->isAdministrator(); setcookie("context", $context_id, 0, '/'); setcookie("isAdmin", $isAdmin, 0, '/'); setcookie("lti_url", "https://apps.ats.udel.edu" . $_SERVER['PHP_SELF'], 0, '/'); //changelog - get token from token table $shared = array_key_exists('custom_shared', $context->info); //this is a Haywood J token. He is an instructor in Becky Test //if($asinstructor)$_SESSION['token']='25~18Dk6lWaa44bnPTWe1xbRydhRJ9zKOc3g3mfbqazxPpgw7MOJ4qGCSRGjJSKQewq'; if ($_SESSION['token']) { //use whatever I've already got from previous trips $api = new CanvasAPI($_SESSION['token'], $domain); $valid = $api->ready; $tokenstatus = "found in session" . $api->status . "," . $api->is_valid_token(); } else { if (!$_SESSION['temptoken']) { /*new plan, use an admin token unless I've set the shared flag*/ if ($isAdmin && !$shared) { //only an admin can create an admin token, and only if we're not sharing if ($domain == "udel.instructure.com") { setcookie('tokenquery', 'none', 0, '/'); } else { setcookie('tokenquery', "insert into tokens (domain, context, token) values ('" . $domain . "', '" . $domain . "', '%s') on duplicate key update token=values(token)", 0, '/'); } } else { if ($context->isInstructor()) { //only instructors can create context tokens, but an admin can be an instructor