*** WARNING *** Access to this page should be restricted to application administrators only.
269 | 270 | EOD; 271 | } 272 | 273 | // Check for any messages to be displayed 274 | if (isset($_SESSION['error_message'])) { 275 | $page .= <<< EOD 276 |ERROR: {$_SESSION['error_message']}
277 | 278 | EOD; 279 | unset($_SESSION['error_message']); 280 | } 281 | 282 | if (isset($_SESSION['message'])) { 283 | $page .= <<< EOD 284 |{$_SESSION['message']}
285 | 286 | EOD; 287 | unset($_SESSION['message']); 288 | } 289 | 290 | // Display table of existing platform records 291 | if ($ok) { 292 | 293 | if (count($platforms) <= 0) { 294 | $page .= <<< EOD 295 |No platforms have been added yet.
296 | 297 | EOD; 298 | } else { 299 | $page .= <<< EOD 300 | 381 | 382 | EOD; 383 | } 384 | 385 | // Display form for adding/editing a platform 386 | $update = ''; 387 | $lti2 = ''; 388 | if (!isset($updatePlatform->created)) { 389 | $mode = 'Add new'; 390 | } else { 391 | $mode = 'Update'; 392 | $update = ' disabled="disabled"'; 393 | if ($updatePlatform->ltiVersion === LtiVersion::V2) { 394 | $lti2 = ' disabled="disabled"'; 395 | } 396 | } 397 | $name = ratingHtmlEntities($updatePlatform->name); 398 | $key = ratingHtmlEntities($updatePlatform->getKey()); 399 | $platformId = ratingHtmlEntities($updatePlatform->platformId); 400 | $clientId = ratingHtmlEntities($updatePlatform->clientId); 401 | $deploymentId = ratingHtmlEntities($updatePlatform->deploymentId); 402 | $authorizationServerId = ratingHtmlEntities($updatePlatform->authorizationServerId); 403 | $authenticationUrl = ratingHtmlEntities($updatePlatform->authenticationUrl); 404 | $accessTokenUrl = ratingHtmlEntities($updatePlatform->accessTokenUrl); 405 | $publicKey = ratingHtmlEntities($updatePlatform->rsaKey); 406 | $jku = ratingHtmlEntities($updatePlatform->jku); 407 | $secret = ratingHtmlEntities($updatePlatform->secret); 408 | if ($updatePlatform->enabled) { 409 | $enabled = ' checked="checked"'; 410 | } else { 411 | $enabled = ''; 412 | } 413 | $enableFrom = ''; 414 | if (!is_null($updatePlatform->enableFrom)) { 415 | $enableFrom = date('j-M-Y H:i', $updatePlatform->enableFrom); 416 | } 417 | $enableUntil = ''; 418 | if (!is_null($updatePlatform->enableUntil)) { 419 | $enableUntil = date('j-M-Y H:i', $updatePlatform->enableUntil); 420 | } 421 | if ($updatePlatform->protected) { 422 | $protected = ' checked="checked"'; 423 | } else { 424 | $protected = ''; 425 | } 426 | $properties = ''; 427 | $settings = $updatePlatform->getSettings(); 428 | foreach ($settings as $prop => $value) { 429 | if (strpos($prop, 'custom_') !== 0) { 430 | $properties .= "{$prop}={$value}\n"; 431 | } 432 | } 433 | if ($updatePlatform->debugMode) { 434 | $debug = ' checked="checked"'; 435 | } else { 436 | $debug = ''; 437 | } 438 | $v1 = LtiVersion::V1->value; 439 | $v1p3 = LtiVersion::V1P3->value; 440 | $v1Selected = ' selected'; 441 | $v1p3Selected = ''; 442 | if ($updatePlatform->ltiVersion === LtiVersion::V1P3) { 443 | $v1Selected = ''; 444 | $v1p3Selected = ' selected'; 445 | } 446 | 447 | $page .= <<< EOD 448 |ERROR: {$_SESSION['error_message']}
258 | 259 | EOD; 260 | unset($_SESSION['error_message']); 261 | } 262 | 263 | if (isset($_SESSION['message'])) { 264 | $page .= <<< EOD 265 |{$_SESSION['message']}
266 | 267 | EOD; 268 | unset($_SESSION['message']); 269 | } 270 | 271 | // Display table of existing platform records 272 | if ($ok) { 273 | 274 | if (count($items) <= 0) { 275 | $page .= <<< EOD 276 |No items have been added yet.
277 | 278 | EOD; 279 | } else { 280 | $page .= <<< EOD 281 |{$title}{$text} | 324 |325 | 326 | EOD; 327 | if (!$_SESSION['isStudent']) { 328 | $page .= <<< EOD 329 | | 330 | 346 | | 347 |
348 | ![]() ![]() |
350 |
351 | EOD;
352 | }
353 | $page .= <<< EOD
354 |
ID | 561 |Name | 562 |Learner? | 563 |Ratings | 564 |
---|---|---|---|
{$user->ltiUserId} | 586 |{$name} | 587 |{$ratings} | 589 |
Name | 607 |Groups | 608 |
---|---|
{$title} | 622 |
623 |
624 | EOD;
625 | foreach ($groupSet['groups'] as $groupId) {
626 | $page .= <<< EOD
627 | {$resourceLink->groups[$groupId]['title']} 628 | 629 | EOD; 630 | } 631 | $page .= <<< EOD 632 | |
633 |
645 | Your course does not appear to offer the ability to access a list of groups, or there are no group sets available. 646 |
647 | 648 | EOD; 649 | } 650 | } else { 651 | $page .= <<< EOD 652 | 655 | 656 | EOD; 657 | } 658 | } else if (!$_SESSION['isContentItem']) { 659 | $page .= <<< EOD 660 | Your course does not appear to offer the ability to access a list of users. 661 | 662 | EOD; 663 | } 664 | $page .= <<< EOD 665 |Label | 684 |Points possible | 685 |Resource Link ID | 686 |Resource ID | 687 |Tag | 688 |
---|---|---|---|---|
{$lineitem->label} | 703 |$lineitem->pointsPossible | 704 |{$lineitem->ltiResourceLinkId} | 705 |{$lineitem->resourceId} | 706 |{$lineitem->tag} | 707 |
138 | Here is a summary of your rating of items: 139 |
140 |289 | This page allows you to perform a dynamic registration with an LTI 1.3 platform. 290 |
291 | 292 |293 | 294 |
295 | 298 | 299 | 302 | 305 | 306 | 309 | 310 | 311 | 312 | EOD; 313 | $this->output = $html; 314 | } 315 | 316 | protected function onError(): void 317 | { 318 | $msg = $this->message; 319 | if ($this->debugMode && !empty($this->reason)) { 320 | $msg = $this->reason; 321 | } 322 | $title = APP_NAME; 323 | 324 | $this->errorOutput = <<< EOD 325 | 326 | 327 | 328 | 329 | 330 |{$msg}
339 | 340 | 341 | EOD; 342 | } 343 | 344 | public function doRegistration(): void 345 | { 346 | $platformConfig = $this->getPlatformConfiguration(); 347 | if ($this->ok) { 348 | $toolConfig = $this->getConfiguration($platformConfig); 349 | $registrationConfig = $this->sendRegistration($platformConfig, $toolConfig); 350 | if ($this->ok) { 351 | $this->getPlatformToRegister($platformConfig, $registrationConfig, false); 352 | if (defined('AUTO_ENABLE') && AUTO_ENABLE) { 353 | $this->platform->enabled = true; 354 | } 355 | if (defined('ENABLE_FOR_DAYS') && (ENABLE_FOR_DAYS > 0)) { 356 | $now = time(); 357 | $this->platform->enableFrom = $now; 358 | $this->platform->enableUntil = $now + (ENABLE_FOR_DAYS * 24 * 60 * 60); 359 | } 360 | $this->ok = $this->platform->save(); 361 | if (!$this->ok) { 362 | $checkPlatform = Platform::fromPlatformId($this->platform->platformId, $this->platform->clientId, 363 | $this->platform->deploymentId, $this->dataConnector); 364 | if (!empty($checkPlatform->created)) { 365 | $this->reason = 'The platform is already registered.'; 366 | } else { 367 | $this->reason = 'Sorry, an error occurred when saving the platform details.'; 368 | } 369 | } 370 | } 371 | } 372 | } 373 | 374 | } 375 | 376 | ?> 377 | -------------------------------------------------------------------------------- /src/register.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright SPV Software Products 11 | * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 12 | */ 13 | require_once('rating_tp.php'); 14 | 15 | // Initialise session and database 16 | $page = ''; 17 | $db = null; 18 | if (init($db)) { 19 | 20 | // Register 21 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { 22 | 23 | $errorMsg = ''; 24 | $url = $_SESSION['return_url']; 25 | if (strpos($url, '?') === false) { 26 | $sep = '?'; 27 | } else { 28 | $sep = '&'; 29 | } 30 | $dataConnector = DataConnector\DataConnector::getDataConnector($db, DB_TABLENAME_PREFIX); 31 | $tool = new RatingTool($dataConnector); 32 | $tool->platform = LTI\Platform::fromRecordId($_SESSION['consumer_pk'], $dataConnector); 33 | $do = $_POST['do']; 34 | if ($do == 'Register') { 35 | $ok = $tool->doToolProxyService($_SESSION['tc_profile_url']); 36 | if ($ok) { 37 | $guid = $tool->platform->getKey(); 38 | header("Location: {$url}{$sep}lti_msg=The%20tool%20has%20been%20registered&status=success&tool_proxy_guid={$guid}"); 39 | exit; 40 | } else { 41 | $errorMsg = 'Error setting tool proxy'; 42 | } 43 | } else if ($do == 'Cancel') { 44 | $tool->platform->delete(); 45 | header("Location: {$url}{$sep}lti_msg=The%20tool%20registration%20has%20been%20cancelled&status=failure"); 46 | exit; 47 | } 48 | } 49 | 50 | $page .= <<< EOD 51 | 72 | 73 | EOD; 74 | } 75 | 76 | $title = APP_NAME; 77 | $page = <<< EOD 78 | 79 | 80 | 81 | 82 | 83 |