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
0ad6d58f
Commit
0ad6d58f
authored
Jul 22, 2019
by
Ossi Laine
Browse files
Merge branch 'master' of
https://gitlab.utu.fi/tithei/pet-rating
parents
54c8f4d7
b75809bd
Changes
6
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
0ad6d58f
...
...
@@ -3,6 +3,7 @@ __pycache__/
/rating
/logs
/app/static/experiment_stimuli
/app/static/embody_drawings/*
cmd.txt
DB_inserts.txt
dumb.sql
...
...
app/__init__.py
View file @
0ad6d58f
...
...
@@ -13,7 +13,9 @@ from config import Config
from
flask_cors
import
CORS
,
cross_origin
app
=
Flask
(
__name__
)
CORS
(
app
)
#CORS(app, resources={r"/*": {"cors_allowed_origins":"*"} } )
#app.config['BABEL_DEFAULT_LOCALE'] = 'fin'
#app.config['BABEL_TRANSLATION_DIRECTORIES'] ='C:/Users/Timo/git/pet-rating/app/translations'
...
...
@@ -62,6 +64,7 @@ def get_locale():
@babel.localeselector
def get_locale():
return request.accept_languages.best_match(app.config['LANGUAGES'])
"""
...
...
app/experiment/templates/experiment_statistics.html
View file @
0ad6d58f
...
...
@@ -89,7 +89,11 @@
<tbody>
{% for participant in participants_and_answers %}
<tr>
{% if participant == 'mean' %}
<td><b>
{{ participant }}
</b></td>
{% else %}
<td>
{{ participant }}
</td>
{% endif %}
{% for answer in participants_and_answers[participant] %}
<td>
{{ answer }}
</td>
{% endfor %}
...
...
@@ -186,4 +190,4 @@
<script
src=
"{{ url_for('static', filename='lib/js/socket.io.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/getDrawing.js') }}"
></script>
{% endblock %}
\ No newline at end of file
{% endblock %}
app/experiment/views.py
View file @
0ad6d58f
...
...
@@ -963,35 +963,23 @@ def statistics():
)
def
remove_rows
(
rows
):
"""Remove list of rows from database"""
for
a
in
range
(
len
(
rows
)):
db
.
session
.
delete
(
rows
[
a
])
db
.
session
.
commit
()
import
embody_plot
from
flask_cors
import
CORS
,
cross_origin
from
flask_socketio
import
emit
from
app
import
socketio
'''
Old method
#@experiment_blueprint.route('/create_embody', methods=['POST'])
#@cross_origin()
def create_embody():
#page = request.args.get("page")
page = request.form["page"]
img_path = embody_plot.get_coordinates(page)
#return send_file('static/' + img_path, 'test')
return json.dumps({'path':img_path})
'''
# (https://flask-socketio.readthedocs.io/en/latest/)
# TODO: Using nginx as a WebSocket Reverse Proxy
# TODO: Gunicorn Web Server
@
cross_origin
()
@
socketio
.
on
(
'connect'
,
namespace
=
"/create_embody"
)
def
create_embody
():
print
(
"connection succesful"
)
emit
(
'success'
,
{
'connection'
:
'on'
})
@
cross_origin
()
@
socketio
.
on
(
'draw'
,
namespace
=
"/create_embody"
)
def
create_embody
(
page_id
):
page
=
page_id
[
"page"
]
...
...
@@ -1001,18 +989,10 @@ def create_embody(page_id):
print
(
img_path
)
emit
(
'end'
,
{
'path'
:
img_path
})
'''
@
socketio
.
on
(
'end'
,
namespace
=
"/create_embody"
)
def
create_embody
():
print
(
"connection end"
)
emit
(
'end'
,
{
'connection'
:
'off'
})
'''
def
remove_rows
(
rows
):
"""Remove list of rows from database"""
for
a
in
range
(
len
(
rows
)):
db
.
session
.
delete
(
rows
[
a
])
db
.
session
.
commit
()
# EOF
app/static/js/getDrawing.js
View file @
0ad6d58f
const
baseURI
=
'
http://
127.0.0.1:8000
/
'
;
const
baseURI
=
'
http://
onni.utu.fi
/
'
;
var
getDrawingURI
=
baseURI
+
'
create_embody
'
;
//var getDrawingURI = baseURI + 'experiment/create_embody';
$
(
document
).
ready
(
function
()
{
...
...
@@ -13,6 +12,7 @@ $(document).ready(function() {
// With sockets
function
initConnection
(
socket
)
{
socket
.
on
(
'
success
'
,
function
(
msg
)
{
console
.
log
(
msg
)
});
...
...
@@ -22,12 +22,13 @@ $(document).ready(function() {
});
socket
.
on
(
'
end
'
,
function
(
img
)
{
socket
.
disconnect
()
// Draw image to statistic -page
var
source
=
img
.
path
d
=
new
Date
()
imageContainer
.
attr
(
"
src
"
,
"
/static/
"
+
source
+
"
?
"
+
d
.
getTime
())
imageContainer
.
attr
(
"
src
"
,
"
/static/
embody_drawings/
"
+
source
+
"
?
"
+
d
.
getTime
())
// Remove progress bar
progressBarContainer
.
addClass
(
"
hidden
"
)
...
...
@@ -77,4 +78,4 @@ $(document).ready(function() {
},
500
);
}
})
\ No newline at end of file
})
embody_plot.py
View file @
0ad6d58f
...
...
@@ -41,6 +41,7 @@ from matplotlib.figure import Figure
from
flask_socketio
import
emit
from
app
import
socketio
from
config
import
Config
# Hard coded image size for default embody image
...
...
@@ -50,7 +51,7 @@ HEIGHT = 600
# image paths
DEFAULT_IMAGE_PATH
=
'./app/static/img/dummy_600.png'
IMAGE_PATH_MASK
=
'./app/static/img/dummy_600_mask.png'
STATIC_PATH
=
'./app/static/'
STATIC_PATH
=
'./app/static/
embody_drawings/
'
# Interpolation methods
METHODS
=
[
'none'
,
'bilinear'
,
'bicubic'
,
'gaussian'
]
...
...
@@ -70,7 +71,11 @@ DATE_STRING = now.strftime("%Y-%m-%d")
class
MyDB
(
object
):
def
__init__
(
self
):
self
.
_db_connection
=
mariadb
.
connect
(
user
=
'rating'
,
password
=
'rating_passwd'
,
database
=
'rating_db'
)
self
.
_db_connection
=
mariadb
.
connect
(
user
=
Config
.
MYSQL_USER
,
password
=
Config
.
MYSQL_PASSWORD
,
database
=
Config
.
MYSQL_DB
)
self
.
_db_cur
=
self
.
_db_connection
.
cursor
()
def
query
(
self
,
query
,
params
):
...
...
@@ -114,6 +119,7 @@ def timeit(method):
return
timed
import
sys
@
timeit
def
get_coordinates
(
idpage
,
idembody
=
None
,
select_clause
=
SELECT_BY_PAGE_AND_PICTURE
):
...
...
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