Files
BPLabs/templates/matrix_test_setup.html
T
2019-12-08 19:51:20 +00:00

64 lines
2.5 KiB
HTML

{% extends 'index.html' %}
{% block content %}
<div class="card">
<div id="main-div" class="card-body">
<form action="{{ url_for('matDecStim') }}" method="POST">
<div class="form-group">
<select class="form-control" name="participant" id="participant">
<option>--</option>
{% for p in part_keys %}
<option>{{ p }}</option>
{% endfor %}
</select>
</div>
<div class="form-group d-flex justify-content-center">
<button type="button" id="submit" class="btn btn-primary mx-3">Start new test</button>
<button type="button" id="load-saved" class="btn btn-primary mx-3">Load saved session</button>
<button type="button" id="load-backup" class="btn btn-primary mx-3">Load previous automatic backup</button>
</div>
</form>
</div>
</div>
<script>
$(document).ready(function(){
// Initialise socketio with a namespace called "main"
var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port + '/main');
$('#load-backup').click(function(event) {
socket.emit('load_backup_test', {part_key: $("#participant").val(), test_name: "mat_test"});
return false;
})
$('#load-saved').click(function(event) {
socket.emit('load_session', {part_key: $("#participant").val(), test_name: "mat_test"});
return false;
})
$('#submit').click(function(event) {
socket.emit('start_test', {listN: $("#listN").val(), part_key: $("#participant").val(), test_name: "mat_test"});
return false;
})
socket.on('participant_start', function(msg) {
// Set form test to filepath returned by dialog
window.location.href = '/matrix_test/clinician/control';
});
socket.on('save-dialog-resp', function(msg) {
// Set form test to filepath returned by dialog
document.getElementById("save-dir").value = msg.data
});
$('#mat-dir-button').click(function(event) {
// Send message to call stimulus generation function in Python
socket.emit('open_mat_dialog');
return false;
})
socket.on('mat-dialog-resp', function(msg) {
// Set form test to filepath returned by dialog
document.getElementById("mat-dir").value = msg.data
});
});
</script>
{% endblock %}