private void CopyProblemGroupToContest(ProblemGroup problemGroup, int contestId)
        {
            problemGroup.Contest   = null;
            problemGroup.ContestId = contestId;

            problemGroup.Problems
            .ForEach(p => p.SubmissionTypes = this.submissionTypesData.GetAllByProblem(p.Id).ToList());

            this.problemGroupsData.Add(problemGroup);
        }
Пример #2
0
        private void SeedSubmissionsAndTestRuns(OjsDbContext context)
        {
            foreach (var submission in context.Submissions)
            {
                context.Submissions.Remove(submission);
            }

            foreach (var testRun in context.TestRuns)
            {
                context.TestRuns.Remove(testRun);
            }

            foreach (var participantToDelete in context.Participants)
            {
                context.Participants.Remove(participantToDelete);
            }

            Random random = new Random();

            List <TestRun> testRuns = new List <TestRun>();

            var test = new Test
            {
                IsTrialTest = false,
                OrderBy     = 1
            };

            for (int i = 0; i < 1000; i++)
            {
                testRuns.Add(new TestRun
                {
                    TimeUsed   = (random.Next() % 10) + 1,
                    MemoryUsed = (random.Next() % 1500) + 200,
                    ResultType = (TestRunResultType)(random.Next() % 5),
                    Test       = test
                });
            }

            var contest = new Contest
            {
                Name      = "Contest batka 2",
                StartTime = DateTime.Now.AddDays(1),
                EndTime   = DateTime.Now.AddDays(2),
                IsDeleted = false,
                IsVisible = true,
                OrderBy   = 1
            };

            var problemGroup = new ProblemGroup
            {
                OrderBy = 0,
                Contest = contest
            };

            var problem = new Problem
            {
                ProblemGroup  = problemGroup,
                Name          = "Problem",
                MaximumPoints = 100,
                MemoryLimit   = 100,
                OrderBy       = 1
            };

            var user = new UserProfile
            {
                UserName = "******",
                Email    = "*****@*****.**"
            };

            var participant = new Participant
            {
                Contest    = contest,
                IsOfficial = false,
                User       = user
            };

            for (int i = 0; i < 100; i++)
            {
                var submission = new Submission
                {
                    Problem     = problem,
                    Participant = participant
                };

                for (int j = 0; j < (random.Next() % 20) + 5; j++)
                {
                    submission.TestRuns.Add(testRuns[random.Next() % 1000]);
                }

                context.Submissions.Add(submission);
            }
        }
Пример #3
0
        private void SeedCategoryContestProblem(IOjsDbContext context)
        {
            foreach (var categoryToBeDeleted in context.ContestCategories)
            {
                context.ContestCategories.Remove(categoryToBeDeleted);
            }

            foreach (var contestToBeDeleted in context.Contests)
            {
                context.Contests.Remove(contestToBeDeleted);
            }

            foreach (var problemToBeDeleted in context.Problems)
            {
                context.Problems.Remove(problemToBeDeleted);
            }

            var category = new ContestCategory
            {
                Name      = "Category",
                OrderBy   = 1,
                IsVisible = true,
                IsDeleted = false,
            };

            var otherCategory = new ContestCategory
            {
                Name      = "Other Category",
                OrderBy   = 1,
                IsVisible = true,
                IsDeleted = false,
            };

            var contest = new Contest
            {
                Name              = "Contest",
                OrderBy           = 1,
                PracticeStartTime = DateTime.Now.AddDays(-2),
                StartTime         = DateTime.Now.AddDays(-2),
                IsVisible         = true,
                IsDeleted         = false,
                Category          = category
            };

            var otherContest = new Contest
            {
                Name              = "Other Contest",
                OrderBy           = 2,
                PracticeStartTime = DateTime.Now.AddDays(-2),
                StartTime         = DateTime.Now.AddDays(-2),
                IsVisible         = true,
                IsDeleted         = false,
                Category          = category
            };

            var problemGroup1 = new ProblemGroup
            {
                OrderBy = 0,
                Contest = contest
            };

            var problemGroup2 = new ProblemGroup
            {
                OrderBy = 1,
                Contest = contest
            };

            var problem = new Problem
            {
                Name          = "Problem",
                MaximumPoints = 100,
                TimeLimit     = 10,
                MemoryLimit   = 10,
                OrderBy       = 1,
                ShowResults   = true,
                IsDeleted     = false,
                ProblemGroup  = problemGroup1
            };

            var otherProblem = new Problem
            {
                Name          = "Other Problem",
                MaximumPoints = 100,
                TimeLimit     = 10,
                MemoryLimit   = 10,
                OrderBy       = 1,
                ShowResults   = true,
                IsDeleted     = false,
                ProblemGroup  = problemGroup2
            };

            var test = new Test
            {
                InputDataAsString  = "Input",
                OutputDataAsString = "Output",
                OrderBy            = 0,
                IsTrialTest        = false,
                Problem            = problem,
            };

            var user = new UserProfile
            {
                UserName = "******",
                Email    = "*****@*****.**"
            };

            var participant = new Participant
            {
                Contest    = contest,
                IsOfficial = false,
                User       = user
            };

            var submission = new Submission
            {
                Problem     = problem,
                Participant = participant,
                CreatedOn   = DateTime.Now
            };

            for (int i = 0; i < 10; i++)
            {
                test.TestRuns.Add(new TestRun
                {
                    MemoryUsed       = 100,
                    TimeUsed         = 100,
                    CheckerComment   = "Checked!",
                    ExecutionComment = "Executed!",
                    ResultType       = TestRunResultType.CorrectAnswer,
                    Submission       = submission
                });
            }

            context.Problems.Add(problem);
            context.Problems.Add(otherProblem);
            context.Contests.Add(otherContest);
            context.ContestCategories.Add(otherCategory);
            context.Tests.Add(test);
        }