---
# System prepended metadata

title: Untitled

---

## Jira ticket CAE-115:
https://developers-institute-students.atlassian.net/browse/CAE-109?atlOrigin=eyJpIjoiYWRkMzYzYjQ0NmMwNDU5Y2E2MDlkMjI3NGYyMzI5ODMiLCJwIjoiaiJ9


## User Story
As a user, I want to be able to see if an instructor or learner answered a question, so that I can have a clear overview

## Description

To achieve the user story, we will fetch username data and create a utility component - _IsInstructor_ to determines the role of users (Instructor or Learner)

Due to the data type of `is_instructor` is boolean , a function/component is needed to retrieve the boolean value instead of directly fetching user role

## Acceptance Criteria
- User name is retrieved via changes to SQL Query
- Role type is determined and retrieved via the utility component - _IsInstructor_
- Both user name and role are displayed on the web page.
- The utility component - `IsInstructor` is able to be exported.
- Data is successfully retrieved via the `/questions` endpoint.
- All tests passed

## Changes Made
- Created a folder - utility under `client/src`
- Created a component - `IsInstructor`
- In client/src/components: 
  - Added username data and _IsInstructor_ in `QuestionsPage.js` (Line 72  & 75 )
  - Added username data and _IsInstructor_ in `Question.js` (Line75 &76)
-  Created happy and unhappy tests in `AnswersPage.test.js`
- In api folder, edited `app.js`:
    -  Edited the SQL query to join question table with user table so that user information can be retrieved in client side.
   

## Tests
### Automated Tests pass:
<img width="457" alt="Screen Shot 2022-11-10 at 4 25 01 PM" src="https://user-images.githubusercontent.com/74471007/200993429-3d1671d5-ca50-455a-83aa-8cc524a9744c.png">

#### Happy Path:
This test checks whether or not the username or role are rendering on the page
<img width="1505" alt="Screen Shot 2022-11-10 at 4 21 54 PM" src="https://user-images.githubusercontent.com/74471007/200993057-2593f4e6-7542-4946-95c2-f6cb7e5400bd.png">

#### Unhappy Paths:

#### Username test
Test to check that if an invalid endpoint is visited the username should not display on the page.


<img width="1244" alt="Screen Shot 2022-11-10 at 4 22 26 PM" src="https://user-images.githubusercontent.com/74471007/200993114-d0d8b2ec-fc04-4f20-9350-45809af7f9b3.png">

#### Role test:
Test to check that if an invalid endpoint is visited the role should not display on the page.
<img width="1325" alt="Screen Shot 2022-11-10 at 4 23 02 PM" src="https://user-images.githubusercontent.com/74471007/200993188-f46bf3ab-d879-41a3-86df-da26b51859a4.png">

### Manual Tests pass:
#### Happy Paths:
- When visiting `/questions/1` , username & role are displayed on the page 
<img width="1936" alt="Screen Shot 2022-11-10 at 4 26 56 PM" src="https://user-images.githubusercontent.com/74471007/200993707-5e56e0ed-5e29-4ab1-b9f1-5133919f50d8.png">

#### Unhappy Paths:
- When visiting bad url/endpoint  -  `/questions/1000` , username & role are NOT displayed on the page 
<img width="1943" alt="Screen Shot 2022-11-10 at 4 28 28 PM" src="https://user-images.githubusercontent.com/74471007/200993834-95703c63-a9dc-4238-afb9-81cc877febb8.png">
