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
11 changes: 8 additions & 3 deletions src/gradescopeapi/classes/_helpers/_course_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ def get_course_members(soup: BeautifulSoup, course_id: str) -> list[Member]:
# name, email, role, sections?, submissions, edit, remove
# if course has sections, section column is added before number of submissions column
headers = soup.find("table", class_="js-rosterTable").find_all("th")
has_sections = any(h.text.startswith("Sections") for h in headers)
num_submissions_column = 4 if has_sections else 3
num_submissions_column = -1
for i, h in enumerate(headers):
if h.text.lower().startswith("submissions"):
num_submissions_column = i
break
Comment on lines +142 to +146
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this some more I think we could do a search for the Edit column and take the previous element as the Submissions column. I think the edit column has a unique aria-label. This way we can remove the language dependency on the English "Sections"/"Submissions" wording.

Another option could be searching the headers for the aria-controls="DataTables_Table_0" attribute and taking the last one as the submissions column.


member_list = []

Expand Down Expand Up @@ -187,7 +190,9 @@ def get_course_members(soup: BeautifulSoup, course_id: str) -> list[Member]:
user_id = data_url.split("user_id=")[-1]

# fetch number of submissions from table cell
num_submissions = int(cells[num_submissions_column].text)
num_submissions = (
0 if num_submissions_column < 0 else int(cells[num_submissions_column].text)
)

# create Member object with all relevant info
member_list.append(
Expand Down
Loading