// GET: Activities/DisplaySALog
        public ActionResult DisplaySALog(long ActivityId)
        {
            SALogData saqlData = (SALogData)rsContext.getActivityLog(ActivityId);
            SALog     saql     = Adapting.getShortAnswerQuestionLogFromData(saqlData);

            return(View(saql));
        }
Beispiel #2
0
        public static SALog getShortAnswerQuestionLogFromData(SALogData saqLogData)
        {
            SALog saqLog = new SALog();

            saqLog.ActivityName = saqLogData.ActivityName;
            saqLog.expID        = saqLogData.expID;
            saqLog.id           = saqLogData.id;
            saqLog.RoomId       = saqLogData.RoomId;

            saqLog.question     = saqLogData.question;
            saqLog.explaination = saqLogData.explaination;

            saqLog.correctAnswerString = saqLogData.correctAnswerString;

            saqLog.studentsAnswers = new List <AnswerByPhone>();
            if (saqLogData.studentsAnswers != null)
            {
                foreach (AnswerByPhoneData abpData in saqLogData.studentsAnswers)
                {
                    saqLog.studentsAnswers.Add(getAnswerByPhoneFromData(abpData));
                }
            }
            return(saqLog);
        }
        // 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());
        }