Add button to report bad correction

This commit is contained in:
nemunaire 2022-03-28 10:53:45 +02:00
commit 1a5eea3bb2
7 changed files with 143 additions and 17 deletions

View file

@ -5,7 +5,7 @@ export class Response {
}
}
update({ id, id_question, id_user, value, time_submit, score, score_explaination, id_corrector, time_scored }) {
update({ id, id_question, id_user, value, time_submit, score, score_explaination, id_corrector, time_scored, time_reported }) {
this.id = id;
this.id_question = id_question;
this.id_user = id_user;
@ -15,6 +15,21 @@ export class Response {
this.score_explaination = score_explaination;
this.id_corrector = id_corrector;
this.time_scored = time_scored;
this.time_reported = time_reported;
}
async report(survey) {
const res = await fetch(`api/surveys/${survey.id}/responses/${this.id}/report`, {
method: 'POST',
headers: {'Accept': 'application/json'},
});
if (res.status == 200) {
const data = await res.json();
this.update(data);
return data;
} else {
throw new Error((await res.json()).errmsg);
}
}
async save() {

View file

@ -1,4 +1,5 @@
import { getQuestions } from './questions';
import { Response } from './response';
export class Survey {
constructor(res) {
@ -49,7 +50,7 @@ export class Survey {
headers: {'Accept': 'application/json'},
});
if (res.status == 200) {
return await res.json();
return (await res.json()).map((r) => new Response(r));
} else {
throw new Error((await res.json()).errmsg);
}