public IHttpActionResult PutCloze(int id, Cloze cloze) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cloze.Id) { return(BadRequest()); } db.Entry(cloze).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ClozeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostCloze(Cloze cloze) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Clozes.Add(cloze); try { db.SaveChanges(); } catch (DbUpdateException) { if (ClozeExists(cloze.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = cloze.Id }, cloze)); }
private void DoTransitions() { Sentence = Sentences[Index]; LabelValue = ModifiedSentence(); SentenceLbl.Text = LabelValue; SendBtn.Clicked += SendBtnAction; }
private void DistributeData() { PageList = new List <object>(); foreach (var i in Contents) { if (i.type.ToString().Equals("mcq")) { Models.Mcq q = new Models.Mcq { Question = i.content.Question, Answers = i.content.Answers, CorrectAnswer = i.content.CorrectAnswer }; PageList.Add(q); } if (i.type.ToString().Equals("cloze")) { Cloze c = new Cloze { Sentence = i.content.sentence, MissingWords = i.content.MissingWords }; PageList.Add(c); } } }
public IHttpActionResult GetCloze(int id) { Cloze cloze = db.Clozes.Find(id); if (cloze == null) { return(NotFound()); } return(Ok(cloze)); }
private void CreateCloze(Cloze cloze) { StringBuilder textBuilder = new StringBuilder(); StringBuilder insertsBuilder = new StringBuilder(); for (int i = 0; i < selectInsertsListbox.Items.Count - 1; ++i) { InsertItem item1 = selectInsertsListbox.Items[i] as InsertItem; InsertItem item2 = selectInsertsListbox.Items[i + 1] as InsertItem; if (item1.InsertIndex == 0 && item2.InsertIndex == 0) { textBuilder.Append(item1.Character); } if (item1.InsertIndex == 0 && item2.InsertIndex > 0) { textBuilder.Append(item1.Character); textBuilder.Append('_'); insertsBuilder.Append('_'); } if (item1.InsertIndex > 0 && item2.InsertIndex > 0) { insertsBuilder.Append(item1.Character); if (item1.InsertIndex != item2.InsertIndex) { textBuilder.Append('_'); insertsBuilder.Append('_'); } } if (item1.InsertIndex > 0 && item2.InsertIndex == 0) { insertsBuilder.Append(item1.Character); } } InsertItem item = selectInsertsListbox.Items[selectInsertsListbox.Items.Count - 1] as InsertItem; if (item.InsertIndex > 0) { insertsBuilder.Append(item.Character); } else { textBuilder.Append(item.Character); } cloze.Text = textBuilder.ToString(); cloze.Inserts = insertsBuilder.ToString().TrimStart('_'); //cloze.Hints = hintsTextbox.Text.Replace("、", "_"); }
public DetailItem(Cloze cloze) { InitializeComponent(); sourceKanji = null; sourceWord = null; sourceCloze = cloze; mainTextblock.Text = cloze.ToString(); descTextblock.Text = cloze.Inserts;// + "、" + cloze.Hints; }
public DetailItem(Word word) { InitializeComponent(); sourceWord = word; sourceKanji = null; sourceCloze = null; mainTextblock.Text = word.ToDetailString(); descTextblock.Text = word.ToDescriptionString(); }
public DetailItem(Kanji kanji) { InitializeComponent(); sourceWord = null; sourceKanji = kanji; sourceCloze = null; mainTextblock.Text = kanji.ToDetailString(); descTextblock.Text = kanji.ToExampleString(); }
private void ShowClozeTest(Object o) { ClozeTest = (Cloze)o; Input = new Entry { HorizontalOptions = LayoutOptions.CenterAndExpand, WidthRequest = 100 }; SentenceLbl = new Label { Text = ModifiedSentence(), Padding = 35, TextColor = Color.Black }; MyLayout.Children.Add(SentenceLbl); MyLayout.Children.Add(Input); MyLayout.Children.Add(SubmitBtn); }
public IHttpActionResult DeleteCloze(int id) { Cloze cloze = db.Clozes.Find(id); if (cloze == null) { return(NotFound()); } db.Clozes.Remove(cloze); db.SaveChanges(); return(Ok(cloze)); }
private bool TryCreateCloze() { Cloze cloze = new Cloze(); CreateCloze(cloze); if (cloze.Inserts == "") { return(false); } clozesListbox.Items.Add(new DetailItem(cloze)); return(true); }
private bool TryUpdateCloze() { Cloze cloze = selectedItem.sourceCloze; CreateCloze(cloze); if (cloze.Inserts == "") { return(false); } (clozesListbox.SelectedItem as DetailItem).Update(); return(true); }
private void SendBtnAction(object sender, EventArgs e) { Console.WriteLine("Hey"); foreach (var i in Sentence.MissingWords) { if (EntryAnswer.Text.Equals(i)) { Index++; Sentence = Sentences[Index]; Console.WriteLine("Correct"); LabelValue = FillBack(); RefreshSentence(); } } }
private void RestoreClozeView(Cloze cloze) { StringBuilder textBuilder = new StringBuilder(); StringBuilder insertsBuilder = new StringBuilder(); String[] textParts = cloze.Text.Split('_'); String[] insertParts = cloze.Inserts.Split('_'); for (int i = 0; i < insertParts.Length; ++i) { textBuilder.Append(textParts[i]); textBuilder.Append(insertParts[i]); } textBuilder.Append(textParts.Last()); sentenceTextbox.Text = textBuilder.ToString(); //hintsTextbox.Text = cloze.Hints.Replace('_', '、'); int insertsIndex = 0; foreach (char sign in cloze.Text) { InsertItem item; if (sign == '_') { foreach (char insert in insertParts[insertsIndex]) { item = new InsertItem(insert); item.IsInsertText = true; selectInsertsListbox.Items.Add(item); } InsertItem.ChangeSelectedColor(); ++insertsIndex; } else { item = new InsertItem(sign); selectInsertsListbox.Items.Add(item); } } }
public ClozeViewModel(INavigator navigator) { Debug.WriteLine("ClozeViewModel Constructor:"); _cloze = (Cloze)PageNavigator.GetCurrentPage; _navigator = navigator; _sentences = SplitSentence(_cloze.content.sentence, _cloze.content.missingWords); _missingWord = _cloze.content.missingWords[0]; Title = _cloze.title; Image = _cloze.image; EntryPlaceholder = CreatePlaceholder(_missingWord); GuessedWord = ""; ShowCorrection = false; ShowCorrectMeButton = true; ClozeGuiHelper = InitClozeLabelAndEntry(_cloze.content.missingWords[0], _cloze.content.sentence); }
public void Update(Cloze cloze) { mainTextblock.Text = cloze.ToString(); descTextblock.Text = cloze.Inserts;// + "、" + cloze.Hints; }