private string CheckAns() { int userAns = Judge.RIGHT; if (right.Checked == true) { userAns = Judge.RIGHT; } else if (wrong.Checked == true) { userAns = Judge.WRONG; } if (judge.isDone == 0) { QuestionHistory.SaveProblemIsDone(judge.id, QuestionHistory.TYPE_CHOICE); } if (userAns == judge.ans) { QuestionHistory.UpdateHistory(judge, QuestionHistory.RESULT_RIGHT); MyApp.judgeCount++; return(""); } else { QuestionHistory.UpdateHistory(judge, QuestionHistory.RESULT_WRONG); MyApp.judgeCount++; MyApp.judgeWrongCount++; return("你的选择是" + TranslateAns(userAns) + "\n\n" + "正确答案为" + TranslateAns(judge.ans)); } }
// TODO public void RemoveQuestion(string id, string bankname) { // Find history by id QuestionHistory history = Histories.Find(his => his.Id == id); Debug.Log(JsonConvert.SerializeObject(history, Formatting.Indented)); // Modify the memory strength and date history.LastAttemptDate = DateTime.Now.AddDays(Properties.Instance.ADD_DAYS).ToShortDateString().ToString(); if (history.LastIsCorrect) { history.MemoryStrength += 2; } else { history.LastIsCorrect = true; history.MemoryStrength++; } // Update to db fb.UpdateHistory(Username, bankname, history); // TODO change to generic bankname // Remove from history list Histories.Remove(history); }
// Forgetting algorithm private double CalculateForgettingRate(QuestionHistory history) { double result = 0.0; Question question = QuestionBank[history.Id]; Debug.Log(JsonConvert.SerializeObject(question)); if (history.MemoryStrength != 0) { DateTime dt = DateTime.Now; DateTime lastAttempt = DateTime.Parse(history.LastAttemptDate); int timeInterval = dt.AddDays(Properties.Instance.ADD_DAYS).Subtract(lastAttempt).Days; result = Math.Pow(Math.E, (-timeInterval / Convert.ToDouble(history.MemoryStrength))); } Debug.Log("<color=orange>Memory retention rate: " + result); return(result); /* * Question question = QuestionBank[id]; * Debug.Log(JsonConvert.SerializeObject(question)); * // <color=orange>" + log + "</color>" * Debug.Log("<color=orange>Memory strength: " + CalculateForgettingRate(Histories[id]) + "</color>"); */ }
private void UpdateHistoryList() { long choiceCount = QuestionHistory.GetHisotryCount(QuestionHistory.TYPE_CHOICE); long multipleChoiceCount = QuestionHistory.GetHisotryCount(QuestionHistory.TYPE_MULTIPLECHOICE); long judgeCount = QuestionHistory.GetHisotryCount(QuestionHistory.TYPE_JUDGE); long sum = choiceCount + multipleChoiceCount + judgeCount; long choiceWrongCount = QuestionHistory.GetWrongHisotryCount(QuestionHistory.TYPE_CHOICE); long multipleChoiceWrongCount = QuestionHistory.GetWrongHisotryCount(QuestionHistory.TYPE_MULTIPLECHOICE); long judgeWrongCount = QuestionHistory.GetWrongHisotryCount(QuestionHistory.TYPE_JUDGE); long wrongSum = choiceWrongCount + multipleChoiceWrongCount + judgeWrongCount; this.historyListView.BeginUpdate(); int width = historyListView.Width; for (int i = 0; i < menus.Count; i++) { historyListView.Columns.Add(menus[i], width * widths[i] / 100, textAligns[i]); } ListViewItem item = new ListViewItem { Text = "总做题数" }; item.SubItems.Add(sum.ToString()); item.SubItems.Add(wrongSum.ToString()); historyListView.Items.Add(item); ListViewItem item2 = new ListViewItem { Text = "单选题" }; item2.SubItems.Add(choiceCount.ToString()); item2.SubItems.Add(choiceWrongCount.ToString()); historyListView.Items.Add(item2); ListViewItem item3 = new ListViewItem { Text = "多选题" }; item3.SubItems.Add(multipleChoiceCount.ToString()); item3.SubItems.Add(multipleChoiceWrongCount.ToString()); historyListView.Items.Add(item3); ListViewItem item4 = new ListViewItem { Text = "判断题" }; item4.SubItems.Add(judgeCount.ToString()); item4.SubItems.Add(judgeWrongCount.ToString()); historyListView.Items.Add(item4); this.historyListView.EndUpdate(); }
public void UpdateHistory(string username, string bankname, QuestionHistory history) { string path = endpoint + "History/" + username + "/" + bankname + "/" + history.Id; RestClient.Put(path + "/.json", history).Then(response => { Debug.Log("Updated the history record: " + history.Id); }).Catch(err => { Debug.Log("Error: " + err.Message); }); Debug.Log("Updated History"); }
public void ReorderQuestion(string id) { Debug.Log("Reorder question: " + id); // Find history by id QuestionHistory history = Histories.Find(his => his.Id == id); history.LastIsCorrect = false; Debug.Log("Reorder: Update history to false: " + JsonConvert.SerializeObject(history, Formatting.Indented)); // Remove from history list Histories.Remove(history); Histories.Add(history); }
private void UpdateData() { if (examType == QuestionHistory.EXAM_TYPE_UNDO) { list.AddRange(Choice.LoadUndoChoice(100)); list.AddRange(QuestionHistory.LoadChoice(QuestionHistory.EXAM_TYPE_WRONG, 10)); } else if (examType == QuestionHistory.EXAM_TYPE_WRONG) { list.AddRange(QuestionHistory.LoadChoice(QuestionHistory.EXAM_TYPE_WRONG, 100)); } else if (examType == QuestionHistory.EXAM_TYPE_REVIEW) { list.AddRange(QuestionHistory.LoadChoice(QuestionHistory.EXAM_TYPE_REVIEW, 100)); } list = Util.RandomSortList(list); index = 0; }
private void UpdateData() { switch (examType) { case QuestionHistory.EXAM_TYPE_UNDO: list.AddRange(Judge.LoadUndoChoice(100)); list.AddRange(QuestionHistory.LoadJudge(QuestionHistory.EXAM_TYPE_WRONG, 10)); break; case QuestionHistory.EXAM_TYPE_WRONG: list.AddRange(QuestionHistory.LoadJudge(QuestionHistory.EXAM_TYPE_WRONG, 100)); break; case QuestionHistory.EXAM_TYPE_REVIEW: list.AddRange(QuestionHistory.LoadJudge(QuestionHistory.EXAM_TYPE_REVIEW, 100)); break; } list = Util.RandomSortList(list); index = 0; }
private string CheckAns() { string userAns = ""; if (aska.Checked == true) { userAns = "A"; } else if (askb.Checked == true) { userAns = "B"; } else if (askc.Checked == true) { userAns = "C"; } else if (askd.Checked == true) { userAns = "D"; } if (choice.isDone == 0) { QuestionHistory.SaveProblemIsDone(choice.id, QuestionHistory.TYPE_CHOICE); } if (userAns.Equals(choice.ans)) { QuestionHistory.UpdateHistory(list[index], QuestionHistory.RESULT_RIGHT); MyApp.choiceCount++; return(""); } else { QuestionHistory.UpdateHistory(list[index], QuestionHistory.RESULT_WRONG); MyApp.choiceCount++; MyApp.choiceWrongCount++; return("你的选择是" + userAns + "\n\n" + "正确答案为" + choice.ans); } }
public async Task <ActionResult> CreateQuestionHistory(ResponseQuestionsViewModel oRVM) { TempData["UserMessage"] = new MessageVM() { IsSuccessful = false, Title = "Error!", Message = "Something went wrong." }; if (Helpers.Helpers.IsStaff(User)) { return(RedirectToAction("Index", "Staff")); } if (!ModelState.IsValid) { return(View(oRVM)); } QuestionHistoryViewModel oQuestionHistoryVM = oRVM.QuestionHistoryVM; Course oCourse = db.Courses.Include(c => c.QuestionHistorys).SingleOrDefault(c => c.CourseId == oQuestionHistoryVM.CourseId); if (oCourse == null)//Error. Course DNE. { throw new ArgumentException("CreateQuestionHistory(ResponseQuestionsViewModel oRVM) - Course DNE."); } Student oStudent = db.Students.SingleOrDefault(s => s.StudentId == oQuestionHistoryVM.StudentId && s.Courses.Any(c => c.CourseId == oCourse.CourseId)); if (oStudent == null)//Error. Student DNE OR doesn't take this Course. { throw new ArgumentException("CreateQuestionHistory(ResponseQuestionsViewModel oRVM) - Student DNE."); } Parent oParent = db.Parents.SingleOrDefault(p => p.ParentId == SessionSingleton.Current.ParentId && p.Children.Any(s => s.StudentId == oStudent.StudentId)); if (oParent == null) //Error. This Student/Child doesn't belong to this Parent. { throw new ArgumentException("CreateQuestionHistory(ResponseQuestionsViewModel oRVM) - Parent DNE."); } QuestionHistory oQuestionHistory = new QuestionHistory() { //-- Default values -- //-- end of Default values -- //-- VM to Model -- QuestionTxt = oQuestionHistoryVM.QuestionTxt, Parent = oParent, Student = oStudent, Course = oCourse //-- end of VM to Model -- }; //oParent.QuestionHistorys.Add(oQuestionHistory); //oStudent.QuestionHistorys.Add(oQuestionHistory); oCourse.QuestionHistorys.Add(oQuestionHistory); db.QuestionHistorys.Add(oQuestionHistory); try { if (db.SaveChanges() <= 0) { return(View(oQuestionHistoryVM)); } } catch (Exception e) { return(View(oQuestionHistoryVM)); } TempData["UserMessage"] = new MessageVM() { IsSuccessful = true, Title = "Success!", Message = "Your question for this course has been successfully added." }; return(RedirectToAction("Questions", new { ParentId = oQuestionHistoryVM.ParentId, StudentId = oQuestionHistoryVM.StudentId, CourseId = oQuestionHistoryVM.CourseId })); }
public async Task <ActionResult> EditQuestionHistory(ResponseQuestionsViewModel oRVM) { TempData["UserMessage"] = new MessageVM() { IsSuccessful = false, Title = "Error!", Message = "Something went wrong." }; //This is for Staffer use also so commented out: //if (Helpers.Helpers.IsStaff(User)) // return RedirectToAction("Index", "Staff"); if (!ModelState.IsValid) { return(View(oRVM)); } QuestionHistoryViewModel oQuestionHistoryVM = oRVM.QuestionHistoryVM; Course oCourse = db.Courses.Include(c => c.QuestionHistorys).SingleOrDefault(c => c.CourseId == oQuestionHistoryVM.CourseId); if (oCourse == null)//Error. Course DNE. { throw new ArgumentException("EditQuestionHistory(ResponseQuestionsViewModel oRVM) - Course DNE."); } Student oStudent = db.Students.SingleOrDefault(s => s.StudentId == oQuestionHistoryVM.StudentId && s.Courses.Any(c => c.CourseId == oCourse.CourseId)); if (oStudent == null)//Error. Student DNE OR doesn't take this Course. { throw new ArgumentException("EditQuestionHistory(ResponseQuestionsViewModel oRVM) - Student DNE."); } Parent oParent = db.Parents.SingleOrDefault(p => p.ParentId == oQuestionHistoryVM.ParentId && p.Children.Any(s => s.StudentId == oStudent.StudentId)); if (oParent == null) //Error. This Student/Child doesn't belong to this Parent. { throw new ArgumentException("EditQuestionHistory(ResponseQuestionsViewModel oRVM) - Parent DNE."); } //-- QuestionHistory -- QuestionHistory oQuestionHistory = db.QuestionHistorys.SingleOrDefault(qh => qh.QuestionHistoryId == oQuestionHistoryVM.QuestionHistoryId); if (oQuestionHistory == null) //Error. This Question DNE. { throw new ArgumentException("EditQuestionHistory(ResponseQuestionsViewModel oRVM) - QuestionHistory DNE."); } oQuestionHistory.QuestionTxt = oQuestionHistoryVM.QuestionTxt; //-- end of QuestionHistory -- try { if (db.SaveChanges() <= 0) { return(View(oQuestionHistoryVM)); } } catch (Exception e) { return(View(oQuestionHistoryVM)); } TempData["UserMessage"] = new MessageVM() { IsSuccessful = true, Title = "Success!", Message = "Your question for this course has been successfully updated." }; return(RedirectToAction("Parent", "Staff", new { queryvalues = oQuestionHistoryVM.ParentId }));//, StudentId = oQuestionHistoryVM.StudentId, CourseId = oQuestionHistoryVM.CourseId }