예제 #1
0
        public async Task <IActionResult> Submission(int pid, int sid,
                                                     [FromServices] IJudgingStore judgings)
        {
            var prob = await Store.FindAsync(pid);

            if (prob == null)
            {
                return(NotFound());
            }
            var uid = int.Parse(User.GetUserId() ?? "-100");

            var subs = await Submits.ListWithJudgingAsync(
                predicate : s => s.ProblemId == prob.ProblemId && s.ContestId == 0 &&
                s.Author == uid && s.SubmissionId == sid,
                selector : (s, j) => new CodeViewModel
            {
                CompileError   = j.CompileError,
                CodeLength     = s.CodeLength,
                ExecuteMemory  = j.ExecuteMemory,
                ExecuteTime    = j.ExecuteTime,
                Code           = s.SourceCode,
                LanguageName   = s.l.Name,
                Status         = j.Status,
                JudgingId      = j.JudgingId,
                SubmissionId   = s.SubmissionId,
                DateTime       = s.Time,
                FileExtensions = s.l.FileExtension,
            });

            var sub = subs.SingleOrDefault();

            if (sub == null)
            {
                return(NotFound());
            }
            sub.ProblemTitle = prob.Title;
            sub.Details      = await judgings.GetDetailsAsync(prob.ProblemId, sub.JudgingId);

            return(Window(sub));
        }
예제 #2
0
        public async Task <IActionResult> Detail(int cid, int sid, int?jid,
                                                 [FromServices] IJudgingStore store2)
        {
            var submit = await Store.FindAsync(sid, true);

            if (submit == null || submit.ContestId != cid)
            {
                return(NotFound());
            }
            var judgings = submit.Judgings;

            var prob = Problems.SingleOrDefault(p => p.ProblemId == submit.ProblemId);

            if (prob == null)
            {
                return(NotFound());              // the problem is deleted later
            }
            var judging = jid.HasValue
                ? judgings.SingleOrDefault(j => j.JudgingId == jid.Value)
                : judgings.SingleOrDefault(j => j.Active);

            if (judging == null)
            {
                return(NotFound());
            }

            return(View(new JuryViewSubmissionModel
            {
                Submission = submit,
                Judging = judging,
                AllJudgings = judgings,
                Details = await store2.GetDetailsAsync(submit.ProblemId, judging.JudgingId),
                Team = await Facade.Teams.FindByIdAsync(cid, submit.Author),
                Problem = prob,
                Language = Languages[submit.Language],
            }));
        }
예제 #3
0
        public async Task <IActionResult> Submission(int cid, int sid,
                                                     [FromServices] ISubmissionStore submissions,
                                                     [FromServices] IJudgingStore judgings)
        {
            if (Team == null)
            {
                return(Forbid());
            }

            var models = await submissions.ListWithJudgingAsync(
                predicate : s => s.SubmissionId == sid && s.ContestId == cid,
                selector : (s, j) => new SubmissionViewModel
            {
                SubmissionId   = s.SubmissionId,
                Verdict        = j.Status,
                Time           = s.Time,
                Problem        = Problems.Find(s.ProblemId),
                CompilerOutput = j.CompileError,
                Language       = Languages[s.Language],
                SourceCode     = s.SourceCode,
                Grade          = j.TotalScore ?? 0,
                TeamId         = s.Author,
                JudgingId      = j.JudgingId,
                ExecuteMemory  = j.ExecuteMemory,
                ExecuteTime    = j.ExecuteTime,
            });

            var model = models.SingleOrDefault();

            if (model == null)
            {
                return(NotFound());
            }
            Dictionary <int, (int ac, int tot)> substat = ViewBag.TeamStatistics;

            model.TeamName = (await FindTeamByIdAsync(model.TeamId)).TeamName;

            if (model.TeamId != Team.TeamId)
            {
                if (Contest.StatusAvaliable == 2)
                {
                    if (substat.GetValueOrDefault(model.Problem.ProblemId).ac == 0)
                    {
                        return(Forbid());
                    }
                }
                else if (Contest.StatusAvaliable == 0)
                {
                    return(Forbid());
                }
            }

            var tcs = await judgings.GetDetailsAsync(model.Problem.ProblemId, model.JudgingId);

            if (!model.Problem.Shared)
            {
                tcs = tcs.Where(t => !t.Item2.IsSecret);
            }
            ViewBag.Runs = tcs;

            return(Window(model));
        }