Skip to content

feat: Add code-based attendance option - #1926

Open
TigerCodeHub wants to merge 5 commits into
tjcsl:devfrom
TigerCodeHub:attendance
Open

TigerCodeHub wants to merge 5 commits into
tjcsl:devfrom
TigerCodeHub:attendance

Conversation

@TigerCodeHub

Copy link
Copy Markdown
Member

Closes #1612

Note: This supersedes #1770. The work was moved from the dev branch to a dedicated attendance branch to keep the fork's dev clean and in sync with upstream. See #1770 for prior review history.

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.

@makors

makors commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@greptileai review

@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown

Confidence Score: 3/5

Multiple core paths in the new attendance flow can behave incorrectly.

The auto-window check can crash for nonstandard Eighth blocks, and the teacher UI does not submit code mode changes, so manual open/closed control cannot be applied from the page.

Files Needing Attention: intranet/apps/eighth/views/attendance.py; intranet/templates/eighth/take_attendance.html

T-Rex T-Rex Logs

What T-Rex did

  • Reproduced the crash in check_attendance_open by running a focused Python harness on the PR source; it exercises the Block.DoesNotExist path and raises UnboundLocalError when day_block.eighth_auto_open is accessed.
  • Verified mode save is disconnected: a Playwright harness rendered the mode-control fragment and showed the Save button outside the form with no form attribute; after Open and Save, no submit or POST events were recorded.
  • Identified blocker conditions for eighth-attendance-ui: a SyntaxError during Django URL import in the import check due to a typing syntax around RawPaginationData; runtime inventory shows Python 3.11 is available while the project requires >=3.13, and the nearest compile indicates the changed file can compile under 3.11.
  • Gathered and linked artifacts to support review, including the Python repro harness, Playwright render outputs, and runtime/compile logs.

View all artifacts

T-Rex Ran code and verified through T-Rex

Sequence Diagram

sequenceDiagram
participant Teacher
participant AttendancePage as Teacher attendance page
participant Student
participant StudentPage as Student attendance page
participant DB as Eighth models

Teacher->>AttendancePage: View scheduled activity
AttendancePage->>DB: Read attendance_code/code_mode
AttendancePage-->>Teacher: Show code or QR URL
Teacher-->>Student: Share code/QR
Student->>StudentPage: "Open /student_attendance/{sch_act_id}/{code}"
StudentPage->>DB: Load scheduled activity and signup
StudentPage->>StudentPage: check_attendance_open()
StudentPage->>DB: Compare attendance_code and update signup/activity
StudentPage-->>Student: Show marked/error result
Loading

Fix All in Codex Fix All in Claude Code

Reviews (1): Last reviewed commit: "merge dev" | Re-trigger Greptile

Comment on lines +911 to +916
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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Suggested change
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.

Before: Mode Save Click

  • What the screen looked like at this point in the check.

After: Mode Save Click

  • What the screen looked like at this point in the check.

View artifacts

T-Rex Ran code and verified through T-Rex

Fix in Codex Fix in Claude Code

Comment on lines +456 to +469
<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>
&nbsp;&nbsp;<button type="submit">Save</button>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Suggested change
<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>
&nbsp;&nbsp;<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>
&nbsp;&nbsp;<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.

Before: Mode Save Click

  • What the screen looked like at this point in the check.

After: Mode Save Click

  • What the screen looked like at this point in the check.

▶ Recording of the check

  • The flow T-Rex ran, recorded end to end.

View artifacts

T-Rex Ran code and verified through T-Rex

Fix in Codex Fix in Claude Code

@ElijahFeldman7

Copy link
Copy Markdown
Contributor

Can we revisit this? I think it would be really useful

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alternate attendance options

3 participants