Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions canvasBetter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Canvas betterments 2.1 - LTI Install! [PROD]
// @name Canvas betterments 2.2 - Abort pending SIS Imports [PROD]
// @namespace https://siteadmin.instructure.com/
// @version 2019.03.21
// @version 2021.03.18
// @description try to take over the world!
// @author Daniel Gilogley
// @match https://*.test.instructure.com/*
Expand Down Expand Up @@ -319,7 +319,16 @@ function myJQueryCode() {
});
} else if(document.location.pathname.toLowerCase() === "/dgtools2") {
document.title = "DG Tools";
$('#main').html('<center> <h1>DG Tools</h1> <div><em>DG Tools are the best!</em></div></center><div style="padding-left:50px"> <hr> <h2>Links</h2> <ul> <li><a href="/dgtools">Update User SIS id from one to another</a></li> <li><a href="/dgtools3">Create Users</a></li> <li><a href="/dgtools4">Create Sandboxes</a></li> <li><a href="https://instructure.atlassian.net/wiki/display/ENG/SCORM" target="_blank">SCORM Setup</a></li> <li><a href="/accounts/self/settings/configurations#tab-tools" target="_blank">LTI Tool Config Settings Page</a></li> </ul> <h2>Tools</h2> <ul> <li class="dg_action_lti"> <button class="Button" type="button" id="dg_button_cc" key="1" secret="c9b6c488-4750-48ce-897c-b919ff3cb0f1" url="https://lor.instructure.com/api/account-setup/tool-config">Canvas Commons</button> </li> <li><strong>Sydney</strong></li> <ul> <li class="dg_action_lti"> <button class="Button" type="button" id="dg_button_syd_chat" key="5436" secret="AA7UiLCv5QQ63pQ7gWhIEZwiK0wE9bMUB35BT9JOi7zeW2GtIlJB7SkWttYirL1exa2NrN7Xkzu3O4dZlTRfJv9C" url="https://chat-syd.instructure.com/lti/configure.xml">Chat LTI (SYD)</button> </li> <li class="dg_action_lti"> <button class="Button" type="button" id="dg_button_syd_rollCall" key="6edd0a5c8f95ff156168af6db62bf4fe4b404343bc3a7525e5a990d016c0a4c6" secret="49ba3d056fa0b4939aa1018dfeaf09211e922f1164d2c358daf624a9aed2fa2a" url="https://rollcall-syd.instructure.com/configure.xml">Roll Call - Attendance (SYD)</button> </li> <li class="dg_action_lti"> <button class="Button" type="button" id="dg_button_syd_arcApac" key="2289-1ed35fef912ddbda644bac58387a3cb124b18c3d9fbca935ebda2822e13f4f52" secret="5df67ea01c3fc7ed632b177a8255210bd8397b9f749778ca608a8b062a6cedfb" url="https://apaccs.instructuremedia.com/lti/config.xml">ARC for APAC CS New Employees</button> </li> <li class="dg_action_outcome"> <button class="Button" type="button" id="dg_button_syd_outcomes" guid="A8326BEC-901A-11DF-A622-0C319DFF4B22">Australian Outcomes</button> </li> <li class="dg_action_externalTool"> <button class="Button" type="button" id="dg_button_syd_office365" destination="https://office365-syd-prod.instructure.com" url="https://office365-syd-prod.instructure.com/config.xml">MS Office 365 LTI (SYD)</button> </li> <li class="dg_action_externalTool"> <button class="Button" type="button" id="dg_button_syd_google" destination="https://google-drive-lti-syd-prod.instructure.com/lti_credentials/new" url="https://google-drive-lti-syd-prod.instructure.com/config">Google LTI (SYD)</button> </li> </ul> <li><strong>Singapore</strong></li> <ul> <li class="dg_action_lti"> <button class="Button" type="button" id="dg_button_sg_chat" key="5437" secret="21b2b6008685d7ced7319af8e1349d52b40808cef67e36a6068065c87c13309803adb82c5c880d8f7d928776" url="https://rollcall-sin.instructure.com/configure.xml">Chat LTI (SG)</button> </li> <li class="dg_action_lti"> <button class="Button" type="button" id="dg_button_sg_rollCall" key="6edd0a5c8f95ff156168af6db62bf4fe4b404343bc3a7525e5a990d016c0a4c6" secret="49ba3d056fa0b4939aa1018dfeaf09211e922f1164d2c358daf624a9aed2fa2a" url="https://rollcall-sin.instructure.com/configure.xml">Roll Call - Attendence (SG)</button> </li> <li class="dg_action_externalTool"> <button class="Button" type="button" id="dg_button_sg_office365" destination="https://office365-sin-prod.instructure.com" url="https://office365-sin-prod.instructure.com/config.xml">MS Office 365 LTI (SG)</button> </li> <li class="dg_action_externalTool"> <button class="Button" type="button" id="dg_button_sg_google" destination="https://google-drive-lti-sin-prod.instructure.com/lti_credentials/new" url="https://google-drive-lti-sin-prod.instructure.com/config">Google LTI (SG)</button> </li> </ul> </ul></div><hr><div style="padding-left:50px;width: 40%"> <label for="dg_apiToken">API token:</label> <div class="ic-Input-group"> <input name="focus" type="hidden" value="' + userToken + '"> <input id="dg_apiToken" type="text" name="dg_apiToken" class="ic-Input ui-autocomplete-input" value="' + userToken + '" aria-labelledby="course_name_label" autocomplete="off"> <button class="Button" id="dg_apiTokenButton">Update API Token</button> </div> <br> <br></div>');
$('#main').html('<center> <h1>DG Tools</h1> <div><em>DG Tools are the best!</em></div></center><div style="padding-left:50px"> <hr> <h2>Links</h2> <ul> <li><a href="/dgtools">Update User SIS id from one to another</a></li> <li><a href="/dgtools3">Create Users</a></li> <li><a href="/dgtools4">Create Sandboxes</a></li> <li><a href="https://instructure.atlassian.net/wiki/display/ENG/SCORM" target="_blank">SCORM Setup</a></li> <li><a href="/accounts/self/settings/configurations#tab-tools" target="_blank">LTI Tool Config Settings Page</a></li> </ul> <h2>Tools</h2> <ul> <li class="dg_action_lti"> <button class="Button" type="button" id="dg_button_cc" key="1" secret="c9b6c488-4750-48ce-897c-b919ff3cb0f1" url="https://lor.instructure.com/api/account-setup/tool-config">Canvas Commons</button> </li><li class="dg_action_abortsisimports"><button class="Button" type="button" id="dg_button_abortsisimport" url="#">Abort pending SIS Imports</button></li> <li><strong>Sydney</strong></li> <ul> <li class="dg_action_lti"> <button class="Button" type="button" id="dg_button_syd_chat" key="5436" secret="AA7UiLCv5QQ63pQ7gWhIEZwiK0wE9bMUB35BT9JOi7zeW2GtIlJB7SkWttYirL1exa2NrN7Xkzu3O4dZlTRfJv9C" url="https://chat-syd.instructure.com/lti/configure.xml">Chat LTI (SYD)</button> </li> <li class="dg_action_lti"> <button class="Button" type="button" id="dg_button_syd_rollCall" key="6edd0a5c8f95ff156168af6db62bf4fe4b404343bc3a7525e5a990d016c0a4c6" secret="49ba3d056fa0b4939aa1018dfeaf09211e922f1164d2c358daf624a9aed2fa2a" url="https://rollcall-syd.instructure.com/configure.xml">Roll Call - Attendance (SYD)</button> </li> <li class="dg_action_lti"> <button class="Button" type="button" id="dg_button_syd_arcApac" key="2289-1ed35fef912ddbda644bac58387a3cb124b18c3d9fbca935ebda2822e13f4f52" secret="5df67ea01c3fc7ed632b177a8255210bd8397b9f749778ca608a8b062a6cedfb" url="https://apaccs.instructuremedia.com/lti/config.xml">ARC for APAC CS New Employees</button> </li> <li class="dg_action_outcome"> <button class="Button" type="button" id="dg_button_syd_outcomes" guid="A8326BEC-901A-11DF-A622-0C319DFF4B22">Australian Outcomes</button> </li> <li class="dg_action_externalTool"> <button class="Button" type="button" id="dg_button_syd_office365" destination="https://office365-syd-prod.instructure.com" url="https://office365-syd-prod.instructure.com/config.xml">MS Office 365 LTI (SYD)</button> </li> <li class="dg_action_externalTool"> <button class="Button" type="button" id="dg_button_syd_google" destination="https://google-drive-lti-syd-prod.instructure.com/lti_credentials/new" url="https://google-drive-lti-syd-prod.instructure.com/config">Google LTI (SYD)</button> </li> </ul> <li><strong>Singapore</strong></li> <ul> <li class="dg_action_lti"> <button class="Button" type="button" id="dg_button_sg_chat" key="5437" secret="21b2b6008685d7ced7319af8e1349d52b40808cef67e36a6068065c87c13309803adb82c5c880d8f7d928776" url="https://rollcall-sin.instructure.com/configure.xml">Chat LTI (SG)</button> </li> <li class="dg_action_lti"> <button class="Button" type="button" id="dg_button_sg_rollCall" key="6edd0a5c8f95ff156168af6db62bf4fe4b404343bc3a7525e5a990d016c0a4c6" secret="49ba3d056fa0b4939aa1018dfeaf09211e922f1164d2c358daf624a9aed2fa2a" url="https://rollcall-sin.instructure.com/configure.xml">Roll Call - Attendence (SG)</button> </li> <li class="dg_action_externalTool"> <button class="Button" type="button" id="dg_button_sg_office365" destination="https://office365-sin-prod.instructure.com" url="https://office365-sin-prod.instructure.com/config.xml">MS Office 365 LTI (SG)</button> </li> <li class="dg_action_externalTool"> <button class="Button" type="button" id="dg_button_sg_google" destination="https://google-drive-lti-sin-prod.instructure.com/lti_credentials/new" url="https://google-drive-lti-sin-prod.instructure.com/config">Google LTI (SG)</button> </li> </ul> </ul></div><hr><div style="padding-left:50px;width: 40%"> <label for="dg_apiToken">API token:</label> <div class="ic-Input-group"> <input name="focus" type="hidden" value="' + userToken + '"> <input id="dg_apiToken" type="text" name="dg_apiToken" class="ic-Input ui-autocomplete-input" value="' + userToken + '" aria-labelledby="course_name_label" autocomplete="off"> <button class="Button" id="dg_apiTokenButton">Update API Token</button> </div> <br> <br></div>');

//Abort all pending SIS Imports
$('li.dg_action_abortsisimports').click(function(e){
e.preventDefault();
console.log('Aborting all pending SIS Imports');
//Disable the button
$("button", this).attr("disabled","disabled");
abortPendingSISImports();
});

//LTI Buttons Function
$('li.dg_action_lti').click(function(e){
Expand Down Expand Up @@ -875,6 +884,27 @@ function myJQueryCode() {
xhr.send(data);
}

//Abort all pending SIS Imports function
function abortPendingSISImports(){
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
alert("Aborted all pending SIS Imports.\n" + this.responseText);
}
});

xhr.open("PUT", "/api/v1/accounts/1/sis_imports/abort_all_pending");
xhr.setRequestHeader("Authorization", "Bearer " + userToken);
xhr.setRequestHeader("Cache-Control", "no-cache");

xhr.send(data);
}

//======== Begin Google / Office LTI Auto Install ========

//read the ? part and add to action form for URL
Expand Down