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 = "")
| 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 |
nothing calls this directly
no test coverage detected