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

Method create_class

scratchattach/site/session.py:755–776  ·  view source on GitHub ↗

Create a class on the scratch website Warning: Don't spam this method - it WILL get you banned from Scratch. To prevent accidental spam, a rate limit (5 classes per minute) is implemented for this function.

(self, title: str, desc: str = "")

Source from the content-addressed store, hash-verified

753 return new_studio
754
755 def create_class(self, title: str, desc: str = "") -> classroom.Classroom:
756 """
757 Create a class on the scratch website
758
759 Warning:
760 Don't spam this method - it WILL get you banned from Scratch.
761 To prevent accidental spam, a rate limit (5 classes per minute) is implemented for this function.
762 """
763 enforce_ratelimit("create_scratch_class", "creating Scratch classes")
764
765 if not self.is_teacher:
766 raise exceptions.Unauthorized(f"{self.username} is not a teacher; can't create class")
767
768 data = requests.post(
769 "https://scratch.mit.edu/classes/create_classroom/",
770 json={"title": title, "description": desc},
771 headers=self._headers,
772 cookies=self._cookies,
773 ).json()
774
775 class_id = data[0]["id"]
776 return self.connect_classroom(class_id)
777
778 # --- My stuff page ---
779

Callers

nothing calls this directly

Calls 4

connect_classroomMethod · 0.95
enforce_ratelimitFunction · 0.85
jsonMethod · 0.80
postMethod · 0.80

Tested by

no test coverage detected