Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"python.jediEnabled": false

}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "/Users/user/miniconda3/bin/python"
}
Binary file added __pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/app.cpython-37.pyc
Binary file not shown.
5 changes: 3 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from helpers.io import load_data, write_response, load_responses

app = Flask(__name__)
app.debug = True
logger = logging.getLogger('__main__')
logging.basicConfig(filename='error.log', level=logging.DEBUG)
logger.info('Logging configured')
Expand All @@ -31,13 +32,13 @@ def get_data():
return jsonify({'questions': [r[1] for r in rows]}), 200

if request.method == 'POST':
return jsonify({'answers': [float(r[2]) for r in rows]}), 200
return jsonify({'answers': [(r[2]) for r in rows]}), 200


@app.route("/submit/<id>/<response>", methods=['POST'])
def submit_responses(id, response):
r = {'id': id, 'response': response}
_ = write_response(r)
_ = str(write_response(r))
return 'Submitted {}'.format(r), 200


Expand Down
444 changes: 444 additions & 0 deletions error.log

Large diffs are not rendered by default.

Binary file added helpers/.DS_Store
Binary file not shown.
Binary file added helpers/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file modified helpers/__pycache__/io.cpython-37.pyc
Binary file not shown.
Binary file modified helpers/__pycache__/score.cpython-37.pyc
Binary file not shown.
6 changes: 4 additions & 2 deletions helpers/io.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pandas as pd

def load_data(file_name='questions.csv'):
with open(file_name, 'r') as f:
rows = [row.split(',') for row in f.read().split('\n')]
rows = rows[1:len(rows)]
return rows

def write_response(response, file_name='responses.csv'):
Expand All @@ -11,5 +13,5 @@ def write_response(response, file_name='responses.csv'):
def load_responses(file_name='responses.csv'):
with open(file_name, 'r') as f:
rows = [row.split(',') for row in f.read().split('\n')]
print(rows)
return {row[0]: row[1] for row in rows}

return {row[1]: row[0] for row in rows}
6 changes: 3 additions & 3 deletions questions.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
index,question,answer
1,1+1,2
2,7/2,3.5
index,question,answer
1,1+1,2
2,2-Jul,3.5
3,8*3,24
3 changes: 3 additions & 0 deletions responses.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1,2
2,3.5
3,43