|
1 | 1 | import functools |
2 | 2 | import re |
3 | | -from datetime import timedelta |
| 3 | +from datetime import UTC, timedelta |
4 | 4 | from enum import Enum, StrEnum |
5 | 5 | from typing import Any |
6 | 6 | from urllib.parse import urlparse |
@@ -471,6 +471,41 @@ def enable_instructor_dashboard_entry_point(self, assignment): |
471 | 471 | } |
472 | 472 | self._config["hypothesisClient"] = self._hypothesis_client |
473 | 473 |
|
| 474 | + def enable_toolbar_checkpoint(self, assignment): |
| 475 | + toolbar_config = self._config.get("instructorToolbar", {}) |
| 476 | + |
| 477 | + toolbar_config["checkpoint"] = { |
| 478 | + "enabled": True, |
| 479 | + "revealed": assignment.checkpoint.reveal_date is not None, |
| 480 | + # reveal_date is stored as UTC without timezone info. Adding |
| 481 | + # UTC here so the ISO string includes +00:00 and the browser |
| 482 | + # can convert it to the user's local timezone. |
| 483 | + "revealDate": assignment.checkpoint.reveal_date.replace(tzinfo=UTC).isoformat() |
| 484 | + if assignment.checkpoint.reveal_date |
| 485 | + else None, |
| 486 | + # TODO: use actual due date once available; for now reuse reveal_date. |
| 487 | + "dueDate": assignment.checkpoint.reveal_date.replace(tzinfo=UTC).isoformat() |
| 488 | + if assignment.checkpoint.reveal_date |
| 489 | + else None, |
| 490 | + "revealUrl": self._request.route_url( |
| 491 | + "api.checkpoint.reveal", assignment_id=assignment.id |
| 492 | + ), |
| 493 | + } |
| 494 | + self._config["instructorToolbar"] = toolbar_config |
| 495 | + |
| 496 | + def enable_student_checkpoint(self, assignment): |
| 497 | + revealed = assignment.checkpoint.reveal_date is not None |
| 498 | + self._config["studentCheckpoint"] = { |
| 499 | + "hidden": not revealed, |
| 500 | + # TODO: use actual due date once available; for now reuse reveal_date. |
| 501 | + # reveal_date is stored as UTC without timezone info. Adding |
| 502 | + # UTC here so the ISO string includes +00:00 and the browser |
| 503 | + # can convert it to the user's local timezone. |
| 504 | + "dueDate": assignment.checkpoint.reveal_date.replace(tzinfo=UTC).isoformat() |
| 505 | + if assignment.checkpoint.reveal_date |
| 506 | + else None, |
| 507 | + } |
| 508 | + |
474 | 509 | def enable_toolbar_editing(self): |
475 | 510 | toolbar_config = self._get_toolbar_config() |
476 | 511 |
|
|
0 commit comments