Skip to content

implement user.classroom getter function #382

@faretek1

Description

@faretek1

Implement a method/attribute in the site.user.User class

class User:
    # <...>
    def classroom(self) -> classroom.Classroom | None:
        ... # If this is a student user, return a classroom object. If not, return None

The regular api (api.scratch.mit.edu/users/{username}) does not provide classroom information, so this would require parsing of the user's profile page (scratch.mit.edu/users/{username})

Image

Look for a href that follows this regular expression: \/classes\/\d*\/. if it exists within this <p class="profile-details"> tag, then the user is a student. Otherwise, they are not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions