# Adding a new program state for mentees to confirm the mentor

**URL:** <https://sef.discourse.group/t/adding-a-new-program-state-for-mentees-to-confirm-the-mentor/216>\
**Category:** ScholarX\
**Created:** [December 3, 2020, 8:10pm UTC](https://sef.discourse.group/t/adding-a-new-program-state-for-mentees-to-confirm-the-mentor/216 "2020-12-03T20:10:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![piumal1999](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/piumal1999/32/274_2.png) [@piumal1999](https://sef.discourse.group/u/piumal1999)\
**Post date:** [December 3, 2020, 8:10pm UTC](https://sef.discourse.group/t/adding-a-new-program-state-for-mentees-to-confirm-the-mentor/216/1 "2020-12-03T20:10:28Z")

</div>

In the current version of ScholarX platform, the mentee selection process works in a “First-come first-served” model. So if a mentee is approved by a mentor, all other mentee applications of that mentor get rejected automatically. We had some discussions about this matter earlier and decided to introduce a new program state for the mentees to confirm a mentor from the approved mentor.

> [@SchoalrX Platform Scenario](https://sef.discourse.group/t/schoalrx-platform-scenario/188/8):
>
> To solve this, we can introduce a program state for mentees to confirm their mentor. The new state will be added after the MENTEE\_SELECTION state. So in this state, the mentee can see the list of mentors who have approved his/her mentee request (if the mentee is approved by more than 1 mentor). And the mentee can select and confirm one mentor. For this, a page to display approved mentors has to be added to the UI.

Goals:

- Creating a new program state
- Updating the existing endpoints to work with the new state
- Adding the new endpoints needed for the new state

Related Threads:

> [@Creating Mentee API for ScholarX](https://sef.discourse.group/t/creating-mentee-api-for-scholarx/203/5):
>
> [IMG\_20201110\_125040] Here we have 2 endpoints to get the selected mentor and get applied mentors list. But with the new Program State we need 3 endpoints. Get applied mentors (program/{programId}/mentee/mentors) Get approved mentors Get Selected mentor (program/{programId}/mentee/mentor) So, for the second one, what kind of path is good? @YohanAvishke [@EngTeam](https://sef.discourse.group/groups/engteam)

> [@SchoalrX Platform Scenario](https://sef.discourse.group/t/schoalrx-platform-scenario/188/4):
>
> This is a concurrency problem, so I can think of two solutions for the time being. Three-step process: 1. Share the student's application with the student's number 1 choice 2. If there are students without a mentor AND mentors without students: Share the application of the student with their second choice mentor, given that the mentors have slots. 3. Repeat step 2 for choice number three for the same conditions. 4. If there are still students without mentors and mentors without students, …

---

<div class="post-metadata">

**Author:** ![piumal1999](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/piumal1999/32/274_2.png) [@piumal1999](https://sef.discourse.group/u/piumal1999)\
**Post date:** [December 3, 2020, 8:53pm UTC](https://sef.discourse.group/t/adding-a-new-program-state-for-mentees-to-confirm-the-mentor/216/2 "2020-12-03T20:53:16Z")

</div>

These are the related endpoints which already exists:

- Get applied mentors ( GET /programs/{id}/mentee/mentors )  
`This returns a list of mentors applied by a user for a specific program`

- Get selected mentor ( GET /programs/{id}/mentee/mentor )  
`This returns selected mentor of the mentee for a specific program`

Following are the new endpoints which we need for the new state:

- Get approved mentors ( GET /programs/{id}/mentee/mentor?states=APPROVED)  
`This returns a list of mentors who have approved the user for a specific program`

- Confirm a mentor ( PUT /programs/{id}/mentors/{id}/mentee)  
`This will be used to confirm an approved mentor by rejecting all other applications of the user for a specific program. `

(I’m not much sure about the paths of these endpoints. Please let me know if there are any recommendations)

Btw, is this mentor confirmation process an irreversible process? (Because if a mentee confirms a mentor, all other applications will be rejected and he/she will not be able to get the approved mentors again). WDYT? @jaye @YohanAvishke [@EngTeam](https://sef.discourse.group/groups/engteam)

---

<div class="post-metadata">

**Author:** ![jaye](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/jaye/32/810_2.png) [@jaye](https://sef.discourse.group/u/jaye)\
**Post date:** [December 4, 2020, 4:44am UTC](https://sef.discourse.group/t/adding-a-new-program-state-for-mentees-to-confirm-the-mentor/216/3 "2020-12-04T04:44:19Z")

</div>

Great explanation, @piumal1999! Looks good to me!

btw,  
` PUT /programs/{id}/mentors/{id}/mentee` we don’t need the program id if we have the mentor id, right?

---

<div class="post-metadata">

**Author:** ![piumal1999](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/piumal1999/32/274_2.png) [@piumal1999](https://sef.discourse.group/u/piumal1999)\
**Post date:** [December 5, 2020, 10:21am UTC](https://sef.discourse.group/t/adding-a-new-program-state-for-mentees-to-confirm-the-mentor/216/4 "2020-12-05T10:21:42Z")

</div>

Ah right. We can use “PUT /mentors/id/mentee”

This will be the process for that:

Get the mentor by Id --\> get the program id from mentor object --\> get all mentees (List) by program Id and user Id(taken from cookie) --\> filter the Approved mentees from that list --\> get the mentors list from that list --\> check whether the mentor by Id exists in that list --\> if exists, reject all other mentee objects in the previous list

---

<div class="post-metadata">

**Author:** ![piumal1999](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/piumal1999/32/274_2.png) [@piumal1999](https://sef.discourse.group/u/piumal1999)\
**Post date:** [December 9, 2020, 8:57pm UTC](https://sef.discourse.group/t/adding-a-new-program-state-for-mentees-to-confirm-the-mentor/216/5 "2020-12-09T20:57:25Z")

</div>

> [@piumal1999](#):
>
> Ah right. We can use “PUT /mentors/id/mentee”

Oh, we are already using that path to update mentee data. Is it okay to use the same path but as a POST request?

---

<div class="post-metadata">

**Author:** ![anjisvj](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/anjisvj/32/9_2.png) [@anjisvj](https://sef.discourse.group/u/anjisvj)\
**Post date:** [December 11, 2020, 8:36am UTC](https://sef.discourse.group/t/adding-a-new-program-state-for-mentees-to-confirm-the-mentor/216/6 "2020-12-11T08:36:55Z")

</div>

@piumal1999 Once the endpoints are confirmed can you update the API doc?

---

<div class="post-metadata">

**Author:** ![piumal1999](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/piumal1999/32/274_2.png) [@piumal1999](https://sef.discourse.group/u/piumal1999)\
**Post date:** [December 11, 2020, 10:33am UTC](https://sef.discourse.group/t/adding-a-new-program-state-for-mentees-to-confirm-the-mentor/216/7 "2020-12-11T10:33:18Z")

</div>

Sure.  
I sent the pull request. [https://github.com/sef-global/scholarx/pull/92](https://github.com/sef-global/scholarx/pull/92)  
@YohanAvishke could you please have a look?

---

<div class="post-metadata">

**Author:** ![piumal1999](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/piumal1999/32/274_2.png) [@piumal1999](https://sef.discourse.group/u/piumal1999)\
**Post date:** [December 18, 2020, 6:46pm UTC](https://sef.discourse.group/t/adding-a-new-program-state-for-mentees-to-confirm-the-mentor/216/8 "2020-12-18T18:46:34Z")

</div>

The requested changes are also done.
