Example #1
0
        public ChoiseBlock(List <QuizItem> quizItems, bool isMultiply, IWebElement statusElement, QuizStatus quizStatus)
        {
            this.quizItems  = quizItems;
            this.isMultiply = isMultiply;
            blockStatus     = quizItems.Any(x => x.GetStatus() == Status.Wrong) ? Status.Wrong :
                              quizItems.Any(x => x.GetStatus() == Status.Right) ? Status.Right : Status.Undefined;
            var localStatus = UlearnDriver.HasCss(statusElement, "glyphicon-ok") ? Status.Right :
                              UlearnDriver.HasCss(statusElement, "glyphicon-remove") ? Status.Wrong :
                              Status.Undefined;

            if (localStatus != blockStatus)
            {
                throw new Exception("Не верно произведена оценка квиза");
            }
            if (quizStatus == QuizStatus.NoAttempts && localStatus == Status.Undefined)
            {
                throw new Exception("Не произведена проверка квиза");
            }
            if (quizStatus == QuizStatus.HasAttempts && quizItems.Any(x => x.GetStatus() == Status.Wrong || x.GetStatus() == Status.Right))
            {
                throw new Exception("Отмечены верные/неверные варианты ответа при имеющихся попытках");
            }
            if (quizStatus == QuizStatus.Clean && (quizItems.Any(x => x.GetStatus() == Status.Wrong || x.GetStatus() == Status.Right)) || (localStatus != Status.Undefined))
            {
                throw new Exception("Отмечены верные/неверные варианты ответа или выставлены оценки квиз-блокам, когда квиз еще не решался");
            }
        }
Example #2
0
        public SlideLabelInfo GetInfo()
        {
            if (slideLabelElement == null)
            {
                return(new SlideLabelInfo(false, false));
            }

            var element   = slideLabelElement.Value;
            var isVisited = IsVisited(element);
            var selected  = IsSelected(slideElement.Value);

            if (UlearnDriver.HasCss(element, "glyphicon-edit"))
            {
                return(new ExerciseSlideLabelInfo(isVisited, selected, IsPassed(element)));
            }

            if (UlearnDriver.HasCss(element, "glyphicon-ok"))
            {
                return(new SlideLabelInfo(isVisited, selected));
            }

            if (UlearnDriver.HasCss(element, "glyphicon-pushpin"))
            {
                var isPassed      = IsPassed(element);
                var isHasAttempts = IsHasAttempts(element);
                return(new QuizSlideLabelInfo(isVisited, selected, isPassed, isHasAttempts));
            }

            return(new SlideLabelInfo(false, false));            //throw new NotFoundException("navbar-label is not found");
        }
Example #3
0
        private void Configure()
        {
            var unitsElements = UlearnDriver.FindElementsSafely(driver, By.XPath(XPaths.TocUnitsXPath)).ToList();

            CreateCollections();
            for (var i = 0; i < unitsElements.Count; i++)
            {
                var unitName = unitsElements[i].Text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
                if (unitName == null)
                {
                    throw new Exception(string.Format("Юнит с номером {0} в курсе {1} не имеет названия", i, driver.Title));
                }
                if (unitName == "Total statistics" || unitName == "Users statistics" || unitName == "Personal statistics")
                {
                    if (!statistics.ContainsKey(unitName))
                    {
                        statistics.Add(unitName, new TocUnit(driver, i));
                    }
                }
                else
                {
                    if (units.ContainsKey(unitName))
                    {
                        continue;
                    }
                    var collapsedElement = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.UnitInfoXPath(i)));
                    var isCollapsed      = UlearnDriver.HasCss(collapsedElement, "collapse in");
                    initInfo.Add(unitName, new UnitInitInfo(unitsElements[i], i, isCollapsed));
                    units.Add(unitName, new Lazy <ITocUnit>(() => new TocUnit(driver, initInfo[unitName].Index)));
                }
            }
        }
Example #4
0
 public QuizItem(IWebElement box, IWebElement textElement, IWebElement infoElement)
 {
     this.box         = box;
     this.textElement = textElement;
     this.infoElement = infoElement;
     itemStatus       = UlearnDriver.HasCss(infoElement, "wrong-quiz") ? Status.Wrong :
                        UlearnDriver.HasCss(infoElement, "right-quiz") ? Status.Right : Status.Undefined;
 }
Example #5
0
 public LikeButton(IWebElement like)
 {
     if (like == null)
     {
         throw new NotFoundException("like button not found");
     }
     this.like = like;
     isLiked   = UlearnDriver.HasCss(like, "btn-primary");
 }
Example #6
0
        private List <SlidePageBlock> GetBlocks()
        {
            var blockElements = UlearnDriver.FindElementsSafely(driver, By.XPath(XPaths.SeleniumTextBlockXPath));

            return(UnionSubBlocks(blockElements.Where(
                                      x => x.TagName == "textarea" ||
                                      x.TagName == "p" ||
                                      x.TagName == "ul" ||
                                      (x.TagName == "div" && UlearnDriver.HasCss(x, "video-container")))
                                  .Select(CreateBlock)));
        }
Example #7
0
 private QuizBlock GetBlock(IWebElement webElement, int index)
 {
     if (UlearnDriver.HasCss(webElement, "quiz-block-input"))
     {
         return(new FillInBlock(webElement.FindElement(By.XPath(XPaths.QuizFillInBlockField(index)))));
     }
     return(new ChoiseBlock(
                webElement
                .FindElements(By.XPath(XPaths.QuizItemXPath(index)))
                .Select((x, i) => new QuizItem(x, x, webElement.FindElement(By.XPath(XPaths.QuizItemInfoXPath(i)))))
                .ToList(),
                UlearnDriver.HasCss(webElement, "checkbox"),
                driver.FindElement(By.XPath(XPaths.QuizQuestionStatusXPath(index))),
                quizStatus));
 }
Example #8
0
 private static SlidePageBlock CreateBlock(IWebElement element)
 {
     if (element.TagName == "p")
     {
         return(new SlidePageTextBlock(element.Text));
     }
     if (UlearnDriver.HasCss(element, "video-container"))
     {
         return(new SlidePageVideoBlock());
     }
     if (UlearnDriver.HasCss(element, "code-sample"))
     {
         return(new SlidePageCodeBlock(element.Text, false));
     }
     return(new SlidePageCodeBlock(element.Text, true));
 }
Example #9
0
 private static bool IsPassed(IWebElement webElement)
 {
     return(UlearnDriver.HasCss(webElement, "navbar-label-success"));
 }
Example #10
0
 private static bool IsVisited(IWebElement webElement)
 {
     return(UlearnDriver.HasCss(webElement, "navbar-label-success") ||
            UlearnDriver.HasCss(webElement, "navbar-label-danger"));
 }
Example #11
0
 private bool IsSelected(IWebElement element)
 {
     return(UlearnDriver.HasCss(element, "selected"));
 }
Example #12
0
 private bool IsActive(IWebElement button)
 {
     return(UlearnDriver.HasCss(button, "block_next"));
 }
Example #13
0
        private bool IsCollapse()
        {
            var element = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.TocUnitHeaderCollapseInfoXPath(unitIndex)));

            return(UlearnDriver.HasCss(element, "in"));
        }