diff --git a/ui/package-lock.json b/ui/package-lock.json
index 3ce834a..2c160ee 100644
--- a/ui/package-lock.json
+++ b/ui/package-lock.json
@@ -8,6 +8,7 @@
"name": "atsebayt",
"version": "0.0.1",
"dependencies": {
+ "dayjs": "^1.11.5",
"svelte-frappe-charts": "^1.9.1",
"vite": "^3.0.4"
},
@@ -645,6 +646,11 @@
"node": ">= 8"
}
},
+ "node_modules/dayjs": {
+ "version": "1.11.5",
+ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.5.tgz",
+ "integrity": "sha512-CAdX5Q3YW3Gclyo5Vpqkgpj8fSdLQcRuzfX6mC6Phy0nfJ0eGYOeS7m4mt2plDWLAtA4TqTakvbboHvUxfe4iA=="
+ },
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@@ -3091,6 +3097,11 @@
"which": "^2.0.1"
}
},
+ "dayjs": {
+ "version": "1.11.5",
+ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.5.tgz",
+ "integrity": "sha512-CAdX5Q3YW3Gclyo5Vpqkgpj8fSdLQcRuzfX6mC6Phy0nfJ0eGYOeS7m4mt2plDWLAtA4TqTakvbboHvUxfe4iA=="
+ },
"debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
diff --git a/ui/package.json b/ui/package.json
index 76e67f4..dc0668f 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -28,6 +28,7 @@
},
"type": "module",
"dependencies": {
+ "dayjs": "^1.11.5",
"svelte-frappe-charts": "^1.9.1",
"vite": "^3.0.4"
}
diff --git a/ui/src/components/DateTimeInput.svelte b/ui/src/components/DateTimeInput.svelte
new file mode 100644
index 0000000..d39ff70
--- /dev/null
+++ b/ui/src/components/DateTimeInput.svelte
@@ -0,0 +1,21 @@
+
+
+
diff --git a/ui/src/components/SubmissionStatus.svelte b/ui/src/components/SubmissionStatus.svelte
index 5a2b1d4..b7ad14a 100644
--- a/ui/src/components/SubmissionStatus.svelte
+++ b/ui/src/components/SubmissionStatus.svelte
@@ -1,4 +1,6 @@
{#if work.submission_url == '-'}
{:else if work.submission_url}
- {#await getUserRendu(work.submission_url, user)}
+ {#await renduP}
{:then rendu}
{#if rendu === null}
@@ -24,7 +46,7 @@
{/await}
{:else}
- {#await work.getSubmission(user.id)}
+ {#await submissionP}
{:then submission}
diff --git a/ui/src/components/SurveyAdmin.svelte b/ui/src/components/SurveyAdmin.svelte
index 07b1455..865e6a3 100644
--- a/ui/src/components/SurveyAdmin.svelte
+++ b/ui/src/components/SurveyAdmin.svelte
@@ -3,6 +3,7 @@
import { goto } from '$app/navigation';
import { getQuestions } from '../lib/questions';
+ import DateTimeInput from './DateTimeInput.svelte';
import { ToastsStore } from '../stores/toasts';
const dispatch = createEventDispatcher();
@@ -13,17 +14,21 @@
dispatch('saved', response);
}, (error) => {
ToastsStore.addErrorToast({
- msg: error.errmsg,
+ msg: error,
});
})
}
+ let deleteInProgress = false;
function deleteSurvey() {
+ deleteInProgress = true;
survey.delete().then((response) => {
+ deleteInProgress = false;
goto(`surveys`);
}, (error) => {
+ deleteInProgress = false;
ToastsStore.addErrorToast({
- msg: error.errmsg,
+ msg: error,
});
})
}
@@ -33,7 +38,7 @@
goto(`surveys/${response.id}`);
}).catch((error) => {
ToastsStore.addErrorToast({
- msg: error.errmsg,
+ msg: error,
});
})
}
@@ -104,7 +109,7 @@
-
+
@@ -113,7 +118,7 @@
-
+
@@ -137,7 +142,12 @@
{#if survey.id}
-
+
{/if}
diff --git a/ui/src/components/WorkAdmin.svelte b/ui/src/components/WorkAdmin.svelte
index b9e7c55..8660e1d 100644
--- a/ui/src/components/WorkAdmin.svelte
+++ b/ui/src/components/WorkAdmin.svelte
@@ -2,6 +2,7 @@
import { createEventDispatcher } from 'svelte';
import { goto } from '$app/navigation';
+ import DateTimeInput from './DateTimeInput.svelte';
import { ToastsStore } from '../stores/toasts';
const dispatch = createEventDispatcher();
@@ -12,7 +13,7 @@
dispatch('saved', response);
}, (error) => {
ToastsStore.addErrorToast({
- msg: error.errmsg,
+ msg: error,
});
})
}
@@ -22,7 +23,7 @@
goto(`works`);
}, (error) => {
ToastsStore.addErrorToast({
- msg: error.errmsg,
+ msg: error,
});
})
}
@@ -32,7 +33,7 @@
goto(`works/${response.id}`);
}).catch((error) => {
ToastsStore.addErrorToast({
- msg: error.errmsg,
+ msg: error,
});
})
}
@@ -102,7 +103,7 @@
-
+
@@ -111,7 +112,7 @@
-
+
diff --git a/ui/src/lib/questions.js b/ui/src/lib/questions.js
index bb81ab0..53e2115 100644
--- a/ui/src/lib/questions.js
+++ b/ui/src/lib/questions.js
@@ -120,6 +120,12 @@ export class Question {
async delete() {
if (this.id) {
+ // Start by deleting proposals
+ const proposals = await this.getProposals();
+ for (const p of proposals) {
+ await p.delete();
+ }
+
const res = await fetch(`api/questions/${this.id}`, {
method: 'DELETE',
headers: {'Accept': 'application/json'},
diff --git a/ui/src/lib/surveys.js b/ui/src/lib/surveys.js
index b3904d3..9e1e69f 100644
--- a/ui/src/lib/surveys.js
+++ b/ui/src/lib/surveys.js
@@ -1,3 +1,4 @@
+import { getCorrectionTemplates } from './correctionTemplates';
import { getQuestions } from './questions';
import { Response } from './response';
import { Work } from './works';
@@ -101,9 +102,33 @@ export class Survey {
// Now recopy questions
const questions = await getQuestions(oldSurveyId);
for (const q of questions) {
+ const oldQuestionId = q.id;
+
delete q.id;
q.id_survey = response.id;
- q.save();
+ q.save().then((question) => {
+ q.id = oldQuestionId;
+
+ // Now recopy proposals
+ if (q.kind == "mcq" || q.kind == "ucq") {
+ q.getProposals().then((proposals) => {
+ for (const p of proposals) {
+ delete p.id;
+ p.id_question = question.id;
+ p.save();
+ }
+ });
+ }
+
+ // Now recopy correction templates
+ getCorrectionTemplates(oldQuestionId).then((cts) => {
+ for (const ct of cts) {
+ delete ct.id;
+ ct.id_question = question.id;
+ ct.save();
+ }
+ });
+ });
}
return response;
@@ -115,6 +140,12 @@ export class Survey {
async delete() {
if (this.id) {
+ // Start by deleting questions
+ const questions = await getQuestions(this.id);
+ for (const q of questions) {
+ await q.delete();
+ }
+
const res = await fetch(`api/surveys/${this.id}`, {
method: 'DELETE',
headers: {'Accept': 'application/json'},
diff --git a/ui/src/routes/surveys/[sid]/responses/index.svelte b/ui/src/routes/surveys/[sid]/responses/index.svelte
index f90105f..6414f38 100644
--- a/ui/src/routes/surveys/[sid]/responses/index.svelte
+++ b/ui/src/routes/surveys/[sid]/responses/index.svelte
@@ -13,20 +13,26 @@
{#await surveyP then survey}
- goto(`surveys/${survey.id}/admin`)}
- />
+ {#if $user && $user.is_admin}
+
+ goto(`surveys/${survey.id}/admin`)}
+ />
+ {/if}
+ {#if $user && $user.is_admin && edit}
+ edit = false} />
+ {/if}
+
{#await getQuestions(survey.id)}
diff --git a/ui/src/routes/works/[wid]/rendus.svelte b/ui/src/routes/works/[wid]/rendus.svelte
index 2511e44..55ebb28 100644
--- a/ui/src/routes/works/[wid]/rendus.svelte
+++ b/ui/src/routes/works/[wid]/rendus.svelte
@@ -22,6 +22,14 @@
import { getUsers } from '../../../lib/users';
export let work = null;
+ let usersP = null;
+ work.then((w) => {
+ usersP = getUsers(w.promo, w.group);
+ usersP.then((users) => { nb_users = users.length; });
+ });
+
+ let nb_rendus = 0;
+ let nb_users = 0;
{#await work then w}
@@ -29,12 +37,12 @@
<
{w.title}
+ Rendus {Math.trunc(nb_rendus/nb_users*100)} % ({nb_rendus}/{nb_users})
- {#await getUsers(w.promo, w.group)}
- {:then users}
+ {#await usersP then users}
@@ -48,7 +56,7 @@
{user.login} |
-
+ { nb_rendus += 1; user.show_dl_btn = true; }} />
|
{#await getRepositories(w.id, user.id) then repos}
@@ -82,6 +90,7 @@
|