public static TrueFalseQuestion getTrueFalseQuestionFromData(TrueFalseQuestionData tfqData) { TrueFalseQuestion tfq = new TrueFalseQuestion(); tfq.ActivityName = tfqData.ActivityName; tfq.expID = tfqData.expID; tfq.id = tfqData.id; tfq.isMainActivity = tfqData.isMainActivity; tfq.RoomId = tfqData.RoomId; tfq.Type = tfqData.Type; tfq.question = tfqData.question; tfq.explaination = tfqData.explaination; tfq.correctAnswerBool = tfqData.correctAnswerBool; tfq.counterFalse = tfqData.counterFalse; tfq.counterTrue = tfqData.counterTrue; tfq.studentsAnswers = new List<AnswerByPhone>(); if (tfqData.studentsAnswers != null) { foreach (AnswerByPhoneData abpData in tfqData.studentsAnswers) { tfq.studentsAnswers.Add(getAnswerByPhoneFromData(abpData)); } } return tfq; }
public static TrueFalseQuestionData getTrueFalseQuestionAsData(TrueFalseQuestion tfq) { TrueFalseQuestionData tfqData = new TrueFalseQuestionData(); tfqData.ActivityName = tfq.ActivityName; tfqData.expID = tfq.expID; tfqData.id = tfq.id; tfqData.RoomId = tfq.RoomId; tfqData.question = tfq.question; tfqData.explaination = tfq.explaination; tfqData.correctAnswerBool = tfq.correctAnswerBool; tfqData.counterFalse = tfq.counterFalse; tfqData.counterTrue = tfq.counterTrue; tfqData.studentsAnswers = new List<AnswerByPhoneData>(); if (tfq.studentsAnswers != null) { foreach (AnswerByPhone abp in tfq.studentsAnswers) { tfqData.studentsAnswers.Add(getAnswerByPhoneAsData(abp)); } } return tfqData; }
public ActionResult SaveTrueFalseQuestion(TrueFalseQuestion ques) { TeacherData teacherData = rsContext.getTeacher(User.Identity.Name); if (ques.expID == -1) { ques.RoomId = teacherData.RoomId; TrueFalseQuestionData tfqData = Adapting.getTrueFalseQuestionAsData(ques); rsContext.addActivity(tfqData); rsContext.SaveChanges(); return RedirectToDashboard(); } else { ques.RoomId = 0; TrueFalseQuestionData tfqData = Adapting.getTrueFalseQuestionAsData(ques); rsContext.addActivity(tfqData); ExperimentData experimentData = (ExperimentData)rsContext.getActivity(ques.expID); tfqData.experimentOrder = experimentData.activities.Count; experimentData.addStep(tfqData); rsContext.SaveChanges(); return RedirectToAction("EditExperiment", new { ExpID = ques.expID }); } }