aboutsummaryrefslogtreecommitdiff
path: root/app/main/demo.py
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2019-06-03 15:19:28 +0100
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2019-06-03 15:19:28 +0100
commit94c3656bea0ff16b826f1adf34a3ada9084c7f8f (patch)
treeb9e64849ea5dd15ab94fb3b8f79a2080fa050d1e /app/main/demo.py
parentInitial version of demo (diff)
downloadAnnotateChange-94c3656bea0ff16b826f1adf34a3ada9084c7f8f.tar.gz
AnnotateChange-94c3656bea0ff16b826f1adf34a3ada9084c7f8f.zip
Rewrite the task assignment flow
With the demo in place, we're rewriting the task assignment flow such that users only get a task assigned when: 1. They finish the demo 2. They finish a task 3. They login again. This way we can better balance the datasets and we won't have datasets that don't get enough annotations because some users didn't finish tasks they were assigned.
Diffstat (limited to 'app/main/demo.py')
-rw-r--r--app/main/demo.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/app/main/demo.py b/app/main/demo.py
index a126fd8..a5dbc0f 100644
--- a/app/main/demo.py
+++ b/app/main/demo.py
@@ -23,6 +23,7 @@ from app.main import bp
from app.main.forms import NextForm
from app.main.routes import RUBRIC
from app.utils.datasets import load_data_for_chart, get_demo_true_cps
+from app.utils.tasks import generate_user_task
LOGGER = logging.getLogger(__name__)
@@ -253,13 +254,21 @@ def redirect_user(demo_id, phase_id):
last_demo_id = max(DEMO_DATA.keys())
demo_last_phase_id = 3
if demo_id == last_demo_id and phase_id == demo_last_phase_id:
- # User is introduced.
+ # User is already introduced (happens if they redo the demo)
if current_user.is_introduced:
return redirect(url_for("main.index"))
+ # mark user as introduced
current_user.is_introduced = True
db.session.commit()
- # TODO: Assign real tasks to the user here.
+
+ # assign a task to the user
+ task = generate_user_task(current_user)
+ if task is None:
+ return redirect(url_for("main.index"))
+ db.session.add(task)
+ db.session.commit()
+
return redirect(url_for("main.index"))
elif phase_id == demo_last_phase_id:
demo_id += 1
@@ -352,7 +361,7 @@ def demo_annotate(demo_id):
if dataset is None:
LOGGER.error(
"Demo requested unavailable dataset: %s"
- % demo_data["dataset"]["name"]
+ % DEMO_DATA[demo_id]["dataset"]["name"]
)
flash(
"An internal error occured. The administrator has been notified. We apologise for the inconvenience, please try again later.",