Fix corrections propagation

This commit is contained in:
nemunaire 2022-09-02 11:54:58 +02:00
parent e0cd502c35
commit 3d772704b7
4 changed files with 13 additions and 5 deletions

View File

@ -287,6 +287,11 @@ func SurveyWSAdmin(c *gin.Context) {
var v WSMessage
var err error
for {
// Reset variable state
v.Corrected = false
v.Corrections = nil
v.Timer = 0
err = wsjson.Read(context.Background(), ws, &v)
if err != nil {
log.Println("Error when receiving message:", err)

View File

@ -14,7 +14,7 @@
export let qid;
export let response_history = null;
export let readonly = false;
export let corrections = {};
export let corrections = null;
export let survey = null;
export let value = "";

View File

@ -9,7 +9,7 @@
export let kind = 'mcq';
export let prefixid = '';
export let readonly = false;
export let corrections = {};
export let corrections = null;
export let id_question = 0;
export let value;

View File

@ -86,11 +86,14 @@
ws.addEventListener("message", (message) => {
const data = JSON.parse(message.data);
console.log(data);
if (data.action && data.action == "new_question") {
show_question = data.question;
survey.corrected = data.corrected;
corrections = data.corrections;
if (data.corrected) {
corrections = data.corrections;
} else {
corrections = null;
}
if (timer_cancel) {
clearInterval(timer_cancel);
timer_cancel = null;
@ -158,7 +161,7 @@
});
}
let corrections = {};
let corrections = null;
</script>
{#await surveyP then unused}