aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2019-09-16 15:06:12 +0100
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2019-09-16 15:06:12 +0100
commitd20891f10e0ead40e63109f61791c937a8f96487 (patch)
treefb73b0f3355072895065ba0f0c42846eb7322784 /app
parentBump version (diff)
downloadAnnotateChange-d20891f10e0ead40e63109f61791c937a8f96487.tar.gz
AnnotateChange-d20891f10e0ead40e63109f61791c937a8f96487.zip
Allow user to redo demo and pass
Annotations wouldn't be stored on the second try, so the user would never be able to pass the demo.
Diffstat (limited to 'app')
-rw-r--r--app/main/demo.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/app/main/demo.py b/app/main/demo.py
index 75546a0..29687d6 100644
--- a/app/main/demo.py
+++ b/app/main/demo.py
@@ -16,6 +16,8 @@ from flask import (
)
from flask_login import current_user
+from sqlalchemy import desc
+
from app import db
from app.decorators import login_required
from app.models import Annotation, Dataset, Task
@@ -336,9 +338,13 @@ def demo_performance(user_id):
dataset = Dataset.query.filter_by(
name=DEMO_DATA[demo_id]["dataset"]["name"]
).first()
- task = Task.query.filter_by(
- annotator_id=user_id, dataset_id=dataset.id
- ).first()
+ tasks = (
+ Task.query.filter_by(annotator_id=user_id, dataset_id=dataset.id)
+ .order_by(desc(Task.annotated_on))
+ .limit(1)
+ .all()
+ )
+ task = tasks[0]
annotations = (
Annotation.query.join(Task, Annotation.task)
.filter_by(id=task.id)
@@ -425,14 +431,6 @@ def process_annotations(demo_id):
dataset = Dataset.query.filter_by(
name=DEMO_DATA[demo_id]["dataset"]["name"]
).first()
- task = Task.query.filter_by(
- annotator_id=current_user.id, dataset_id=dataset.id
- ).first()
- # this happens if the user returns to the same demo page, but hasn't
- # completed the full demo yet. Same as above, not updating because we want
- # the originals.
- if not task is None:
- return retval
# Create a new task
task = Task(annotator_id=current_user.id, dataset_id=dataset.id)