Skip to content

Classroom alerts parser & update Classroom private activity parser. solves #304 #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

FAReTek1
Copy link
Collaborator

@FAReTek1 FAReTek1 commented May 5, 2025

Classroom alerts/activity parser (updates)

This pr reverts commit d93c9a4.

the commits reverted in that commit were intended to be the contents of this PR. When cleaning up my workspace in my IDE, it seems that I accidentally linked to https://github.com/TimMcCool/scratchattach/ instead of https://github.com/faretek1/scratchattach/

In #294, many Classroom methods were added, including the ability to fetch classrooms' private activity (using a teacher account's session) and the ability to fetch classroom alerts (using a teacher account's session). This PR improves these features: (`site.classroom.Classroom.activity` & `site.session.Session.classroom_alerts`)

site.classroom.Classroom.activity

The parser for the private classroom activity has been updated to more accurately match the scratch website's HTML, since the 'empty' cases actually just relay onto the case below them.

i found this out when testing the classroom alerts parser which had the same issue, and fixed both issues.

site.session.Session.classroom_alerts

(solves #304)
The main feature of this PR is the implementation of the Classroom alert parser. The function for requesting to the scratch api was already implemented in #294, but the site.classroom.Classroom.activity would just return a list of JSON objects, which is not very helpful for the user.

This is done with an edit to enums.py, classroom.py, and a new file alerts.py.
Classroom alerts are implemented as the EducatorAlert dataclass,, with 9 attributes. These also have 3 getter methods:

  • alert_type for parsing/looking-up the 'type' attribute using an enum. This enum is used internally in the message getter
  • message for emulating Scratch's own display of the alert, e.g. "Blockly by TimMcCool was censored"
  • target_object_title for getting the title of the linked project/studio (if it's a comment or other stuff, returns None): used by message

appendix

there are still a few more things to do:

  • docstrings
  • comments
  • code review

there are also a few # todo: <...> comments within the code, which cannot be done until certain conditions are met:

  • test the parser with a studio-related alert (when possible)
  • implement the regular user's alert (not classroom), and see if the classroom alert could subclass that

@FAReTek1 FAReTek1 marked this pull request as ready for review May 5, 2025 13:38
@FAReTek1
Copy link
Collaborator Author

FAReTek1 commented May 5, 2025

It won't be applicable to test for studio-related alerts for a while, as I haven't personally got any myself, unless someone else can

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant