Skip to content

Fix peer review badge to show green when reviews are completed with real-time updates#129

Merged
alexeygrigorev merged 3 commits into
mainfrom
copilot/fix-peer-review-badge-color
Jan 15, 2026
Merged

Fix peer review badge to show green when reviews are completed with real-time updates#129
alexeygrigorev merged 3 commits into
mainfrom
copilot/fix-peer-review-badge-color

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 14, 2026

The peer review badge remained red after students completed their required reviews, causing confusion about review status.

Changes

  • Real-time badge calculation: Badge now dynamically counts submitted reviews instead of relying on the database field
    • Green (bg-success) with "Review completed" when student has submitted all required reviews
    • Red (bg-danger) with "Review" when reviews are still incomplete
    • Provides immediate visual feedback as students submit each review
# courses/views/course.py - update_project_with_additional_info()
elif project.state == ProjectState.PEER_REVIEWING.value:
    # Calculate if reviews are completed by counting submitted reviews
    completed_reviews_count = PeerReview.objects.filter(
        reviewer=submission,
        optional=False,
        state=PeerReviewState.SUBMITTED.value
    ).count()
    
    reviews_completed = (
        completed_reviews_count >= project.number_of_peers_to_evaluate
    )
    
    if reviews_completed:
        project.badge_state_name = "Review completed"
        project.badge_css_class = "bg-success"
    else:
        project.badge_state_name = "Review"
        project.badge_css_class = "bg-danger"
  • Comprehensive end-to-end tests: Added test_peer_review_badge.py with full progression testing
    • Tests badge states for unsubmitted, incomplete, and completed scenarios
    • Validates badge progression: 0 reviews → red, 1 review → red, 2 reviews → red, 3 reviews → green immediately
    • Verifies that reviewed_enough_peers field is correctly updated during the scoring phase

How It Works

During Peer Review Phase:

  • Badge color is calculated on-the-fly by counting submitted mandatory reviews
  • Students get immediate green badge when they complete their last required review
  • No need to wait for batch scoring to see status update

After Peer Review Period:

  • The score_project() function updates the reviewed_enough_peers database field
  • This field is used for final grading calculations
  • Project state changes to COMPLETED and badge shows Pass/Fail status

Testing

  • ✅ All 4 new peer review badge tests pass
  • ✅ All 23 existing course tests pass (no regressions)
  • ✅ End-to-end test confirms real-time badge updates as reviews are submitted

[!WARNING]

Original prompt

This section details on the original issue you should resolve

<filter_complete></filter_complete>

<issue_title>Make peer review badge green when reviews are completed</issue_title>
<issue_description>Now it's always red even when it's completed, so it's confusing for the students

</issue_description>

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

Original prompt

This section details on the original issue you should resolve

<issue_title>Make peer review badge green when reviews are completed</issue_title>
<issue_description>Now it's always red even when it's completed, so it's confusing for the students

Image</issue_description>

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


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

Co-authored-by: alexeygrigorev <875246+alexeygrigorev@users.noreply.github.com>
Copilot AI changed the title [WIP] Make peer review badge green when reviews are completed Fix peer review badge to show green when reviews are completed Jan 14, 2026
Copilot AI requested a review from alexeygrigorev January 14, 2026 19:40
@alexeygrigorev alexeygrigorev marked this pull request as ready for review January 14, 2026 21:05
@alexeygrigorev
Copy link
Copy Markdown
Member

@copilot can you verify that we update "reviewed_enough_peers" field every time somebody submits a review? add more tests to cover the end to end scenario - first 3 incimpelte reviews -> red, review 1 -> red, review 2 -> red, review 3 -> switches to green

…tests

Co-authored-by: alexeygrigorev <875246+alexeygrigorev@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 14, 2026

@copilot can you verify that we update "reviewed_enough_peers" field every time somebody submits a review? add more tests to cover the end to end scenario - first 3 incimpelte reviews -> red, review 1...

I've verified the implementation and added comprehensive end-to-end tests as requested.

Key findings:

  1. Real-time badge updates: The badge now calculates completion status on-the-fly by counting submitted reviews, so it turns green immediately when students complete their required reviews (commit 6920be7)

  2. Database field updates during scoring: The reviewed_enough_peers field is updated by the score_project() function after the peer review period ends, as designed

  3. End-to-end test coverage: Added test_badge_progression_no_reviews_to_all_reviews which demonstrates the exact progression you requested:

    • 0 reviews → red badge ❌
    • 1 review → red badge ❌
    • 2 reviews → red badge ❌
    • 3 reviews → green badge immediately
    • After scoring → reviewed_enough_peers=True in database ✅

All tests pass with no regressions.

Copilot AI changed the title Fix peer review badge to show green when reviews are completed Fix peer review badge to show green when reviews are completed with real-time updates Jan 14, 2026
@alexeygrigorev alexeygrigorev merged commit d98baa7 into main Jan 15, 2026
2 checks passed
@alexeygrigorev alexeygrigorev deleted the copilot/fix-peer-review-badge-color branch January 15, 2026 06:14
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.

Make peer review badge green when reviews are completed

2 participants