Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 14, 2025

Overview

This PR implements a comprehensive user role system that differentiates between teachers, amanuenses, and hourly TAs in the nytid system. The key improvement is in prep time calculations, where teachers now receive appropriate credit for lecture preparation while TAs are compensated for assisting during lectures.

Problem

Previously, the system used a boolean amanuensis flag to distinguish between two types of TAs. This approach had several limitations:

  1. No distinction for teachers: Teachers and TAs were treated identically, despite teachers doing significantly more prep work for lectures
  2. Inaccurate prep time: Teachers prep lectures (factor 3) but the system gave them the same credit as TAs who just help during lectures (factor 1)
  3. Limited access control: No systematic way to manage which users have access to course data
  4. Binary classification: Only two categories (amanuensis vs hourly) couldn't represent the actual roles

Solution

1. User Role Enum

Introduced a three-level classification system:

  • Teacher: Course instructors, always treated like amanuenses except with 3x prep time for lectures
  • Amanuensis: TAs with amanuensis contracts
  • Hourly: TAs paid by the hour
class UserRole(str, Enum):
    TEACHER = "teacher"
    AMANUENSIS = "amanuensis"
    HOURLY = "hourly"

2. Users Command

Added comprehensive user management through a new users subcommand:

# Add a teacher to a course with proper role
nytid courses users add prgi24 dbosk --role teacher

# List all users and their roles
nytid courses users list prgi24

# Remove a user from a course
nytid courses users rm prgi24 student1

User roles are stored in the course configuration and automatically grant/revoke storage ACL access.

3. Differentiated Prep Time

Updated prep time calculations to reflect actual work performed:

Event Type Teacher Amanuensis Hourly TA
Lecture 3.0x 1.0x 1.0x
Exercise 2.0x 2.0x 2.0x
Lab (online/recent) 1.5x 1.5x 1.5x
Lab (on-campus) 1.5x 1.5x 1.8x

Rationale: Teachers prepare lectures (3x factor), while TAs assist during lectures with no prep (1x factor). For other activities, teachers and amanuenses are treated the same.

Technical Implementation

Modified Files (Literate Programming Sources)

  1. src/nytid/cli/courses.nw: Added UserRole enum and users command with add/list/rm subcommands
  2. src/nytid/courses/init.nw: Added set_course_config() function for programmatic config updates
  3. src/nytid/signup/hr/hr.nw: Updated prep_factor(), add_prep_time(), and time_for_event() to accept role parameter
  4. src/nytid/storage/init.nw: Added add_user() and remove_user() convenience methods
  5. src/nytid/cli/hr.nw: Added get_user_role() helper function with fallback to contract detection

Backward Compatibility

The implementation maintains full backward compatibility:

  • Existing functions continue to work with default parameters
  • Legacy code without role specifications defaults to UserRole.HOURLY
  • Falls back to contract-based detection when no explicit role is configured
  • All existing tests pass (29 passed, 10 expected failures for AFS/LADOK credentials)

Python API Example

from nytid.signup.hr import UserRole, prep_factor
import datetime

# Calculate prep time for a teacher's lecture
teacher_factor = prep_factor("lecture", datetime.date.today(), UserRole.TEACHER)
# Returns: 3.0 (teachers do prep)

# Calculate prep time for a TA helping at lecture
ta_factor = prep_factor("lecture", datetime.date.today(), UserRole.HOURLY)
# Returns: 1.0 (TAs just help, no prep)

# Both get same prep time for tutoring
teacher_lab = prep_factor("laboration", datetime.date.today(), UserRole.TEACHER)
ta_lab = prep_factor("laboration", datetime.date.today(), UserRole.AMANUENSIS)
# Both return: 1.5 (treated the same for tutoring)

Testing

  • ✅ All 29 existing tests pass
  • ✅ 10 expected failures (AFS/LADOK credentials not available in test environment)
  • ✅ Verified prep time calculations for all role combinations
  • ✅ Tested CLI commands for user management
  • ✅ Confirmed backward compatibility with existing code

Future Enhancements

This foundation enables future improvements:

  • Integration with UG (user groups) for automatic group management
  • Role-based permissions for course operations
  • Automatic role detection from LADOK/Canvas
  • Migration tool for existing contract data

References

Closes #[issue_number]

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Handle teachers and TAs differently</issue_title>
<issue_description>We want to teach TAs and teachers differently:

  • They have slightly differing prep time. Usually TAs help out during a lecture, requiring no prep time, but teachers do that prep (a factor 3).
  • Teachers and TAs should be added to different groups in UG.
  • Teachers are always more like amanuenses. (Except for the prep time.)

We want to add to the config who is a teacher, then everyone else is treated as a TA (either hourly or amanuensis). Probably we should instead of having amanuensis set to true or false, we should have three classes:

  1. teacher
  2. amanuensis
  3. hourly

It would probably be useful to add it as an enum. That would fit into how typer works too with options on the command line. And then we can easily add more later.

We need a users command to manage users in a course. Particularly we should be able to add a teacher, an add subcommand. Then they should be added to the ACL in the StorageRoot for the course too. We also want to have a subcommand list to list them too. And rm to remove them.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #236


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits October 14, 2025 07:06
- Created UserRole enum (teacher, amanuensis, hourly) in courses and hr modules
- Added 'users' command with add, list, and rm subcommands
- Updated prep_factor to handle teacher role (prep time 3 for lectures, 1 for TAs)
- Added set_course_config function to courses module
- Added add_user and remove_user methods to StorageRoot
- Teachers now differentiated from TAs with higher lecture prep time

Co-authored-by: dbosk <237222+dbosk@users.noreply.github.com>
- Added get_user_role helper function to hr CLI
- Verified prep time calculations work correctly for all roles
- Teachers get 3x prep time for lectures, TAs get 1x
- Teachers and amanuenses treated the same for tutoring (1.5x)
- All tests passing (10 expected failures for AFS/LADOK)

Co-authored-by: dbosk <237222+dbosk@users.noreply.github.com>
Copilot AI changed the title [WIP] Add user classification for teachers and TAs Add user role management and differentiated prep time for teachers and TAs Oct 14, 2025
Copilot AI requested a review from dbosk October 14, 2025 07:13
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.

Handle teachers and TAs differently

2 participants