public ActionResult LessonDetails(string id) { if (NeedLogin()) { return(LoginRedir()); } var lesson = LessonsCtrl.Get(id); if (lesson == null) { return(new HttpNotFoundResult()); } if (!IsAdmin()) { if (!AllowedLessons(CurrentUserEmail()).Contains(lesson.LessonID)) { return(RedirectToAction("Lessons")); } } var lessonTurns = LessonsCtrl.DBConn().FindTurns(lesson.LessonID, null); var modelObj = new ExpandoObject(); var modelDict = (IDictionary <string, object>)modelObj; modelDict["Lesson"] = lesson; modelDict["Turns"] = lessonTurns; return(View("LessonDetail", modelObj)); }
public ActionResult Lessons() { if (NeedLogin()) { return(LoginRedir()); } var lessons = new List <Lesson>(); //Only lessons we're allowed to see bool admin = IsAdmin(); HashSet <string> allowedLessons = null; if (!admin) { //Only populate allowedLessons if we're not admin allowedLessons = AllowedLessons(CurrentUserEmail()); } foreach (Lesson le in LessonsCtrl.Get()) { if (admin || allowedLessons.Contains(le.LessonID)) { lessons.Add(le); } } var modelObj = new ExpandoObject(); var modelDict = (IDictionary <string, object>)modelObj; modelDict["Lessons"] = lessons; modelDict["AnswerTots"] = LessonsCtrl.DBConn().FindLessonAnswerTots(); return(View("Lessons", modelObj)); }
public ActionResult StudentLessonDevView(string id, string id2) { if (NeedLogin()) { return(LoginRedir()); } string lessonID = Util.RenderHelp.URIDecode(id); string userID = Util.RenderHelp.URIDecode(id2); if (!IsAdmin()) { if (!AllowedLessons(CurrentUserEmail()).Contains(lessonID)) { return(RedirectToAction("StudentLessonDevSelect")); } } var lesson = LessonsCtrl.Get(lessonID); if (lesson == null) { return(RedirectToAction("StudentLessonDevSelect")); } var student = StudentsCtrl.Get(userID); if (student == null) { return(RedirectToAction("StudentLessonDevSelect")); } var turns = StudentsCtrl.DBConn().FindTurns(lessonID, userID); if (turns == null || turns.Count < 1) { return(RedirectToAction("StudentLessonDevSelect")); } var modelObj = new ExpandoObject(); var modelDict = (IDictionary <string, object>)modelObj; modelDict["ID"] = id; modelDict["ID2"] = id2; modelDict["LessonID"] = lessonID; modelDict["LessonName"] = lesson.ShortName; modelDict["UserID"] = userID; modelDict["Details"] = turns[0]; return(View("StudentLessonDevView", modelObj)); }
public ActionResult StudentLessonDrill(string id, string id2) { if (NeedLogin()) { return(LoginRedir()); } string lessonID = Util.RenderHelp.URIDecode(id); string userID = Util.RenderHelp.URIDecode(id2); if (!IsAdmin()) { if (!AllowedLessons(CurrentUserEmail()).Contains(lessonID)) { return(RedirectToAction("Lessons")); } } var lesson = LessonsCtrl.Get(lessonID); if (lesson == null) { return(RedirectToAction("Lessons")); } var student = StudentsCtrl.Get(userID); if (student == null) { return(RedirectToAction("Students")); } var turns = StudentsCtrl.DBConn().FindTurns(lessonID, userID); var detailLog = new List <ExpandoObject>(); if (turns == null || turns.Count < 1 || turns[0].Turns == null || turns[0].Turns.Count < 1) { detailLog.Add(DetailLogEntry(student, "No information")); } else { var details = turns[0]; string lastQuestion = "???"; string lastDiff = "M"; foreach (var turn in details.Turns) { if (turn.TurnID == StudentLessonActs.TURN_ID_START) { detailLog.Add(DetailLogEntry(student, "Start of Lesson Attempt", "Attempt", entry: turn)); } bool completion = false; //The ignore-case comparison we use const StringComparison CMP = StringComparison.InvariantCultureIgnoreCase; foreach (var act in turn.AllValidActions()) { if (String.Equals(act.Agent, "System", CMP)) { if (String.Equals(act.Act, "Display", CMP) && !String.IsNullOrWhiteSpace(act.Data)) { lastQuestion = act.Data; } if (String.Equals(act.Act, "End", CMP)) { completion = true; } } } string evt = null; bool correct = false; bool incorrect = false; if (turn.Input != null) { evt = turn.Input.Event; if (evt != null) { evt = evt.Trim().ToLowerInvariant(); if (evt == "correct") { correct = true; } else if (evt.StartsWith("incorrect")) { incorrect = true; } } } if (correct) { detailLog.Add(DetailLogEntry(student, "CORRECT", "Answer", lastQuestion, turn)); } else if (incorrect) { detailLog.Add(DetailLogEntry(student, "MISS", "Answer", lastQuestion, turn)); } if (turn.Transitions != null && turn.Transitions.Count > 0) { foreach (var tran in turn.Transitions) { string ruleID = tran.RuleID; if (String.IsNullOrWhiteSpace(ruleID)) { continue; } ruleID = ruleID.Trim().ToLowerInvariant(); //lastDiff string newState = null; if (ruleID.EndsWith("easy")) { newState = "E"; } else if (ruleID.EndsWith("medium")) { newState = "M"; } else if (ruleID.EndsWith("hard")) { newState = "H"; } if (newState != null && newState != lastDiff) { detailLog.Add(DetailLogEntry(student, lastDiff + " to " + newState, "PathChange", entry: turn)); lastDiff = newState; } } } if (completion) { detailLog.Add(DetailLogEntry(student, "Completed Lesson", "Completion", entry: turn)); } } } var modelObj = new ExpandoObject(); var modelDict = (IDictionary <string, object>)modelObj; modelDict["ID"] = id; modelDict["ID2"] = id2; modelDict["LessonID"] = lessonID; modelDict["LessonName"] = lesson.ShortName; modelDict["UserID"] = userID; modelDict["DetailLog"] = detailLog; modelDict["BlindTarget"] = student.FirstName; return(View("StudentLessonDrill", modelObj)); }