private LogEvent LogEventForAnswer(Question question, Answer answer, AnswerResult answerResult) { return LogEvent .OfSeverity(Severity.Info) .Add("site", "learnsomesql.com") .Add("eventName", "submittedAnswer") .Add("question", question.Description) .Add("correctQuery", question.CorrectQuery) .Add("submittedQuery", answer.Query) .Add("isCorrect", answerResult.IsCorrect); }
public AnswerResult SubmitAnswer(Answer answer) { var queryResult = m_SqlExecutor.ExecuteQuery(answer.Query); var question = m_Questions[answer.QuestionIdentifier]; var correctResult = m_SqlExecutor.ExecuteQuery(question.CorrectQuery).ExpectSuccess(); var isCorrect = queryResult.Map( correctResult.Equals, error => false ); var hint = queryResult.Map( submittedResult => m_HintGenerator.GenerateHint(correctResult, submittedResult), error => Option.None<string>() ); var answerResult = new AnswerResult(queryResult, isCorrect, hint); m_Logger.Log(LogEventForAnswer(question, answer, answerResult)); return answerResult; }