# ScholarX Model Update to Improve the Mentor Application

**URL:** <https://sef.discourse.group/t/scholarx-model-update-to-improve-the-mentor-application/259>\
**Category:** ScholarX\
**Created:** [May 4, 2021, 4:29am UTC](https://sef.discourse.group/t/scholarx-model-update-to-improve-the-mentor-application/259 "2021-05-04T04:29:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gravewalker](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/gravewalker/32/12_2.png) [@Gravewalker](https://sef.discourse.group/u/Gravewalker)\
**Post date:** [May 4, 2021, 4:29am UTC](https://sef.discourse.group/t/scholarx-model-update-to-improve-the-mentor-application/259/1 "2021-05-04T04:29:48Z")

</div>

The existing scholarx model is designed to keep only two hardcoded mentor application questions. But the requirement is to get all the necessary details from a mentor right then and there in the mentor application process to make a good comprehensive profile so everything from selecting mentors for the program to mentees selecting mentors for themselves would be easier.

**The Current Model**

 ![image](https://global.discourse-cdn.com/free1/uploads/sef/original/1X/b537ed328a814caff83729264e8b0bdedf5d2383.jpeg)

**Mentor Application Wireframes**  
[![](https://global.discourse-cdn.com/free1/uploads/sef/original/1X/ebc6cabe70dd125b7e0287f4aa0edeadd8afe071.png) ](https://global.discourse-cdn.com/free1/uploads/sef/original/1X/ebc6cabe70dd125b7e0287f4aa0edeadd8afe071.png)

**The New Model**  
Even though we could have just added more columns to the existing mentor model or make a secondary table to keep the mentor responses I thought of going with a different approach. This new approach will provide admins with the ability to add questions to the mentor application as they go, so the question system would be dynamic, not hardcoded. With this, the front end will be provided with an endpoint to get those application questions and render them out in the mentor application view.

 ![image](https://global.discourse-cdn.com/free1/uploads/sef/original/1X/04e557c8e7285b91299588f41a0502ae92e573d0.jpeg)

---

<div class="post-metadata">

**Author:** ![akshika47](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/akshika47/32/993_2.png) [@akshika47](https://sef.discourse.group/u/akshika47)\
**Post date:** [May 5, 2021, 10:53am UTC](https://sef.discourse.group/t/scholarx-model-update-to-improve-the-mentor-application/259/2 "2021-05-05T10:53:03Z")

</div>

Love the separation of concerns!

---

<div class="post-metadata">

**Author:** ![Gravewalker](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/gravewalker/32/12_2.png) [@Gravewalker](https://sef.discourse.group/u/Gravewalker)\
**Post date:** [May 5, 2021, 1:49pm UTC](https://sef.discourse.group/t/scholarx-model-update-to-improve-the-mentor-application/259/3 "2021-05-05T13:49:35Z")

</div>

### **New and Updated Endpoints**

**Question Category, ENUM - [`MENTOR`, `MENTEE`]**

**Add Questions**

- Request

```auto
POST /api/admin/programs/{programId}/questions/{Question_Category} HTTP/1.1
Host: localhost:8080
Content-Type: application/json

[
    {
        "question": "What is your highest level of education?"
    },
    {
        "question": "What is your current position/job role?"
    },
    {
        "question": "What is your organisation/institute?"
    }
]

```

- Sample Response

```auto
Status: 200 OK
[
    {
        "id": 1,
        "category": "MENTOR",
        "program": {
            "id": 2,
            "title": "test program 1",
            "headline": "scholarx test ",
            "imageUrl": "sdf",
            "landingPageUrl": "slk",
            "state": "MENTOR_APPLICATION"
        },
        "question": "What is your highest level of education?"
    },
    {
        "id": 2,
        "category": "MENTOR",
        "program": {
            "id": 2,
            "title": "test program 1",
            "headline": "scholarx test ",
            "imageUrl": "sdf",
            "landingPageUrl": "slk",
            "state": "MENTOR_APPLICATION"
        },
        "question": "What is your current position/job role?"
    },
    {
        "id": 3,
        "category": "MENTOR",
        "program": {
            "id": 2,
            "title": "test program 1",
            "headline": "scholarx test ",
            "imageUrl": "sdf",
            "landingPageUrl": "slk",
            "state": "MENTOR_APPLICATION"
        },
        "question": "What is your organisation/institute?"
    }
]

```

**Get Questions**

- Request

```auto
GET /api/programs/{programId}/questions/{Question_Category} HTTP/1.1
Host: localhost:8080

```

- Sample Response

```auto
Status: 200 OK
[
    {
        "id": 1,
        "category": "MENTOR",
        "program": {
            "id": 2,
            "title": "test program 1",
            "headline": "scholarx test ",
            "imageUrl": "sdf",
            "landingPageUrl": "slk",
            "state": "MENTOR_APPLICATION"
        },
        "question": "What is your highest level of education?"
    },
    {
        "id": 2,
        "category": "MENTOR",
        "program": {
            "id": 2,
            "title": "test program 1",
            "headline": "scholarx test ",
            "imageUrl": "sdf",
            "landingPageUrl": "slk",
            "state": "MENTOR_APPLICATION"
        },
        "question": "What is your current position/job role?"
    },
    {
        "id": 3,
        "category": "MENTOR",
        "program": {
            "id": 2,
            "title": "test program 1",
            "headline": "scholarx test ",
            "imageUrl": "sdf",
            "landingPageUrl": "slk",
            "state": "MENTOR_APPLICATION"
        },
        "question": "What is your organisation/institute?"
    }
]

```

**Apply as a mentor**

- Request

```auto
POST /api/programs/{programId}/mentor HTTP/1.1
Host: localhost:8080
Content-Type: application/json

[
    {
        "question": {
            "id": 1
        },
        "response": "PhD"
    },
    {
        "question": {
            "id": 2
        },
        "response": "PhD Candidate"
    },
    {
        "question": {
            "id": 3
        },
        "response": "Monash University"
    }
]

```

- Sample Response

```auto
Status: 200 OK
{
    "id": 3,
    "profile": {
        "id": 1,
        "uid": "3rt9kAbxZR",
        "email": "jondoe@gmail.com",
        "firstName": "Jon",
        "lastName": "Doe",
        "imageUrl": "https://media-exp1.licdn.com/dms/image/C5103AQEDtOL8DCcMnQ/profile-displayphoto-shrink_100_100/0/1574510520118?e=1625702400&v=beta&t=kXh5dC_5vmr_cZvfKWCrKchgTgA3rQXNvrWjHCkGeGs",
        "headline": null,
        "type": "DEFAULT",
        "name": "JonDoe",
        "attributes": null,
        "authorities": [
            {
                "authority": "DEFAULT"
            }
        ]
    },
    "state": "PENDING",
    "program": {
        "id": 2,
        "title": "test program 1",
        "headline": "scholarx test ",
        "imageUrl": "sdf",
        "landingPageUrl": "slk",
        "state": "MENTOR_APPLICATION"
    }
}

```

**Get mentor responses**

- Request

1. With `profileId` and `programId`

```auto
GET /api/programs/{programId}/responses/mentor HTTP/1.1
Host: localhost:8080

```

1. With `mentorId`

```auto
GET /api/programs/{programId}/responses/mentor?mentorId={mentorId} HTTP/1.1
Host: localhost:8080

```

- Sample Response

```auto
[
    {
        "id": {
            "questionId": 1,
            "mentorId": 3
        },
        "question": {
            "id": 1,
            "category": "MENTOR",
            "program": {
                "id": 2,
                "title": "test program 1",
                "headline": "scholarx test ",
                "imageUrl": "sdf",
                "landingPageUrl": "slk",
                "state": "MENTOR_APPLICATION"
            },
            "question": "What is your highest level of education?"
        },
        "mentor": {
            "id": 3,
            "profile": {
                "id": 1,
                "uid": "3rt9kAbxZR",
                "email": "jondoe@gmail.com",
                "firstName": "Jon",
                "lastName": "Doe",
                "imageUrl": "https://media-exp1.licdn.com/dms/image/C5103AQEDtOL8DCcMnQ/profile-displayphoto-shrink_100_100/0/1574510520118?e=1625702400&v=beta&t=kXh5dC_5vmr_cZvfKWCrKchgTgA3rQXNvrWjHCkGeGs",
                "headline": null,
                "type": "DEFAULT",
                "name": "JonDoe",
                "attributes": null,
                "authorities": [
                    {
                        "authority": "DEFAULT"
                    }
                ]
            },
            "state": "PENDING",
            "program": {
                "id": 2,
                "title": "test program 1",
                "headline": "scholarx test ",
                "imageUrl": "sdf",
                "landingPageUrl": "slk",
                "state": "MENTOR_APPLICATION"
            }
        },
        "response": "PhD"
    },
    {
        "id": {
            "questionId": 2,
            "mentorId": 3
        },
        "question": {
            "id": 2,
            "category": "MENTOR",
            "program": {
                "id": 2,
                "title": "test program 1",
                "headline": "scholarx test ",
                "imageUrl": "sdf",
                "landingPageUrl": "slk",
                "state": "MENTOR_APPLICATION"
            },
            "question": "What is your current position/job role?"
        },
        "mentor": {
            "id": 3,
            "profile": {
                "id": 1,
                "uid": "3rt9kAbxZR",
                "email": "jondoe@gmail.com",
                "firstName": "Jon",
                "lastName": "Doe",
                "imageUrl": "https://media-exp1.licdn.com/dms/image/C5103AQEDtOL8DCcMnQ/profile-displayphoto-shrink_100_100/0/1574510520118?e=1625702400&v=beta&t=kXh5dC_5vmr_cZvfKWCrKchgTgA3rQXNvrWjHCkGeGs",
                "headline": null,
                "type": "DEFAULT",
                "name": "JonDoe",
                "attributes": null,
                "authorities": [
                    {
                        "authority": "DEFAULT"
                    }
                ]
            },
            "state": "PENDING",
            "program": {
                "id": 2,
                "title": "test program 1",
                "headline": "scholarx test ",
                "imageUrl": "sdf",
                "landingPageUrl": "slk",
                "state": "MENTOR_APPLICATION"
            }
        },
        "response": "PhD Candidate"
    },
    {
        "id": {
            "questionId": 3,
            "mentorId": 3
        },
        "question": {
            "id": 3,
            "category": "MENTOR",
            "program": {
                "id": 2,
                "title": "test program 1",
                "headline": "scholarx test ",
                "imageUrl": "sdf",
                "landingPageUrl": "slk",
                "state": "MENTOR_APPLICATION"
            },
            "question": "What is your organisation/institute?"
        },
        "mentor": {
            "id": 3,
            "profile": {
                "id": 1,
                "uid": "3rt9kAbxZR",
                "email": "jondoe@gmail.com",
                "firstName": "Jon",
                "lastName": "Doe",
                "imageUrl": "https://media-exp1.licdn.com/dms/image/C5103AQEDtOL8DCcMnQ/profile-displayphoto-shrink_100_100/0/1574510520118?e=1625702400&v=beta&t=kXh5dC_5vmr_cZvfKWCrKchgTgA3rQXNvrWjHCkGeGs",
                "headline": null,
                "type": "DEFAULT",
                "name": "JonDoe",
                "attributes": null,
                "authorities": [
                    {
                        "authority": "DEFAULT"
                    }
                ]
            },
            "state": "PENDING",
            "program": {
                "id": 2,
                "title": "test program 1",
                "headline": "scholarx test ",
                "imageUrl": "sdf",
                "landingPageUrl": "slk",
                "state": "MENTOR_APPLICATION"
            }
        },
        "response": "Monash University"
    }
]

```

**Edit Mentor Responses**

- Request

```auto
PUT /api/programs/{programId}/responses/mentor HTTP/1.1
Host: localhost:8080
Content-Type: application/json

[
    {
        "id": {
            "questionId": 1,
            "mentorId": 3
        },
        "response": "PhD, something else"
    },
    {
        "id": {
            "questionId": 2,
            "mentorId": 3
        },
        "response": "PhD Candidate, ML Engineer"
    },
    {
        "id": {
            "questionId": 3,
            "mentorId": 3
        },
        "response": "Monash University"
    }
]

```

- Sample Response

```auto
[
    {
        "id": {
            "questionId": 1,
            "mentorId": 3
        },
        "question": {
            "id": 1,
            "category": "MENTOR",
            "program": {
                "id": 2,
                "title": "test program 1",
                "headline": "scholarx test ",
                "imageUrl": "sdf",
                "landingPageUrl": "slk",
                "state": "MENTOR_APPLICATION"
            },
            "question": "What is your highest level of education?"
        },
        "mentor": {
            "id": 3,
            "profile": {
                "id": 1,
                "uid": "3rt9kAbxZR",
                "email": "jondoe@gmail.com",
                "firstName": "Jon",
                "lastName": "Doe",
                "imageUrl": "https://media-exp1.licdn.com/dms/image/C5103AQEDtOL8DCcMnQ/profile-displayphoto-shrink_100_100/0/1574510520118?e=1625702400&v=beta&t=kXh5dC_5vmr_cZvfKWCrKchgTgA3rQXNvrWjHCkGeGs",
                "headline": null,
                "type": "DEFAULT",
                "name": "JonDoe",
                "attributes": null,
                "authorities": [
                    {
                        "authority": "DEFAULT"
                    }
                ]
            },
            "state": "PENDING",
            "program": {
                "id": 2,
                "title": "test program 1",
                "headline": "scholarx test ",
                "imageUrl": "sdf",
                "landingPageUrl": "slk",
                "state": "MENTOR_APPLICATION"
            }
        },
        "response": "PhD, something else"
    },
    {
        "id": {
            "questionId": 2,
            "mentorId": 3
        },
        "question": {
            "id": 2,
            "category": "MENTOR",
            "program": {
                "id": 2,
                "title": "test program 1",
                "headline": "scholarx test ",
                "imageUrl": "sdf",
                "landingPageUrl": "slk",
                "state": "MENTOR_APPLICATION"
            },
            "question": "What is your current position/job role?"
        },
        "mentor": {
            "id": 3,
            "profile": {
                "id": 1,
                "uid": "3rt9kAbxZR",
                "email": "jondoe@gmail.com",
                "firstName": "Jon",
                "lastName": "Doe",
                "imageUrl": "https://media-exp1.licdn.com/dms/image/C5103AQEDtOL8DCcMnQ/profile-displayphoto-shrink_100_100/0/1574510520118?e=1625702400&v=beta&t=kXh5dC_5vmr_cZvfKWCrKchgTgA3rQXNvrWjHCkGeGs",
                "headline": null,
                "type": "DEFAULT",
                "name": "JonDoe",
                "attributes": null,
                "authorities": [
                    {
                        "authority": "DEFAULT"
                    }
                ]
            },
            "state": "PENDING",
            "program": {
                "id": 2,
                "title": "test program 1",
                "headline": "scholarx test ",
                "imageUrl": "sdf",
                "landingPageUrl": "slk",
                "state": "MENTOR_APPLICATION"
            }
        },
        "response": "PhD Candidate, ML Engineer"
    },
    {
        "id": {
            "questionId": 3,
            "mentorId": 3
        },
        "question": {
            "id": 3,
            "category": "MENTOR",
            "program": {
                "id": 2,
                "title": "test program 1",
                "headline": "scholarx test ",
                "imageUrl": "sdf",
                "landingPageUrl": "slk",
                "state": "MENTOR_APPLICATION"
            },
            "question": "What is your organisation/institute?"
        },
        "mentor": {
            "id": 3,
            "profile": {
                "id": 1,
                "uid": "3rt9kAbxZR",
                "email": "jondoe@gmail.com",
                "firstName": "Jon",
                "lastName": "Doe",
                "imageUrl": "https://media-exp1.licdn.com/dms/image/C5103AQEDtOL8DCcMnQ/profile-displayphoto-shrink_100_100/0/1574510520118?e=1625702400&v=beta&t=kXh5dC_5vmr_cZvfKWCrKchgTgA3rQXNvrWjHCkGeGs",
                "headline": null,
                "type": "DEFAULT",
                "name": "JonDoe",
                "attributes": null,
                "authorities": [
                    {
                        "authority": "DEFAULT"
                    }
                ]
            },
            "state": "PENDING",
            "program": {
                "id": 2,
                "title": "test program 1",
                "headline": "scholarx test ",
                "imageUrl": "sdf",
                "landingPageUrl": "slk",
                "state": "MENTOR_APPLICATION"
            }
        },
        "response": "Monash University"
    }
]

```

---

<div class="post-metadata">

**Author:** ![Gravewalker](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/gravewalker/32/12_2.png) [@Gravewalker](https://sef.discourse.group/u/Gravewalker)\
**Post date:** [May 5, 2021, 2:14pm UTC](https://sef.discourse.group/t/scholarx-model-update-to-improve-the-mentor-application/259/4 "2021-05-05T14:14:47Z")

</div>

> <https://github.com/sef-global/scholarx/pull/140>
>
> \## Purpose
> The purpose of this PR is to fix #139 
> 
> \## Goals
> \* To extend mode…ls to accommodate dynamic mentor applications
> 
> \## Approach
> \* Introduced two new models, 
> \* Question
> \* MentorResponses
> \* Removed attributes \`application\` and \`prerequisites\` from \`mentor\` with the related service methods and controllers 
> \* Added four new endpoints and update one existing to be compatible with the above new models
> \* Add Questions
> \* Get Questions
> \* Apply as a mentor (Updated)
> \* Get mentor responses
> \* Edit Mentor Responses
> 
> More Info : \[SEF Hive: ScholarX Model Update to Improve the Mentor Application\](https://sef.discourse.group/t/scholarx-model-update-to-improve-the-mentor-application/259?u=gravewalker)
> 
> \## Checklist
> \- \[x\] This PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.
> \- \[x\] I have read and understood the development best practices guidelines ( http://bit.ly/sef-best-practices )
> \- \[x\] My code follows the style guidelines of this project
> \- \[x\] I have performed a self-review of my own code
> \- \[x\] I have commented my code, particularly in hard-to-understand areas
> \- \[x\] I have made corresponding changes to the documentation
> 
> \## Test environment
> \- Postman
> \- Java Oracle 8
> \- Apache Maven 3.6.3
> \- macOS Big Sur
> 
> \## Learning
> \- https://www.baeldung.com/jpa-many-to-many
> \- https://stackoverflow.com/questions/46740624/org-springframework-orm-jpa-jpasystemexception-could-not-set-field-value-post
> \- https://stackoverflow.com/questions/3585034/how-to-map-a-composite-key-with-jpa-and-hibernate

---

<div class="post-metadata">

**Author:** ![Gravewalker](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/gravewalker/32/12_2.png) [@Gravewalker](https://sef.discourse.group/u/Gravewalker)\
**Post date:** [May 5, 2021, 2:17pm UTC](https://sef.discourse.group/t/scholarx-model-update-to-improve-the-mentor-application/259/5 "2021-05-05T14:17:24Z")

</div>

@Neith you can take a pull from my development branch and start on your task for we have to get this reviewed properly before merging

---

<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:** [May 5, 2021, 2:51pm UTC](https://sef.discourse.group/t/scholarx-model-update-to-improve-the-mentor-application/259/6 "2021-05-05T14:51:49Z")

</div>

This is amazing @Gravewalker ! The thread is also well documented!  
Btw, How did you overcome that JPA issue?

Seems profileID is missing here:

> [@Gravewalker](#):
>
> 1. With `profileId` and `programId`
> 
> ```auto
> GET /api/programs/{programId}/responses/mentor HTTP/1.1
> Host: localhost:8080
> 
> ```

---

<div class="post-metadata">

**Author:** ![Gravewalker](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/gravewalker/32/12_2.png) [@Gravewalker](https://sef.discourse.group/u/Gravewalker)\
**Post date:** [May 5, 2021, 4:10pm UTC](https://sef.discourse.group/t/scholarx-model-update-to-improve-the-mentor-application/259/7 "2021-05-05T16:10:26Z")

</div>

profileID can be taken from the authentication so no need to provide it explicitly

---

<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:** [May 7, 2021, 10:43am UTC](https://sef.discourse.group/t/scholarx-model-update-to-improve-the-mentor-application/259/8 "2021-05-07T10:43:11Z")

</div>

Oh! Cool! Didn’t noticed it 🤗
