//questionID, quizTakerID public async Task <JsonResult> QUAGet(string id, string qtid) { try { var data = QuizUserAnswerService.GetByQQIDQTID(Guid.Parse(id), Guid.Parse(qtid)); return(Success(QuizUserAnswerVM.MsToVMs(data))); } catch { return(Failed(MessageUtilityService.ServerError())); } }
public async Task <JsonResult> QTCheckTestScore() { try { var qtid = Guid.Parse(Request.Form["id"]); var aid = Guid.Parse(Request.Form["aid"]); var answers = QuizUserAnswerService.GetByQTID(qtid); var ts = 0f; foreach (var answer in answers) { //if multiple choice if (answer.OtherAnswer.Length <= 0) { var choiceSelected = QuizQuestionAnswerService.GetByID(answer.QuizAnswerID, answer.QuizQuestionID); answer.PointsEarned = choiceSelected.Points; } //if essay retain the assigned score QuizUserAnswerService.Update(answer.ID, answer.QuizTakersID, answer.QuizQuestionID, answer.QuizAnswerID, answer.OtherAnswer, answer.PointsEarned); ts += answer.PointsEarned; } //update total score var qtModel = QuizTakerService.GetByID(qtid); QuizTakerService.Update(qtid, qtModel.QuizInfoID, qtModel.UserID, ts, qtModel.DateTimeStorageID); return(Success(true)); } catch { return(Failed(MessageUtilityService.ServerError())); } }
public async Task <JsonResult> QUARemove() { try { var id = Guid.Parse(Request.Form["id"]); var quizTakerID = Guid.Parse(Request.Form["qtid"]); if (QuizUserAnswerService.Remove(id, quizTakerID)) { return(Success("")); } return(Failed(MessageUtility.ServerError())); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> QUARemove() { try { var id = Guid.Parse(Request.Form["id"]); var qtid = Guid.Parse(Request.Form["qtid"]); var qqid = Guid.Parse(Request.Form["qqid"]); var qaid = Guid.Parse(Request.Form["qaid"]); if (QuizUserAnswerService.Remove(id, qtid, qqid, qaid)) { return(Success(id.ToString())); } return(Failed(MessageUtilityService.FailedRemove("Answer"))); } catch { return(Failed(MessageUtilityService.ServerError())); } }
public async Task <JsonResult> QUAUpdate() { try { var id = Guid.Parse(Request.Form["id"]); var qtid = Guid.Parse(Request.Form["qtid"]); var qqid = Guid.Parse(Request.Form["qqid"]); var qaid = Guid.Parse(Request.Form["qaid"]); var oa = Request.Form["oa"]; var pe = float.Parse(Request.Form["pe"]); if (QuizUserAnswerService.Update(id, qtid, qqid, qaid, oa, pe)) { return(Success(id.ToString())); } return(Failed(MessageUtilityService.FailedUpdate("Answer"))); } catch { return(Failed(MessageUtilityService.ServerError())); } }
public async Task <JsonResult> QUAInsert() { try { var id = Guid.Parse(Request.Form["id"]); var questionTakerID = Guid.Parse(Request.Form["qtid"]); var questionQuizID = Guid.Parse(Request.Form["qqid"]); var quizAnswerID = Guid.Parse(Request.Form["qaid"]); var otherAnswer = Request.Form["oa"]; var points = int.Parse(Request.Form["point"]); if (QuizUserAnswerService.Insert(id, questionTakerID, questionQuizID, quizAnswerID, otherAnswer, points)) { return(Success(id.ToString())); } return(Failed(MessageUtility.ServerError())); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> QUAGet() { try { var qiid = Guid.Parse(Request.Form["qiid"]); var aid = Guid.Parse(Request.Form["aid"]); var qtid = Guid.Parse(Request.Form["qtid"]); var questions = QuizQuestionsService.GetByQIID(qiid); questions = QuizQuestionsService.SortByOrder(questions, false); var vmQues = QuizQuestionsService.SetSubDatas(questions, aid); var uanswers = QuizUserAnswerVM.MsToVMs(QuizUserAnswerService.GetByQTID(qtid)); foreach (var model in vmQues) { model.UserAnswers = uanswers.Where(x => x.QuizQuestionID == model.ID).ToList(); } return(Success(vmQues)); } catch { return(Failed(MessageUtilityService.ServerError())); } }