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 v WSMessage
var err error var err error
for { for {
// Reset variable state
v.Corrected = false
v.Corrections = nil
v.Timer = 0
err = wsjson.Read(context.Background(), ws, &v) err = wsjson.Read(context.Background(), ws, &v)
if err != nil { if err != nil {
log.Println("Error when receiving message:", err) log.Println("Error when receiving message:", err)

View File

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

View File

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

View File

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