Skip to content

feat(be): add update blueprint assignment problems - #3976

Open
weno7 wants to merge 1 commit into
feat/blueprint-assignment-problem-createfrom
feat/blueprint-assignment-problem-update
Open

weno7 wants to merge 1 commit into
feat/blueprint-assignment-problem-createfrom
feat/blueprint-assignment-problem-update

Conversation

@weno7

@weno7 weno7 commented Nov 27, 2026 •

Copy link
Copy Markdown

Description

Adds APIs to update the problems of a Blueprint assignment. Stacked on #3974 (feat/blueprint-assignment-problem-create).
Changes are also applied to linked section copies (Assignment) in the same transaction.

Update API

  • updateBlueprintAssignmentProblems(blueprintAssignmentId, problems: [{ problemId, score }]): updates problem scores
  • updateBlueprintAssignmentProblemsOrder(blueprintAssignmentId, orders: [problemId]): resets order from 0 by array index
  • Permission: professors and TAs of the blueprint course (via assertBlueprintLeader)
  • Errors:
    • Score: CONFLICT if a linked copy has learning records, NOT_FOUND if a problem is not in the blueprint assignment
    • Order: UNPROCESSABLE_DATA if orders does not list every problem exactly once
    • Both: NOT_FOUND if the blueprint assignment does not exist, FORBIDDEN if not a leader

Changes

  • Add updateBlueprintAssignmentProblems and updateBlueprintAssignmentProblemsOrder to the service and resolver
  • Lock the source first with lockBlueprintAssignment, same as #3967
  • Block score changes when copies have learning records (reuses assertAssignmentsHaveNoLearningRecords); allow order changes since they do not affect grading

Additional context

  • Based on the existing updateAssignmentProblems / updateAssignmentProblemsOrder structure
  • 11 service unit tests added
  • schema.gql, D will be updated in a following commit

Before submitting the PR, please make sure you do the following

Summary by CodeRabbit

  • New Features
    • Blueprint assignment problems can now be updated and reordered. Score changes are reflected in linked copies.
    • Score updates are blocked when linked copies have learning records; reordering remains available.
    • Invalid or incomplete problem selections are rejected.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 63325de9-68f8-4a81-a148-568d7d059192

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The change adds mutations to update blueprint assignment problem scores and ordering. The service validates each request and applies updates to the blueprint assignment and its linked copies. Tests cover authorization, validation, and copy updates.

Changes: Blueprint assignment problem updates

Layer / File(s) Summary
Update problem scores
apps/backend/apps/admin/src/blueprint-assignment-problem/blueprint-assignment-problem.resolver.ts, apps/backend/apps/admin/src/blueprint-assignment-problem/blueprint-assignment-problem.service.ts, apps/backend/apps/admin/src/blueprint-assignment-problem/blueprint-assignment-problem.service.spec.ts
The resolver exposes a score-update mutation. The service checks access, imported problems, and copy learning records before updating the blueprint and its copies. Tests cover authorization, score propagation, and rejected updates.
Update problem order
apps/backend/apps/admin/src/blueprint-assignment-problem/blueprint-assignment-problem.resolver.ts, apps/backend/apps/admin/src/blueprint-assignment-problem/blueprint-assignment-problem.service.ts, apps/backend/apps/admin/src/blueprint-assignment-problem/blueprint-assignment-problem.service.spec.ts
The resolver parses an integer order array. The service requires every imported problem ID exactly once, then updates ordering on the blueprint and its copies. Tests cover authorization, validation, and reordering despite submissions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Possibly related PRs

Merge Risk: Minimal · previous review 800ae

This PR adds mutations to update problem scores and ordering on Blueprint assignments and apply the changes to linked section copies. Authorization, locking, and input validation checks are in place, and no concrete defects were found. The only CI failure is a formatting warning in a file this PR does not change, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(be): add update blueprint assignment problems" matches the main change. The PR adds two mutations to the admin resolver, updateBlueprintAssignmentProblems (score updates) and updateBlu…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(be): add update blueprint assignment problems" matches the main change. The PR adds two mutations to the admin resolver, updateBlueprintAssignmentProblems (score updates) and updateBlueprintAssignmentProblemsOrder (ordering), with service logic that propagates changes to assignment copies. The title names the core feature (updating blueprint assignment problems) and omits the ordering mutation and the copy propagation, which is acceptable for a title. It is concise, specific, and follows a conventional commit format.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bc7bd2d7-de0a-48b2-af48-a10cce2068bb
Commits

Reviewing files that changed from the base of the PR and between e8ddccf and 800aebd.

Files selected for processing: 3

  • apps/backend/apps/admin/src/blueprint-assignment-problem/blueprint-assignment-problem.resolver.ts
  • apps/backend/apps/admin/src/blueprint-assignment-problem/blueprint-assignment-problem.service.spec.ts
  • apps/backend/apps/admin/src/blueprint-assignment-problem/blueprint-assignment-problem.service.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@weno7

weno7 commented Nov 27, 2026

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
backend 55.77% <100.00%> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...nt-problem/blueprint-assignment-problem.service.ts 97.80% <100.00%> (+1.08%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@weno7

weno7 commented Nov 27, 2026

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@weno7
weno7 force-pushed the feat/blueprint-assignment-problem-update branch from 800aebd to bde2a2b Compare November 27, 2026 19:52
@weno7
weno7 force-pushed the feat/blueprint-assignment-problem-update branch from bde2a2b to d278787 Compare November 28, 2026 09:45

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant