Display mcq and ucq corrections
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
8acdf30ba4
commit
e0cd502c35
31
direct.go
31
direct.go
@ -98,10 +98,16 @@ func msgCurrentState(survey *Survey) (msg WSMessage) {
|
|||||||
Action: "pause",
|
Action: "pause",
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
var correction map[string]int
|
||||||
|
if survey.Corrected {
|
||||||
|
correction = getCorrectionString(*survey.Direct)
|
||||||
|
}
|
||||||
|
|
||||||
msg = WSMessage{
|
msg = WSMessage{
|
||||||
Action: "new_question",
|
Action: "new_question",
|
||||||
QuestionId: survey.Direct,
|
QuestionId: survey.Direct,
|
||||||
Corrected: survey.Corrected,
|
Corrected: survey.Corrected,
|
||||||
|
Corrections: correction,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -154,6 +160,7 @@ type WSMessage struct {
|
|||||||
UserId *int64 `json:"user,omitempty"`
|
UserId *int64 `json:"user,omitempty"`
|
||||||
Response string `json:"value,omitempty"`
|
Response string `json:"value,omitempty"`
|
||||||
Corrected bool `json:"corrected,omitempty"`
|
Corrected bool `json:"corrected,omitempty"`
|
||||||
|
Corrections map[string]int `json:"corrections,omitempty"`
|
||||||
Timer uint `json:"timer,omitempty"`
|
Timer uint `json:"timer,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,6 +238,25 @@ loopadmin:
|
|||||||
log.Println(u.Login, "admin disconnected")
|
log.Println(u.Login, "admin disconnected")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getCorrectionString(qid int64) (ret map[string]int) {
|
||||||
|
q, err := getQuestion(int(qid))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cts, err := q.GetCorrectionTemplates()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = map[string]int{}
|
||||||
|
for _, ct := range cts {
|
||||||
|
ret[ct.RegExp] = ct.Score
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func SurveyWSAdmin(c *gin.Context) {
|
func SurveyWSAdmin(c *gin.Context) {
|
||||||
u := c.MustGet("LoggedUser").(*User)
|
u := c.MustGet("LoggedUser").(*User)
|
||||||
survey := c.MustGet("survey").(*Survey)
|
survey := c.MustGet("survey").(*Survey)
|
||||||
@ -286,7 +312,7 @@ func SurveyWSAdmin(c *gin.Context) {
|
|||||||
survey.Corrected = v.Corrected
|
survey.Corrected = v.Corrected
|
||||||
survey.Update()
|
survey.Update()
|
||||||
|
|
||||||
survey.WSWriteAll(WSMessage{Action: "new_question", QuestionId: v.QuestionId, Corrected: true})
|
survey.WSWriteAll(WSMessage{Action: "new_question", QuestionId: v.QuestionId, Corrected: true, Corrections: getCorrectionString(*v.QuestionId)})
|
||||||
} else {
|
} else {
|
||||||
survey.WSWriteAll(WSMessage{Action: "pause"})
|
survey.WSWriteAll(WSMessage{Action: "pause"})
|
||||||
WSAdminWriteAll(WSMessage{Action: "pause", SurveyId: &survey.Id})
|
WSAdminWriteAll(WSMessage{Action: "pause", SurveyId: &survey.Id})
|
||||||
@ -296,6 +322,9 @@ func SurveyWSAdmin(c *gin.Context) {
|
|||||||
} else {
|
} else {
|
||||||
survey.Direct = v.QuestionId
|
survey.Direct = v.QuestionId
|
||||||
survey.Corrected = v.Corrected
|
survey.Corrected = v.Corrected
|
||||||
|
if v.Corrected {
|
||||||
|
v.Corrections = getCorrectionString(*v.QuestionId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_, err = survey.Update()
|
_, err = survey.Update()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -14,6 +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 survey = null;
|
export let survey = null;
|
||||||
export let value = "";
|
export let value = "";
|
||||||
|
|
||||||
@ -92,6 +93,7 @@
|
|||||||
{proposals}
|
{proposals}
|
||||||
readonly
|
readonly
|
||||||
live={survey.direct !== null}
|
live={survey.direct !== null}
|
||||||
|
{corrections}
|
||||||
bind:value={value}
|
bind:value={value}
|
||||||
on:change={() => { dispatch("change"); }}
|
on:change={() => { dispatch("change"); }}
|
||||||
/>
|
/>
|
||||||
@ -110,6 +112,7 @@
|
|||||||
{proposals}
|
{proposals}
|
||||||
{readonly}
|
{readonly}
|
||||||
live={survey.direct !== null}
|
live={survey.direct !== null}
|
||||||
|
{corrections}
|
||||||
bind:value={value}
|
bind:value={value}
|
||||||
on:change={() => { dispatch("change"); }}
|
on:change={() => { dispatch("change"); }}
|
||||||
/>
|
/>
|
||||||
|
@ -9,6 +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 id_question = 0;
|
export let id_question = 0;
|
||||||
export let value;
|
export let value;
|
||||||
|
|
||||||
@ -91,8 +92,11 @@
|
|||||||
class:form-check-label={!live}
|
class:form-check-label={!live}
|
||||||
class:btn={live}
|
class:btn={live}
|
||||||
class:btn-lg={live}
|
class:btn-lg={live}
|
||||||
class:btn-primary={live && value.indexOf(proposal.id.toString()) != -1}
|
class:btn-primary={live && !corrections && value.indexOf(proposal.id.toString()) != -1}
|
||||||
class:btn-outline-primary={live && value.indexOf(proposal.id.toString()) == -1}
|
class:btn-outline-primary={live && !corrections && value.indexOf(proposal.id.toString()) == -1}
|
||||||
|
class:btn-success={live && corrections && corrections[proposal.id] == 0}
|
||||||
|
class:btn-outline-warning={live && corrections && corrections[proposal.id] != 0 && corrections[proposal.id] != -100}
|
||||||
|
class:btn-outline-danger={live && corrections && corrections[proposal.id] == -100}
|
||||||
for={prefixid + 'p' + proposal.id}
|
for={prefixid + 'p' + proposal.id}
|
||||||
>
|
>
|
||||||
{proposal.label}
|
{proposal.label}
|
||||||
|
@ -90,6 +90,7 @@
|
|||||||
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;
|
||||||
|
corrections = data.corrections;
|
||||||
if (timer_cancel) {
|
if (timer_cancel) {
|
||||||
clearInterval(timer_cancel);
|
clearInterval(timer_cancel);
|
||||||
timer_cancel = null;
|
timer_cancel = null;
|
||||||
@ -156,6 +157,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let corrections = {};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#await surveyP then unused}
|
{#await surveyP then unused}
|
||||||
@ -189,6 +192,7 @@
|
|||||||
{survey}
|
{survey}
|
||||||
{question}
|
{question}
|
||||||
readonly={timer >= 100 || survey.corrected}
|
readonly={timer >= 100 || survey.corrected}
|
||||||
|
{corrections}
|
||||||
bind:value={value}
|
bind:value={value}
|
||||||
on:change={sendValue}
|
on:change={sendValue}
|
||||||
>
|
>
|
||||||
|
Reference in New Issue
Block a user