Skip to content

Implement create and update assignment pages - #361

Merged
bestinlalu merged 7 commits into
expertiza:mainfrom
bestinlalu:feature/create-assignment-page
Oct 8, 2026
Merged

bestinlalu merged 7 commits into
expertiza:mainfrom
bestinlalu:feature/create-assignment-page

Conversation

@bestinlalu

Copy link
Copy Markdown
Collaborator

Summary

  • Implements the full create and update endpoints for assignments, including nested due_dates_attributes and assignment_questionnaires_attributes
  • Adds alias attributes and explicit DB-to-frontend field mappings in the Assignment model
  • Adds AssignmentSerializer, DueDateSerializer, and AssignmentQuestionnaireSerializer for structured API responses
  • Adds three database migrations for new feature flag columns
  • Adds RSpec coverage for the serializer, model virtual attributes, and the PATCH endpoint

API changes

PATCH /assignments/:id and POST /assignments now accept:

  • due_dates_attributes — creates or updates submission, review, drop topic, signup, and team formation deadlines. Omitting due_at on an existing record updates only the allowed_id columns while preserving the stored date (Rails accepts_nested_attributes_for partial-update behavior; the NOT NULL DB constraint is not challenged).
  • assignment_questionnaires_attributes — creates, updates, or destroys rubric associations per round. Sends _destroy: true for records no longer in the active set to prevent duplicates.
  • Full set of front-end field names mapped to their DB columns via alias_attribute (e.g. set_allowed_number_of_reviews_per_reviewer → num_reviews_allowed, is_penalty_calculated → is_penalty_calculated).

Virtual attributes (apply_late_policy, has_max_review_limit, show_template_review, calibration_for_training) are declared attr_writer only — permitted by strong params and accepted without error, but not persisted. The real DB columns (is_penalty_calculated, num_reviews_allowed) are what the serializer returns and what the frontend now reads.

Serializer response

AssignmentSerializer returns is_penalty_calculated and set_allowed_number_of_reviews_per_reviewer (not the virtual aliases). DueDateSerializer includes deadline_name derived from ExpertizaConstants::DeadlineTypes::NAMES so the frontend can match named deadline rows by name ('drop_topic', 'team_formation', 'signup').

Migrations

Migration Purpose
add_dropdown_to_assignment_questionnaires Adds dropdown boolean to assignment_questionnaires
add_calibrate_to_to_response_maps Adds calibrate_to boolean to response_maps
add_missing_assignment_feature_flags Adds has_mentors, auto_assign_mentor, duty_based_assignment, bidding_for_reviews_enabled, enable_bidding_for_topics, enable_authors_to_review_other_topics, team_reviewing_enabled to assignments

Spec coverage

File What is tested
spec/serializers/assignment_serializer_spec.rb (new) is_penalty_calculated is serialized; apply_late_policy is not. set_allowed_number_of_reviews_per_reviewer is serialized; has_max_review_limit is not. deadline_name values for all three named deadline types
spec/models/assignment_spec.rb (additions) Virtual attr_writer fields are accepted but not persisted. is_penalty_calculated round-trips through DB. set_allowed_number_of_reviews_per_reviewer alias reads/writes num_reviews_allowed. Updating named deadline allowed_id columns without due_at preserves the existing date
spec/requests/api/v1/assignment_controller_spec.rb (additions) PATCH /assignments/:id — is_penalty_calculated persists; apply_late_policy alone is a no-op; review limit alias persists; named deadline created from scratch; dropdown-only update preserves due_at; response includes correct deadline_name

Test plan

  • bundle exec rspec spec/serializers/assignment_serializer_spec.rb
  • bundle exec rspec spec/models/assignment_spec.rb
  • bundle exec rspec spec/requests/api/v1/assignment_controller_spec.rb
  • bundle exec rails db:migrate on a fresh test DB — all three migrations run cleanly
  • Verify PATCH /assignments/:id with is_penalty_calculated: true → field persists on reload
  • Verify PATCH /assignments/:id with named deadline due_dates_attributes (no due_at) → existing date unchanged, allowed_id updated

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: expertiza/reimplementation-back-end/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f933b473-5732-4601-88b9-0b39980acd63
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@bestinlalu bestinlalu changed the title Feature/create assignment page Implement create and update assignment pages Sep 22, 2026
@bestinlalu
bestinlalu force-pushed the feature/create-assignment-page branch from 126c059 to ff0b267 Compare September 25, 2026 13:56
@github-actions

Copy link
Copy Markdown

🚨 RSpec Tests Report

Failing Controller Test Cases:
rspec ./spec/requests/api/v1/assignment_controller_spec.rb:536 # Assignments API PATCH /assignments/:id is_penalty_calculated persists true when sent in the payload
rspec ./spec/requests/api/v1/assignment_controller_spec.rb:543 # Assignments API PATCH /assignments/:id is_penalty_calculated persists false when sent in the payload
rspec ./spec/requests/api/v1/assignment_controller_spec.rb:563 # Assignments API PATCH /assignments/:id set_allowed_number_of_reviews_per_reviewer persists a positive limit
rspec ./spec/requests/api/v1/assignment_controller_spec.rb:570 # Assignments API PATCH /assignments/:id set_allowed_number_of_reviews_per_reviewer persists zero to clear the limit
rspec ./spec/requests/api/v1/assignment_controller_spec.rb:577 # Assignments API PATCH /assignments/:id set_allowed_number_of_reviews_per_reviewer has_max_review_limit (virtual) in payload is accepted without error and is a no-op
rspec ./spec/requests/api/v1/assignment_controller_spec.rb:589 # Assignments API PATCH /assignments/:id named deadline due_dates_attributes creates a drop_topic deadline when none exists
rspec ./spec/requests/api/v1/assignment_controller_spec.rb:606 # Assignments API PATCH /assignments/:id named deadline due_dates_attributes updates only allowed_ids on an existing named deadline (no due_at change)
rspec ./spec/requests/api/v1/assignment_controller_spec.rb:633 # Assignments API PATCH /assignments/:id named deadline due_dates_attributes creates a team_formation deadline with the correct deadline_name in the response

@github-actions

Copy link
Copy Markdown

🚨 RSpec Tests Report

All tests passed.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

🚨 RSpec Tests Report

All tests passed.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

🚨 RSpec Tests Report

Failing Controller Test Cases:
rspec ./spec/requests/api/v1/assignment_controller_spec.rb:671 # Assignments API POST /assignments with valid params sets instructor_id to the authenticated user when no course_id is given
rspec ./spec/requests/api/v1/assignment_controller_spec.rb:677 # Assignments API POST /assignments with valid params inherits instructor_id from the course when course_id is given
rspec ./spec/requests/api/v1/assignment_controller_spec.rb:687 # Assignments API POST /assignments with invalid params returns 422 when name is blank

@bestinlalu
bestinlalu force-pushed the feature/create-assignment-page branch from 1d3c738 to 7575adb Compare October 6, 2026 04:54
Comment thread app/controllers/assignments_controller.rb Outdated
Comment thread app/models/review_mapping_handler.rb Outdated
Comment thread db/migrate/20260921000001_add_calibrate_to_to_response_maps.rb Outdated
Comment thread db/migrate/20260921000002_add_missing_assignment_feature_flags.rb Outdated
Comment thread db/migrate/20260921000002_add_missing_assignment_feature_flags.rb Outdated
Comment thread db/migrate/20260921000002_add_missing_assignment_feature_flags.rb Outdated
Comment thread db/migrate/20260921000002_add_missing_assignment_feature_flags.rb Outdated
@bestinlalu
bestinlalu force-pushed the feature/create-assignment-page branch from b424f98 to 745d467 Compare October 8, 2026 03:31
@bestinlalu
bestinlalu merged commit 6863fd6 into expertiza:main Oct 8, 2026
7 of 8 checks passed
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