Skip to content

Comments

feat(api): Endpoints for classroom - exchanging user data#62063

Open
NewtonLC wants to merge 11 commits intofreeCodeCamp:mainfrom
NewtonLC:challenge-map-newton
Open

feat(api): Endpoints for classroom - exchanging user data#62063
NewtonLC wants to merge 11 commits intofreeCodeCamp:mainfrom
NewtonLC:challenge-map-newton

Conversation

@NewtonLC
Copy link

@NewtonLC NewtonLC commented Sep 6, 2025

Co-Authored by:
@CarlyAThomas
@ZhenyuYu1

Checklist:

Closes freeCodeCamp/classroom#548

This issue calls for the Classroom App to retrieve real users' data directly from freeCodeCamp proper, which is vital for making the Classroom App work. This will allow teachers to monitor students' progress and activity in the freeCodeCamp curriculum.

This PR creates an API endpoint in freeCodeCamp that allows the Classroom App to fetch students' completed challenge data from their usernames. Since users' completedChallenges attribute does not contain metadata about the completed challenges(name, certification, etc.), we also created an endpoint that maps challenge IDs to challenge metadata, then returns this map. The Classroom App will call this endpoint in order to retrieve the map, which will be used to help display the challenges.

@NewtonLC NewtonLC requested a review from a team September 6, 2025 03:27
@github-actions github-actions bot added the platform: api Server application that needs familiarity with Express, Fastify, MongoDB etc. label Sep 6, 2025
@raisedadead raisedadead self-assigned this Sep 6, 2025
@raisedadead raisedadead changed the title feat: created new classroom API endpoints for exchanging user data feat(api): Endpoints for classroom - exchanging user data Sep 6, 2025
@majestic-owl448

This comment was marked as resolved.

@majestic-owl448 majestic-owl448 added the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label Sep 11, 2025
@NewtonLC NewtonLC force-pushed the challenge-map-newton branch from 4fdb50a to ef20294 Compare September 16, 2025 02:50
@majestic-owl448 majestic-owl448 added the MERGE CONFLICT! To be applied to PR's that have a merge conflict and need updating label Sep 19, 2025
@NewtonLC NewtonLC force-pushed the challenge-map-newton branch from ef20294 to b584e86 Compare September 23, 2025 01:23
@freeCodeCamp freeCodeCamp deleted a comment from camper-chan bot Sep 23, 2025
@raisedadead raisedadead removed the MERGE CONFLICT! To be applied to PR's that have a merge conflict and need updating label Sep 23, 2025
Co-Authored by:
Carly Thomas <CarlyAThomas@users.noreply.github.com>
Zhenyu Yu <ZhenyuYu1@users.noreply.github.com>

Both endpoints are to be called from the Classroom app.
- Added new endpoint to contruct a map of challenge IDs to name, certification, etc. based on _meta files, then return this map.
- Added new endpoint to take in a list of student emails, then return an array of those users' completed challenge data.
@NewtonLC NewtonLC force-pushed the challenge-map-newton branch from b584e86 to 0692114 Compare September 27, 2025 01:23
Copy link
Member

@raisedadead raisedadead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action Items:

@raisedadead:

  • will create the curriculum server repository with all the wiring in it so the @freeCodeCamp/classroom team can expand the same as per the needs of the classroom app
  • will document steps for the Classroom team to setup and start working on it. It will be available in the project README.

@freecodecamp/classroom:

  • needs to remove the build curriculum endpoints entirely, since the functionality will be made available via the above.

This PR:

  • will need another endpoint to send a single email and retrieve the user id (camper's id), classroom can store the User id in its own DB. The user id will not change (emails can).
  • the get-user-data endpoint needs to:
    • send user ids (batch is OK) to retrieve the data it needs
    • check the user consent (more on this later) is given before sending the data out

User consent:

  • will need a separate PR (@raisedadead will share code examples) to add a check box to the settings page UI
  • the check box can map to a isClassroomAccount prop on the user -- false by default

@raisedadead
Copy link
Member

I have left my quick notes on this PR from the meeting. We can discuss more on this async if you prefer in the Google Chat room we have for this.

@raisedadead
Copy link
Member

raisedadead commented Oct 18, 2025

Update: #62891 will add the consent settings.

freeCodeCamp's API will only return data when isClassroomAccount true. This restriction will need to be baked into this PR for acceptance

@raisedadead raisedadead added status: blocked In a transient & temporary hold. and removed status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. labels Oct 22, 2025
@NewtonLC NewtonLC force-pushed the challenge-map-newton branch from a893d42 to 53e02db Compare October 28, 2025 01:52
Co-authored-by: Carly Thomas <CarlyAThomas@users.noreply.github.com>
@NewtonLC NewtonLC force-pushed the challenge-map-newton branch from 53e02db to 45002cb Compare October 28, 2025 01:53
@NewtonLC
Copy link
Author

Update: @CarlyAThomas and I have completed the Action items listed for the classroom team for this PR. When retrieving student data from Classroom, we are explicitly skipping students who did not give permission.

@raisedadead
Copy link
Member

Great! https://github.com/freeCodeCamp/curriculum-db is also coming along nicely.

Copy link
Contributor

@ojeytonwilliams ojeytonwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates @NewtonLC and @CarlyAThomas, this looks like what we want. I found a few things, but nothing serious - just minor tweaks and suggestions to be a little more consistent with the rest of the codebase.

Co-authored by: Carly Thomas <CarlyAThomas@users.noreply.github.com>
@NewtonLC NewtonLC force-pushed the challenge-map-newton branch from 29b3838 to f507292 Compare October 28, 2025 20:58
@CarlyAThomas
Copy link

We have updated the PR based on your suggestions. One note though, we are still looking into how we would like to specify the shape of the userData object and will need to get back to you on this specific.

Thank you for reviewing our PR!

@ojeytonwilliams
Copy link
Contributor

Thanks, @CarlyAThomas, no rush. I'm still discussing with Mrugesh how we want to go about querying for the classroom accounts. It might be easier to go with your original approach (we need fewer indexes that way). I'll let you know.

NewtonLC added a commit to NewtonLC/freeCodeCamp that referenced this pull request Dec 6, 2025
Co-authored-by: Carly Thomas <CarlyAThomas@users.noreply.github.com>
@NewtonLC NewtonLC requested a review from a team as a code owner December 6, 2025 03:28
Copy link
Contributor

@ojeytonwilliams ojeytonwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the lack of updates, but this approach should be fine.

Could you add some simple tests to lock this down? Something that checks the expected output would have caught the fact that challengeName doesn't exist.

NewtonLC and others added 3 commits December 8, 2025 19:56
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Additionally, edited the  body to not require
a max of 50 items, so a custom error message will be used.
Additionally, edited the  body to not require
a max of 50 items, so a custom error message will be used.
@NewtonLC
Copy link
Author

NewtonLC commented Dec 16, 2025

Hello @ojeytonwilliams! I added some simple test cases for the classroom endpoints. Here's a quick summary:
get-user-ids tests:
Call with incorrectly formatted email --> 200 Status, return ''
No classroom account matches email --> 200 Status, return ''
A classroom account matches email --> 200 Status, return camper ID
Other failed database query --> 500 Error

get-user-data tests:
Call with more than 50 camper IDs --> 400 Error
Call with 50 or fewer camper IDs --> 200 Status, return record of camper's data
Other failed database query --> 500 Error

Unauthenticated call --> 401 Error

Changed 404 error to 200 response, along with empty student ID
@NewtonLC NewtonLC requested a review from a team as a code owner January 27, 2026 03:48
Also edited to give 200 responses for invalid email formats
@NewtonLC
Copy link
Author

Hello! Just a quick note to say that this PR is ready for review. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: api Server application that needs familiarity with Express, Fastify, MongoDB etc. status: blocked In a transient & temporary hold.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Integrate with freeCodeCamp Proper's API for getting student dat

5 participants