Can display corrections in live sessions
This commit is contained in:
parent
99441d54f3
commit
89f61d1046
21
direct.go
21
direct.go
@ -101,6 +101,7 @@ func msgCurrentState(survey *Survey) (msg WSMessage) {
|
||||
msg = WSMessage{
|
||||
Action: "new_question",
|
||||
QuestionId: survey.Direct,
|
||||
Corrected: survey.Corrected,
|
||||
}
|
||||
}
|
||||
return
|
||||
@ -152,6 +153,7 @@ type WSMessage struct {
|
||||
Stats map[string]interface{} `json:"stats,omitempty"`
|
||||
UserId *int64 `json:"user,omitempty"`
|
||||
Response string `json:"value,omitempty"`
|
||||
Corrected bool `json:"corrected,omitempty"`
|
||||
Timer uint `json:"timer,omitempty"`
|
||||
}
|
||||
|
||||
@ -274,15 +276,26 @@ func SurveyWSAdmin(c *gin.Context) {
|
||||
if *survey.Direct != 0 {
|
||||
var z int64 = 0
|
||||
survey.Direct = &z
|
||||
survey.Corrected = false
|
||||
survey.Update()
|
||||
}
|
||||
go func() {
|
||||
go func(corrected bool) {
|
||||
time.Sleep(time.Duration(OffsetQuestionTimer+v.Timer) * time.Millisecond)
|
||||
survey.WSWriteAll(WSMessage{Action: "pause"})
|
||||
WSAdminWriteAll(WSMessage{Action: "pause", SurveyId: &survey.Id})
|
||||
}()
|
||||
|
||||
if corrected {
|
||||
survey.Corrected = v.Corrected
|
||||
survey.Update()
|
||||
|
||||
survey.WSWriteAll(WSMessage{Action: "new_question", QuestionId: v.QuestionId, Corrected: true})
|
||||
} else {
|
||||
survey.WSWriteAll(WSMessage{Action: "pause"})
|
||||
WSAdminWriteAll(WSMessage{Action: "pause", SurveyId: &survey.Id})
|
||||
}
|
||||
}(v.Corrected)
|
||||
v.Corrected = false
|
||||
} else {
|
||||
survey.Direct = v.QuestionId
|
||||
survey.Corrected = v.Corrected
|
||||
}
|
||||
_, err = survey.Update()
|
||||
if err != nil {
|
||||
|
@ -132,7 +132,7 @@
|
||||
></textarea>
|
||||
{/if}
|
||||
|
||||
{#if survey && survey.corrected}
|
||||
{#if survey && survey.corrected && response_history}
|
||||
<ResponseCorrected
|
||||
response={response_history}
|
||||
{survey}
|
||||
|
@ -43,6 +43,7 @@
|
||||
let wsstats = null;
|
||||
let current_question = null;
|
||||
let responses = {};
|
||||
let corrected = false;
|
||||
let timer = 20;
|
||||
let timer_end = null;
|
||||
let timer_remain = 0;
|
||||
@ -248,9 +249,21 @@
|
||||
class="btn btn-sm btn-primary"
|
||||
disabled={!current_question || !ws_up}
|
||||
on:click={() => { ws.send('{"action":"pause"}')} }
|
||||
title="Passer sur une scène sans question"
|
||||
>
|
||||
<i class="bi bi-pause-fill"></i>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm"
|
||||
class:btn-outline-success={!corrected}
|
||||
class:btn-success={corrected}
|
||||
disabled={!current_question || !ws_up}
|
||||
on:click={() => { corrected = !corrected } }
|
||||
title="La prochaine question est affichée corrigée"
|
||||
>
|
||||
<i class="bi bi-eye"></i>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -277,9 +290,11 @@
|
||||
<td>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-primary"
|
||||
class="btn btn-sm"
|
||||
class:btn-primary={!corrected}
|
||||
class:btn-success={corrected}
|
||||
disabled={question.id === current_question || !ws_up}
|
||||
on:click={() => { ws.send('{"action":"new_question", "timer": 0, "question":' + question.id + '}')} }
|
||||
on:click={() => { ws.send('{"action":"new_question", "corrected": ' + corrected + ', "timer": 0, "question":' + question.id + '}')} }
|
||||
>
|
||||
<i class="bi bi-play-fill"></i>
|
||||
</button>
|
||||
@ -291,6 +306,14 @@
|
||||
>
|
||||
<i class="bi bi-stopwatch-fill"></i>
|
||||
</button>
|
||||
<a
|
||||
href="/surveys/{survey.id}/responses/{question.id}"
|
||||
target="_blank"
|
||||
type="button"
|
||||
class="btn btn-sm btn-success"
|
||||
>
|
||||
<i class="bi bi-files"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
|
@ -89,6 +89,7 @@
|
||||
console.log(data);
|
||||
if (data.action && data.action == "new_question") {
|
||||
show_question = data.question;
|
||||
survey.corrected = data.corrected;
|
||||
if (timer_cancel) {
|
||||
clearInterval(timer_cancel);
|
||||
timer_cancel = null;
|
||||
@ -157,7 +158,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
{#await surveyP then survey}
|
||||
{#await surveyP then unused}
|
||||
{#if $user && $user.is_admin}
|
||||
<a href="surveys/{survey.id}/admin" class="btn btn-primary ms-1 float-end" title="Aller à l'interface d'administration"><i class="bi bi-pencil"></i></a>
|
||||
<a href="surveys/{survey.id}/responses" class="btn btn-success ms-1 float-end" title="Voir les réponses"><i class="bi bi-files"></i></a>
|
||||
@ -185,8 +186,9 @@
|
||||
</div>
|
||||
{:then question}
|
||||
<QuestionForm
|
||||
{survey}
|
||||
{question}
|
||||
readonly={timer >= 100}
|
||||
readonly={timer >= 100 || survey.corrected}
|
||||
bind:value={value}
|
||||
on:change={sendValue}
|
||||
>
|
||||
|
Reference in New Issue
Block a user