Example #1
0
        public static AmericanQuestion getAmericanQuestionFromData(AmericanQuestionData aqData)
        {
            AmericanQuestion aq = new AmericanQuestion();

            aq.ActivityName   = aqData.ActivityName;
            aq.expID          = aqData.expID;
            aq.id             = aqData.id;
            aq.isMainActivity = aqData.isMainActivity;
            aq.RoomId         = aqData.RoomId;
            aq.Type           = aqData.Type;

            aq.question     = aqData.question;
            aq.explaination = aqData.explaination;

            aq.counterFirst  = aqData.counterFirst;
            aq.counterSecond = aqData.counterSecond;
            aq.counterThird  = aqData.counterThird;
            aq.counterFourth = aqData.counterFourth;
            aq.correctAnswer = aqData.correctAnswer;

            aq.firstAnswer  = aqData.firstAnswer;
            aq.secondAnswer = aqData.secondAnswer;
            aq.thirdAnswer  = aqData.thirdAnswer;
            aq.fourthAnswer = aqData.fourthAnswer;

            aq.studentsAnswers = new List <AnswerByPhone>();
            if (aqData.studentsAnswers != null)
            {
                foreach (AnswerByPhoneData abpData in aqData.studentsAnswers)
                {
                    aq.studentsAnswers.Add(getAnswerByPhoneFromData(abpData));
                }
            }
            return(aq);
        }
Example #2
0
        public static AmericanQuestion getAmericanQuestionFromData(AmericanQuestionData aqData)
        {
            AmericanQuestion aq = new AmericanQuestion();
            aq.ActivityName = aqData.ActivityName;
            aq.expID = aqData.expID;
            aq.id = aqData.id;
            aq.isMainActivity = aqData.isMainActivity;
            aq.RoomId = aqData.RoomId;
            aq.Type = aqData.Type;

            aq.question = aqData.question;
            aq.explaination = aqData.explaination;

            aq.counterFirst = aqData.counterFirst;
            aq.counterSecond = aqData.counterSecond;
            aq.counterThird = aqData.counterThird;
            aq.counterFourth = aqData.counterFourth;
            aq.correctAnswer = aqData.correctAnswer;

            aq.firstAnswer = aqData.firstAnswer;
            aq.secondAnswer = aqData.secondAnswer;
            aq.thirdAnswer = aqData.thirdAnswer;
            aq.fourthAnswer = aqData.fourthAnswer;

            aq.studentsAnswers = new List<AnswerByPhone>();
            if (aqData.studentsAnswers != null)
            {
                foreach (AnswerByPhoneData abpData in aqData.studentsAnswers)
                {
                    aq.studentsAnswers.Add(getAnswerByPhoneFromData(abpData));
                }
            }
            return aq;
        }
        public ActionResult SaveAmericanQuestion(AmericanQuestion ques)
        {

            TeacherData teacherData = rsContext.getTeacher(User.Identity.Name);

            if (ques.expID == -1)
            {
                ques.RoomId = teacherData.RoomId;
                AmericanQuestionData aqData = Adapting.getAmericanQuestionAsData(ques);
                rsContext.addActivity(aqData);
                rsContext.SaveChanges();
                return RedirectToDashboard();
            }

            else
            {
                ques.RoomId = 0;
                AmericanQuestionData aqData = Adapting.getAmericanQuestionAsData(ques);
                rsContext.addActivity(aqData);
                ExperimentData experimentData = (ExperimentData)rsContext.getActivity(ques.expID);
                aqData.experimentOrder = experimentData.activities.Count;
                experimentData.addStep(aqData);
                rsContext.SaveChanges();
                return RedirectToAction("EditExperiment", new { ExpID = ques.expID });
            }

        }