-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
72 lines (59 loc) · 2.05 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
This project uses python 3.6.6
* `pip install requirements.txt`
* `./manage.py migrate`
* `./manage.py loaddata form_builder/fixtures/initial_data.json`
* `./manage.py createsuperuser`
* `./manage.py runserver`
* `$ curl -X POST -d "username=admin&password=password123" http://localhost:8000/api-token-auth/`
* `$ curl -H "Authorization: JWT <your_token>" http://localhost:8000/protected-url/`
View Form
```
curl -X GET \
http://127.0.0.1:8000/forms/1/ \
-H 'authorization: Basic bWFub2o6MQ==' \
-H 'content-type: application/json'
```
View Attempt
```
curl -X GET \
http://127.0.0.1:8000/attempts/1/ \
-H 'authorization: Basic bWFub2oyOjE=' \
-H 'content-type: application/json'
```
Respond with Text
```
curl -X PATCH \
http://127.0.0.1:8000/attempts/1/fields/1/ \
-H 'authorization: Basic bWFub2oyOjE=' \
-H 'content-type: application/json' \
-d '{
"text": "Manoj Kumar P"
}'
```
Respond with Multiple Options
```
curl -X POST \
http://127.0.0.1:8000/attempts/1/fields/2/options/ \
-H 'authorization: Basic bWFub2oyOjE=' \
-H 'content-type: application/json' \
-d '{
"option": 1
}'
```
Workflow
=======
Author a Form
1. Create Form `POST http://127.0.0.1:8000/forms/`
2. Add Fields,...
3. Publish Form `POST http://127.0.0.1:8000/forms/:id/publish/`
4. View Forms Created `GET http://127.0.0.1:8000/forms/`
Add Fields
* Create Multiple Choice Field `POST http://127.0.0.1:8000/forms/:id/fields/ -d {"field": "R", "text": "Married?"}`
* Create Text Field `POST http://127.0.0.1:8000/forms/:id/fields/ -d {"field": "T", "text": "Name?"}`
* `GET http://127.0.0.1:8000/forms/:id/fields/`
* Add Options for Radio Form-Field `POST http://127.0.0.1:8000/forms/1/fields/5/options/ -d {"value": "Choice 1"}`
Attempt a Form
1. Create Attempt with fields populated `POST http://127.0.0.1:8000/attempts/ -d {"form": 1}`
2. Text Response `PATCH http://127.0.0.1:8000/attempts/:id/fields/:id/ -d {"text": "value"}`
3. Radio Response `POST http://127.0.0.1:8000/attempts/1/fields/2/options/ -d {"option": 1}`
4. View Attempt `GET http://127.0.0.1:8000/attempts/:id/`