Пример #1
0
		private RunnerSubmition ToRunnerSubmition(UserSolution details)
		{
			return new RunnerSubmition
			{
				Id = details.Id.ToString(),
				Code = Utils.GetSource(
					details.CourseId, 
					details.SlideId, 
					courseManager, 
					details.SolutionCode.Text
					),
				Input = "",
				NeedRun = true
			};
		}
		public Solution(ExerciseSlide slide, UserSolution solution)
		{
			Id = solution.Id;
			UserCode = GetText(solution.SolutionCode);
			Code = slide.Exercise.Solution.BuildSolution(UserCode).SourceCode;
			IsCompilationError = solution.IsCompilationError;
			CompilationError = GetText(solution.CompilationError);
			ActualOutput = GetText(solution.Output);
			IsRightAnswer = solution.IsRightAnswer;
			ExpectedOutput = slide.Exercise.ExpectedOutput.NormalizeEoln();
		}
Пример #3
0
		private async Task<UserSolution> UpdateSubmission(UserSolution submission, RunningResults result)
		{
			var compilationErrorHash = (await textsRepo.AddText(result.CompilationOutput)).Hash;
			var outputHash = (await textsRepo.AddText(result.GetOutput().NormalizeEoln())).Hash;

			var webRunner = submission.CourseId == "web" && submission.SlideId == "runner";
			var exerciseSlide = webRunner ? null : ((ExerciseSlide)courseManager.GetCourse(submission.CourseId).GetSlideById(submission.SlideId));
			var updated = new UserSolution
			{
				Id = submission.Id,
				SolutionCodeHash = submission.SolutionCodeHash,
				CompilationErrorHash = compilationErrorHash,
				CourseId = submission.CourseId,
				SlideId = submission.SlideId,
				IsCompilationError = result.Verdict == Verdict.CompilationError,
				IsRightAnswer = result.Verdict == Verdict.Ok 
					&& (webRunner || exerciseSlide.Exercise.ExpectedOutput.NormalizeEoln() == result.GetOutput().NormalizeEoln()),
				OutputHash = outputHash,
				Timestamp = submission.Timestamp,
				UserId = submission.UserId,
				CodeHash = submission.CodeHash,
				Likes = submission.Likes,
				ExecutionServiceName = submission.ExecutionServiceName,
				Status = SubmissionStatus.Done,
				DisplayName = submission.DisplayName,
				Elapsed = DateTime.Now - submission.Timestamp
			};

			return updated;
		}
Пример #4
0
		public void Delete(UserSolution userSolution)
		{
			db.UserSolutions.Remove(userSolution);
			db.SaveChanges();
		}
Пример #5
0
		protected void Save(UserSolution solution)
		{
			db.UserSolutions.AddOrUpdate(solution);
			db.SaveChanges();
		}