Skip to content

Instantly share code, notes, and snippets.

@rickcnagy
Created March 4, 2014 19:41
Show Gist options
  • Select an option

  • Save rickcnagy/9354024 to your computer and use it in GitHub Desktop.

Select an option

Save rickcnagy/9354024 to your computer and use it in GitHub Desktop.
Delete all subjects visible in the Global Subject(Course) Setup tab. All students must be unenrolled from all visible subjects.
//
// DeleteSubjects.js
// Rick Nagy
// 2014-03-04
//
// Run via js console
javascript: buttons = document.getElementsByClassName('buttonWidget allButtons');
i = 0;
function deleteSubject() {
i++;
if (i % 100 == 0) if (!confirm("continue?")) return;
if (buttons[i].innerText === 'Delete') {
buttons[i].click();
var bottomButtons = document.getElementsByClassName('ui-button-text');
bottomButtons[0].click();
var loadingInterval = setInterval(function() {
if (!isLoading()) {
clearInterval(loadingInterval);
deleteSubject();
}
}, 100);
} else deleteSubject();
}
function isLoading() {
if (document.getElementsByClassName('loadingWidget').length !== 0) return true;
else return false;
}
deleteSubject();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment