cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Adventurer

Sort Enrollments

https://institution.instructure.com/accounts/1/users/000

On this endpoint the Enrollments are sorted alpha and it was hard for admins to easily search for a student's current enrollments. So I created a script that sorts- Current Enrollment, Completed Enrollment, and Unpublished Enrollment. 

 

 

function sortCoursesPeopleView() {
  const checkIfNull = async (selector) => {
    while (document.querySelector(selector) === null) {
      await new Promise((resolve) => requestAnimationFrame(resolve));
    }
    return document.querySelector(selector);
  };
  checkIfNull("#user-info-fieldsets").then(() => {
    const enrollmentsFieldset = document.querySelector("#courses > #content");
    enrollmentsFieldset.setAttribute("style","resize: vertical; overflow: scroll; font-size: 0.8em; height:200px;");
    const subFieldset = document.querySelector("#courses_list > div > ul");
    subFieldset.setAttribute("style", "margin-left: 5px; font-size: 0.9em; margin-bottom: 10px; overflow:auto");

    let ulList = document.querySelector("#courses_list > div > ul");
    let items = ulList.querySelectorAll("li");

    for (
      let i = 0, arr = ["active", "completed", "unpublished"];
      i < arr.length;
      i++
    ) {
      for (let j = 0; j < items.length; j++) {
        if (~(" " + items[j].className + " ").indexOf(" " + arr[i] + " "))
          ulList.appendChild(items[j]);
      }
    }
  });
}sortCoursesPeopleView();

 

 

That is All.
ALSO THIS NEW CANVAS COMMUNITY UI SUCKS

Labels (2)
0 Replies