diff --git a/app/experiment/templates/experiment_statistics.html b/app/experiment/templates/experiment_statistics.html index 9c3bbd8e5c5d7e0fe847b02d101d125b6d8682cb..817470eafe2cfc7e485c63e9c1c60db30827c24d 100644 --- a/app/experiment/templates/experiment_statistics.html +++ b/app/experiment/templates/experiment_statistics.html @@ -130,6 +130,12 @@ <iframe class="embed-responsive-item thumbnail" src="/{{ s.media }}" allowFullScreen></iframe> </div> </td> + {% elif s.type == 'audio' %} + <td> + <div class="embed-responsive embed-responsive-16by9 "> + <iframe class="embed-responsive-item thumbnail" src="/{{ s.media }}" allowFullScreen></iframe> + </div> + </td> {% else %} <td>{{ s.text }}</td> {% endif %} diff --git a/app/experiment/views.py b/app/experiment/views.py index 0d40d637a6e306e02fa0bc97f27ebdccc2bc4df1..6b02e510950e60e156b686cefddd00646103b2a7 100644 --- a/app/experiment/views.py +++ b/app/experiment/views.py @@ -986,7 +986,7 @@ def create_embody(page_id): embody = page_id["embody"] img_path = embody_plot.get_coordinates(page, embody) - print(img_path) + app.logger.info(img_path) emit('end', {'path':img_path}) @socketio.on('end', namespace="/create_embody") diff --git a/app/routes.py b/app/routes.py index ada9a29402d470cecb2406d09ace7dc181e4d0b3..342fcb19825935a067d22e8d145fe361c2a48a86 100644 --- a/app/routes.py +++ b/app/routes.py @@ -409,12 +409,22 @@ def download_csv(): embody_answers = embody_answer.query.filter_by(answer_set_idanswer_set=participant.idanswer_set).all() answers_list = [] for embody_answer_data in embody_answers: - embody_answer_data = json.loads(embody_answer_data.coordinates) - coordinates_to_bitmap = [[0 for x in range(embody_answer_data['height'] + 2)] for y in range(embody_answer_data['width'] + 2)] - for point in list(zip( embody_answer_data['x'], embody_answer_data['y'])): - coordinates_to_bitmap[point[0]][point[1]] += 0.1 - answers_list.append(json.dumps(coordinates_to_bitmap)) + try: + embody_answer_data = json.loads(embody_answer_data.coordinates) + coordinates_to_bitmap = [[0 for x in range(embody_answer_data['height'] + 2)] for y in range(embody_answer_data['width'] + 2)] + + for point in list(zip( embody_answer_data['x'], embody_answer_data['y'] )): + + try: + coordinates_to_bitmap[point[0]][point[1]] += 0.1 + except IndexError: + continue + + answers_list.append(json.dumps(coordinates_to_bitmap)) + + except ValueError as err: + app.logger.info(err) # old way to save only visited points: # answers_list = [ json.dumps(list(zip( json.loads(a.coordinates)['x'], json.loads(a.coordinates)['y']))) for a in embody_answers] @@ -444,4 +454,4 @@ def researcher_info(): return render_template('researcher_info.html') -# EOF \ No newline at end of file +# EOF diff --git a/config.py b/config.py index b945f2f5fc08ca3dd740a2782cab4891ad3f1401..26d0769b571c8e7f552ff5588aef47003fa91695 100644 --- a/config.py +++ b/config.py @@ -27,6 +27,13 @@ class Config(object): SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://'+MYSQL_USER+':'+MYSQL_PASSWORD+'@'+MYSQL_SERVER+'/'+MYSQL_DB+'?charset=utf8mb4' SQLALCHEMY_TRACK_MODIFICATIONS = False + + SQLALCHEMY_ENGINE_OPTIONS = { + "pool_pre_ping": True, + "pool_recycle": 300, + "max_overflow": 30, + "pool_size": 20 + } TEMPLATES_AUTO_RELOAD = True - DEBUG = True + DEBUG = False diff --git a/embody_plot.py b/embody_plot.py index 76bafdf8ffc6554f8cc2d03732c35f91cac1dc56..58f629a319c18760a642c05040c4218d50eecdc2 100644 --- a/embody_plot.py +++ b/embody_plot.py @@ -36,7 +36,7 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure from flask_socketio import emit -from app import socketio +from app import socketio, app from config import Config @@ -134,6 +134,7 @@ def get_coordinates(idpage, idembody=None, select_clause=SELECT_BY_PAGE_AND_PICT image_path = db._db_cur.fetchone()[0] image_path = './app' + image_path + # Draw image plt = plot_coordinates(coordinates, image_path) else: @@ -167,6 +168,9 @@ def format_coordinates(cursor): standard_radiuses = np.full((1, len(coordinates['x'])), standard_radius).tolist()[0] r.extend(standard_radiuses) continue + except ValueError as err: + app.logger.info(err) + continue return { "x":x, @@ -196,9 +200,15 @@ def plot_coordinates(coordinates, image_path=DEFAULT_IMAGE_PATH): frame = np.zeros((image_data[0] + 10,image_data[1] + 10)) if image_path == DEFAULT_IMAGE_PATH: + #app.logger.info(coordinates) for idx, point in enumerate(coordinates["coordinates"]): - frame[int(point[1]), int(point[0])] = 1 + + try: + frame[int(point[1]), int(point[0])] = 1 + except IndexError as err: + app.logger.info(err) + point = ndimage.gaussian_filter(frame, sigma=5) ax2.imshow(point, cmap='hot', interpolation='none') @@ -212,6 +222,7 @@ def plot_coordinates(coordinates, image_path=DEFAULT_IMAGE_PATH): image_mask = mpimg.imread(IMAGE_PATH_MASK) ax2.imshow(image_mask) + else: # TODO: gaussian disk appearing only on empty spaces in the pictures # -> at the moment this implementation works only for the default image @@ -223,6 +234,8 @@ def plot_coordinates(coordinates, image_path=DEFAULT_IMAGE_PATH): ax1.plot(coordinates["x"],coordinates["y"], 'ro', alpha=0.2) ax1.imshow(image, alpha=0.6) + app.logger.info("iamge plotted") + # return figure for saving/etc... return fig