Initial commit

This commit is contained in:
Kasiaaaaaa committed 2026-09-22 11:52:03 +02:00
commit d89b82be4a
103 files changed
+23110

No files matched your search

+279
View File
@@ -0,0 +1,279 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='css/bootstrap.min.css')}}">
<link rel="stylesheet" href="{{url_for('static', filename='css/styles.css')}}">
<link rel="stylesheet" href="{{url_for('static', filename='css/jquery-ui.min.css')}}">
<script type="text/javascript" src="{{url_for('static', filename='js/jquery.min.js')}}"></script>
<!-- <script src="https://code.jquery.com/jquery-1.12.4.js"></script> -->
<script src="{{url_for('static', filename='js/jquery-ui.min.js')}}"></script>
<title>{% block title %}{% endblock %}</title>
</head>
<script type="text/javascript">
function submitAnswer(colour, number) {
console.log(colour)
console.log(number)
var jqXHR = $.ajax({
type: "POST",
url: "/crm_answer",
async: true,
data: {
colour: colour,
number: number
},
success: function (response) {
if (response.trials.current_trial > response.trials.total_trials) {
response.trials.current_trial = response.trials.total_trials;
};
$('#current_trial').text(response.trials.current_trial)
$('#total_trials').text(response.trials.total_trials)
// if (response.trials.current_trial == 4) {
// var timer = 10;
// setTimeout(checkBreak, 1000);
// console.log("Running break")
// function checkBreak() {
// var b = window.confirm("You can now take a break.")
// if (b == true) {
// return
// } else {
// return
// }
// timer--;
// if (timer >= 0) setTimeout(checkBreak, 1000);
// }
// };
$(function () {
$('#progressBar').progressbar({
value: (response.trials.current_trial / response.trials
.total_trials) * 100
})
})
},
error: function (error) {
console.log(error)
}
});
};
$(function () {
var dialog, form,
participant = $("#p_id"),
phase = $("#phase"),
language = $("#lang"),
game = ""
parent = this
allFields = $([]).add(participant).add(phase).add(language),
tips = $(".validateTips");
function updateTips(t) {
tips
.text(t)
.addClass("ui-state-highlight");
setTimeout(function () {
tips.removeClass("ui-state-highlight", 1500);
}, 500);
}
function getGame(target) {
parent.game = target.dataset.game
}
function checkPID(o, n, max) {
x = o.val().substring(0, 3)
if (o.val().length > max) {
o.addClass("ui-state-error");
updateTips("Length of " + n + "must be " +
max + " characters long.");
return false;
} else if (o.val() != "") {
switch (o.val().startsWith(x)) {
case x == "NHA":
return true;
case x == "NHK":
return true;
case x == "CIA":
return true;
case x == "CIK":
return true;
case x == "":
o.addClass("ui-state-error");
updateTips("Participant ID must start either with NHA, NHK, CIA, or CIK. ");
default:
o.addClass("ui-state-error");
updateTips("Participant ID must start either with NHA, NHK, CIA, or CIK. ");
}
} else {
return false;
}
}
function checkPhase(o) {
x = o.val().toLowerCase();
switch (x) {
case "training":
return true;
case "test":
return true;
default:
o.addClass("ui-state-error");
updateTips("Phase must be either 'training' or 'test'.");
return false;
}
}
function addparticipant() {
var valid = true;
allFields.removeClass("ui-state-error");
valid = valid &&
checkPID(participant, "ID", 6);
valid = valid && checkPhase(phase);
// valid = valid &&
// checkLanguage(language);
if (valid) {
$.ajax({
type: "POST",
url: "/check_participant",
async: true,
data: {
game: parent.game,
phase: phase.val(),
participant: participant.val(),
lang: lang.value
},
success: function (response) {
// window.location.href = "/no-interaction"
// console.log("success")
console.log(response)
var p_exists
if (response.p_exists) {
var c = confirm("This participant already exists. Use their file?")
if (c == true) {
p_exists = true;
} else {
window.location.href = "/";
}
} else {
var c = confirm("The participant doesn't exist. Create new file?");
if (c == true) {
p_exists = false
} else {
window.location.href = "/";
}
};
$.ajax({
type: "POST",
url: "/run_picka",
async: true,
data: {
p_exists: p_exists,
game: response.game,
phase: response.phase,
participant: response.subject,
lang: response.lang
},
success: function (response) {
if (response.game == "crm") {
if (response.error) {
alert(
"There was an error connecting to Sam. Please try again."
)
} else {
window.location.href = "/crm-game"
}
} else if (response.game == "emotion") {
if (response.error) {
alert(
"There was an error connecting to Sam. Please try again."
)
} else {
window.location.href = "/no-interaction-diagram"
}
} else {
if (response.error) {
alert(
"There was an error connecting to Sam. Please try again."
)
} else {
window.location.href = "/no-interaction"
}
}
}
})
},
// error: function (error) {
// console.log(error)
// }
});
dialog.dialog("close");
}
return valid;
}
dialog = $("#dialog-form").dialog({
autoOpen: false,
height: 400,
width: 350,
modal: true,
buttons: {
"Create participant": addparticipant,
Cancel: function () {
dialog.dialog("close");
}
},
close: function () {
form[0].reset();
allFields.removeClass("ui-state-error");
}
});
form = dialog.find("form").on("submit", function (event) {
event.preventDefault();
addparticipant();
});
$(".create-participant").button().on("click", function (resp) {
game = getGame(resp.target);
dialog.data('game', game).dialog("open");
});
});
var i = 0;
$(document).ready(function () {
$('#progressBar').progressbar({
value: (parseInt($('#current_trial').text()) / parseInt($('#total_trials').text())) * 100
})
})
</script>
<body style="background-color: #54B77E;">
{% block content %}
{% endblock %}
</body>
</html>