public IActionResult UpdateExamQuestion(ExamQuestion.QuestionType type, int id, int examid, string stem, [FromBody] object[] parameters)
 {
     try
     {
         return(Ok(questionBll.UpdateExamQuestion(type, id, examid, stem, parameters)));
     }
     catch (Exception e)
     {
         return(NotFound(e.Message));
     }
 }
 public IActionResult AddExamQuestion(int type, int examid, string stem, [FromBody] object[] parameters)
 {
     try
     {
         ExamQuestion.QuestionType questionType = (ExamQuestion.QuestionType)type;
         return(Ok(questionBll.AddExamQuestion(questionType, examid, stem, parameters)));
     }
     catch (Exception e)
     {
         return(NotFound(e.Message));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 通过题目类型增加题目
        /// </summary>
        /// <param name="type">题目类型</param>
        /// <param name="examid">考试Id</param>
        /// <param name="stem">题目题干</param>
        /// <param name="parameters">题目参数</param>
        /// <returns>增加成功与否</returns>
        public bool AddExamQuestion(ExamQuestion.QuestionType type, int examid, string stem, object[] parameters)
        {
            bool result = false;

            try
            {
                result = questionDal.AddExamQuestion(type, examid, stem, parameters);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message); throw e;
            }
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 通过题目类型更改题目
        /// </summary>
        /// <param name="type">题目类型</param>
        /// <param name="id">题目Id</param>
        /// <param name="examid">考试Id</param>
        /// <param name="stem">题目题干</param>
        /// <param name="parameters">题目参数</param>
        /// <returns>更改成功与否</returns>
        public bool UpdateExamQuestion(ExamQuestion.QuestionType type, int id, int examid, string stem, object[] parameters)
        {
            if (parameters == null)
            {
                return(false);
            }
            ExaminationQuestion question = null;

            switch (type)
            {
            case ExamQuestion.QuestionType.ChoiceQuestion:
                if (parameters.Length == 2)
                {
                    List <string> ops = Newtonsoft.Json.JsonConvert.DeserializeObject <List <string> >(parameters[1].ToString());
                    question = new ChoiceQuestion(Convert.ToInt32(parameters[0].ToString()), ops.ToArray(), stem);
                }
                else
                {
                    return(false);
                }
                break;

            case ExamQuestion.QuestionType.GapFillingQuestion:
                if (parameters.Length == 1)
                {
                    question = new GapFillingQuestion(parameters[0].ToString(), stem);
                }
                else
                {
                    return(false);
                }
                break;

            case ExamQuestion.QuestionType.ShortAnswerQuestion:
                if (parameters.Length == 1)
                {
                    question = new ShortAnswerQuestion(parameters[0].ToString(), stem);
                }
                else
                {
                    return(false);
                }
                break;

            case ExamQuestion.QuestionType.TrueOrFalseQuestion:
                if (parameters.Length == 1)
                {
                    question = new TrueOrFalseQuestion(Convert.ToBoolean(parameters[0].ToString()), stem);
                }
                else
                {
                    return(false);
                }
                break;
            }
            if (question == null)
            {
                return(false);
            }
            ExamQuestion examQuestion = new ExamQuestion(id, examid, question);

            return(UpdateExaminationQuestion(examQuestion));
        }