Skip to content

Bug:Pros & Cons Challenge is Completely Non-Functional (Missing Routes) - #454

Open
Surajshivam-123 wants to merge 1 commit into
AOSSIE-Org:mainfrom
Surajshivam-123:BugPros-and-Cons-Challenge-is-Non-Functional
Open

Bug:Pros & Cons Challenge is Completely Non-Functional (Missing Routes) #454
Surajshivam-123 wants to merge 1 commit into
AOSSIE-Org:mainfrom
Surajshivam-123:BugPros-and-Cons-Challenge-is-Non-Functional

Conversation

@Surajshivam-123

@Surajshivam-123 Surajshivam-123 commented Sep 7, 2026

Copy link
Copy Markdown

Addressed Issues:

Fixes #452

Screenshots/Recordings:

bug_resolved.mp4

Additional Notes:

This PR resolves the issue where the Pros & Cons Challenge was completely non-functional. Previously, the backend endpoints for generating challenge topics and submitting evaluations were missing from the router registration, returning 404 errors. In addition, this PR implements the route handlers, adds input validation, and fixes the user ID extraction so earned points are properly awarded to the user's account.

Added coach.go:12-20 to group and register all coach-related endpoints under /coach:

  • GET /coach/strengthen-argument/weak-statement
  • POST /coach/strengthen-argument/evaluate
  • GET /coach/pros-cons/topic
  • POST /coach/pros-cons/submit
  • Replaced standalone handler registrations in main.go:122 with routes.SetupCoachRoutes(auth).

Implemented Pros & Cons Route Handlers (backend/routes/coach.go)

  • coach.go:76-101:
  • Dynamically determines the user's debate skill level (beginner, intermediate, advanced) based on their authenticated profile rating.
  • Defaults safely to "beginner" if rating is not present or non-float.
  • Calls services.GenerateDebateTopic(skillLevel) to generate a topic.
  • coach.go:109-157:
  • Validates payload: requires at least 1 and up to 5 non-empty pros and cons.
  • Sends the arguments to services.EvaluateProsCons(topic, pros, cons).
  • Awards points using services.UpdateUserPoints.

Fixed User Points Update (backend/routes/coach.go & backend/services/coach.go)

  • Fixed context key and type retrieval: replaced c.GetString("user_id") with userID, _ := c.Get("userID") in both EvaluateStrengthenedArgument and SubmitProsCons.
  • Updated coach.go:117 to accept userID interface{} to properly support MongoDB primitive.ObjectID extracted from the auth middleware context.

AI Usage Disclosure:

  • This PR does not contain AI-generated code at all.

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

  • New Features

    • Added a new pros-and-cons coaching challenge.
    • Users can receive a debate topic and submit their proposed pros and cons for evaluation.
    • Expanded coaching functionality alongside the existing argument-strengthening exercises.
  • Bug Fixes

    • Improved authenticated user handling during argument evaluation.
    • User points can now be updated reliably across supported account identifier formats.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 62b2f680-fc89-4016-9765-b0452b300e75

📥 Commits

Reviewing files that changed from the base of the PR and between abfb604 and 5050d8e.

📒 Files selected for processing (3)
  • backend/cmd/server/main.go
  • backend/routes/coach.go
  • backend/services/coach.go

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


📝 Walkthrough

Walkthrough

The server now centralizes coach route registration and adds functional pros-and-cons topic and submission endpoints. Coach handlers use the authenticated context user ID, and point updates accept both string and object identifier values.

Changes

Coach routes and challenge flow

Layer / File(s) Summary
Coach route setup and identity propagation
backend/cmd/server/main.go, backend/routes/coach.go, backend/services/coach.go
Coach routes are registered through SetupCoachRoutes. Existing evaluation and point updates use the authenticated context user ID.
Pros-and-cons topic generation
backend/routes/coach.go
GetProsConsTopic maps the user rating to a skill level and returns a generated debate topic.
Pros-and-cons submission evaluation
backend/routes/coach.go
SubmitProsConsRequest defines the request payload. SubmitProsCons validates entries, evaluates the submission, updates points, and returns the evaluation.

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

Merge Risk: ⚪ Minimal · up to 5050d

This change enables the Pros & Cons Challenge to fetch topics and submit evaluated responses while preserving authenticated coach routing. No merge-blocking risk is identified.

Sequence Diagram(s)

sequenceDiagram
  participant CoachClient
  participant GetProsConsTopic
  participant GenerateDebateTopic
  participant SubmitProsCons
  participant EvaluateProsCons
  participant UpdateUserPoints

  CoachClient->>GetProsConsTopic: request topic
  GetProsConsTopic->>GenerateDebateTopic: generate topic for skill level
  GenerateDebateTopic-->>GetProsConsTopic: return topic
  GetProsConsTopic-->>CoachClient: return topic

  CoachClient->>SubmitProsCons: submit topic, pros, and cons
  SubmitProsCons->>EvaluateProsCons: evaluate validated entries
  EvaluateProsCons-->>SubmitProsCons: return evaluation
  SubmitProsCons->>UpdateUserPoints: update points for context userID
  SubmitProsCons-->>CoachClient: return evaluation
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the Pros & Cons Challenge bug and the missing routes addressed by the changes.
Linked Issues check ✅ Passed The changes address issue #452 by registering GET /coach/pros-cons/topic and POST /coach/pros-cons/submit, adding their handlers, validating submissions, evaluating responses, and awarding points. The…
Out of Scope Changes check ✅ Passed The changes are related to the linked issue. Route grouping, authentication user ID handling, and MongoDB-compatible point updates support the new Pros & Cons endpoints and existing coach routes.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files.

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.

@Surajshivam-123

Copy link
Copy Markdown
Author

@Ri1tik let me know if any changes needed.

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.

[BUG]: Pros & Cons Challenge is Completely Non-Functional (Missing Routes)

1 participant