Skip to content

E2605: Complete backend support for specialized rubrics by topic#325

Open
PositivelyBookish wants to merge 10 commits into
expertiza:mainfrom
PositivelyBookish:main
Open

E2605: Complete backend support for specialized rubrics by topic#325
PositivelyBookish wants to merge 10 commits into
expertiza:mainfrom
PositivelyBookish:main

Conversation

@PositivelyBookish
Copy link
Copy Markdown

@PositivelyBookish PositivelyBookish commented Mar 31, 2026

Summary

This PR finalizes backend support for specialized review rubrics by topic.

It enables assignments to use a default review rubric while allowing individual topics to override that rubric, with support for round-specific behavior when rubrics vary by both topic and round.

Changes

  • support topic-aware rubric mappings in assignment questionnaires
  • add backend handling for retrieving topic-specific rubric data for an assignment
  • add backend handling for saving topic-specific rubric selections
  • preserve assignment-level review rubrics as the default fallback when no topic-specific override exists
  • support rubric resolution for all required cases:
    • no variation by round or topic
    • variation by round only
    • variation by topic only
    • variation by both round and topic
  • align assignment update handling with the persisted vary-by-topic / vary-by-round assignment state

Behavior

After this change:

  • an assignment can keep a default review rubric
  • each topic can optionally override that review rubric
  • if rubrics vary by round, topic-specific rubric selection can also vary by round
  • when no topic-specific rubric is defined, the assignment default is used

Testing

Verified through manual integration testing with the assignment editor by:

  • enabling Review rubric varies by topic?
  • selecting topic-specific review rubrics
  • saving the assignment
  • reloading the assignment editor
  • confirming the selected rubric persisted for the topic

Summary by CodeRabbit

  • New Features

    • Added assignment questionnaire management with topic-specific rubric support.
    • Reviewers are automatically notified when instructors update review rubrics.
    • Review questionnaires can now vary by topic and round configuration.
    • Previous reviews are archived when rubrics are updated, allowing reviewers to redo evaluations with current criteria.
  • Tests

    • Added comprehensive test coverage for assignment questionnaire management, student tasks, and questionnaire updates.

@github-actions
Copy link
Copy Markdown

2 Warnings
⚠️ Pull request is too big (more than 500 LoC).
⚠️ RSpec tests seem shallow (single it blocks or no context). Consider improving test structure.

Generated by 🚫 Danger

@PositivelyBookish PositivelyBookish marked this pull request as draft March 31, 2026 01:07
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e814724-4920-4ee8-a63b-a21058b95a4c

📥 Commits

Reviewing files that changed from the base of the PR and between cc03ecd and 16cd1bf.

📒 Files selected for processing (24)
  • app/controllers/assignment_questionnaires_controller.rb
  • app/controllers/assignments_controller.rb
  • app/controllers/concerns/review_reset_handler.rb
  • app/controllers/questionnaires_controller.rb
  • app/controllers/questions_controller.rb
  • app/controllers/student_tasks_controller.rb
  • app/mailers/rubric_update_mailer.rb
  • app/models/assignment.rb
  • app/models/assignment_questionnaire.rb
  • app/models/concerns/topic_based_rubric_lookup.rb
  • app/models/project_topic.rb
  • app/models/response.rb
  • app/models/review_reset_archive.rb
  • app/serializers/assignment_serializer.rb
  • app/views/rubric_update_mailer/review_redo_notification.html.erb
  • app/views/rubric_update_mailer/review_redo_notification.text.erb
  • config/routes.rb
  • db/migrate/20260419000001_add_vary_by_topic_to_assignments.rb
  • db/migrate/20260419000002_add_project_topic_to_assignment_questionnaires.rb
  • db/migrate/20260424000003_create_review_reset_archives.rb
  • db/schema.rb
  • spec/controllers/assignment_questionnaires_controller_spec.rb
  • spec/controllers/questionnaires_controller_spec.rb
  • spec/controllers/student_tasks_controller_spec.rb

📝 Walkthrough

Walkthrough

This PR introduces a topic-aware rubric management system for assignments. It adds a new controller for assignment questionnaires, implements automatic review reset with archival when rubrics change, enables instructors to assign rubrics per topic, and notifies reviewers when rubrics are updated.

Changes

Cohort / File(s) Summary
New Assignment Questionnaire Controller
app/controllers/assignment_questionnaires_controller.rb, config/routes.rb
Introduces AssignmentQuestionnairesController with CRUD actions (index, create, update, destroy). Routes include GET /assignment_questionnaires and standard RESTful endpoints. Authorization gates access by assignment admin/teaching staff status.
Review Reset & Notification System
app/controllers/concerns/review_reset_handler.rb, app/mailers/rubric_update_mailer.rb, app/views/rubric_update_mailer/*, app/models/review_reset_archive.rb
Adds ReviewResetHandler concern to plan and execute review resets (filtering mappings, fetching responses, creating archives, sending notifications). RubricUpdateMailer dispatches redo notifications with HTML/text templates. ReviewResetArchive model persists reset event snapshots with required fields and validation.
Topic-Based Rubric Lookup
app/models/concerns/topic_based_rubric_lookup.rb, app/models/response.rb
Introduces TopicBasedRubricLookup concern that resolves questionnaires by prioritizing topic-specific then round-specific assignments. Updates Response#questionnaire to use the new lookup logic via assignment_questionnaire_for_response_map.
Model Associations & Validations
app/models/assignment.rb, app/models/assignment_questionnaire.rb, app/models/project_topic.rb
Extends Assignment with nested attributes management and TopicBasedRubricLookup mixin. Adds project_topic association to AssignmentQuestionnaire with referential consistency and duplicate review-rubric validations. Links ProjectTopic to assignment_questionnaires with nullify on destroy.
Controller Integration
app/controllers/questions_controller.rb, app/controllers/questionnaires_controller.rb, app/controllers/student_tasks_controller.rb
Integrates ReviewResetHandler into QuestionsController and QuestionnairesController to conditionally trigger reset plans when review questionnaires are modified. Adds rubric_for action to StudentTasksController to retrieve rubric metadata by response map.
Strong Parameters & Serialization
app/controllers/assignments_controller.rb, app/serializers/assignment_serializer.rb
Refactors assignment_params to whitelist new fields (vary_by_round, vary_by_topic, rounds_of_reviews, assignment_questionnaires_attributes). Expands AssignmentSerializer to expose 30+ attributes including nested questionnaires and due dates.
Database Schema & Migrations
db/migrate/20260419000001_add_vary_by_topic_to_assignments.rb, db/migrate/20260419000002_add_project_topic_to_assignment_questionnaires.rb, db/migrate/20260424000003_create_review_reset_archives.rb, db/schema.rb
Adds vary_by_topic boolean to assignments. Adds project_topic_id foreign key and composite index to assignment_questionnaires. Creates review_reset_archives table with required fields, timestamps, and lookup indexes.
Test Specifications
spec/controllers/assignment_questionnaires_controller_spec.rb, spec/controllers/questionnaires_controller_spec.rb, spec/controllers/student_tasks_controller_spec.rb
Comprehensive RSpec coverage for new/modified actions: CRUD workflows for assignment questionnaires including reset side effects, questionnaire update with review archival, and rubric resolution endpoint with 200/404 scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant Instructor
    participant Controller as AssignmentQuestionnairesController
    participant Planner as ReviewResetHandler
    participant Archive as ReviewResetArchive
    participant Mailer as RubricUpdateMailer
    participant DB as Database

    Instructor->>Controller: POST/PATCH assignment_questionnaire
    Controller->>Planner: build_review_reset_plan(context)
    Planner->>DB: Query ReviewQuestionnaire mappings<br/>for assignment & topic
    Planner->>DB: Fetch associated Responses<br/>by round
    Planner->>DB: Build archive payloads<br/>(with snapshots)
    Planner-->>Controller: Return reset_plan
    
    Controller->>DB: Save mapping (create/update)
    Controller->>Planner: apply_review_reset_plan(plan)
    
    Planner->>Archive: Create ReviewResetArchive<br/>(for each response)
    Planner->>Mailer: Enqueue redo notifications<br/>for reviewers
    Mailer-->>Instructor: Email sent (async)
    
    Planner->>DB: Delete archived Responses
    Planner-->>Controller: Plan applied
    Controller-->>Instructor: JSON response (201/200)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 Rubrics now bloom by topic fair,
Resets cascade through the air!
When instructors change the review,
Archives keep what once was true.
Notifications hop with glee,
New questionnaires, wild and free!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@PositivelyBookish PositivelyBookish marked this pull request as ready for review April 28, 2026 22:22
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.

1 participant