public static List <QuizQuestionsVM> SetUserAnswers(Guid qtid, List <QuizQuestionsVM> list) { foreach (var item in list) { item.UserAnswers = QuizUserAnswerVM.MsToVMs(QuizUserAnswerService.GetByQQIDQTID(Guid.Parse(item.ID), qtid)); } return(list); }
public static QuizQuestionAnswerVM SetSurveyFormat(QuizQuestionAnswer model, Guid qiid, int takerCount, Guid aid) { var temp = SetSubData(model, aid); var answered = QuizUserAnswerService.GetByQQIDQAID(model.QuizQuestionsID, model.ID).Count(); temp.Percent = takerCount > 0? (answered / takerCount) * 100:0; return(temp); }
public static bool Remove(Guid id, Guid qiid, Guid aid) { try { using (var context = new CentralProcessContext()) { var query = (from i in context.QuizTakersDB where i.ID == id && i.QuizInfoID == qiid select i).FirstOrDefault(); context.QuizTakersDB.Remove(query); context.SaveChanges(); //remove quizUserAnswers if (QuizUserAnswerService.RemoveByQTID(id) && DateTimeStorageService.Remove(query.DateTimeStorageID, aid, query.ID)) { return(true); } return(false); } } catch { return(false); } }