From dbcf1c6594a70e0375ec20c10670fb67260b34c2 Mon Sep 17 00:00:00 2001 From: Scott Sievert Date: Wed, 29 Jul 2020 11:04:59 -0500 Subject: [PATCH] MAINT: add button for crowdsourcing user to get new query (#53) --- salmon/frontend/private.py | 1 + salmon/frontend/public.py | 2 ++ templates/query_page.html | 37 ++++++++++++++++++++++++++----------- tests/data/button.yaml | 11 +++++++++++ 4 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 tests/data/button.yaml diff --git a/salmon/frontend/private.py b/salmon/frontend/private.py index 99e5af88..4f6f35d8 100644 --- a/salmon/frontend/private.py +++ b/salmon/frontend/private.py @@ -145,6 +145,7 @@ async def _get_config(exp: bytes, targets: bytes) -> Dict[str, Any]: "debrief": "Thanks!", "samplers": {"random": {"module": "RandomSampling"}}, "max_queries": -1, + "skip_button": False, } exp_config.update(config) diff --git a/salmon/frontend/public.py b/salmon/frontend/public.py index cc9b2788..65628867 100644 --- a/salmon/frontend/public.py +++ b/salmon/frontend/public.py @@ -80,6 +80,7 @@ async def _ensure_initialized(): "n", "max_queries", "debrief", + "skip_button", ] if not set(exp_config) == set(expected_keys): msg = "Experiment keys are not correct. Expected {}, got {}" @@ -101,6 +102,7 @@ async def get_query_page(request: Request): "targets": exp_config["targets"], "max_queries": exp_config["max_queries"], "debrief": exp_config["debrief"], + "skip_button": exp_config["skip_button"], } items.update(request=request) return templates.TemplateResponse("query_page.html", items) diff --git a/templates/query_page.html b/templates/query_page.html index dacea598..464e093d 100644 --- a/templates/query_page.html +++ b/templates/query_page.html @@ -7,6 +7,10 @@ + + + + Salmon - - - - - - -
-

{{instructions | safe}}

+ +
+

Target:

+
+
+

Comparisons:

+
@@ -81,10 +84,17 @@
- 0 - {% if max_queries > 0 %} - /{{ max_queries }} + 0{% if max_queries > 0 %}/{{ max_queries }} {% endif %} +
+
+
+ {% if skip_button %} + {% endif %} +
@@ -104,6 +114,11 @@