Skip to content

Conversation

Copy link

Copilot AI commented Dec 13, 2025

The log tracking tables (AssignmentLog, CourseLog, RoleLog) were created but not being populated. This adds event logging at appropriate model lifecycle points.

Changes

Assignment events:

  • CREATE on Assignment.new()
  • DELETE on Assignment.remove()
  • FORK on Assignment.fork()
  • EDIT already logged in save_assignment() endpoint

Course events:

  • CREATE on Course.new()
  • DELETE on Course.remove()
  • EDIT on Course.edit() - one log entry per field changed

Role events:

  • GIVEN on User.add_role() and User.update_roles()
  • REMOVED on Role.remove() and User.update_roles()
  • CHANGED on Role.update_role()

Key additions:

  • Added authorizer_id parameter to role operations to distinguish actor from subject (defaults to self-authorization)
  • Updated course endpoints to pass current user as authorizer
  • Optimized update_roles() to batch flush operations
# Example: Role logging with authorizer tracking
def add_role(self, name, course_id, authorizer_id=None):
    new_role = models.Role(name=name, user_id=self.id, course_id=course_id)
    db.session.add(new_role)
    db.session.commit()
    
    if authorizer_id is None:
        authorizer_id = self.id  # Self-authorization
    models.RoleLog.new(new_role.id, course_id, self.id, authorizer_id,
                       RoleLogEvent.GIVEN, name)
    return new_role

All logging follows existing SubmissionLog patterns with proper enum values and foreign key relationships.

Original prompt

We have created a set of new log tracking tables, but we are not currently populating them. We need to start logging events for these other tables.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits December 13, 2025 16:50
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
…ame consistently

Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Copilot AI changed the title [WIP] Add event logging for new tracking tables Populate log tracking tables for Assignment, Course, and Role events Dec 13, 2025
Copilot AI requested a review from acbart December 13, 2025 17:03
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.

2 participants