public static ShortAnswerQuestion getShortAnswerQuestionFromData(ShortAnswerQuestionData saqData) { ShortAnswerQuestion saq = new ShortAnswerQuestion(); saq.ActivityName = saqData.ActivityName; saq.expID = saqData.expID; saq.id = saqData.id; saq.RoomId = saqData.RoomId; saq.question = saqData.question; saq.explaination = saqData.explaination; saq.correctAnswerString = saqData.correctAnswerString; saq.studentsAnswers = new List <AnswerByPhone>(); if (saqData.studentsAnswers != null) { foreach (AnswerByPhoneData abpData in saqData.studentsAnswers) { saq.studentsAnswers.Add(getAnswerByPhoneFromData(abpData)); } } return(saq); }
public static ShortAnswerQuestion getShortAnswerQuestionFromData(ShortAnswerQuestionData saqData) { ShortAnswerQuestion saq = new ShortAnswerQuestion(); saq.ActivityName = saqData.ActivityName; saq.expID = saqData.expID; saq.id = saqData.id; saq.RoomId = saqData.RoomId; saq.question = saqData.question; saq.explaination = saqData.explaination; saq.correctAnswerString = saqData.correctAnswerString; saq.studentsAnswers = new List<AnswerByPhone>(); if (saqData.studentsAnswers != null) { foreach (AnswerByPhoneData abpData in saqData.studentsAnswers) { saq.studentsAnswers.Add(getAnswerByPhoneFromData(abpData)); } } return saq; }
public ActionResult SaveShortAnswerQuestion(ShortAnswerQuestion ques) { TeacherData teacherData = rsContext.getTeacher(User.Identity.Name); if (ques.expID == -1) { ques.RoomId = teacherData.RoomId; ShortAnswerQuestionData saData = Adapting.getShortAnswerQuestionAsData(ques); rsContext.addActivity(saData); rsContext.SaveChanges(); return RedirectToDashboard(); } else { ques.RoomId = 0; ShortAnswerQuestionData saData = Adapting.getShortAnswerQuestionAsData(ques); rsContext.addActivity(saData); ExperimentData experimentData = (ExperimentData)rsContext.getActivity(ques.expID); saData.experimentOrder = experimentData.activities.Count; experimentData.addStep(saData); rsContext.SaveChanges(); return RedirectToAction("EditExperiment", new { ExpID = ques.expID }); } }