ui: Display grades works

This commit is contained in:
nemunaire 2022-07-08 13:14:17 +02:00
commit 4f87298f63
5 changed files with 71 additions and 1 deletions

View file

@ -61,7 +61,7 @@ export async function getUserNeedingHelp() {
}
export async function getScore(survey) {
const res = await fetch(`api/surveys/${survey.id}/score`, {headers: {'Accept': 'application/json'}})
const res = await fetch(survey.kind === "w" ? `api/works/${survey.id}/score` : `api/surveys/${survey.id}/score`, {headers: {'Accept': 'application/json'}})
if (res.status == 200) {
return await res.json();
} else {

View file

@ -87,6 +87,18 @@ export class Work {
}
}
}
async getGrades() {
const res = await fetch(`api/works/${this.id}/grades`, {
method: 'GET',
headers: {'Accept': 'application/json'},
});
if (res.status == 200) {
return await res.json();
} else {
throw new Error((await res.json()).errmsg);
}
}
}
export async function getWorks() {