Skip to content

Instantly share code, notes, and snippets.

@DavidPesticcio
Last active January 8, 2024 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidPesticcio/c26d5b782b5b209f2d667a66359f4a86 to your computer and use it in GitHub Desktop.
Save DavidPesticcio/c26d5b782b5b209f2d667a66359f4a86 to your computer and use it in GitHub Desktop.
Udemy: Reset a course, i.e. uncheck all boxes

Un/check all visible checkboxes for a course.

Currently only works if course content is visible, and course section(s) is/are already expanded.

Usage:

Open console for web browser (F12 or Right-Click Inspect) Paste the section of JavaScript below into the console according to your needs.

Open Course Content (WIP)

// Activate sidebar menu to expose course sections
const courseContent = document.querySelector("section[data-purpose='open-course-content']");

Expand Course Sections (WIP)

// Find all accordian-panel--???? entries in course sections
const courseSection = document.querySelector("section[data-css-toggle-id='accordion-panel--1097']");
// For each accordian-panel--???? entry in course sections, set the data-checked to "checked"
courseSection.forEach((checkbox) => {
    if (checkbox.checked) {
        checkbox.click();
    }
});

Uncheck all visible checkboxes

const checkboxes = document.querySelectorAll("input[type='checkbox']");
checkboxes.forEach((checkbox) => {
    if (checkbox.checked) {
        checkbox.click();
    }
});

Check all visible checkboxes

const sectionEl = document.querySelector("section[data-purpose='sidebar']");
const checkboxes = sectionEl.querySelectorAll("input[type='checkbox']");
checkboxes.forEach((checkbox) => {
    if (!checkbox.checked) {
        checkbox.disabled = false;
        checkbox.click();
    }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment