Within our system, we have two arrays: AnswersList[], which contains all potential answers for questions. We then further divided AnswersList[] into six separate arrays: gender, age, disability, ethnic origin, religion, and sexual orientation. For this specific issue, let's focus on genderList[].
The primary array is EqualityAnswers[], which is of type IApplicantAnswers.
import {IAnswers} from "../Enum/answer.model";
export interface IApplicantAnswers {
ApplicantAnswersKey: number;
CompetitionKey: number;
Gender: IAnswers;
Age: IAnswers;
SexualOrientation: IAnswers;
Religion: IAnswers;
EthnicOrigin: IAnswers;
Disability:IAnswers;
}
Our goal is to examine genderList[], also of type IAnswer.
export interface IAnswers {
AnswerKey: number;
QuestionKey: number;
Name: string;
Description: string;
}
We aim to analyze each genderList[i].AnswerKey to determine how many individuals selected that answer in EqualityAnswers[].
Initially, the approach was to iterate through genderList[] and filter EqualityAnswers[].Gender.AnswerKey to obtain the count.
The challenge lies in assigning this data to an array of ResourceList.
export class ResourceList {
Name: string;
Count: number;
}
This array would be named genderCountList: ResourceList[];
The intention is for genderCountList to appear like this: {name:"female", count:2}, {name:"male", count:5}, {name:"prefer not to say", count: 3}
Subsequently, we can dynamically construct tables using this information, enabling us to add answers at the database level.
The only setback is a mental block preventing me from structuring this effectively.