コード例 #1
0
ファイル: QuestionDTO.cs プロジェクト: jlaci/erlab-webapi
 private void MapTrueOrFalse(TrueOrFalseQuestion trueOrFalseQuestion)
 {
     this.QuestionType    = QuestionType.TrueOrFalse;
     this.PossibleAnswers = new List <string>()
     {
         "true", "false"
     };
     this.MaxAnswerLength = 1;
 }
コード例 #2
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));
        }