public async Task <ActionResult <TestResultsDto> > CheckAnswers(TestAnswersDto answers, CancellationToken token) { var test = await testStorage.FindTest(answers.TestId, token); if (test == null) { return(UnprocessableEntity("test with this id does not exist")); } if (!User.OwnsResource(test)) { return(Forbid()); } var userAnswers = new Dictionary <Guid, IAnswer>(); foreach (var answer in answers.Answers) { if (!userAnswers.ContainsKey(answer.Id)) { userAnswers.Add(answer.Id, answer.Answer); } } var verdicts = TestChecker.Check(userAnswers, test); var results = new TestResultsDto(); foreach (var(key, _) in verdicts) { var exercise = test.Exercises.First(e => e.Id == key); results.Answers.Add(key, new ExerciseVerdictDto(verdicts[key], exercise.Answer)); await storage.UpdateCardsAwareness(exercise.UsedCardsIds, verdicts[key]? 3 : -3, token); } return(Ok(results)); }
private void Awake() { instance = this; }
static void Main(string[] args) { TestChecker testChecker = new TestChecker(); testChecker.StartChecking(); }