コード例 #1
0
ファイル: GymController.cs プロジェクト: yang-er/OnlineJudge
        public async Task <IActionResult> FetchTestcase(
            string prob, int tcid, string filetype,
            [FromServices] ITestcaseStore testcases)
        {
            if (filetype == "input")
            {
                filetype = "in";
            }
            else if (filetype == "output")
            {
                filetype = "out";
            }
            else
            {
                return(NotFound());
            }

            if (TooEarly && !ViewData.ContainsKey("IsJury"))
            {
                return(NotFound());
            }
            var problem = Problems.Find(prob);

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

            var tc = await testcases.FindAsync(problem.ProblemId, tcid);

            if (tc == null)
            {
                return(NotFound());
            }
            if (tc.IsSecret && !problem.Shared)
            {
                return(NotFound());
            }

            var file = testcases.GetFile(tc, filetype);

            if (!file.Exists)
            {
                return(NotFound());
            }

            return(File(
                       fileStream: file.CreateReadStream(),
                       contentType: "application/octet-stream",
                       fileDownloadName: $"{problem.ShortName}.t{tcid}.{filetype}"));
        }
コード例 #2
0
 public KattisExportProvider(
     IProblemStore store,
     ISubmissionStore submissions,
     IExecutableStore execs,
     ITestcaseStore tcs,
     IMarkdownService markdown,
     IStaticFileRepository io2)
 {
     Store       = store;
     StaticFile  = io2;
     Markdown    = markdown;
     Submissions = submissions;
     Executables = execs;
     Testcases   = tcs;
 }
コード例 #3
0
        public async Task <IActionResult> Overview(int pid,
                                                   [FromServices] ITestcaseStore tcs,
                                                   [FromServices] IArchiveStore archs,
                                                   [FromServices] IProblemsetStore cps)
        {
            ViewBag.TestcaseCount = await tcs.CountAsync(Problem);

            ViewBag.Archive = await archs.FindInternalAsync(pid);

            ViewBag.Contests = await cps.ListByProblemAsync(pid);

            ViewBag.Users = await Problems.ListPermittedUserAsync(pid);

            return(View(Problem));
        }
コード例 #4
0
        public async Task <IActionResult> List(
            [FromServices] ITestcaseStore tcs,
            int pid, bool all = false, int page = 1)
        {
            if (page < 0)
            {
                return(NotFound());
            }

            Expression <Func <Submission, bool> > cond =
                s => s.ProblemId == pid;

            if (!all)
            {
                cond = cond.Combine(s => s.ExpectedResult != null);
            }

            var(result, totPage) = await Submissions.ListWithJudgingAsync((page, 30), cond, true);

            totPage = (totPage - 1) / 30 + 1;

            if (result.Any())
            {
                var id1 = result.First().SubmissionId;
                var id2 = result.Last().SubmissionId;
                if (id1 > id2)
                {
                    (id1, id2) = (id2, id1);
                }
                var cond2 = cond.Combine(s => s.SubmissionId >= id1 && s.SubmissionId <= id2);
                var names = await Submissions.GetAuthorNamesAsync(cond2);

                foreach (var item in result)
                {
                    item.AuthorName = names.GetValueOrDefault(item.SubmissionId, "SYSTEM");
                }
            }

            ViewBag.TotalPage = totPage;
            ViewBag.Page      = page;
            ViewBag.AllSub    = all;
            ViewBag.Testcase  = await tcs.ListAsync(pid);

            return(View(result));
        }
コード例 #5
0
 public TestcasesController(ITestcaseStore store)
 {
     Store = store;
 }
コード例 #6
0
 public TestcasesController(ITestcaseStore testcases, IJudgingStore judgings)
 {
     Testcases = testcases;
     Judgings  = judgings;
 }