Ejemplo n.º 1
0
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         QuizGroup regulargroup = db.RegularGroup.Find(id);
         db.RegularGroup.Remove(regulargroup);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(View("Error"));
     }
 }
Ejemplo n.º 2
0
        // GET: /QuizGroup/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            QuizGroup regulargroup = db.RegularGroup.Find(id);

            if (regulargroup == null)
            {
                return(HttpNotFound());
            }
            return(View(regulargroup));
        }
Ejemplo n.º 3
0
        // GET: /QuizGroup/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            QuizGroup regulargroup = db.RegularGroup.Find(id);

            if (regulargroup == null)
            {
                return(HttpNotFound());
            }
            var x = new SelectList(Enum.GetValues(typeof(GroupType)));

            ViewBag.GroupTypes = x;
            return(View(regulargroup));
        }
Ejemplo n.º 4
0
        public ICollection <QuizModuleGroup> Scrapping()
        {
            List <QuizModuleGroup> moduleGroups = new List <QuizModuleGroup>();

            QuizModuleGroup moduleGroup = new QuizModuleGroup();

            moduleGroup.Title  = "EnglishGrammar";
            moduleGroup.Source = "EnglishTestStore";
            moduleGroup.Status = QuizStatus.JustCreated;

            string targetSiteContent = CrawlerEngine.GetResponseString(BaseUrl + "/index.php?option=com_content&view=article&id=11387&Itemid=380");
            var    doc = new HtmlDocument();

            doc.LoadHtml(targetSiteContent);
            string url = "", subSection = "";

            moduleGroup.QuizModules = new List <QuizModule>();

            var englishGrammarSectionNodes = doc.DocumentNode.SelectNodes("//div[@itemprop='articleBody']//table[1]//li/a[@href]");

            if (englishGrammarSectionNodes != null)
            {
                QuizModule module = new QuizModule();
                module.Title             = "Basic English Grammar exercises and tests";
                module.Source            = "EnglishTestStore";
                module.Status            = QuizStatus.JustCreated;
                module.QuizGroupSections = new List <QuizGroupSection>();

                foreach (var node in englishGrammarSectionNodes.Take(1))
                {
                    QuizGroupSection section = new QuizGroupSection();
                    section.Title      = node.InnerText.Trim();
                    section.Status     = QuizStatus.JustCreated;
                    section.QuizGroups = new List <QuizGroup>();

                    url = BaseUrl + node.GetAttributeValue("href", "");
                    var subLinks = LookUpLinkAndScrapLinks(url, section.Title);

                    foreach (var link in subLinks)
                    {
                        QuizGroup group = new QuizGroup();
                        group.Title = node.InnerText.Trim();
                        string json = LookUpLinkAndScrapQuizes(link.Key, link.Value);
                        group.Quizes = ParseJsonToModel(json);

                        section.QuizGroups.Add(group);
                    }

                    module.QuizGroupSections.Add(section);
                }

                moduleGroup.QuizModules.Add(module);
            }

            moduleGroups.Add(moduleGroup);

            //var englishTenseSectionLinks = new List<string>();
            //if (nodes != null)
            //{
            //    foreach (var node in nodes)
            //    {
            //        englishTenseSectionLinks.Add(node.GetAttributeValue("href", ""));
            //    }
            //}

            //var advEnglishGrammarSectionLinks = new List<string>();
            //if (nodes != null)
            //{
            //    foreach (var node in nodes)
            //    {
            //        advEnglishGrammarSectionLinks.Add(node.GetAttributeValue("href", ""));
            //    }
            //}

            //var commonlyConfusedSectionLinks = new List<string>();
            //if (nodes != null)
            //{
            //    foreach (var node in nodes)
            //    {
            //        commonlyConfusedSectionLinks.Add(node.GetAttributeValue("href", ""));
            //    }
            //}

            return(moduleGroups);
        }