Beispiel #1
0
        public async Task <IActionResult> Submission(int cid, int sid,
                                                     [FromServices] ISubmissionStore submissions)
        {
            int teamid = Team.TeamId;

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

            var model = models.SingleOrDefault();

            if (model == null)
            {
                return(NotFound());
            }
            return(Window(model));
        }
Beispiel #2
0
        public async Task <IActionResult> Home(int cid,
                                               [FromServices] ISubmissionStore submits,
                                               [FromServices] IClarificationStore clars)
        {
            int teamid = Team.TeamId;
            var board  = await FindScoreboardAsync(teamid);

            ViewBag.Clarifications = await clars.ListAsync(cid,
                                                           c => (c.Sender == null && c.Recipient == null) ||
                                                           c.Recipient == teamid || c.Sender == teamid);

            ViewBag.Submissions =
                await submits.ListWithJudgingAsync(
                    predicate : s => s.ContestId == cid && s.Author == teamid,
                    selector : (s, j) => new SubmissionViewModel
            {
                Grade        = j.TotalScore ?? 0,
                Language     = Languages[s.Language],
                SubmissionId = s.SubmissionId,
                Time         = s.Time,
                Verdict      = j.Status,
                Problem      = Problems.Find(s.ProblemId),
            });

            return(View(board));
        }
Beispiel #3
0
        public async Task <IActionResult> Problemset(string prob,
                                                     [FromServices] IProblemStore probs)
        {
            if (TooEarly && !ViewData.ContainsKey("IsJury"))
            {
                return(NotFound());
            }
            var problem = Problems.Find(prob);

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

            var viewFile = probs.GetFile(problem, "view.html");
            var view     = await viewFile.ReadAsync();

            if (string.IsNullOrEmpty(view))
            {
                return(NotFound());
            }

            ViewData["Content"] = view;
            return(View("ProblemView"));
        }
Beispiel #4
0
        public async Task <IActionResult> ProblemView(string prob,
                                                      [FromServices] ISubmissionStore submissions,
                                                      [FromServices] IProblemStore problems)
        {
            if (TooEarly && !ViewData.ContainsKey("IsJury"))
            {
                return(NotFound());
            }
            var problem = Problems.Find(prob);

            if (problem == null)
            {
                return(NotFound());
            }
            ViewBag.CurrentProblem = problem;

            var fileInfo = problems.GetFile(problem, "view.html");
            var view     = await fileInfo.ReadAsync();

            if (string.IsNullOrEmpty(view))
            {
                return(NotFound());
            }
            ViewData["Content"] = view;

            int pid = problem.ProblemId;
            int tid = Team?.TeamId ?? -1000;
            int cid = Contest.ContestId;

            var model = await submissions.ListWithJudgingAsync(
                s => s.ProblemId == pid && s.Author == tid && s.ContestId == cid);

            return(View(model));
        }
        public void TrenTest()
        {
            var probleme = new Problems();
            float distanta_pasare = probleme.Tren(50, 10);

            Assert.AreEqual(distanta_pasare, 25);
        }
        public void RataTest()
        {
            var probleme = new Problems();
            double rata = probleme.Rata(40000, 7.67, 20);

            Assert.AreEqual(Math.Round(rata,2), 366.49);
        }
 public void CiuperciTest()
 {
     var probleme = new Problems();
     var ciuperci= probleme.Ciuperci(121, 10);
     Assert.AreEqual(ciuperci[0], 11, "Numarul de Ciuperci albe");
     Assert.AreEqual(ciuperci[1], 110, "Numarul de Ciuperci rosii");
 }
 public static Problems.QueensPuzzle.State ApplyAction(Problems.QueensPuzzle.State state, int action)
 {
     var copy = new int[state.ColumnPlacements.Length];
     state.ColumnPlacements.CopyTo(copy, 0);
     copy[state.PlacementsCount] = action;
     return new Problems.QueensPuzzle.State(copy);
 }
        public override ProblemCollection Check(TypeNode type)
        {
            if (type == null)
            {
                return(Problems);
            }

            if (!IsPresenterImplementation(type))
            {
                return(Problems);
            }

            if (type.Name.Name.Equals("Presenter", StringComparison.OrdinalIgnoreCase))
            {
                Problems.Add(new Problem(
                                 GetResolution(type.FullName))
                {
                    Certainty    = 100,
                    FixCategory  = FixCategories.Breaking,
                    MessageLevel = MessageLevel.Warning
                });
            }

            return(Problems);
        }
Beispiel #10
0
        public override void VisitReturn(ReturnNode returnInstruction)
        {
            if (_problemRound && IsSqlGeneratingFunction(_currentMember))
            {
                if (returnInstruction.Expression != null && IsStringIsh(returnInstruction.Expression.Type) && !IsConst(returnInstruction.Expression) && !_dirty.IsSafe(returnInstruction.Expression))
                {
                    if (!_params.Contains(returnInstruction.Expression.UniqueKey) || _dirty.MarkedDirtyInsideMethod(returnInstruction.Expression)) //if the return IS a param, then it's also got to be marked dirty inside the method (like if you pass a SQL builder in, append stuff to it, and then return it back out)
                    {
                        Problems.Add(new Problem(this.GetResolution(returnInstruction.Expression.GetName(), _dirty.GetDirtyDetails(returnInstruction.Expression, returnInstruction, true)), returnInstruction.SourceContext));
                    }
                }

                var currentMethod = _currentMember as Method;
                foreach (var p in currentMethod.Parameters.Where(w => !IsTypeSafe(w.Type)))
                {
                    //if it's been marked dirty (aside from being a param), DANGER!
                    if (_dirty.MarkedDirtyInsideMethod(p))
                    {
                        Problems.Add(new Problem(this.GetResolution(p.GetName(), _dirty.GetDirtyDetails(p, returnInstruction, false)), returnInstruction.SourceContext));
                    }
                }
            }

            base.VisitReturn(returnInstruction);
        }
 private void CheckCollaborators(TypeNode type)
 {
     if (CreateCollabCount().Calculate(type) > 3)
     {
         string[] resolutionParams = { type.FullName };
         Problems.Add(new Problem(new Resolution("Type {0} has more than 3 collaborators", resolutionParams), type));
     }
 }
Beispiel #12
0
 public override ProblemCollection Check(Member member)
 {
     if (member.IsControllerAction() && !member.HasActionMethodSelectorAttribute())
     {
         Problems.Add(new Problem(this.GetResolution()));
     }
     return(Problems);
 }
Beispiel #13
0
 public override ProblemCollection Check(Member member)
 {
     if (member.IsControllerAction() && member.Attributes.Any(a => a.Type.FullName == "CDS.Web.Authorization.SkipAuthorizeAttribute"))
     {
         Problems.Add(new Problem(this.GetResolution()));
     }
     return(Problems);
 }
 public void AddProblem(string problem)
 {
     if (null == Problems)
     {
         Problems = new List <string>();
     }
     Problems.Add(problem);
 }
        private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var      selectedId     = (sender as ListBox).SelectedIndex;
            Problems clickedProblem = (Problems)listofitems[selectedId];
            var      navCont        = new CodeEditorContext(clickedProblem, "Problems");

            Frame.Navigate(typeof(CodeEditor), navCont);
        }
Beispiel #16
0
 private void CheckForLargeClass(TypeNode type)
 {
     if (MethodCount(type) > 8)
     {
         string[] resolutionParams = { type.FullName };
         Problems.Add(new Problem(new Resolution("Type {0} has too many methods/properties", resolutionParams)));
     }
 }
 private void CheckType(TypeNode type, Member member)
 {
     if (IsAssignableTo(type, MD5Type))
     {
         var resolution = GetResolution(type, member.FullName);
         Problems.Add(new Problem(resolution));
     }
 }
Beispiel #18
0
        public ActionResult DeleteConfirmed(int id)
        {
            Problems problems = db.Problems.Find(id);

            db.Problems.Remove(problems);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void GetOrderedSquaresTests(int[] input, int[] expectedOutput)
        {
            // Act
            var actual = Problems.GetOrderedSquares(input);

            // Assert
            CollectionAssert.AreEqual(expectedOutput, actual);
        }
Beispiel #20
0
 private void CheckLongIdentifier(Identifier identifier)
 {
     if (identifier.Name.Length > 20 & !(identifier.Name.Contains("<") || (identifier.Name.Contains("$"))))
     {
         string[] resolutionParams = { identifier.Name };
         Problems.Add(new Problem(new Resolution("Identifier {0} has more than 20 characters", resolutionParams), _currentNode));
     }
 }
        public void AddProblem(ProblemMetadata problemMetadata)
        {
            ArgumentUtility.CheckNotNull("problemMetadata", problemMetadata);
            var resolution = GetResolution(problemMetadata.ExpectedFragment, problemMetadata.GivenFragment);
            var problem    = new Problem(resolution, problemMetadata.SourceContext, CheckId);

            Problems.Add(problem);
        }
        public void GetTwoPrimeWithSumEqualsTests(int sum, int first, int second)
        {
            // Act
            var tuple = Problems.GetTwoPrimeWithSumEquals(sum);

            // Assert
            Assert.That(tuple, Is.EqualTo(new Tuple <int, int>(first, second)));
        }
Beispiel #23
0
 public void PepeneTest()
 {
     var probleme = new Problems();
     string par = probleme.Pepene(12);
     string impar = probleme.Pepene(11);
     Assert.AreEqual(par, "DA");
     Assert.AreEqual(impar, "NU");
 }
Beispiel #24
0
 private void CheckForLongMethod(Method method)
 {
     if (CreateMetrics().Calculate(method) > 10)
     {
         string[] resolutionParams = { method.FullName };
         Problems.Add(new Problem(new Resolution("Method {0} is too long", resolutionParams)));
     }
 }
Beispiel #25
0
 public T RequiresComponent <T>(string expectedLocation = null) where T : Component
 {
     if (!Entity.TryGetComponentInChildren(out T component))
     {
         Problems.Add(new MissingComponent(Entity, typeof(T), of, expectedLocation));
     }
     return(component);
 }
 private void CheckParamsLength(Method method)
 {
     if (method.Parameters.Count > 3)
     {
         string[] resolutionParams = { method.FullName };
         Problems.Add(new Problem(new Resolution("Method {0} has too many parameters", resolutionParams)));
     }
 }
 private void CheckStatic(TypeNode containerType, TypeNode typeOfStatic)
 {
     if (ImplementsILogger(typeOfStatic))
     {
         var resolution = GetResolution(containerType, typeOfStatic, LoggerInterfaceFullName);
         Problems.Add(new Problem(resolution));
     }
 }
        public async Task <bool> LoadAsync()
        {
            if (string.IsNullOrEmpty(Path))
            {
                return(false);
            }
            try
            {
                FileStream fs   = new FileStream(Path, FileMode.Open, FileAccess.Read);
                byte[]     data = new byte[fs.Length];
                await fs.ReadAsync(data, 0, data.Length).ConfigureAwait(false);

                List <ProblemViewModel> ps = new List <ProblemViewModel>();
                data = DocumentHelper.UnpackData(data);
                if (data == null)
                {
                    return(false);
                }
                MemoryStream ms = new MemoryStream(data);
                while (ms.Position < ms.Length)
                {
                    ProblemViewModel problem = null;
                    Dispatcher.BeginInvoke((Action)(() => {
                        problem = ProblemViewModel.CreateFromStream(ms);
                    })).Wait();
                    if (problem == null)
                    {
                        return(false);
                    }
                    if (!await Task.Factory.StartNew(() =>
                    {
                        if (problem == null || !problem.Load(ms))
                        {
                            return(false);
                        }
                        return(true);
                    }).ConfigureAwait(false))
                    {
                        return(false);
                    }
                    ps.Add(problem);
                }
                ms.Close();
                Dispatcher.BeginInvoke((Action)(() => {
                    Problems.Clear();
                    foreach (var problem in ps)
                    {
                        Problems.Add(problem);
                    }
                }));
                IsDirty = false;
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #29
0
        protected TeamModel CreateTeamViewModel(
            IScoreboardRow row,
            Tenant.Entities.Affiliation?aff,
            Tenant.Entities.Category?cat,
            bool ispublic,
            ProblemStatisticsModel[]?stat = null)
        {
            var prob = new ScoreCellModel[Problems.Count];

            foreach (var pp in row.ScoreCache)
            {
                var p = Problems.Find(pp.ProblemId);
                if (p == null)
                {
                    continue;
                }
                var pid = p.Rank - 1;
                prob[pid] = RankingStrategy.ToCell(pp, ispublic);

                if (stat == null)
                {
                    continue;
                }
                if (prob[pid].Score.HasValue)
                {
                    var score = prob[pid].Score !.Value;
                    if (prob[pid].IsFirstToSolve)
                    {
                        stat[pid].FirstSolve ??= score;
                    }
                    stat[pid].Accepted++;
                    stat[pid].Rejected += prob[pid].JudgedCount - 1;
                    stat[pid].Pending  += prob[pid].PendingCount;
                    stat[pid].MaxScore  = System.Math.Max(stat[pid].MaxScore, score);
                }
                else
                {
                    stat[pid].Rejected += prob[pid].JudgedCount;
                    stat[pid].Pending  += prob[pid].PendingCount;
                }
            }

            var(points, penalty, lastac) = RankingStrategy.GetRanks(row.RankCache, ispublic);
            return(new TeamModel
            {
                TeamId = row.TeamId,
                TeamName = row.TeamName,
                Affiliation = aff?.Name ?? "",
                AffiliationId = aff?.Abbreviation ?? "null",
                Category = cat?.Name ?? "",
                CategoryColor = cat?.Color ?? "#ffffff",
                Eligible = cat?.IsEligible ?? false,
                Points = points,
                Penalty = penalty,
                LastAc = lastac,
                Problems = prob,
            });
        }
Beispiel #30
0
        public void RemoveAll(ComponentProblemTypes filter)
        {
            var filteredProblems = Select(filter);

            foreach (var p in filteredProblems.Problems)
            {
                Problems.Remove(p);
            }
        }
Beispiel #31
0
        public void RemoveAll(Func <ComponentProblem, bool> filter)
        {
            var ps = Problems.Where(filter).ToList();

            foreach (var p in ps)
            {
                Problems.Remove(p);
            }
        }
Beispiel #32
0
 public void Close()
 {
     foreach (var p in Problems)
     {
         p.Close();
     }
     Problems.Clear();
     FixWhat.Close();
 }
Beispiel #33
0
 private void SortByPriority()
 {
     if (IsProblemsSorted || Problems.Count <= 1)
     {
         return;
     }
     IsProblemsSorted = true;
     Problems.Sort((a, b) => ComponentProblemTypesManager.Infos[b.Type].Priority - ComponentProblemTypesManager.Infos[a.Type].Priority);
 }
Beispiel #34
0
        public static TrafficProblem NewRoad(string reasonName)
        {
            TrafficProblem problem = new TrafficProblem(reasonName);

            Problems.Add(problem);
            Save();

            return(problem);
        }
Beispiel #35
0
        /// <inheritdoc />
        public override ProblemCollection Check(TypeNode type)
        {
            if (type.IsAssignableTo(FrameworkTypes.Exception) && type.IsAbstract == false && RuleUtilities.IsSerializable(type) == false)
            {
                Problems.Add(new Problem(GetResolution(type.Name.Name)));
            }

            return(Problems);
        }
        public static List<int> GetPossibleActions(Problems.QueensPuzzle.State state)
        {
            var result = new List<int>();
            var newPlacement = state.PlacementsCount;
            for (var action = 0; action < state.ColumnPlacements.Length; action++)
            {
                var isAttacking = false;
                for (var placement = 0; placement < newPlacement; placement++)
                {
                    if (Problems.QueensPuzzle.State.IsAttacking(placement, state.ColumnPlacements[placement], newPlacement, action))
                    {
                        isAttacking = true;
                        break;
                    }
                }

                if (!isAttacking) result.Add(action);
            }

            return result.OrderBy(x => rnd.Next()).ToList();
        }
Beispiel #37
0
#pragma warning disable 1591 // Xml Comments
        public IProblems Create()
        {
            var problems = new Problems();
            return problems;
        }
Beispiel #38
0
 public void SportivTest()
 {
     var probleme = new Problems();
     int sportiv_runde = probleme.Sportiv(5);
     Assert.AreEqual(sportiv_runde, 25);
 }
Beispiel #39
0
 public void PavajTest()
 {
     var probleme = new Problems();
     var piatra = probleme.Pavaj(6, 6, 4);
     Assert.AreEqual(piatra, 4);
 }
Beispiel #40
0
 public void CapreTest()
 {
     var probleme = new Problems();
     int kg_fan = probleme.Capre(5, 6, 12, 20, 30);
     Assert.AreEqual(kg_fan, 3);
 }
 public void EulerProblem12Test()
 {
     var problems = new Problems();
     var answer = problems.Problem12();
     Assert.AreEqual(76576500, answer);
 }
Beispiel #42
0
 public void ParchetTest()
 {
     var probleme = new Problems();
     var mp_parchet = probleme.Parchet(16, 20);
     Assert.AreEqual(mp_parchet, 9.2);
 }