private static GeneralAnswerOption CopyAnswerOptionModel(SlideQuestionModel slideQuestionModel, GeneralAnswerOption answerOption) { if (answerOption.AnswerOptionType == AnswerOptionType.ShowRangedAnswerOption) { var newAnswerOption = new GeneralAnswerOption { Id = answerOption.Id, RangedLowerLimit = answerOption.RangedLowerLimit, RangedCorrectValue = answerOption.RangedCorrectValue, RangedHigherLimit = answerOption.RangedHigherLimit, AnswerOptionType = AnswerOptionType.ShowRangedAnswerOption }; return(newAnswerOption); } else { var newAnswerOption = new GeneralAnswerOption(); newAnswerOption.ObjectChangedEventHandler += delegate { slideQuestionModel.AnswerOptionsSet = true; slideQuestionModel.AnswerOptionModelChanged(); }; newAnswerOption.Id = answerOption.Id; newAnswerOption.Position = answerOption.Position; newAnswerOption.AlphabeticPosition = answerOption.AlphabeticPosition; newAnswerOption.Text = answerOption.Text; newAnswerOption.IsTrue = answerOption.IsTrue; return(newAnswerOption); } throw new ArgumentException($"Unknow answer option type {answerOption.GetType()}"); }
private GeneralAnswerOption CreateGeneralAnswerOption(int position = 1, string text = "", bool isTrue = false) { var generalAnswerOption = new GeneralAnswerOption { Id = Guid.NewGuid(), Position = position, AlphabeticPosition = this.GetAlphabeticPosition(position), Text = text, IsTrue = isTrue }; generalAnswerOption.ObjectChangedEventHandler += delegate { this.SlideQuestionModel.AnswerOptionsSet = true; this.SlideQuestionModel.AnswerOptionModelChanged(); }; return(generalAnswerOption); }
private AnswerOptionModel SlideAnswerOptionModelToAnswerOptionModel(GeneralAnswerOption answerOption, string hashtag, int questionIndex, bool isFreetextAnswerOption) { var answerOptionModel = new AnswerOptionModel { hashtag = Uri.EscapeDataString(hashtag), questionIndex = questionIndex, answerText = Uri.EscapeDataString(answerOption.Text), answerOptionNumber = answerOption.Position - 1, isCorrect = answerOption.IsTrue, type = isFreetextAnswerOption ? "FreeTextAnswerOption" : "DefaultAnswerOption" }; if (isFreetextAnswerOption) { answerOptionModel.configCaseSensitive = answerOption.ConfigCaseSensitive; answerOptionModel.configTrimWhitespaces = answerOption.ConfigTrimWhitespaces; answerOptionModel.configUseKeywords = answerOption.ConfigUseKeywords; answerOptionModel.configUsePunctuation = answerOption.ConfigUsePunctuation; } return(answerOptionModel); }