Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class AnswerResult {
userAnswer: string;
isValid: boolean;
correctAnswer: string;
class AnswerQuestion {
questionRepository: QuestionRepository;
answerValidationPolicy: AnswerValidationPolicy;
async invoke(questionId: string, userAnswer: string): Promise<AnswerResult> {
const question = await this.questionRepository.getById(questionId);
const correctAnswer = question.answer;
const isAnswerCorrect = await this.answerValidationPolicy.isAnswerValid(
userAnswer, correctAnswer
return new AnswerResult(userAnswer, isAnswerCorrect, correctAnswer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.