Example #1
0
        /// <summary>
        /// 设置正确选项
        /// </summary>
        /// <param name="questionOptionGuid"></param>
        public void SetCorrectOption(Guid questionOptionGuid)
        {
            if (QuestionOptions == null)
            {
                throw new Exception($"问题选项{questionOptionGuid}不存在!");
            }

            var qOption = QuestionOptions.FirstOrDefault(p => p.QuestionOptionGuid.Equals(questionOptionGuid));

            CorrectOption   = qOption ?? throw new Exception($"问题选项{questionOptionGuid}不存在!");
            CorrectOptionId = questionOptionGuid;
        }
Example #2
0
        /// <summary>
        /// 删除问题选项
        /// </summary>
        /// <param name="questionOptionGuid"></param>
        public void RemoveQuestionOption(Guid questionOptionGuid)
        {
            if (QuestionOptions == null)
            {
                throw new Exception($"问题选项{questionOptionGuid}不存在!");
            }
            var qOption = QuestionOptions.FirstOrDefault(p => p.QuestionOptionGuid.Equals(questionOptionGuid));

            if (qOption == null)
            {
                throw new Exception($"问题选项{questionOptionGuid}不存在!");
            }

            QuestionOptions.Remove(qOption);
            if (qOption.QuestionOptionGuid.Equals(CorrectOptionId))
            {
                CorrectOptionId = default(Guid);
                CorrectOption   = null;
            }
        }
Example #3
0
        /// <summary>
        /// 修改问题选项
        /// </summary>
        /// <param name="questionOptionGuid"></param>
        /// <param name="description"></param>
        public void UpdateQuestionOption(Guid questionOptionGuid, string description)
        {
            if (QuestionOptions == null)
            {
                throw new Exception($"问题选项{questionOptionGuid}不存在!");
            }
            var qOption = QuestionOptions.FirstOrDefault(p => p.QuestionOptionGuid.Equals(questionOptionGuid));

            if (qOption == null)
            {
                throw new Exception($"问题选项{questionOptionGuid}不存在!");
            }

            qOption.UpdateDescription(description);

            if (qOption.QuestionOptionGuid.Equals(CorrectOptionId))
            {
                CorrectOption = qOption;
            }
        }