Esempio n. 1
0
        public IHttpActionResult TestAnswer(TestAnswerModel data)
        {
            //get user Id
            var userWithClaims = (ClaimsPrincipal)User;
            var userCo         = Convert.ToInt64(userWithClaims.Claims.First(c => c.Type == "userId").Value);

            var result = new Response();

            try
            {
                var res = ClsDatabase.ExecuteDatatableSP("SPCHTTestSaveResult",
                                                         ClsDatabase.GenParameters("@SignalCo", data.TestId, "@UserCo", userCo, "@Res", data.Answer), 1);
                result.Code = (int)ResponseType.Ok;

                if (result.Code == 200)
                {
                    result.Message = "Success";
                }
                result.Data = res.Rows[0].Table;


                return(Ok(result));
            }
            catch (Exception e)
            {
                string ex = e.InnerException.ToString();
                result.Code    = 400;
                result.Message = "Server error";
                return(Ok(result));
            }
        }
 public TestPassingAnswerModel(TestAnswerModel answerModel, int questionType)
 {
     Id                   = answerModel.Id;
     QuestionType         = questionType;
     Content              = answerModel.Content;
     IsSelected           = false;
     CorrectnessIndicator = answerModel.СorrectnessIndicator;
 }
Esempio n. 3
0
        public void Update(int id, [FromBody] TestAnswerModel value)
        {
            var existingTestAnswer = testAnswers.Find(id);

            if (existingTestAnswer != null)
            {
                existingTestAnswer.Content      = value.Content;
                existingTestAnswer.N_QuestionId = value.QuestionId;
                db.SaveChanges();
            }
        }
 public TestResultServiceTestBase()
 {
     testModel            = new TestModel();
     testAnswerModel      = new TestAnswerModel(testModel);
     testWrongAnswerModel = new TestWrongAnswerModel(testModel);
 }
Esempio n. 5
0
 public static TestAnswer TestAnswerModelToTestAnswer(TestAnswerModel value)
 {
     return(new TestAnswer {
         Id = value.Id, Content = value.Content, N_QuestionId = value.QuestionId
     });
 }
Esempio n. 6
0
 public void Add([FromBody] TestAnswerModel value)
 {
     testAnswers.Add(TestAnswerConverter.TestAnswerModelToTestAnswer(value));
     db.SaveChanges();
 }