diff --git a/frontend/src/lang/fr.json b/frontend/src/lang/fr.json index 2d0aed6bfd0bb051fcb38f66e1ca9bffb5e278e8..ca33c724bcf0b256106c1e69e449275c13f18808 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 d70b2eab7fe412ef7f803f2bd043f45adc42e30a..f1722d690a6908613cb567c877fbd47a0508095d 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 0f8bb45b6846a723090b10d2e1ef9e841869ed43..de7e8434225391925337db985b66bd3cbb51128e 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 8226102785d45b41c5f30e90e0812978dde1bd03..a28ba68e29c2c156a16e2ac9e1ecccc987f265f2 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 d26d02e0f2bd37130574894b29e34da11734ae8a..3d2652024ebd9e1dbffae1d6cb6a83815307c1b9 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,