/// <summary> /// Build and runs an assignment and checks the scores for the user submitted code. /// </summary> /// <param name="runJob">See RunController.</param> /// <returns></returns> public HttpResponseMessage Post(RunController.RunJob runJob) { _compiler.CompileFromPlainText(_participant, runJob.Code); var runResult = _runner.RunAndCheckInput(_participant); var correctOutput = IsCorrectOutput(runResult); var timeDifference = TimeDifferenceHelper.GetTimeDifference(_participant.Progress.StartTime); var score = ScoreHelper.CreateScore(_participant.Progress.Assignment, _participant, correctOutput, timeDifference); _context.Scores.Add(score); _context.Progresses.Remove(_participant.Progress); _context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Created)); }