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

Method activity

scratchattach/site/classroom.py:357–381  ·  view source on GitHub ↗

Get a list of private activity, only available to the class owner. Returns: list The private activity of users in the class

(self, student: str = "all", mode: str = "Last created", page: Optional[int] = None)

Source from the content-addressed store, hash-verified

355 return activities
356
357 def activity(self, student: str = "all", mode: str = "Last created", page: Optional[int] = None) -> list[activity.Activity]:
358 """
359 Get a list of private activity, only available to the class owner.
360 Returns:
361 list<activity.Activity> The private activity of users in the class
362 """
363
364 self._check_session()
365
366 ascsort, descsort = commons.get_class_sort_mode(mode)
367
368 with requests.no_error_handling():
369 try:
370 data = requests.get(f"https://scratch.mit.edu/site-api/classrooms/activity/{self.id}/{student}/",
371 params={"page": page, "ascsort": ascsort, "descsort": descsort},
372 headers=self._headers, cookies=self._cookies).json()
373 except json.JSONDecodeError:
374 return []
375
376 _activity: list[activity.Activity] = []
377 for activity_json in data:
378 _activity.append(activity.Activity(_session=self._session))
379 _activity[-1]._update_from_json(activity_json) # NOT the same as _update_from_dict
380
381 return _activity
382
383
384def get_classroom(class_id: str) -> Classroom:

Callers

nothing calls this directly

Calls 5

_check_sessionMethod · 0.95
jsonMethod · 0.80
_update_from_jsonMethod · 0.80
no_error_handlingMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected