Module Server Side
Module Server Side
Module Server Side
Contents
1. MODULE_SERVER_SIDE.docx
2. MODULE_SERVER_SIDE.pdf
3. MODULE_SERVER_SIDE_MEDIA.zip
Introduction
Your company “Formify Inc.” points you as a Web Developer to build a website which is
possible for users to create form dynamically according to the question types such as short
answer, paragraph, date input, multiple choice, dropdown and checkboxes. Users who
created the form can share the form link to the user to submit a response of the form and
also see all of the responses.
Description of Projects
There are 2 phases in this module. In the first phase, you will make the RESTFul API using
Laravel Frameworks according to the provided documentation. In the second phase, you
should build a frontend with the Interactive Maps using one of the provided Javascript
Frameworks (React/Vue/Angular) and the data must come from the created RESTFul API.
You can find the provided media files to support your work:
- Postman collection and environment
- Api tests (to testing your endpoints automatically)
- Template GUI (to build frontend UI)
- Formify.sql (a database with structures and dummy data)
Login
Endpoint : [DOMAIN]/api/v1/auth/login
Method : POST
Validation : email:
- required
- valid email address
password:
- required
- min 5 chars
Response : If success:
Headers:
- Response status: 200
Body (JSON):
{
"message": "Login success",
"user": {
"name": "User 1",
"email": "user1@webtech.id",
"accessToken": "1|
QnHFgF0C7ml2LkbDG5QDn34qvJoYGdpxoXy63Poi"
}
}
If invalid field:
Headers:
- Response status: 422
Body (JSON):
{
"message": "Invalid field",
"errors": {
"email": [
"The email must be a valid email address."
],
"password": [
"The password field is required."
]
}
}
If failed:
Headers:
- Response status: 401
Body (JSON):
{
"message": "Email or password incorrect"
}
Logout
Endpoint : [DOMAIN]/api/v1/auth/logout
Method : POST
Request : Headers:
- Authorization: “Bearer <accessToken>”
Response : If success:
Headers:
- Response status: 200
Body (JSON):
{
"message": "Logout success"
}
If invalid token:
Headers:
- Response status: 401
Body (JSON):
{
"message": "Unauthenticated."
}
2. Form
Users can manage (create, see all created forms, and see detail form) with questions
to share to invited users based on email domain to submit.
Create a Form
Endpoint : [DOMAIN]/api/v1/forms
Method : POST
Request : Headers:
- Authorization: “Bearer <accessToken>”
Body (JSON):
{
"name": "Stacks of Web Tech Members",
"slug": "member-stacks",
"allowed_domains": [ "webtech.id" ],
"description": "To collect all of favorite stacks",
"limit_one_response": true
}
Validation : name:
- required
slug:
- required
- unique
- alphanumeric with special characters only dash “-”
and dot “.” and without space
allowed_domains:
- array
Response : If success:
Headers:
- Response status: 200
Body (JSON):
{
"message": "Create form success",
"form": {
"name": "Stacks of Web Tech Members",
"slug": "member-stacks",
"description": "To collect all of favorite..",
"limit_one_response": true,
"creator_id": 1,
"id": 3
}
}
If invalid field:
Headers:
- Response status: 422
Body (JSON):
{
"message": "Invalid field",
"errors": {
"name": [
"The name field is required."
],
"slug": [
"The slug has already been taken."
],
"allowed_domains": [
"The allowed domains must be an array."
]
}
}
If invalid token:
Headers:
- Response status: 401
Body (JSON)
{
"message": "Unauthenticated."
}
Method : GET
Request : Headers:
- Authorization: “Bearer <accessToken>”
Response : If success:
Headers:
- Response status: 200
Body (JSON):
{
"message": "Get all forms success",
"forms": [
{
"id": 1,
"name": "Biodata - Web Tech Members",
"slug": "biodata",
"description": "To save web tech membe..",
"limit_one_response": 1,
"creator_id": 1
},
{
"id": 2,
"name": "HTML and CSS Skills - Quiz",
"slug": "htmlcss-quiz",
"description": "Fundamental web tests",
"limit_one_response": 1,
"creator_id": 1
},
{
"id": 3,
"name": "Stacks of Web Tech Members",
"slug": "member-stacks",
"description": "To collect all of favorit..",
"limit_one_response": 1,
"creator_id": 1
}
]
}
If invalid token:
Headers:
- Response status: 401
Body (JSON):
{
"message": "Unauthenticated."
}
Detail Form
Endpoint : [DOMAIN]/api/v1/forms/<form_slug>
Method : GET
Request : -
Response : If success:
Headers:
- Response status: 200
Body (JSON):
{
"message": "Get form success",
"form": {
"id": 1,
"name": "Biodata - Web Tech Members",
"slug": "biodata",
"description": "To save web tech members data",
"limit_one_response": 1,
"creator_id": 1,
"allowed_domains": [
"webtech.id"
],
"questions": [
{
"id": 1,
"form_id": 1,
"name": "Name",
"choice_type": "short answer",
"choices": null,
"is_required": 1
},
{
"id": 2,
"form_id": 1,
"name": "Address",
"choice_type": "paragraph",
"choices": null,
"is_required": 0
},
{
"id": 3,
"form_id": 1,
"name": "Born Date",
"choice_type": "date",
"choices": null,
"is_required": 1
},
{
"id": 4,
"form_id": 1,
"name": "Sex",
"choice_type": "multiple choice",
"choices": "Male,Female",
"is_required": 1
}
]
}
}
Body (JSON):
{
"message": "Form not found"
}
Body (JSON):
{
"message": "Forbidden access"
}
If invalid token:
Headers:
- Response status: 401
Body (JSON):
{
"message": "Unauthenticated."
}
3. Question
Users can manage questions (add and remove) from one of their created forms.
Choices field must be required if the user selects multiple choice, dropdown, or
checkboxes. There are 6 choice types:
1. Short answer (TextField)
2. Paragraph (TextArea)
3. Date (Input Date)
4. Multiple Choice (Radio) : with choices
5. Dropdown (Select) : with choices
6. Checkboxes (Checkboxes) : with choices
Add a Question
Endpoint : [DOMAIN]/api/v1/forms/<form_slug>/questions
Method : POST
Request : Headers:
- Authorization: “Bearer <accessToken>”
Body (JSON):
{
"name": "Most Favorite JS Framework",
"choice_type": "multiple choice",
"choices": [
"React JS",
"Vue JS",
"Angular JS",
"Svelte"
],
"is_required": true
}
Validation : name:
- required
choice_type:
- required
- only: “short answer”, “paragraph”, “date”,
“multiple choice”, “dropdown”, or “checkboxes”
choices
- required if selected choice type is “multiple
choice”, “dropdown”, or “checkboxes”
Response : If success:
Headers:
- Response status: 200
Body (JSON):
{
"message": "Add question success",
"question": {
"name": "Most Favorite JS Framework",
"choice_type": "multiple choice",
"is_required": true,
"choices": "React JS,Vue JS,Angular JS,Svelte",
"form_id": 3,
"id": 10
}
}
If invalid field:
Headers:
- Response status: 422
Body (JSON):
{
"message": "Invalid field",
"errors": {
"name": [
"The name field is required."
],
"choice_type": [
"The choice type field is required."
],
"choices": [
"The choices must be an array.",
"The choices must be a string."
]
}
}
Body (JSON):
{
"message": "Form not found"
}
If invalid token:
Headers:
- Response status: 401
Body (JSON):
{
"message": "Unauthenticated."
}
Remove a Question
Endpoint : [DOMAIN]/api/v1/forms/<form_slug>/questions/<question_id>
Method : DELETE
Request : Headers:
- Authorization: “Bearer <accessToken>”
Response : If success:
Headers:
- Response status: 200
Body (JSON):
{
"message": "Remove question success"
}
Body (JSON):
{
"message": "Form not found"
}
Body (JSON):
{
"message": "Question not found"
}
Body (JSON):
{
"message": "Forbidden access"
}
If invalid token:
Headers:
- Response status: 401
Body (JSON):
{
"message": "Unauthenticated."
}
4. Response
If the creator form sets the form with limit 1 response, then the invited user can’t
submit a response twice. Submit Response only can be accessed by users with an
allowed domain of the user email. If the creator form does not fill allowed domains, it
means that the form can be accessed by anyone/public.
For example:
An user with email “user3@worldskills.org” can’t submit a response to the form with
allowed domains webtech.id and inaskills.id, because worldskills.org can't be allowed
to access the form.
Submit Response
Endpoint : [DOMAIN]/api/v1/forms/<form_slug>/responses
Method : POST
Request : Headers:
- Authorization: “Bearer <accessToken>”
Body (JSON):
{
"answers": [
{
"question_id": 1,
"value": "Ica Amalia"
},
{
"question_id": 2,
"value": "Bandung"
},
{
"question_id": 3,
"value": "2006-08-01"
},
{
"question_id": 4,
"value": "Female"
}
]
}
Validation : answers
- array
[question value]
- required if sets true
Response : If success:
Headers:
- Response status: 200
Body (JSON):
{
"message": "Submit response success"
}
If invalid field:
Headers:
- Response status: 422
Body (JSON):
{
"message": "Invalid field",
"errors": {
"answers": [
"The answers field is required."
]
}
}
Body (JSON):
{
"message": "Forbidden access"
}
Body (JSON):
{
"message": "You can not submit form twice"
}
If invalid token
Headers:
- Response status: 401
Body (JSON):
{
"message": "Unauthenticated."
}
Method : GET
Request : Headers:
- Authorization: “Bearer <accessToken>”
Response : If success:
Headers:
- Response status: 200
Body (JSON):
{
"message": "Get responses success",
"responses": [
{
"date": "2022-10-24 01:47:14",
"user": {
"id": 1,
"name": "User 1",
"email": "user1@webtech.id",
"email_verified_at": null
},
"answers": {
"Name": "Budi Setiawan",
"Address": "Jakarta, Indonesia",
"Born Date": "2004-05-05",
"Sex": "Male"
}
},
{
"date": "2022-10-24 02:03:27",
"user": {
"id": 2,
"name": "User 2",
"email": "user2@webtech.id",
"email_verified_at": null
},
"answers": {
"Name": "Ica Amalia",
"Address": "Bandung",
"Born Date": "2006-08-01",
"Sex": "Female"
}
}
]
}
Body (JSON):
{
"message": "Form not found"
}
If try access another user form:
Headers:
- Response status: 403
Body (JSON)
{
"message": "Forbidden access"
}
If invalid token
Headers
- Response status: 401
Body (JSON)
{
"message": "Unauthenticated."
}
Phase 2 : Front-end Development
In this part, you should build a front-end application using one of the provided frameworks
(vue js or react js). You can use the provided template gui on the media files to build the
front-end ui.
General:
- Form detail displayed correctly
- Form link displayed correctly
- User can copy form link
Questions:
- Questions displayed correctly
- Question inputs should be disabled when has created
- Users can add questions by filling in a question form
and clicking the save button.
Detail Form
- Choices input should be displayed when the user
selects multiple choice, dropdown, or checkboxes.
- Alert errors should be displayed when created failed.
- Users can remove questions by clicking the remove
button.
Responses:
- Table displayed correctly according to questions and
responses.
- Total responses count is displayed correctly.
Instructions
- Save your REST Api in the directory called “SERVER_MODULE/backend” and
save it in the repository folder.
- Save your front-end app in the directory called “SERVER_MODULE/frontend” and
save it in the repository folder.
- When developing the Frontend, you can use/consume the provided REST API.
- You should build the frontend app to production mode and save the production
files in the “SERVER_MODULE/frontend/build” folder before you push it to the
github repository.
- Make sure the “/build” folder isn't written on the .gitgnore file.
- You should commit and push your changes to the github repository at least every 30
minutes.
Marking Overview
Phase Parts Measurement Judgment Total