Skip to content
Snippets Groups Projects
Commit 3962ca68 authored by root's avatar root
Browse files

Merge branch 'master' of https://gitlab.utu.fi/tithei/pet-rating

parents ff0db8c5 a5d0ada5
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,13 @@ source venv/bin/activate ...@@ -15,6 +15,13 @@ source venv/bin/activate
pip install -r requirements.txt pip install -r requirements.txt
``` ```
Create user 'rating' and grant access to database 'rating_db'.
Create necessary tables by running the initialization script:
```
mysql -u rating -p -D rating_db < create_rating_db.sql
```
### Deployment ### Deployment
There are multiple deployment options, but one working solution is: There are multiple deployment options, but one working solution is:
......
/* /*
MYSQL script SQL initialization script
Run: mysql -u rating -p -D rating_db < create_rating_db.sql Run: mysql -u rating -p -D rating_db < create_rating_db.sql
This will create user 'admin' with password 'password'.
*/ */
/* Drop all tables (cascade removes foreign keys also) */ /* Drop all tables (cascade removes foreign keys also) */
...@@ -95,7 +98,6 @@ CREATE TABLE user ( ...@@ -95,7 +98,6 @@ CREATE TABLE user (
password_hash VARCHAR(128), password_hash VARCHAR(128),
PRIMARY KEY (id) PRIMARY KEY (id)
); );
INSERT INTO user VALUES(1,'Yngwie',NULL,'pbkdf2:sha256:50000$QioS5ICE$17a468394e72aef1243576aa80d29c296c6482ada48be9d25bd7c3b6e8129b40');
/* By using forced ID login subjects can only participate to a rating task by logging in with a pregenerated ID */ /* By using forced ID login subjects can only participate to a rating task by logging in with a pregenerated ID */
CREATE TABLE forced_id ( CREATE TABLE forced_id (
...@@ -160,13 +162,23 @@ CREATE INDEX ix_page_type ON page (type); ...@@ -160,13 +162,23 @@ CREATE INDEX ix_page_type ON page (type);
/* New fields for updating embody tool to onni.utu.fi */ /* New fields for updating embody tool to onni.utu.fi */
/* Embody picture/question information */
CREATE TABLE embody_question (
idembody INTEGER NOT NULL AUTO_INCREMENT,
experiment_idexperiment INTEGER,
picture TEXT,
question TEXT,
PRIMARY KEY (idembody),
FOREIGN KEY(experiment_idexperiment) REFERENCES experiment (idexperiment)
);
/* Embody answer (coordinates). Answer is saved as a json object: /* Embody answer (coordinates). Answer is saved as a json object:
{x:[1,2,100,..], y:[3,4,101,..], r:[13,13,8,...]} */ {x:[1,2,100,..], y:[3,4,101,..], r:[13,13,8,...]} */
CREATE TABLE embody_answer ( CREATE TABLE embody_answer (
idanswer INTEGER NOT NULL AUTO_INCREMENT, idanswer INTEGER NOT NULL AUTO_INCREMENT,
answer_set_idanswer_set INTEGER, answer_set_idanswer_set INTEGER,
page_idpage INTEGER, page_idpage INTEGER,
embody_question_idembody INTEGER, embody_question_idembody INTEGER DEFAULT 0,
coordinates TEXT, coordinates TEXT,
PRIMARY KEY (idanswer), PRIMARY KEY (idanswer),
FOREIGN KEY(answer_set_idanswer_set) REFERENCES answer_set (idanswer_set), FOREIGN KEY(answer_set_idanswer_set) REFERENCES answer_set (idanswer_set),
...@@ -174,21 +186,11 @@ CREATE TABLE embody_answer ( ...@@ -174,21 +186,11 @@ CREATE TABLE embody_answer (
FOREIGN KEY(embody_question_idembody) REFERENCES embody_question (idembody) FOREIGN KEY(embody_question_idembody) REFERENCES embody_question (idembody)
); );
/* Embody picture/question information */
CREATE TABLE embody_question (
idembody INTEGER NOT NULL AUTO_INCREMENT,
experiment_idexperiment INTEGER,
picture TEXT,
question TEXT,
PRIMARY KEY (idembody),
FOREIGN KEY(experiment_idexperiment) REFERENCES experiment (idexperiment)
);
ALTER TABLE embody_answer ADD COLUMN (embody_question_idembody INTEGER DEFAULT 0);
ALTER TABLE embody_answer ADD CONSTRAINT FOREIGN KEY (embody_question_idembody) REFERENCES embody_question (idembody);
/* Set flag if embody tool is enabled -> this is not the most modular solution, but works for now */ /* Set flag if embody tool is enabled -> this is not the most modular solution, but works for now */
ALTER TABLE experiment ADD COLUMN (embody_enabled BOOLEAN DEFAULT 0); ALTER TABLE experiment ADD COLUMN (embody_enabled BOOLEAN DEFAULT 0);
/* Set current answer type (embody/slider/etc..) so returning users are routed to correct question */ /* Set current answer type (embody/slider/etc..) so returning users are routed to correct question */
ALTER TABLE answer_set ADD COLUMN (answer_type VARCHAR(120)); ALTER TABLE answer_set ADD COLUMN (answer_type VARCHAR(120));
INSERT INTO user VALUES(1,'admin',NULL,'pbkdf2:sha256:50000$6Cc6Mjmo$3fe413a88db1bacfc4d617f7c1547bd1ea4cbd6c5d675a58e78332201f6befc6');
...@@ -30,6 +30,10 @@ import argparse ...@@ -30,6 +30,10 @@ import argparse
import numpy as np import numpy as np
import scipy.ndimage as ndimage import scipy.ndimage as ndimage
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import matplotlib.image as mpimg import matplotlib.image as mpimg
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment