Handle anon participants

This commit is contained in:
Dennis Schoepf 2021-08-03 19:19:06 +02:00
parent 095a50b9a4
commit 92c349a135
3 changed files with 30 additions and 7 deletions

View file

@ -167,7 +167,7 @@
<div id="intro-step3">
<h1>General Questions</h1>
<p>Please provide some additional information about you below:</p>
<label for="name">
<label id="name-label" for="name">
Your name
<input type="text" id="intro-name" name="name" placeholder="e.g. Max" />
</label>

View file

@ -58,7 +58,13 @@ export class Logger {
}
}
public logPersonalData(name: string, age: number, background: string, experience: string) {
public logPersonalData(
name: string,
age: number,
background: string,
experience: string,
anonymous: boolean
) {
const uid = store.getState().uid;
this.database.ref(uid).set({
@ -66,6 +72,7 @@ export class Logger {
age,
background,
experience,
anonymous,
});
}

View file

@ -125,7 +125,12 @@ export class Intro {
const background = this.backgroundRef.value;
const experience = this.experienceRef.value;
if (!name || !age || !background || experience === 'Choose an option...') {
if (
(this.anonymous ? false : !name) ||
!age ||
!background ||
experience === 'Choose an option...'
) {
this.errorRef.style.display = 'block';
return;
} else {
@ -158,11 +163,15 @@ export class Intro {
this.sendGeneralQuestionAnswers();
}
if (currentStep === 5) {
this.sendKnowledgeQuestionAnswers();
}
store.setState((state) => ({ currentIntroStep: state.currentIntroStep + 1 }));
}
private sendDemographicData(name: string, age: number, background: string, experience: string) {
logger.logPersonalData(name, age, background, experience);
logger.logPersonalData(name, age, background, experience, this.anonymous);
}
private sendGeneralQuestionAnswers() {
@ -179,13 +188,20 @@ export class Intro {
this.fb10.value,
];
console.log(answers);
logger.logQuestions(answers);
}
private sendKnowledgeQuestionAnswers() {}
private sendKnowledgeQuestionAnswers() {
const answers = [];
private hideNameInput() {}
logger.logQuestions(answers, true);
}
private hideNameInput() {
this.nameRef.style.display = 'none';
const label = document.querySelector('#name-label') as HTMLElement;
label.style.display = 'none';
}
private showStep() {
if (this.currentStep === 1) {