Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Server maintenance on Tue 31.5. at 12:00.
Open sidebar
Timo Heikkilä
PET-rating
Commits
886193cb
Commit
886193cb
authored
May 20, 2020
by
Ossi Laine
Browse files
Get results also from unfinnished answer sets
parent
9160aa6b
Changes
5
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
886193cb
...
...
@@ -14,4 +14,8 @@ config.py
/embody
/app/static/lib
.env
/app/static/*.png
/app/static/embody_images
.vscode/
documentation
app/experiment/views.py
View file @
886193cb
...
...
@@ -19,6 +19,7 @@ from flask import (
from
wtforms
import
Form
from
sqlalchemy
import
and_
,
update
from
flask_login
import
login_required
from
werkzeug
import
secure_filename
from
app
import
app
,
db
from
app.routes
import
APP_ROOT
...
...
@@ -35,7 +36,8 @@ from app.forms import (
EditQuestionForm
,
EditExperimentForm
,
UploadResearchBulletinForm
,
EditPageForm
,
RemoveExperimentForm
,
GenerateIdForm
,
CreateEmbodyForm
)
from
werkzeug
import
secure_filename
from
app.utils
import
get_mean_from_slider_answers
#Stimuli upload folder setting
#APP_ROOT = os.path.dirname(os.path.abspath(__file__))
...
...
@@ -916,19 +918,13 @@ def statistics():
#List of answers per participant in format question Stimulus ID/Question ID
#those are in answer table as page_idpage and question_idquestion respectively
slider_answers
=
{}
for
participant
in
participants
:
# list only finished answer sets
if
experiment_page_count
==
participant
.
answer_counter
:
if
participant
.
answer_counter
>
0
:
answers
=
answer
.
query
.
filter_by
(
answer_set_idanswer_set
=
participant
.
idanswer_set
).
all
()
slider_answers
[
participant
.
session
]
=
[
a
.
answer
for
a
in
answers
]
# map slider_answers from str to int and calculate mean
a
=
[
map
(
int
,
i
)
for
i
in
list
(
slider_answers
.
values
())]
slider_answers
[
'mean'
]
=
[
round
(
float
(
sum
(
l
))
/
len
(
l
),
2
)
for
l
in
zip
(
*
a
)]
slider_answers
[
'mean'
]
=
get_mean_from_slider_answers
(
slider_answers
)
#Background question answers
bg_questions
=
background_question
.
query
.
filter_by
(
...
...
@@ -936,9 +932,7 @@ def statistics():
bg_answers_for_participants
=
{}
for
participant
in
participants
:
# list only finished answer sets
if
experiment_page_count
==
participant
.
answer_counter
:
if
participant
.
answer_counter
>
0
:
bg_answers
=
background_question_answer
.
query
.
filter_by
(
answer_set_idanswer_set
=
participant
.
idanswer_set
).
all
()
bg_answers_list
=
[(
a
.
answer
)
for
a
in
bg_answers
]
...
...
@@ -982,6 +976,9 @@ def create_embody():
@
socketio
.
on
(
'draw'
,
namespace
=
"/create_embody"
)
def
create_embody
(
page_id
):
print
(
"DRAW"
)
page
=
page_id
[
"page"
]
embody
=
page_id
[
"embody"
]
...
...
app/routes.py
View file @
886193cb
...
...
@@ -360,14 +360,6 @@ def download_csv():
# embody questions
embody_questions
=
embody_question
.
query
.
filter_by
(
experiment_idexperiment
=
exp_id
).
all
()
#started and finished ratings counters
started_ratings
=
answer_set
.
query
.
filter_by
(
experiment_idexperiment
=
exp_id
).
count
()
experiment_page_count
=
page
.
query
.
filter_by
(
experiment_idexperiment
=
exp_id
).
count
()
finished_ratings
=
answer_set
.
query
.
filter
(
and_
(
answer_set
.
answer_counter
==
experiment_page_count
,
answer_set
.
experiment_idexperiment
==
exp_id
)).
count
()
csv
=
''
# create CSV-header
...
...
@@ -377,6 +369,7 @@ def download_csv():
for
idx
in
range
(
1
,
len
(
pages
)
+
1
):
if
len
(
questions
)
>
0
:
header
+=
';'
+
';'
.
join
([
'page'
+
str
(
idx
)
+
'_'
+
str
(
count
)
+
'. slider_question: '
+
question
.
question
.
strip
()
for
count
,
question
in
enumerate
(
questions
,
1
)])
for
idx
in
range
(
1
,
len
(
pages
)
+
1
):
if
len
(
embody_questions
)
>
0
:
header
+=
';'
+
';'
.
join
([
'page'
+
str
(
idx
)
+
'_'
+
str
(
count
)
+
'. embody_question: '
+
question
.
picture
.
strip
()
for
count
,
question
in
enumerate
(
embody_questions
,
1
)])
...
...
@@ -385,12 +378,9 @@ def download_csv():
answer_row
=
''
for
participant
in
participants
:
# list only finished answer sets
if
experiment_page_count
==
participant
.
answer_counter
:
if
participant
.
answer_counter
>
0
:
try
:
# append user session id
answer_row
+=
participant
.
session
+
';'
...
...
@@ -408,6 +398,9 @@ def download_csv():
# save embody answers as bitmap images
embody_answers
=
embody_answer
.
query
.
filter_by
(
answer_set_idanswer_set
=
participant
.
idanswer_set
).
all
()
answers_list
=
[]
# TODO: check randomization
for
embody_answer_data
in
embody_answers
:
try
:
...
...
app/static/js/getDrawing.js
View file @
886193cb
const
baseURI
=
'
http://onni.utu.fi/
'
;
const
baseURI
=
'
localhost/
'
;
//const baseURI = 'http://onni.utu.fi/';
var
getDrawingURI
=
baseURI
+
'
create_embody
'
;
$
(
document
).
ready
(
function
()
{
...
...
app/task/views.py
View file @
886193cb
...
...
@@ -37,14 +37,11 @@ task_blueprint = Blueprint("task", __name__,
def
get_randomized_page
(
page_id
):
"""if trial randomization is on we will still use the same functionality that is used otherwise
but we will pass the randomized pair of the page_id from trial randomization table to the task.html"""
randomized_page
=
trial_randomization
.
query
.
filter
(
and_
(
return
trial_randomization
.
query
.
filter
(
and_
(
trial_randomization
.
answer_set_idanswer_set
==
session
[
'answer_set'
],
trial_randomization
.
page_idpage
==
page_id
)).
first
()
return
randomized_page
def
add_slider_answer
(
key
,
value
,
page_id
=
None
):
"""Insert slider value to database. If trial randomization is set to 'Off'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment