baseUrl(); $HtmlTable = new HtmlTable(); $HtmlTable->setTableClass("table table-striped"); $HtmlTable->addRowsWithHeaders([ [ "Public key", "
".$Plugin->getConfigSetting("PublicKey")."
", (new CopyButton("os-public-key"))->getHtml(), ], [ "JWKS", "
".$Plugin->getPublicJWKS()."
", (new CopyButton("os-jwks"))->getHtml(), ], [ "LTI version", "LTI 1.3", "", ], [ "Tool URL", "
".$BaseUrl."
", (new CopyButton("os-tool-url"))->getHtml(), ], [ "Initiate login URL", "
".$BaseUrl."lti/login
", (new CopyButton("os-login-url"))->getHtml(), ], [ "Redirection URI(s)", "
".$BaseUrl."lti/launch
", (new CopyButton("os-redirect-url"))->getHtml(), ], ]); return $HtmlTable->getHtml(); } # --- Canvas /** * Get configuration instructions for Canvas. * @return string Instructions in HTML. */ function getCanvasInstructions() : string { $AF = ApplicationFramework::getInstance(); $Plugin = EduLink::getInstance(); $ServiceName = $Plugin->getConfigSetting("ServiceName"); $HtmlTable = new HtmlTable(); $HtmlTable->isPseudoTable(true); $HtmlTable->addRows([ [ "", "", ], [ "1. Log in to your Canvas site as an administrator.", "" ], [ "2. Open the Admin menu at left (icon is a shield with a" ." key in it). If your Canvas install has multiple accounts," ." select your site administrator account. Otherwise, select your" ." main / only account.", $AF->gUIFileTag("Canvas_Instructions_1.jpg"), ], [ "3. Select "Developer Keys"", $AF->gUIFileTag("Canvas_Instructions_2.jpg"), ], [ "4. Push the + Developer Key button, select the + LTI" ." Key entry.", $AF->gUIFileTag("Canvas_Instructions_3.jpg"), ], [ "5. Enter the parameters shown in the "LMS Settings" table" ." below.", "" ], [ "", "" ], [ "6. Enable the Link Selection, Homework" ." Submission, and Assignment Selection placements" ." and disable any other placements Canvas offers. The UI here" ." is an interactive selector. You may need to click Xs to the" ." right of extra placements to delete them. If a placement you" ." want is not shown, then you will need to click to the right" ." of the current placements, start typing the name of the" ." placement you want, then select your desired placement from" ." the menu that appears.", $AF->gUIFileTag("Canvas_Instructions_4.jpg") ], [ "7. Expand all your selected placements from the list and ensure" ." that they are set to use the LtiDeepLinkingRequest message" ." type. For each placement, enter 2048 as the Selection Height" ." and 1024 as the Selection Width.", $AF->gUIFileTag("Canvas_Instructions_5.jpg") ], [ "8. Push save.", "" ], [ "9. Copy down the number listed in the Details for" ." your newly created key and turn the key on. If you are on" ." a multi-account Canvas, also mark the key visible so that" ." all your Accounts will have access to it.", $AF->gUIFileTag("Canvas_Instructions_6.jpg") ], [ "", "" ], [ "10. From the Admin menu at left (the shield + key again, as in Step 2)," ." select an Account containing courses that you want to use" ." with ".$ServiceName.". Click Settings, select" ." the Apps tab, then push the + App button.", $AF->gUIFileTag("Canvas_Instructions_7.jpg"), ], [ "11. Select By Client Id from the Configuration" ." Type menu, then paste in the number copied from the" ." LTI Key Details entry, push "Submit"," ." then "Install".", "" ], [ "12. Repeat the last two steps for every other account that" ." you want to use with ".$ServiceName."." , "" ], [ "", "" ], [ "13. Lastly, in the 'Information From LMS'" ." form below, enter your email, the URL of your" ." Canvas site, and the key details from Step 9." ." Then press the Register button at the bottom of" ." this page.", "" ] ]); $Result = "

The following steps will set up ".$ServiceName ." for use on your Canvas site.

" ."

The screenshots below depict a multi-account Canvas installation." ." If you have a single-account Canvas installation, then you will see " ." only one entry in the Admin menu rather than several. " ."(Canvas uses the term "Account" to denote not just users" ." but also groups of related users and courses. Depending on your" ." version of Canvas you may have either a single "Account"" ." containing everything OR a "Site Admin" account containing" ." administrative users one or more other accounts representing" ." different institutions / schools / departments / etc.)" ."

"; $Result .= $HtmlTable->getHtml(); return $Result; } /** * Print configuration settings for Canvas. * @return string Settings in HTML. */ function getCanvasSettings() : string { $Plugin = EduLink::getInstance(); $AF = ApplicationFramework::getInstance(); $SysConfig = SystemConfiguration::getInstance(); $BaseUrl = $AF->baseUrl(); $HtmlTable = new HtmlTable(); $HtmlTable->setTableClass("table table-striped"); $JWKS = json_decode($Plugin->getPublicJWKS(), true); $HtmlTable->addRowsWithHeaders([ [ "Key Name", "
".$Plugin->getConfigSetting("ServiceName")."
", (new CopyButton("cs-key-name"))->getHtml(), ], [ "Owner Email", "
".$SysConfig->getString("AdminEmail")."
", (new CopyButton("cs-admin-email"))->getHtml(), ], [ "Redirect URI(s)", "
".$BaseUrl."lti/launch
", (new CopyButton("cs-redirect-uri"))->getHtml(), ], [ "Notes", "(optional)", "" ], [ "Method", "Manual Entry", "" ], [ "Title", "
".$Plugin->getConfigSetting("ServiceName")."
", (new CopyButton("cs-service-name"))->getHtml(), ], [ "Description", "
".$Plugin->getConfigSetting("ServiceDescription")."
",
            (new CopyButton("cs-description"))->getHtml(),
        ],
        [
            "Target Link URI",
            "
".$BaseUrl."
", (new CopyButton("cs-target-uri"))->getHtml(), ], [ "OpenID Connect Initiation URL", "
".$BaseUrl."lti/login
", (new CopyButton("cs-login-url"))->getHtml(), ], [ "JWK Method", "Public JWK", "" ], [ "Public JWK", "
".json_encode($JWKS["keys"][0])."
", (new CopyButton("cs-jwks"))->getHtml(), ], ]); return $HtmlTable->getHtml(); } # --- Moodle /** * Get configuration instructions for Moodle. * @return string Instructions in HTML. */ function getMoodleInstructions() : string { $AF = ApplicationFramework::getInstance(); $Plugin = EduLink::getInstance(); $HtmlTable = new HtmlTable(); $HtmlTable->isPseudoTable(true); $HtmlTable->addRows([ [ "1. Log in to your Moodle site as an administrator.", "", ], [ "2. Select Site Administration from the left-hand navigation.", $AF->gUIFileTag("Moodle_Instructions_1.jpg") ], [ "3. Select the Plugins tab, then click Manage" ." tools under Activity modules > External tool", $AF->gUIFileTag("Moodle_Instructions_2.jpg") ], [ "4. Click configure a tool manually", $AF->gUIFileTag("Moodle_Instructions_3.jpg") ], [ "5. Enter the parameters shown in the "LMS Settings" table" ." below and click Save Changes.", "" ], [ "6. Click View Configuration Details (shown as a list icon)" ." in the box that appears for your newly created tool.", $AF->gUIFileTag("Moodle_Instructions_4.jpg") ], [ "7. Enter the Platform ID and Client ID parameters shown in the pop-up" ." into the "Information From LMS" section below.", "" ], [ "8. Push "Register".", "" ] ]); $Html = "

Take the following steps to set up " .$Plugin->getConfigSetting("ServiceName") ." for use on your Moodle site.

" .$HtmlTable->getHtml(); return $Html; } /** * Get configuration settings for Moodle. * @return string Settings in HTML. */ function getMoodleSettings() : string { $AF = ApplicationFramework::getInstance(); $Plugin = EduLink::getInstance(); $BaseUrl = $AF->baseUrl(); $HtmlTable = new HtmlTable(); $HtmlTable->setTableClass("table table-striped"); $HtmlTable->addRowsWithHeaders([ [ "Tool name", "
".$Plugin->getConfigSetting("ServiceName")."
", (new CopyButton("ms-tool-name"))->getHtml(), ], [ "Tool URL", "
".$BaseUrl."
", (new CopyButton("ms-tool-url"))->getHtml(), ], [ "Tool description", "
".$Plugin->getConfigSetting("ServiceDescription")."
",
            (new CopyButton("ms-description"))->getHtml(),
        ],
        [
            "LTI Version",
            "LTI 1.3",
            ""
        ],
        [
            "Public key type",
            "RSA Key",
            ""
        ],
        [
            "Public key",
            "
".$Plugin->getConfigSetting("PublicKey")."
", (new CopyButton("ms-public-key"))->getHtml(), ], [ "Initiate login URL", "
".$BaseUrl."lti/login
", (new CopyButton("ms-login-url"))->getHtml(), ], [ "Redirection URI(s)", "
".$BaseUrl."lti/launch
", (new CopyButton("ms-redirect-uri"))->getHtml(), ], [ "Custom parameters", "(blank)", "" ], [ "Tool configuration usage", "Show in activity chooser and as a preconfigured tool", "" ], [ "Default launch container", "Embed", "" ], [ "Supports Deep Linking", "(checked)", "" ], [ "Content Selection URL", "(blank)", "" ], ]); return $HtmlTable->getHtml(); } # --- Blackboard /** * Get configuration instructions for Blackboard. * @return string Instructions in HTML. */ function getBlackboardInstructions() : string { $AF = ApplicationFramework::getInstance(); $Plugin = EduLink::getInstance(); $ClientId = $Plugin->getBlackboardClientId(); $HtmlTable = new HtmlTable(); $HtmlTable->isPseudoTable(true); $HtmlTable->addRows([ [ "1. Log in to your blackboard instance as an administrator.", "", ], [ "2. Select System Admin from the top navigation.", $AF->gUIFileTag("Blackboard_Instructions_1.jpg") ], [ "3. From the Integrations box in the right-hand column, select" ."LTI Tool Provider.", $AF->gUIFileTag("Blackboard_Instructions_2.jpg") ], [ "4. Select Register LTI 1.3/Advantage Tool.", $AF->gUIFileTag("Blackboard_Instructions_3.jpg") ], [ "5. Enter " .$ClientId." as the Client ID, and press Submit.", "
" .(new CopyButton("bb-client-id"))->getHtml()."
", ], [ "6. Toggle the tool status to Approved and press Submit.", $AF->gUIFileTag("Blackboard_Instructions_4.jpg") ] ]); $Html = "

Take the following steps to configure your Blackboard " ."instance to use ".$Plugin->getConfigSetting("ServiceName").".

" .$HtmlTable->getHtml(); return $Html; } # --- Brightspace /** * Get configuration instructions for Blackboard. * @return string Instructions in HTML. */ function getBrightspaceInstructions() : string { $AF = ApplicationFramework::getInstance(); $Plugin = EduLink::getInstance(); $HtmlTable = new HtmlTable(); $HtmlTable->isPseudoTable(true); $HtmlTable->addRows([ [ "", "", ], [ "1. Log in to your Brightspace instance as an administrator.", "", ], [ "2. Open the Admin Tools menu using the gear icon at" ." the top right of the page.", $AF->gUIFileTag("Brightspace_Instructions_1.jpg"), ], [ "3. Select Manage Extensibility" ." (usually in the left column, third from the bottom).", $AF->gUIFileTag("Brightspace_Instructions_2.jpg"), ], [ "4. Select the LTI Advantage tab, then click the" ." Register Tool button.", $AF->gUIFileTag("Brightspace_Instructions_3.jpg"), ], [ "5. Select Standard as the registration type, then fill in" ." the settings using the values provided below.", $AF->gUIFileTag("Brightspace_Instructions_4.jpg"), ], [ "6. In the Extensions setting, check the Deep Linking checkbox.", $AF->gUIFileTag("Brightspace_Instructions_5.jpg"), ], [ "7. Press the Register button at the bottom of the page.", $AF->gUIFileTag("Brightspace_Instructions_6.jpg"), ], [ "", "", ], [ "8. Copy the parameters provided by Brightspace into the table below.", "", ], [ "9. From the Admin Tools menu, select External Learning Tools" ." (usually in the left column, sixth entry under " ."Organization Related).", $AF->gUIFileTag("Brightspace_Instructions_7.jpg"), ], [ "10. Click the New Deployment button", $AF->gUIFileTag("Brightspace_Instructions_8.jpg"), ], [ "11. From the Tool dropdown, select " .$Plugin->getConfigSetting("ServiceName"), $AF->gUIFileTag("Brightspace_Instructions_9.jpg"), ], [ "12. Fill in Name and Descrption from the values below.", "", ], [ "13. Under Make available to near the bottom of the page," ." click the Add Org Units button.", $AF->gUIFileTag("Brightspace_Instructions_10.jpg"), ], [ "14. In the resulting popup, use the search box at top right to find" ." your Org Unit. Click the checkbox in the leftmost column to" ." select your Org Unit. Toggle the radio button in the rightmost" ." column to This org unite and all descendants. Press the" ." Add button at the bottom left of the popup.", $AF->gUIFileTag("Brightspace_Instructions_11.jpg"), ], [ "15. Press the Create Deployment button at the bottom left of the page.", $AF->gUIFileTag("Brightspace_Instructions_12.jpg"), ], [ "", "", ], [ "16. Click on View Links in the popup that comes up.", "", ], [ "17. Press the New Link button.", $AF->gUIFileTag("Brightspace_Instructions_13.jpg"), ], [ "18. Fill in the Name and Description from the values below." ." For the URL setting, use the Domain value below." , "", ], [ "19. From the Type menu, select Deep Linking Quicklink.", $AF->gUIFileTag("Brightspace_Instructions_14.jpg"), ], [ "20. Enter 1024 for the Width and 2048 for the Height.", $AF->gUIFileTag("Brightspace_Instructions_15.jpg"), ], [ "21. Press Save and Close at the bottom left of the page." ." Registration is now complete.", $AF->gUIFileTag("Brightspace_Instructions_16.jpg"), ], ]); $Html = "

Take the following steps to configure your Brightspace " ."instance to use ".$Plugin->getConfigSetting("ServiceName").".

" .$HtmlTable->getHtml(); return $Html; } /** * Get configuration settings for Brightspace. * @return string Settings in HTML. */ function getBrightspaceSettings() : string { $AF = ApplicationFramework::getInstance(); $Plugin = EduLink::getInstance(); $BaseUrl = $AF->baseUrl(); $HtmlTable = new HtmlTable(); $HtmlTable->setTableClass("table table-striped"); $HtmlTable->addRowsWithHeaders([ [ "Name", "
".$Plugin->getConfigSetting("ServiceName")."
", (new CopyButton("brs-tool-name"))->getHtml(), ], [ "Description", "
".$Plugin->getConfigSetting("ServiceDescription")."
",
            (new CopyButton("brs-description"))->getHtml(),
        ],
        [
            "Domain",
            "
".$BaseUrl."
", (new CopyButton("brs-tool-url"))->getHtml(), ], [ "Redirect URLs", "
".$BaseUrl."lti/launch
", (new CopyButton("brs-redirect-uri"))->getHtml(), ], [ "OpenID Connect Login URL", "
".$BaseUrl."lti/login
", (new CopyButton("brs-login-url"))->getHtml(), ], [ "Target Link URI", "(blank)", ], [ "Keyset URL", "
".$BaseUrl."lti/jwks
", (new CopyButton("brs-jwks-url"))->getHtml(), ], ]); return $HtmlTable->getHtml(); } # ----- SETUP ---------------------------------------------------------------- $AF = ApplicationFramework::getInstance(); $User = User::getCurrentUser(); $H_Plugin = EduLink::getInstance(); $References = [ "Other" => [ "https://www.imsglobal.org/spec/lti/v1p3/" => "LTI v1.3 specification", "https://www.imsglobal.org/spec/lti-dl/v2p0" => "Deep Linking v2.0 specification" ], "Canvas" => [ "https://community.canvaslms.com/t5/Admin-Guide/How-do-I-configure-an-LTI-key-for-an-account/ta-p/140" => "Canvas Admin Guide: How do I configure an LTI key for an account?", "https://community.canvaslms.com/t5/Admin-Guide/How-do-I-configure-an-external-app-for-an-account-using-a-client/ta-p/202" => "Canvas Admin Guide: How do I configure an external app for an account using a client ID?", "https://community.canvaslms.com/t5/Admin-Guide/How-do-I-manage-external-app-placements-for-an-account/ta-p/417797" => "Canvas Admin Guide: How do I manage external app placements for an account?", ], "Moodle" => [ "https://docs.moodle.org/311/en/External_tool_settings#Adding_a_tool_site-wide" => "Moodle Docs - External Tool Settings: Adding a tool site-wide" ], "Blackboard" => [ "https://help.blackboard.com/Learn/Administrator/SaaS/Integrations/Learning_Tools_Interoperability#add_lti13" => "Blackboard: Add an LTI 1.3/Advantage Tool", ], "Brightspace" => [ "https://community.d2l.com/brightspace/kb/articles/23660-lti-advantage-v1-3" => "D2L KB: LTI Advantage", "https://community.d2l.com/brightspace/kb/articles/23755-deep-linking-extension-with-lti-1-3" => "D2L KB: Deep linking extension with LTI 1.3" ] ]; $FormFields = [ "LMS" => [ "Type" => FormUI::FTYPE_OPTION, "Label" => "Select Your LMS Platform", "Options" => [ "Other" => "Other LMS", "Blackboard" => "Blackboard", "Canvas" => "Canvas", "Moodle" => "Moodle", "Brightspace" => "Brightspace", ], "Default" => "Canvas", "OptionType" => FormUI::OTYPE_LIST, "OptionThreshold" => 0, ], "HEADER_Instructions" => [ "Type" => FormUI::FTYPE_HEADING, "Label" => "Instructions", ], "Other_Instructions" => [ "Type" => FormUI::FTYPE_CUSTOMCONTENT, "Label" => "", "Content" => "

Below are the parameters for this site that are necessary to " ."register it as a tool provider with an LMS. You may not need all of them, " ."depending on your specific LMS.

", "DisplayIf" => ["LMS" => "Other"], ], "Canvas_Instructions" => [ "Type" => FormUI::FTYPE_CUSTOMCONTENT, "Label" => "", "Content" => getCanvasInstructions(), "DisplayIf" => ["LMS" => "Canvas"], ], "Moodle_Instructions" => [ "Type" => FormUI::FTYPE_CUSTOMCONTENT, "Label" => "", "Content" => getMoodleInstructions(), "DisplayIf" => ["LMS" => "Moodle"], ], "Blackboard_Instructions" => [ "Type" => FormUI::FTYPE_CUSTOMCONTENT, "Label" => "", "Content" => getBlackboardInstructions(), "DisplayIf" => ["LMS" => "Blackboard"], ], "Brightspace_Instructions" => [ "Type" => FormUI::FTYPE_CUSTOMCONTENT, "Label" => "", "Content" => getBrightspaceInstructions(), "DisplayIf" => ["LMS" => "Brightspace"], ], "HEADER_Settings" => [ "Type" => FormUI::FTYPE_HEADING, "Label" => "LMS Settings", ], "Other_Settings" => [ "Type" => FormUI::FTYPE_CUSTOMCONTENT, "Label" => "", "Content" => getOtherSettings(), "DisplayIf" => ["LMS" => "Other"], ], "Canvas_Settings" => [ "Type" => FormUI::FTYPE_CUSTOMCONTENT, "Label" => "Enter into Canvas", "Content" => getCanvasSettings(), "DisplayIf" => ["LMS" => "Canvas"], ], "Moodle_Settings" => [ "Type" => FormUI::FTYPE_CUSTOMCONTENT, "Label" => "Enter into Moodle", "Content" => getMoodleSettings(), "DisplayIf" => ["LMS" => "Moodle"], ], "Brightspace_Settings" => [ "Type" => FormUI::FTYPE_CUSTOMCONTENT, "Label" => "Enter into Brightspace", "Content" => getBrightspaceSettings(), "DisplayIf" => ["LMS" => "Brightspace"], ], "HEADER_Info" => [ "Type" => FormUI::FTYPE_HEADING, "Label" => "Information From LMS", ], "ContactEmail" => [ "Type" => FormUI::FTYPE_TEXT, "Label" => "Contact Email", "Help" => "Email address for your LMS administrator.", "ValidateFunction" => ["\\Metavus\\FormUI", "validateEmail"], "Required" => true, ], "Other_Issuer" => [ "Label" => "Issuer", "Type" => FormUI::FTYPE_TEXT, "Required" => true, "DisplayIf" => ["LMS" => "Other"], ], "Other_ClientId" => [ "Label" => "Client ID", "Type" => FormUI::FTYPE_TEXT, "Required" => true, "ValidateFunction" => [$H_Plugin, 'validateIdParameter'], "DisplayIf" => ["LMS" => "Other"], ], "Other_AuthLoginUrl" => [ "Label" => "Auth Login URL", "Type" => FormUI::FTYPE_URL, "Required" => true, "DisplayIf" => ["LMS" => "Other"], ], "Other_AuthTokenUrl" => [ "Label" => "Auth Token URL", "Type" => FormUI::FTYPE_URL, "Required" => true, "DisplayIf" => ["LMS" => "Other"], ], "Other_KeySetUrl" => [ "Label" => "Key Set URL", "Type" => FormUI::FTYPE_URL, "Required" => true, "DisplayIf" => ["LMS" => "Other"], ], "Canvas_Issuer" => [ "Label" => "Site URL", "Type" => FormUI::FTYPE_URL, "Help" => "Main URL of your LMS (e.g., https://canvas.my-institution.edu).", "Required" => true, "DisplayIf" => ["LMS" => "Canvas"], "ValidateFunction" => function(string $FieldName, $FieldValues, $AllValues) { # if no value provided, nothing to validate if (strlen($FieldValues) == 0) { return null; } # if host can not be extracted, nothing to validate # (FormUI's built-in URL validation will complain on invalid URLs) $Host = parse_url($FieldValues, PHP_URL_HOST); if ($Host === null || $Host === false) { return null; } # otherwise, ensure that we're not claiming to self-host something that # lives in Instructure's cloud if ($AllValues["Canvas_SelfHosted"] === true && preg_match('/\.instructure\.com$/', $Host)) { return $FieldValues." ends in .instructure.com, so it cannot be " ."Self Hosted."; } }, ], "Canvas_SelfHosted" => [ "Label" => "Self Hosted", "Type" => FormUI::FTYPE_FLAG, "Help" => "Is your LMS hosted on a server owned by your institution " ."(as oppossed to being hosted by Instructure in their cloud)?", "OffLabel" => "No", "OnLabel" => "Yes", "DisplayIf" => ["LMS" => "Canvas"], ], "Canvas_ClientId" => [ "Label" => "LTI Key Details", "Type" => FormUI::FTYPE_TEXT, "Required" => true, "Help" => "Key details copied in Step 9.", "ValidateFunction" => [$H_Plugin, 'validateIdParameter'], "DisplayIf" => ["LMS" => "Canvas"], ], "Moodle_Issuer" => [ "Label" => "Platform ID", "Type" => FormUI::FTYPE_TEXT, "Required" => true, "DisplayIf" => ["LMS" => "Moodle"], ], "Moodle_ClientId" => [ "Label" => "Client ID", "Type" => FormUI::FTYPE_TEXT, "Required" => true, "ValidateFunction" => [$H_Plugin, 'validateIdParameter'], "DisplayIf" => ["LMS" => "Moodle"], ], "Brightspace_ClientId" => [ "Label" => "Client Id", "Type" => FormUI::FTYPE_TEXT, "Required" => true, "ValidateFunction" => [$H_Plugin, 'validateIdParameter'], "DisplayIf" => ["LMS" => "Brightspace"], ], "Brightspace_KeySetUrl" => [ "Label" => "Brightspace Keyset URL", "Type" => FormUI::FTYPE_URL, "Required" => true, "DisplayIf" => ["LMS" => "Brightspace"], ], "Brightspace_AuthTokenUrl" => [ "Label" => "Brightspace OAuth2 Access Token URL", "Type" => FormUI::FTYPE_URL, "Required" => true, "DisplayIf" => ["LMS" => "Brightspace"], ], "Brightspace_AuthLoginUrl" => [ "Label" => "OpenID Connect Authentication Endpoint", "Type" => FormUI::FTYPE_URL, "Required" => true, "DisplayIf" => ["LMS" => "Brightspace"], ], "Brightspace_Issuer" => [ "Label" => "Issuer", "Type" => FormUI::FTYPE_TEXT, "Required" => true, "DisplayIf" => ["LMS" => "Brightspace"], ], ]; # ----- MAIN ----------------------------------------------------------------- $Values = []; if ($User->isLoggedIn()) { $Values["ContactEmail"] = $User->get("EMail"); } $H_FormUI = new FormUI( $FormFields, $Values ); $H_Status = null; $ButtonPushed = StdLib::getFormValue("Submit"); switch ($ButtonPushed) { case "Register": if ($H_FormUI->validateFieldInput() == 0) { $FormValues = $H_FormUI->getNewValuesFromForm(); $LMS = $FormValues["LMS"]; $NewValues = [ "LMS" => $LMS, "ContactEmail" => $FormValues["ContactEmail"], ]; $ValueInfo = [ "Moodle" => [ "ProvidedValues" => [ "Issuer", "ClientId", ], "DerivedValues" => [ "AuthLoginUrl" => "/mod/lti/auth.php", "AuthTokenUrl" => "/mod/lti/token.php", "KeySetUrl" => "/mod/lti/certs.php", ], ], "Canvas" => [ "ProvidedValues" => [ "Issuer", "ClientId", ], "DerivedValues" => [ "AuthLoginUrl" => "/api/lti/authorize_redirect", "AuthTokenUrl" => "/login/oauth2/token", "KeySetUrl" => "/api/lti/security/jwks", ], ], "Brightspace" => [ "ProvidedValues" => [ "Issuer", "ClientId", "AuthLoginUrl", "AuthTokenUrl", "KeySetUrl", ], "DerivedValues" => [], ], "Other" => [ "ProvidedValues" => [ "Issuer", "ClientId", "AuthLoginUrl", "AuthTokenUrl", "KeySetUrl", ], "DerivedValues" => [], ], ]; if (!isset($ValueInfo[$LMS])) { throw new \Exception( "Invalid LMS provided '".$LMS."' (should be impossible)." ); } foreach ($ValueInfo[$LMS]["ProvidedValues"] as $Param) { $NewValues[$Param] = $FormValues[$LMS."_".$Param]; } # handle hosted canvas instances if ($LMS == "Canvas" && $FormValues["Canvas_SelfHosted"] === false) { $NewValues["Issuer"] = "https://canvas.instructure.com"; } $Issuer = $NewValues["Issuer"]; foreach ($ValueInfo[$LMS]["DerivedValues"] as $Param => $UrlSuffix) { $NewValues[$Param] = $Issuer.$UrlSuffix; } if (!LMSRegistration::registrationExists($NewValues)) { LMSRegistration::create($NewValues); $H_Status = "RegistrationCreated"; } else { $H_Status = "DuplicateRegistration"; } } break; default: break; } # ----- SETUP ---------------------------------------------------------------- $RegisterButton = new HtmlButton("Register"); $RegisterButton->addSemanticClass("btn-outline-primary"); # ----- DISPLAY -------------------------------------------------------------- if (isset($H_Error)) { print "

".$H_Error."

"; return; } switch ($H_Status) { case "RegistrationCreated": print '
' .'Registration successfully created and activated.' .'
'; return; case "DuplicateRegistration": print '
' .'A registration already exists with the provided parameters.' .'
'; return; default: break; } ?>

getConfigSetting("RegistrationTitle") ?>

getConfigSetting("RegistrationIntroText") ?> displayErrorBlock(); ?>
 

References