Skip to content

Commit 1923f9d

Browse files
LJW-DevTyranid789jsun1590
authored
I72 quiz creation app (#108)
* feat(quiz): Created the app quiz_create, added basic quiz models, and migrated the database * docs(quiz): Wrote documentation on the quiz models structure * folder restructure * changed models structure * updated models to work with the new MVP, added basic REST api GET and POST methods, added documentation on the REST api methods * feat(quiz): Added DELETE and PUT api methods and added tests * test(quiz): added tag tests and refactored code to pass linter * refactor(quiz): WIP refactor code to use new shared models app * Finished migrating tests and views * docs(quiz): updated REST api documentation * ran linting tool and changed URL * fixed linting issue * updated tests * Rewrote views to facilitate permission classes: create custom isOwner permission class * fixed basic permissions and updated everything to be more like other apps * linting * merge migrations * fix migration files * purge migrations * format codebase * ignore test for now * create quiz app model * complete generate quiz app, uses quiz m2m field * lintfix * fix tests * lintfix Co-authored-by: Tyranid789 <tyranid789@gmail.com> Co-authored-by: Jack Sun <jsun1590@gmail.com>
1 parent 697a370 commit 1923f9d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1077
-861
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Question Creation
2+
3+
## REST api
4+
5+
### Creating a question
6+
7+
- `quiz-api/question/`
8+
- GET - Returns an array of all the questions in the database
9+
- id
10+
- integer
11+
- database ID of the question
12+
- question_type
13+
- string
14+
- Can be either:
15+
- MC - Multiple Choice
16+
- NA - Numerical Answer
17+
- SA - Short Answer
18+
- See shared models app documentation for more info
19+
- text
20+
- string
21+
- question text
22+
- date_created
23+
- datetime
24+
- date and time that the quiz was created
25+
- POST - Add a question to the database
26+
- Required JSON fields:
27+
- question_type
28+
- string
29+
- Can be either:
30+
- MC - Multiple Choice
31+
- NA - Numerical Answer
32+
- SA - Short Answer
33+
- See shared models app documentation for more info
34+
- text
35+
- string
36+
- question text
37+
- date_created
38+
- datetime
39+
- date and time that the quiz was created
40+
- tags
41+
- string array
42+
- array of question tags
43+
- answers
44+
- 2D array
45+
- Can be empty or not included depending on the question type
46+
- An array of answer text and is_correct arrays, must be in the order: 1. answer text, 2. is_correct
47+
- e.g. "answers": [["Answer 1", true], ["Answer 2", false]]
48+
- adds 2 answers, where answer 1 is correct while answer 2 is incorrect
49+
- invalid request: "answers": [[true, "Answer 1"], [false, "Answer 2"]]
50+
- Invalid as answer text must be first, then if it's correct second
51+
52+
- `quiz-api/question/(question_id)/`
53+
- GET - Returns the question with the id `question_id`
54+
- PUT - update a question's text, question type, or date created. Can update only one or all 3 feields at a time
55+
- DELETE - Deletes the question and it's answers from the database
56+
57+
- `quiz-api/question/(question_id)/answer/`
58+
- GET - Returns an array of `question_id`s answers
59+
- id
60+
- integer
61+
- database ID of the answer
62+
- is_correct
63+
- boolean
64+
- is the answer correct
65+
- text
66+
- string
67+
- answer text
68+
- POST - Add an answer to `question_id`s question
69+
- Required JSON fields:
70+
- is_correct
71+
- boolean
72+
- is the answer correct
73+
- text
74+
- string
75+
- answer text
76+
- `quiz-api/question/(question_id)/answer/(answer_id)`
77+
- GET - Returns a specific answer with the id `answer_id` from the question `question_id`
78+
- PUT - update an answer's text or is_correct. Can update only one or both feields at a time
79+
- DELETE - Removes the answer from the question and deletes it from the database
80+
81+
- `quiz-api/question/(question_id)/tag`
82+
- GET - Returns an array of `question_id`s tags
83+
- id
84+
- integer
85+
- database ID of the tag
86+
- name
87+
- string
88+
- tag text
89+
- POST - Add a tag to `question_id`s question
90+
- Required JSON fields:
91+
- name
92+
- string
93+
- tag text
94+
95+
- `quiz-api/question/(question_id)/answer/(answer_id)`
96+
- GET - Returns a specific tag with the id `answer_id` from the question `question_id`
97+
- DELETE - Removes the tag from the question but does not delete it from the database
Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2-
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/docker-existing-docker-compose
3-
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
4-
{
5-
"name": "Backend",
6-
7-
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
8-
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
9-
"dockerComposeFile": [
10-
"../../docker-compose-server.yml",
11-
"docker-compose.yml"
12-
],
13-
14-
// The 'service' property is the name of the service for the container that VS Code should
15-
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
16-
"service": "server",
17-
18-
// The optional 'workspaceFolder' property is the path VS Code should open by default when
19-
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
20-
"workspaceFolder": "/workspace/server"
21-
22-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
23-
// "forwardPorts": [],
24-
25-
// Uncomment the next line if you want start specific services in your Docker Compose config.
26-
// "runServices": [],
27-
28-
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
29-
// "shutdownAction": "none",
30-
31-
// Uncomment the next line to run commands after the container is created - for example installing curl.
32-
// "postCreateCommand": "apt-get update && apt-get install -y curl",
33-
34-
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
35-
// "remoteUser": "vscode"
36-
}
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/docker-existing-docker-compose
3+
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
4+
{
5+
"name": "Backend",
6+
7+
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
8+
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
9+
"dockerComposeFile": [
10+
"../../docker-compose-server.yml",
11+
"docker-compose.yml"
12+
],
13+
14+
// The 'service' property is the name of the service for the container that VS Code should
15+
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
16+
"service": "server",
17+
18+
// The optional 'workspaceFolder' property is the path VS Code should open by default when
19+
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
20+
"workspaceFolder": "/workspace/server"
21+
22+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
23+
// "forwardPorts": [],
24+
25+
// Uncomment the next line if you want start specific services in your Docker Compose config.
26+
// "runServices": [],
27+
28+
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
29+
// "shutdownAction": "none",
30+
31+
// Uncomment the next line to run commands after the container is created - for example installing curl.
32+
// "postCreateCommand": "apt-get update && apt-get install -y curl",
33+
34+
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
35+
// "remoteUser": "vscode"
36+
}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
version: "3.3"
2-
services:
3-
server:
4-
volumes:
5-
- .:/workspace:cached
6-
links:
7-
- db
8-
depends_on:
9-
- db
10-
11-
db:
12-
image: postgres
13-
restart: unless-stopped
1+
version: "3.3"
2+
services:
3+
server:
4+
volumes:
5+
- .:/workspace:cached
6+
links:
7+
- db
8+
depends_on:
9+
- db
10+
11+
db:
12+
image: postgres
13+
restart: unless-stopped

server/.vscode/extensions.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
{
2-
"recommendations": [
3-
// backend
4-
"ms-python.python",
5-
"batisteo.vscode-django",
6-
"KevinRose.vsc-python-indent",
7-
"njpwerner.autodocstring",
8-
"mtxr.sqltools",
9-
"mtxr.sqltools-driver-pg",
10-
11-
// quality of life
12-
"aaron-bond.better-comments",
13-
"eamodio.gitlens",
14-
"GitHub.vscode-pull-request-github",
15-
"VisualStudioExptTeam.vscodeintellicode",
16-
"christian-kohler.path-intellisense",
17-
"oderwat.indent-rainbow",
18-
"DavidAnson.vscode-markdownlint",
19-
"yzhang.markdown-all-in-one",
20-
"rangav.vscode-thunder-client"
21-
]
22-
}
1+
{
2+
"recommendations": [
3+
// backend
4+
"ms-python.python",
5+
"batisteo.vscode-django",
6+
"KevinRose.vsc-python-indent",
7+
"njpwerner.autodocstring",
8+
"mtxr.sqltools",
9+
"mtxr.sqltools-driver-pg",
10+
11+
// quality of life
12+
"aaron-bond.better-comments",
13+
"eamodio.gitlens",
14+
"GitHub.vscode-pull-request-github",
15+
"VisualStudioExptTeam.vscodeintellicode",
16+
"christian-kohler.path-intellisense",
17+
"oderwat.indent-rainbow",
18+
"DavidAnson.vscode-markdownlint",
19+
"yzhang.markdown-all-in-one",
20+
"rangav.vscode-thunder-client"
21+
]
22+
}

server/README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# Elucidate Backend
2-
3-
## Getting started
4-
5-
### Development server
6-
7-
After setting up your development workspace in the main guide, you can launch a Django development server by running `python manage.py runserver`. Note, you must be in the `server` folder inside the docker container for this to work.
8-
9-
### Running tests
10-
11-
Tests can be run with the command `python manage.py test`
12-
13-
If you are running through container
14-
15-
```bash
16-
docker exec -t -i elucidate_server python manage.py
17-
test
18-
```
1+
# Elucidate Backend
2+
3+
## Getting started
4+
5+
### Development server
6+
7+
After setting up your development workspace in the main guide, you can launch a Django development server by running `python manage.py runserver`. Note, you must be in the `server` folder inside the docker container for this to work.
8+
9+
### Running tests
10+
11+
Tests can be run with the command `python manage.py test`
12+
13+
If you are running through container
14+
15+
```bash
16+
docker exec -t -i elucidate_server python manage.py
17+
test
18+
```

server/api/apps/auth/migrations/__init__.py

Whitespace-only changes.

server/api/apps/auth/reset_password/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from rest_framework import serializers
21
from django.contrib.auth.password_validation import validate_password
2+
from rest_framework import serializers
33

44

55
class ChangePasswordSerializer(serializers.Serializer):

server/api/apps/auth/reset_password/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.urls import path
2-
from .views import ResetPasswordView, EmailResetLinkView
2+
3+
from .views import EmailResetLinkView, ResetPasswordView
34

45
urlpatterns = [
56
path("email/", EmailResetLinkView.as_view(), name="send-reset-email"),

server/api/apps/auth/reset_password/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.contrib.auth.tokens import PasswordResetTokenGenerator
66
from django.core.mail import send_mail
77
from django.utils.encoding import force_bytes, force_str
8-
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
8+
from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode
99
from rest_framework import generics, status
1010
from rest_framework.response import Response
1111

server/api/apps/auth/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.urls import path, include
1+
from django.urls import include, path
22
from rest_framework_jwt.views import (
33
obtain_jwt_token,
44
refresh_jwt_token,

0 commit comments

Comments
 (0)