aboutsummaryrefslogtreecommitdiff
path: root/app/main
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
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')
-rw-r--r--app/main/demo.py15
-rw-r--r--app/main/routes.py17
2 files changed, 27 insertions, 5 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.",
diff --git a/app/main/routes.py b/app/main/routes.py
index 11de2f9..a0033b1 100644
--- a/app/main/routes.py
+++ b/app/main/routes.py
@@ -11,6 +11,7 @@ from app.decorators import login_required
from app.main import bp
from app.models import Annotation, Task
from app.utils.datasets import load_data_for_chart
+from app.utils.tasks import generate_user_task
logger = logging.getLogger(__name__)
@@ -31,7 +32,9 @@ def index():
user_id = current_user.id
tasks = Task.query.filter_by(annotator_id=user_id).all()
tasks_done = [t for t in tasks if t.done and not t.dataset.is_demo]
- tasks_todo = [t for t in tasks if not t.done]
+ tasks_todo = [
+ t for t in tasks if (not t.done) and (not t.dataset.is_demo)
+ ]
return render_template(
"index.html",
title="Home",
@@ -78,8 +81,18 @@ def annotate(task_id):
task.done = True
task.annotated_on = now
db.session.commit()
-
flash("Your annotation has been recorded, thank you!", "success")
+
+ # assign a new task if necessary
+ task = generate_user_task(current_user)
+ if task is None:
+ return url_for("main.index")
+ db.session.add(task)
+ db.session.commit()
+ flash(
+ "A new dataset has been assigned for you to annotate. Thanks for your help!",
+ "info",
+ )
return url_for("main.index")
task = Task.query.filter_by(id=task_id).first()