public ActionResult StudentsProgress(ActiveExperiment ae, bool flag = false) { ActiveExperimentData aeData = Adapting.getActiveExperimentAsData(ae); ExperimentData expData = (ExperimentData)rsContext.getActivity(ae.ExpID); if (flag == false) { rsContext.addActiveExperiment(aeData); } expData.ActiveExpID = aeData.ActiveExpID; ae.ActiveExpID = aeData.ActiveExpID; rsContext.SaveChanges(); TempData["NumberOfExperimentSteps"] = expData.activities.Count; TempData["DifferenceBetweenMeasures"] = 0; TempData["NumOfMeasures"] = 0; foreach (ActivityData act in expData.activities) { if (act is MeasurementData) { MeasurementData measurement = (MeasurementData)act; TempData["DifferenceBetweenMeasures"] = measurement.DifferenceBetweenMeasures; TempData["NumOfMeasures"] = measurement.NumOfMeasures; } } return(View("StudentsProgress", ae)); }
// This function used by the view "DisplayExperimentLog" public ActionResult GetDataForCollaborativeGraphAsJSON(long ActiveExpID) { ActiveExperimentData activeExpData = (ActiveExperimentData)rsContext.getActiveExperiment(ActiveExpID); var groupsProgress = new List <Object>(); foreach (GroupData gData in rsContext.getGroupsByActiveExpID(ActiveExpID)) { //StudentData sData = gData.getfirstInStudents(); //if (sData == null) // return null; var students = gData.studentListAsString; string groupName = students.Split(',')[0]; var measurements = new List <Object>(); MeasurementByGroupIdData md = gData.getLastInMeasurements(); if (md == null) // no measurements yet { groupsProgress.Add(new { GroupName = groupName, Progress = gData.Progress, GroupMeasurements = new List <Object>(), GroupStudents = students }); continue; } foreach (OneMeasureByGroupIdData om in md.measurements) { // TODO: PAY ATTENTION: THIS CODE IS ONLY FOR ONE PARAMETER! measurements.Add(om.getFirstInMeasurements()); } groupsProgress.Add(new { GroupName = groupName, Progress = gData.Progress, GroupMeasurements = measurements, GroupStudents = students }); } return(Json(groupsProgress, JsonRequestBehavior.AllowGet)); }
// GET: Student/GroupCreation public ActionResult GroupCreation(long expId, string studentPhone, long studentRoom) { ExperimentData expData = (ExperimentData)rsContext.getActivity(expId); ActiveExperimentData aeData = rsContext.getActiveExperiment(expData.ActiveExpID); TempData["ActiveExpID"] = aeData.ActiveExpID; TempData["StudentPhone"] = studentPhone; TempData["StudentRoom"] = studentRoom; return(View()); }
public static ActiveExperiment getActiveExperimentFromData(ActiveExperimentData aeData) { ActiveExperiment ae = new ActiveExperiment(); ae.ActiveExpID = aeData.ActiveExpID; ae.ExpID = aeData.ExpID; ae.MaxStudentPerGroup = aeData.MaxStudentPerGroup; ae.NumberOfGroups = aeData.NumberOfGroups; return(ae); }
public ActionResult SaveNewGroup(List <string> allStudentPhones, long activeExpId, long roomId) { // add group to activeExp List <StudentData> students = new List <StudentData>(); bool allAvailable = true; StudentData sd; string errMsg = ""; foreach (string currentStudentPhone in allStudentPhones) { sd = rsContext.getStudent(currentStudentPhone, roomId); if (sd == null || !sd.isAvailable()) { allAvailable = false; if (sd == null) { errMsg = Resources.Resources.StudentErrorMsg1; } else { errMsg = Resources.Resources.StudentErrorMsg2; } } students.Add(sd); } if (!allAvailable) { TempData["StudentPhone"] = allStudentPhones.ElementAt(0); TempData["ActiveExpID"] = activeExpId; TempData["StudentRoom"] = roomId; TempData["errorMessage"] = errMsg; return(PartialView("CreateGroupForm")); } GroupData groupData = new GroupData(activeExpId, students); rsContext.addGroup(groupData); foreach (StudentData currentSD in students) { currentSD.GroupID = groupData.GroupID; } string studentPhone = allStudentPhones[0]; ActiveExperimentData aeData = rsContext.getActiveExperiment(activeExpId); aeData.IncrementCreatedGroupsCounter(); rsContext.SaveChanges(); return(RedirectToAction("Experiment", new { expId = aeData.ExpID, studentPhone = studentPhone, studentRoom = roomId, currActivityIndex = 0 })); }
public ActionResult ShowCurrentActivity() { TeacherData teacherData = rsContext.getTeacher(User.Identity.Name); RoomData roomData = rsContext.getRoom(teacherData.RoomId); ActivityData currActivity = rsContext.getActivity(roomData.CurrentActivityId); if (currActivity == null) { TempData["alertMessage"] = Resources.Resources.ThereIsNoActivityActivated; return(RedirectToAction("Dashboard")); } else { if (currActivity is TrueFalseQuestionData) { return(View("DisplayTrueFalseQuestion", Adapting.getTrueFalseQuestionFromData((TrueFalseQuestionData)currActivity))); } else if (currActivity is ShortAnswerQuestionData) { return(View("DisplayShortAnswerQuestion", Adapting.getShortAnswerQuestionFromData((ShortAnswerQuestionData)currActivity))); } else if (currActivity is AmericanQuestionData) { return(View("DisplayAmericanQuestion", Adapting.getAmericanQuestionFromData((AmericanQuestionData)currActivity))); } else // experiment { ExperimentData expData = (ExperimentData)currActivity; if (expData.ActiveExpID == 0) { return(RedirectToAction("GroupSelection", new { ExpID = expData.id })); } else { ActiveExperimentData ae = rsContext.getActiveExperiment(expData.ActiveExpID); return(StudentsProgress(Adapting.getActiveExperimentFromData(ae), true)); } } } }
public ActionResult GetGroupsAsJSON(long ActiveExpID) { ActiveExperimentData activeExpData = (ActiveExperimentData)rsContext.getActiveExperiment(ActiveExpID); var groupsProgress = new List <Object>(); foreach (GroupData gData in rsContext.getGroupsByActiveExpID(ActiveExpID)) { StudentData sData = gData.getfirstInStudents(); if (sData == null) { return(null); } string groupName = sData.FirstName + " " + sData.LastName; var students = new List <Object>(); foreach (StudentData sd in gData.Students) { students.Add(" " + sd.FirstName + " " + sd.LastName); } var measurements = new List <Object>(); MeasurementByGroupIdData md = gData.getLastInMeasurements(); if (md == null) // no measurements yet { groupsProgress.Add(new { GroupName = groupName, Progress = gData.Progress, GroupMeasurements = new List <Object>(), GroupStudents = students }); continue; } foreach (OneMeasureByGroupIdData om in md.measurements) { // TODO: PAY ATTENTION: THIS CODE IS ONLY FOR ONE PARAMETER! measurements.Add(om.getFirstInMeasurements()); } groupsProgress.Add(new { GroupName = groupName, Progress = gData.Progress, GroupMeasurements = measurements, GroupStudents = students }); } return(Json(groupsProgress, JsonRequestBehavior.AllowGet)); }
public ActionResult CreateGroupForm(long ActiveExpId, string studentPhone, long studentRoom) { StudentData sd = rsContext.getStudent(studentPhone, studentRoom); if (!sd.isAvailable()) { TempData["alertMessage"] = Resources.Resources.YouAreAlreadyInAGroup; return(RedirectToAction("StudentLogin", "Account")); } ActiveExperimentData aeData = rsContext.getActiveExperiment(ActiveExpId); if (aeData.NumberCreatedGroups == aeData.NumberOfGroups) { return(RedirectToAction("ShowNoAvailableGroups")); } else { TempData["MaxStudentsPerGroup"] = aeData.MaxStudentPerGroup; TempData["StudentPhone"] = studentPhone; TempData["StudentRoom"] = studentRoom; TempData["ActiveExpID"] = ActiveExpId; return(View()); } }
// GET: Teacher/DashboardAfterLog public ActionResult DashboardAfterLog(long id) { TeacherData teacherData = rsContext.getTeacher(User.Identity.Name); RoomData roomData = rsContext.getRoom(teacherData.RoomId); roomData.updateCurrentActivityId(0); rsContext.SaveChanges(); // Save activity log ActivityData actData = rsContext.getActivity(id); if (actData is TrueFalseQuestionData) { TFQLogData tfqlData = new TFQLogData((TrueFalseQuestionData)actData, DateTime.Now); rsContext.addActivityLog(tfqlData); ((TrueFalseQuestionData)actData).reset(); rsContext.SaveChanges(); } else if (actData is AmericanQuestionData) { AmericanLogData aqlData = new AmericanLogData((AmericanQuestionData)actData, DateTime.Now); rsContext.addActivityLog(aqlData); ((AmericanQuestionData)actData).reset(); rsContext.SaveChanges(); } else if (actData is ShortAnswerQuestionData) { SALogData saqlData = new SALogData((ShortAnswerQuestionData)actData, DateTime.Now); rsContext.addActivityLog(saqlData); ((ShortAnswerQuestionData)actData).reset(); rsContext.SaveChanges(); } else { ActiveExperimentData aed = rsContext.getActiveExperiment(id); actData = rsContext.getActivity(aed.ExpID); // The experiment // Save Experiment Log long NumOfMeasuresToCollaborativeGraph = ((ExperimentData)actData).getNumOfMeasures(); long DiffBetweenMeasuresToCollaborativeGraph = ((ExperimentData)actData).getDiffBetweenMeasures(); ExperimentLogData expLogData = new ExperimentLogData((ExperimentData)actData, DateTime.Now, NumOfMeasuresToCollaborativeGraph, DiffBetweenMeasuresToCollaborativeGraph); rsContext.addActivityLog(expLogData); // Save for each group its students foreach (GroupData gData in rsContext.getGroupsByActiveExpID(id)) { gData.SaveAllStudentInGroupAsList(); } // Initialize Students and ExperimentData ActiveExperimentData activeExpData = rsContext.getActiveExperiment(id); List <StudentData> studentsInRoom = rsContext.getStudentsByTeacher(roomData.id); foreach (StudentData studentData in studentsInRoom) { studentData.GroupID = 0; } ExperimentData expData = (ExperimentData)rsContext.getActivity(activeExpData.ExpID); expData.ActiveExpID = 0; rsContext.SaveChanges(); } return(RedirectToDashboard()); }