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())); }
 }
Пример #2
0
 public async Task <JsonResult> QUAGetByQTID(string id)
 {
     try {
         var data = QuizUserAnswerService.GetByQTID(Guid.Parse(id));
         return(Success(QuizUserAnswerVM.MsToVMs(data)));
     } 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())); }
 }