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())); }
 }
Ejemplo n.º 2
0
 public async Task <JsonResult> QUAUpdate()
 {
     try {
         var id        = Guid.Parse(Request.Form["id"]);
         var quizTaker = Guid.Parse(Request.Form["qtid"]);
         var point     = int.Parse(Request.Form["point"]);
         if (QuizUserAnswerService.Update(id, quizTaker, point))
         {
             return(Success(""));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.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())); }
 }