Exemple #1
0
        public async Task <IActionResult> Detail(
            int pid, int sid, int?jid,
            [FromServices] ILanguageStore langs)
        {
            var s = await Submissions.FindAsync(sid, true);

            if (s == null || s.ProblemId != pid)
            {
                return(NotFound());
            }
            var j = s.Judgings.SingleOrDefault(jj => jid.HasValue ? jj.JudgingId == jid : jj.Active);

            if (j == null)
            {
                return(NotFound());
            }
            var l = await langs.FindAsync(s.Language);

            var det = await Judgings.GetDetailsAsync(pid, j.JudgingId);

            var uname = await Submissions.GetAuthorNameAsync(sid);

            return(View(new ViewSubmissionModel
            {
                SubmissionId = s.SubmissionId,
                ContestId = s.ContestId,
                Status = j.Status,
                ExecuteMemory = j.ExecuteMemory,
                ExecuteTime = j.ExecuteTime,
                Judging = j,
                Expected = s.ExpectedResult,
                JudgingId = j.JudgingId,
                LanguageId = s.Language,
                Time = s.Time,
                SourceCode = s.SourceCode,
                CompileError = j.CompileError,
                CombinedRunCompare = Problem.CombinedRunCompare,
                TimeLimit = Problem.TimeLimit,
                AllJudgings = s.Judgings,
                UserName = uname ?? "SYSTEM",
                Details = det,
                TestcaseNumber = det.Count(),
                Author = s.Author,
                ServerName = j.Server ?? "UNKNOWN",
                LanguageName = l.Name,
                LanguageExternalId = l.Id,
                TimeFactor = l.TimeFactor,
            }));
        }
Exemple #2
0
        public async Task <IActionResult> Submit(
            CodeSubmitModel model,
            [FromServices] ILanguageStore langs)
        {
            var lang = await langs.FindAsync(model.Language);

            if (lang == null)
            {
                return(BadRequest());
            }

            var sub = await Submissions.CreateAsync(
                code : model.Code,
                language : lang.Id,
                problemId : Problem.ProblemId,
                contestId : null,
                userId : int.Parse(User.GetUserId()),
                ipAddr : HttpContext.Connection.RemoteIpAddress,
                via : "polygon-page",
                username : User.GetUserName(),
                expected : Verdict.Unknown);

            return(RedirectToAction(nameof(Detail), new { sid = sub.SubmissionId }));
        }