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> QQAGetByID(string id, string qqid)
 {
     try {
         var data = QuizQuestionAnswerService.GetByID(Guid.Parse(id), Guid.Parse(qqid));
         return(Success(QuizQuestionAnswerVM.MToVM(data)));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
 //nid=qqid
 public async Task <JsonResult> QQAGet(string id, string aid, string nid)
 {
     try {
         var data = QuizQuestionAnswerService.GetByID(Guid.Parse(id), Guid.Parse(nid));
         var vms  = QuizQuestionAnswerService.SetSubData(data, Guid.Parse(aid));
         return(Success(vms));
     } catch { return(Failed(MessageUtilityService.ServerError())); }
 }