Esempio n. 1
0
        public ActionResult GenerateFlashCards(WordLookUp lookUp)
        {
            LevelCount Level = new LevelCount();

            ArrayList arrayList = textService.DecomposeIntoWords(lookUp.Text, out Level);

            //Ambiguity
            ArrayList arrayListToInclude = new ArrayList();

            foreach (Word w in arrayList)
            {
                if (!w.Character.Contains("Ambiguity detected"))
                {
                    arrayListToInclude.Add(w);
                }
            }



            IncludedWords includedWords = new IncludedWords {
                Words = ToList(arrayList)
            };

            Session["IncludedWords"] = includedWords;
            return(RedirectToAction("Index", "FlashCardRandom"));
        }
        public ActionResult Answer(IncludedWords included, int Level, string Question, int Page)
        {
            FlashCardListViewModel flashCardListViewModel = new FlashCardListViewModel();

            flashCardListViewModel.Words = included.Words;

            flashCardListViewModel.PagingPrevNext = new PagingPrevNext {
                CurrentPage = Page, TotalItems = flashCardListViewModel.Words.Count()
            };

            //Find Solution
            Word   word = flashCardListViewModel.Words.ElementAt(Page - 1);
            string URL  = "";


            //TRANSPARENCY ON LINE https://www194.lunapic.com/editor/
            if (Question == word.NumberPinyin)
            {
                Result = "Ok";
                URL    = "/FlashCardRandom/Index/" + Level + "/" + (Page + 1).ToString() + "/Ok";
            }
            else
            {
                Result = "Wrong";
                URL    = "/FlashCardRandom/Index/" + Level + "/" + (Page + 1).ToString() + "/Ko";
            }



            return(new RedirectResult(URL));
        }
Esempio n. 3
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            IncludedWords included = null;

            //SESSION
            if (controllerContext.HttpContext.Session != null)
            {
                included = (IncludedWords)controllerContext.HttpContext.Session[sessionKey];
            }

            if (included == null)
            {
                included = new IncludedWords();

                //ACCESS TO PARAM LEVEL AT QUERY STRING
                QueryStringValueProvider queryStringValueProvider = new QueryStringValueProvider(controllerContext);
                ValueProviderResult      Value = queryStringValueProvider.GetValue("Level");
                var Level = Value.ConvertTo(typeof(Int32));


                included.Words = ToList(LoadIncluded((Int32)Level));

                if (controllerContext.HttpContext.Session != null)
                {
                    controllerContext.HttpContext.Session[sessionKey] = included;
                }
            }

            return(included);
        }
        public ActionResult Index(IncludedWords includedWords, int Level = 1, int Page = 1, string Result = "")
        {
            //Generate Words
            FlashCardListViewModel flashCardListViewModel = new FlashCardListViewModel();

            flashCardListViewModel.Words = includedWords.Words;

            GenerateAnswers(flashCardListViewModel, Page);

            //Select One for Show and Pagination
            flashCardListViewModel.Words = flashCardListViewModel.Words.OrderBy(w => w.Id).Skip((Page - 1)).Take(1);

            flashCardListViewModel.PagingPrevNext = new PagingPrevNext {
                CurrentPage = Page, TotalItems = flashCardListViewModel.Words.Count()
            };

            ViewBag.Result = Result;
            ViewBag.Level  = Level;

            return(View("Index", flashCardListViewModel));
        }