/// <summary> /// Author: Mrunmay NAphade /// Date: 24/10/18 /// </summary> /// <param name="serialno"></param> /// <param name="testID"></param> /// <param name="answer"></param> /// <returns>Marks the answer for given question</returns> public bool MarkAnswer(int serialno, int utestID, string answer) { try { userTestAnswer option = context.userTestAnswers.FirstOrDefault(ans => ans.srno == serialno && ans.userTestID == utestID); if (option.question.answerType == 1) { option.answerMarked = answer; } if (context.SaveChanges() > 0) { return(true); } else { return(false); } } catch (SqlException e) { throw; } catch (Exception e) { throw; } }
public userTestAnswer GetNextQuestion(int srno, int utestID, int currentsrno) { try { userTestAnswer ques = userData.GetQuestionBySrNo(srno, utestID); if (userData.AddTotestlog(utestID, ques.question.topicID.Value)) { return(new userTestAnswer { question = new question { marks = ques.question.marks, option1 = ques.question.option1, option2 = ques.question.option2, option3 = ques.question.option3, option4 = ques.question.option4, questionID = ques.question.questionID, questionText = ques.question.questionText, testid = ques.question.testid, topicID = ques.question.topicID, topic = ques.question.topic }, questionID = ques.questionID, srno = ques.srno, userTestID = ques.userTestID, answerMarked = ques.answerMarked, }); } else { throw new Exception("Could'nt add topic to logs"); } } catch (Exception) { throw; } }