Newer
Older
export async function getSurveyAPI(fetch: fetchType, survey_id: number) {
const response = await fetch(`/api/surveys/${survey_id}`);
if (!response.ok) return null;
Delphine van Rossum
a validé
code: string,
Delphine van Rossum
a validé
uid: number | null,
const response = await fetch(`/api/surveys/responses`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
code,
sid,
uid,
survey_id,
question_id,
group_id,
selected_id: option_id,
response_time,
text
})
export async function getSurveyScoreAPI(fetch: fetchType, survey_id: number, sid: string) {
const response = await fetch(`/api/surveys/${survey_id}/score/${sid}`);
if (!response.ok) return null;
return await response.json();
Delphine van Rossum
a validé
export async function sendSurveyResponseInfoAPI(
Delphine van Rossum
a validé
survey_id: number,
sid: string,
birthyear: number,
gender: string,
primary_language: string,
other_language: string,
Delphine van Rossum
a validé
education: string
) {
const response = await fetch(`/api/surveys/info/${survey_id}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
sid,
birthyear,
gender,
primary_language,
other_language,
Delphine van Rossum
a validé
});