MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / mystuff_ended_classes

Method mystuff_ended_classes

scratchattach/site/session.py:963–988  ·  view source on GitHub ↗
(self, mode: str = "Last created", page: Optional[int] = None)

Source from the content-addressed store, hash-verified

961 return classes
962
963 def mystuff_ended_classes(self, mode: str = "Last created", page: Optional[int] = None) -> list[classroom.Classroom]:
964 if not self.is_teacher:
965 raise exceptions.Unauthorized(f"{self.username} is not a teacher; can't have (deleted) classes")
966 ascsort, descsort = get_class_sort_mode(mode)
967
968 classes_data = requests.get(
969 "https://scratch.mit.edu/site-api/classrooms/closed/",
970 params={"page": page, "ascsort": ascsort, "descsort": descsort},
971 headers=self._headers,
972 cookies=self._cookies,
973 ).json()
974 classes = []
975 for data in classes_data:
976 fields = data["fields"]
977 educator_pf = fields["educator_profile"]
978 classes.append(
979 classroom.Classroom(
980 id=data["pk"],
981 title=fields["title"],
982 classtoken=fields["token"],
983 datetime=datetime.datetime.fromisoformat(fields["datetime_created"]),
984 author=user.User(username=educator_pf["user"]["username"], id=educator_pf["user"]["pk"], _session=self),
985 _session=self,
986 )
987 )
988 return classes
989
990 def backpack(self, limit: int = 20, offset: int = 0) -> list[backpack_asset.BackpackAsset]:
991 """

Callers

nothing calls this directly

Calls 3

get_class_sort_modeFunction · 0.90
jsonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected