scratchattach
scratchattach copied to clipboard
Classroom alerts parser & update Classroom private activity parser. solves #304
Classroom alerts/activity parser (updates)
This pr reverts commit d93c9a4c25a4f13fcb6692de6ccf1289b9208f11.
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/
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.
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_typefor parsing/looking-up the 'type' attribute using an enum. This enum is used internally in themessagegettermessagefor emulating Scratch's own display of the alert, e.g."Blockly by TimMcCool was censored"target_object_titlefor getting the title of the linked project/studio (if it's a comment or other stuff, returns None): used bymessage
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