Beispiel #1
0
 public JsonResult SaveQuestion(QuestionViewModel questionViewModel)
 {
     try
     {
         var savedQuestion = QuestionsManagementService.SaveQuestion(questionViewModel.ToQuestion());
         return(Json(QuestionViewModel.FromQuestion(savedQuestion)));
     }
     catch (Exception e)
     {
         return(Json(new { ErrorMessage = e.Message }));
     }
 }
Beispiel #2
0
        public JsonResult GetQuestion(int id)
        {
            var test = id == 0
                ? new QuestionViewModel {
                Answers = new[] { new AnswerViewModel {
                                      IsCorrect = 0
                                  } }, ComplexityLevel = 1
            }
                : QuestionViewModel.FromQuestion(QuestionsManagementService.GetQuestion(id));

            return(Json(test, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        public JsonResult AddQuestionsFromAnotherTest(int[] questionItems, int testId)
        {
            try
            {
                QuestionsManagementService.CopyQuestionsToTest(testId, questionItems);

                return(Json("Ok"));
            }
            catch (Exception e)
            {
                return(Json(new { ErrorMessage = e.Message }));
            }
        }
Beispiel #4
0
 public JsonResult DeleteQuestion(int id)
 {
     QuestionsManagementService.DeleteQuestion(id);
     return(Json(id));
 }
Beispiel #5
0
        public JsonResult GetQuestions(int testId)
        {
            var questions = QuestionsManagementService.GetQuestionsForTest(testId).Select(QuestionItemListViewModel.FromQuestion).ToArray();

            return(Json(questions, JsonRequestBehavior.AllowGet));
        }