public bool CheckResult(int id, string value) { List <Word> words = Session["questions"] as List <Word>; bool result = CompareResult(words[Convert.ToInt32(Session["Index"])], id, value, Session["Exercise"].ToString()); if (result) { Session["AnswerCount"] = Convert.ToInt32(Session["AnswerCount"]) + 1; int userId = GetCurrentUserId(); LearningWord learnedWord = (from lw in db.LearningWord where lw.WordId == id && lw.UserId == userId select lw).First(); learnedWord.ExcerciseDate = DateTime.Now; if (learnedWord.LearnPercent >= 100 - 15) { learnedWord.LearnPercent = 100; learnedWord.LearnedDate = DateTime.Now.Date; } else { learnedWord.LearnPercent += 15; } db.SaveChanges(); } return(result); }
void NewTestingWord() { _learningWord = _learningWordService.LearningWordGetNewid(); if (_learningWord == null) { XtraMessageBox.Show("Öğrendiğiniz kelime yok veya test sırası gelmemiştir.", "Uyarı!"); Close(); } else { _word = _wordService.WordGet(_learningWord.WordId); lblKelime.Text = _word.English; Random rnd = new Random(); int rndSayi = rnd.Next(0, 3); var btn = (SimpleButton)groupBox1.Controls[rndSayi]; btn.Text = _word.Turkish; List <Word> wordList = _wordService.GetAll().Where(x => x.Id != _learningWord.WordId).OrderBy(u => Guid.NewGuid()).Take(3).ToList(); int i = 0; foreach (var word in wordList) { if (i == rndSayi) { i++; } btn = (SimpleButton)groupBox1.Controls[i]; btn.Text = word.Turkish; i++; } } }
public void LoadDrop() { drpYears.Items.Clear(); LearningWord learningWord = _learningWordSevice.GetAll().OrderByDescending(x => x.LearningDate).FirstOrDefault(); if (learningWord != null) { int sonYil = learningWord.LearningDate.Year; learningWord = _learningWordSevice.GetAll().OrderBy(x => x.LearningDate).FirstOrDefault(); if (learningWord != null) { int ilkYil = learningWord.LearningDate.Year; for (int i = ilkYil; i <= sonYil; i++) { drpYears.Items.Add(i); } drpYears.SelectedIndex = 0; } } }
internal static void Learned(LearningWord learning) { if (learning.Learned == false) { return; } var learned = GetLearnedWords(); learned.Add(learning.Word); }
void WordNewid() { _learningWord = _learningWordSevice.LearningWordAddNewid(); if (_learningWord != null) { _word = _wordService.WordGet(_learningWord.WordId); lblTurkishWord.Text = _word.Turkish; lblEnglishWord.Text = _word.English; lblSententeEnglish.Text = _word.Sentence; } else { XtraMessageBox.Show("Öğrenilebilecek yeni kelime bulunmamaktadır...", "Uyarı"); Close(); } }
public int EditWord(int id, bool check) { LearningWord lw = new LearningWord(); if (check) { int userId = GetUser().UserId; lw = (from learningWord in db.LearningWord where learningWord.UserId == userId && learningWord.WordId == id select learningWord).First(); db.LearningWord.Remove(lw); db.SaveChanges(); } else { lw.AddedDate = DateTime.Now; lw.WordId = id; lw.LearnPercent = 0; lw.UserId = GetUser().UserId; db.LearningWord.Add(lw); db.SaveChanges(); } return(lw.LearningWordId); }
private void ReadDataFromSource() { Task.Run(() => { try { SetFormState(false); var assembly = IntrospectionExtensions.GetTypeInfo(typeof(DictViewModel)).Assembly; Stream stream = assembly.GetManifestResourceStream("MultiplicationTable.LanguageWords.xml"); string txtXml = string.Empty; using (var reader = new System.IO.StreamReader(stream)) { txtXml = reader.ReadToEnd(); } XDocument xDoc = XDocument.Parse(txtXml); CategoriesSource = new ObservableCollection <string>(); LearningWords = new ObservableCollection <LearningWord>(); IEnumerable <XElement> de = from el in xDoc.Descendants() select el; foreach (XElement el in de) { if (el.Name == "Word") { IEnumerable <XElement> desc = from elDesc in el.Descendants() select elDesc; LearningWord lw = new LearningWord(); foreach (XElement elDescendant in desc) { if (elDescendant.Name == "en") { lw.English = elDescendant.Value; } if (elDescendant.Name == "pl") { lw.Polish = elDescendant.Value; } if (elDescendant.Name == "category_pl") { if (CategoriesSource.Where(q => q == elDescendant.Value).FirstOrDefault() == null) { MainThread.BeginInvokeOnMainThread(() => { //UWAGA -> na androidzie działa to inaczej !!, to jest wykonywane PO FAKCIE if (!CategoriesSource.Contains(elDescendant.Value)) { CategoriesSource.Add(elDescendant.Value); } }); } lw.PolishCategory = elDescendant.Value; } if (elDescendant.Name == "category_en") { lw.EnglishCategory = elDescendant.Value; } } MainThread.BeginInvokeOnMainThread(() => { LearningWords.Add(lw); }); } } //LOAD USER DATA XML IFolder folder = PCLStorage.FileSystem.Current.LocalStorage; if (PCLHelper.IsFolderExistAsync("UserXML", folder).GetAwaiter().GetResult()) { IFolder destFolder = folder.GetFolderAsync("UserXML").GetAwaiter().GetResult(); if (PCLHelper.IsFileExistAsync("UserWord.xml", destFolder).GetAwaiter().GetResult()) { IFile file = destFolder.GetFileAsync("UserWord.xml").GetAwaiter().GetResult(); string content = file.ReadAllTextAsync().GetAwaiter().GetResult(); XDocument xDocUser = XDocument.Parse(content); IEnumerable <XElement> deUser = from el in xDocUser.Descendants() select el; foreach (XElement el in deUser) { if (el.Name == "Word") { IEnumerable <XElement> desc = from elDesc in el.Descendants() select elDesc; LearningWord lw = new LearningWord(); foreach (XElement elDescendant in desc) { if (elDescendant.Name == "en") { lw.English = elDescendant.Value; } if (elDescendant.Name == "pl") { lw.Polish = elDescendant.Value; } if (elDescendant.Name == "category_pl") { if (!CategoriesSource.Contains(elDescendant.Value)) { MainThread.BeginInvokeOnMainThread(() => { if (!CategoriesSource.Contains(elDescendant.Value)) { CategoriesSource.Add(elDescendant.Value); } }); } lw.PolishCategory = elDescendant.Value; } if (elDescendant.Name == "category_en") { lw.EnglishCategory = elDescendant.Value; } } MainThread.BeginInvokeOnMainThread(() => { LearningWords.Add(lw); }); } } } } SetFormState(true); } catch (Exception ex) { UserDialogs.Instance.Alert(Language.txtErrorMessage + ex.Message, Language.txtErrorTitle); } }); }
private void ShuffleCommandAction(object o) { ImageVisible = false; if (!string.IsNullOrEmpty(SelectedCategory) && LearningWords != null) { List <LearningWord> lstLw = LearningWords.Where(q => q.PolishCategory == SelectedCategory).ToList(); List <LearningWord> lstBadLw = new List <LearningWord>(lstLw); Random r = new Random(); int idx = r.Next(0, lstLw.Count()); LearningWord lw = lstLw.ElementAt(idx); GeneratedWord = lw.Polish; properCorrespondingWord = lw.English; lstBadLw.RemoveAt(idx); int firstWrongIdx = r.Next(0, lstBadLw.Count()); firstWrongCorrespondingWord = lstBadLw[firstWrongIdx].English; lstBadLw.RemoveAt(firstWrongIdx); int secondWrongIdx = r.Next(0, lstBadLw.Count()); secondWrongCorrespondingWord = lstBadLw[secondWrongIdx].English; //ustawienie buttonow; int okIdx = r.Next(0, 3); if (Settings.TestModeEnglishWords) { if (okIdx == 0) { HintA = properCorrespondingWord; HintC = secondWrongCorrespondingWord; HintB = firstWrongCorrespondingWord; } if (okIdx == 1) { HintB = properCorrespondingWord; HintA = firstWrongCorrespondingWord; HintC = secondWrongCorrespondingWord; } if (okIdx == 2) { HintC = properCorrespondingWord; HintA = firstWrongCorrespondingWord; HintB = secondWrongCorrespondingWord; } } else { InputAnswer = ""; HintA = Language.btnAnswer; HintB = Language.btnAnswer; HintC = Language.btnAnswer; } } else { UserDialogs.Instance.Alert(Language.txtLearningSetCategory, Language.txtErrorTitle); } }
public void DeleteWordId(int id) { LearningWord learningWord = _learningWordDal.Get(x => x.WordId == id); _learningWordDal.Delete(learningWord); }
public void Update(LearningWord learningWord) { _learningWordDal.Update(learningWord); }
public void Delete(LearningWord learningWord) { _learningWordDal.Delete(learningWord); }
public void Add(LearningWord learningWord) { _learningWordDal.Add(learningWord); }