Question: ? ? * * * * Consumes a question and a potential answer, and returns whether or not the answer is valid ( but not

??****
Consumes a question and a potential "answer", and returns whether or not
the "answer" is valid (but not necessarily correct). For a "short_answer_question",
any answer is valid. But for a 'multiple_choice_question', the "answer" must
be exactly one of the options.
*/
export function isValid(question: Question, answer: string): boolean {
if(question.type === "short_answer_question"){
return true;
}
else if(question.type == "multiple_choice_question" && Option){
const trimmedAnswer = answer.trim().tolowerCase();
return Option.map(Option => Option.trim().toLowerCase()). includes(trimmedAnswer);
}
else
return false;
}
??****
Consumes a question and produces a string representation combining the
"id" and first 10 characters of the "name". The two strings should be
separated by ": ". So for example, the question with id 9 and the
name "My First Question" would become "9: My First Q".
*
export function toShortForm(question: Question): string {
return "";
}
 ??**** Consumes a question and a potential "answer", and returns whether

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!