feat: Add code-based attendance option - #1926
TigerCodeHub wants to merge 5 commits into
Conversation
|
@greptileai review |
|
| try: | ||
| day_block = day_blocks.get(name="8" + block.block_letter) | ||
| except Block.DoesNotExist: | ||
| mark_result = "invalid_time" | ||
| if not day_block.eighth_auto_open <= timezone.localtime().time() <= day_block.eighth_auto_close: | ||
| mark_result = "invalid_time" |
There was a problem hiding this comment.
Special blocks crash
When the current day type does not contain a matching 8{{ block_letter }} block, the except Block.DoesNotExist branch sets mark_result but execution still reaches day_block.eighth_auto_open. That leaves day_block undefined and raises UnboundLocalError, so the attendance page and related checks return a 500 for nonstandard blocks.
| try: | |
| day_block = day_blocks.get(name="8" + block.block_letter) | |
| except Block.DoesNotExist: | |
| mark_result = "invalid_time" | |
| if not day_block.eighth_auto_open <= timezone.localtime().time() <= day_block.eighth_auto_close: | |
| mark_result = "invalid_time" | |
| try: | |
| day_block = day_blocks.get(name="8" + block.block_letter) | |
| except Block.DoesNotExist: | |
| return "invalid_time" | |
| if not day_block.eighth_auto_open <= timezone.localtime().time() <= day_block.eighth_auto_close: | |
| mark_result = "invalid_time" |
Artifacts
Repro: focused check_attendance_open harness
- Evidence file captured while the check ran.
Repro: execution output showing UnboundLocalError
- The full error output from the failing run.
▶ page@d8d7e3c0a12b097cd5278b76b21866ff.webm
- The flow T-Rex ran, recorded end to end.
- What the screen looked like at this point in the check.
- What the screen looked like at this point in the check.
| <form id="mode-form" method="post"> | ||
| {% csrf_token %} | ||
| {% for value, label in scheduled_activity.mode_choices %} | ||
| <label> | ||
| <input type="radio" name="att_code_mode" value="{{ value }}" | ||
| {% if scheduled_activity.code_mode == value %}checked{% endif %}> | ||
| {{ label }} | ||
| {% if value == 0 %} | ||
| {{ auto_time_string }} | ||
| {% endif %} | ||
| </label> | ||
| {% endfor %} | ||
| </form> | ||
| <button type="submit">Save</button> |
There was a problem hiding this comment.
Mode save is disconnected
The Save button is outside #mode-form and has no form="mode-form", so clicking it does not submit the selected att_code_mode. Teachers cannot switch a code from Auto to Open or Closed from this page, leaving manual code control nonfunctional.
| <form id="mode-form" method="post"> | |
| {% csrf_token %} | |
| {% for value, label in scheduled_activity.mode_choices %} | |
| <label> | |
| <input type="radio" name="att_code_mode" value="{{ value }}" | |
| {% if scheduled_activity.code_mode == value %}checked{% endif %}> | |
| {{ label }} | |
| {% if value == 0 %} | |
| {{ auto_time_string }} | |
| {% endif %} | |
| </label> | |
| {% endfor %} | |
| </form> | |
| <button type="submit">Save</button> | |
| <form id="mode-form" method="post"> | |
| {% csrf_token %} | |
| {% for value, label in scheduled_activity.mode_choices %} | |
| <label> | |
| <input type="radio" name="att_code_mode" value="{{ value }}" | |
| {% if scheduled_activity.code_mode == value %}checked{% endif %}> | |
| {{ label }} | |
| {% if value == 0 %} | |
| {{ auto_time_string }} | |
| {% endif %} | |
| </label> | |
| {% endfor %} | |
| </form> | |
| <button type="submit" form="mode-form">Save</button> |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Artifacts
Repro: Playwright harness rendering the repository template fragment and clicking Save
- Evidence file captured while the check ran.
Repro: command output showing detached button facts and no submit or POST after click
- The full command output behind this check.
- What the screen looked like at this point in the check.
- What the screen looked like at this point in the check.
- The flow T-Rex ran, recorded end to end.
|
Can we revisit this? I think it would be really useful |
Closes #1612
Proposed changes
Added a new method of attendance. For each EighthScheduledActivity, a random 6-character code 0-9 & A-Z is generated. This is displayed to the teacher (and eighth admins). Teachers can share the code to students at the activity, who can then input the code on a new eighth/student_attendance page which marks them as present if the code is correct (and shows a message as such).
This also sets the attendance_taken on a sch. activity to True (as it would be odd otherwise).
Note: Migration is required (new attendance_code attribute for EightScheduledActivity object).
Attendance will only be marked if the code is given during the block (2:25 - 3:05 for A blocks, 3:15 - 4:00 for B blocks, anytime for other kinds of blocks). Otherwise, the student will get an error message.
Students may access the attendance page through buttons which will appear on the eighth/glance (location.html) and eight/signup (signup.html) pages from 2:25 to 4:00.
This attendance method coexists with already-existing methods (so the last change is the one which has effect).
(All above times in PM).
Brief description of rationale
This method (credits to Alan Zhu for the idea) will let students mark themselves present if they are at an activity (and thus receive the code from the teacher). This makes it more convenient for the teacher to take attendance, as all they need to do is show the code to the students at the activity.