From e18b07362801f11b37d8491eeb0dd4d5a477c898 Mon Sep 17 00:00:00 2001 From: delphvr <delphine.vanrossum@student.uclouvain.be> Date: Tue, 25 Feb 2025 16:00:54 +0100 Subject: [PATCH] session duration replaced by number of sessions --- frontend/src/lang/fr.json | 1 + frontend/src/lib/api/studies.ts | 4 +-- .../lib/components/studies/StudyForm.svelte | 10 +++--- frontend/src/lib/types/study.svelte.ts | 34 ++++++------------- .../routes/admin/studies/new/+page.server.ts | 10 +++--- 5 files changed, 24 insertions(+), 35 deletions(-) diff --git a/frontend/src/lang/fr.json b/frontend/src/lang/fr.json index 2d0aed6b..ca33c724 100644 --- a/frontend/src/lang/fr.json +++ b/frontend/src/lang/fr.json @@ -346,6 +346,7 @@ "startDate": "Date de début", "endDate": "Date de fin", "chatDuration": "Durée des sessions (en minutes)", + "nbSession": "Nombre de sessions", "updated": "Étude mise à jour avec succès", "noChanges": "Aucune modification", "updateError": "Erreur lors de la mise à jour de l'étude", diff --git a/frontend/src/lib/api/studies.ts b/frontend/src/lib/api/studies.ts index d70b2eab..f1722d69 100644 --- a/frontend/src/lib/api/studies.ts +++ b/frontend/src/lib/api/studies.ts @@ -26,7 +26,7 @@ export async function createStudyAPI( description: string, startDate: Date, endDate: Date, - chatDuration: number, + nbSession: number, tests: { type: string; id?: number }[], consentParticipation: string, consentPrivacy: string, @@ -41,7 +41,7 @@ export async function createStudyAPI( description, start_date: formatToUTCDate(startDate), end_date: formatToUTCDate(endDate), - chat_duration: chatDuration, + nb_session: nbSession, tests, consent_participation: consentParticipation, consent_privacy: consentPrivacy, diff --git a/frontend/src/lib/components/studies/StudyForm.svelte b/frontend/src/lib/components/studies/StudyForm.svelte index 0f8bb45b..de7e8434 100644 --- a/frontend/src/lib/components/studies/StudyForm.svelte +++ b/frontend/src/lib/components/studies/StudyForm.svelte @@ -30,7 +30,7 @@ let description = study ? study.description : ''; let startDate = study ? study.startDate : new Date(); let endDate = study ? study.endDate : new Date(); - let chatDuration = study ? study.chatDuration : 30; + let nbSession = study ? study.nbSession : 8; let tests = study ? [...study.tests] : []; let consentParticipation = study ? study.consentParticipation : ''; let consentPrivacy = study ? study.consentPrivacy : ''; @@ -106,14 +106,14 @@ <DateInput class="input w-full" id="endDate" name="endDate" date={endDate} required /> <!-- Chat Duration --> - <label class="label" for="chatDuration">{$t('studies.chatDuration')} *</label> + <label class="label" for="nbSession">{$t('studies.nbSession')} *</label> <input class="input w-full" type="number" - id="chatDuration" - name="chatDuration" + id="nbSession" + name="nbSession" min="0" - bind:value={chatDuration} + bind:value={nbSession} required /> diff --git a/frontend/src/lib/types/study.svelte.ts b/frontend/src/lib/types/study.svelte.ts index 82261027..a28ba68e 100644 --- a/frontend/src/lib/types/study.svelte.ts +++ b/frontend/src/lib/types/study.svelte.ts @@ -18,7 +18,7 @@ export default class Study { private _description: string; private _startDate: Date; private _endDate: Date; - private _chatDuration: number; + private _nbSession: number = $state(0); private _users: User[]; private _consentParticipation: string; private _consentPrivacy: string; @@ -32,7 +32,7 @@ export default class Study { description: string, startDate: Date, endDate: Date, - chatDuration: number, + nbSession: number, users: User[], consentParticipation: string, consentPrivacy: string, @@ -45,7 +45,7 @@ export default class Study { this._description = description; this._startDate = startDate; this._endDate = endDate; - this._chatDuration = chatDuration; + this._nbSession = nbSession; this._users = users; this._consentParticipation = consentParticipation; this._consentPrivacy = consentPrivacy; @@ -90,12 +90,12 @@ export default class Study { this._endDate = value; } - get chatDuration(): number { - return this._chatDuration; + get nbSession(): number { + return this._nbSession; } - set chatDuration(value: number) { - this._chatDuration = value; + set nbSession(value: number) { + this._nbSession = value; } get users(): User[] { @@ -155,7 +155,7 @@ export default class Study { description: string, startDate: Date, endDate: Date, - chatDuration: number, + nbSession: number, consentParticipation: string, consentPrivacy: string, consentRights: string, @@ -163,19 +163,7 @@ export default class Study { tests: (SurveyTypingSvelte | Survey)[], f: fetchType = fetch ): Promise<Study | null> { - const id = await createStudyAPI( - f, - title, - description, - startDate, - endDate, - chatDuration, - [], - consentParticipation, - consentPrivacy, - consentRights, - consentStudyData - ); + const id = await createStudyAPI(f, title, description, startDate, endDate, nbSession, []); if (id) { return new Study( @@ -184,7 +172,7 @@ export default class Study { description, startDate, endDate, - chatDuration, + nbSession, [], consentParticipation, consentPrivacy, @@ -207,7 +195,7 @@ export default class Study { if (data.description) this._description = data.description; if (data.start_date) this._startDate = parseToLocalDate(data.start_date); if (data.end_date) this._endDate = parseToLocalDate(data.end_date); - if (data.chat_duration) this._chatDuration = data.chat_duration; + if (data.chat_duration) this._nbSession = data.chat_duration; if (data.consent_participation) this._consentParticipation = data.consent_participation; if (data.consent_privacy) this._consentPrivacy = data.consent_privacy; if (data.consent_rights) this._consentRights = data.consent_rights; diff --git a/frontend/src/routes/admin/studies/new/+page.server.ts b/frontend/src/routes/admin/studies/new/+page.server.ts index d26d02e0..3d265202 100644 --- a/frontend/src/routes/admin/studies/new/+page.server.ts +++ b/frontend/src/routes/admin/studies/new/+page.server.ts @@ -9,7 +9,7 @@ export const actions: Actions = { let description = formData.get('description')?.toString(); const startDateStr = formData.get('startDate')?.toString(); const endDateStr = formData.get('endDate')?.toString(); - const chatDurationStr = formData.get('chatDuration')?.toString(); + const nbSessionStr = formData.get('nbSession')?.toString(); const consentParticipation = formData.get('consentParticipation')?.toString(); const consentPrivacy = formData.get('consentPrivacy')?.toString(); @@ -20,7 +20,7 @@ export const actions: Actions = { !title || !startDateStr || !endDateStr || - !chatDurationStr || + !nbSessionStr || !consentParticipation || !consentPrivacy || !consentRights || @@ -44,8 +44,8 @@ export const actions: Actions = { }; } - const chatDuration = parseInt(chatDurationStr, 10); - if (isNaN(chatDuration)) { + const nbSession = parseInt(nbSessionStr, 10); + if (isNaN(nbSession)) { return { message: 'Invalid request 3' }; @@ -74,7 +74,7 @@ export const actions: Actions = { description, startDate, endDate, - chatDuration, + nbSession, tests, consentParticipation, consentPrivacy, -- GitLab