コード例 #1
0
        public Question Create(int surveyTemplateID, SurveyQuestionType questionType)
        {
            switch (questionType)
            {
            case SurveyQuestionType._input:
                return(new InputQuestion(surveyTemplateID));

            case SurveyQuestionType._LikelyQuestion:
                return(new LikelyQuestion(surveyTemplateID));

            case SurveyQuestionType._MatricSelection:
                return(new MatricsQuestion(surveyTemplateID));

            case SurveyQuestionType._Range:
                return(new RangeQuestion(surveyTemplateID));

            case SurveyQuestionType._Ranking:
                return(new RankingQuestion(surveyTemplateID));

            case SurveyQuestionType._singleSelection:
                return(new SingleSelectionQuestion(surveyTemplateID));

            case SurveyQuestionType._MatricsMultiChoice:
                return(new MatricsMultiChoiseQuestion(surveyTemplateID));

            default:
                return(new InputQuestion(surveyTemplateID));
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="questionType"></param>
        /// <returns></returns>
        public Question NewQuestionWithDefault(int surveyTemplateID, SurveyQuestionType questionType, int pageNo)
        {
            var question = QuestionFactory.Create(
                new QuestionHanlderFactory(), surveyTemplateID, questionType);

            question.PageNo = pageNo;
            return(question.Default());
        }
        public static SurveyQuestion Get(SurveyQuestionType questionType)
        {
            switch (questionType)
            {
                case SurveyQuestionType.ValidText:
                    return new SurveyQuestion(
                        SurveysConstants.TextQuestionTypeIndex,
                        SurveysConstants.TextQuestionText);

                case SurveyQuestionType.ValidTextArea:
                    return new SurveyQuestion(
                        SurveysConstants.TextAreaQuestionTypeIndex,
                        SurveysConstants.TextAreaQuestionText);

                case SurveyQuestionType.ValidCheckbox:
                    return new SurveyQuestion(
                        SurveysConstants.CheckBoxQuestionTypeIndex,
                        SurveysConstants.CheckBoxQuestionText);

                case SurveyQuestionType.ValidRadio:
                    return new SurveyQuestion(
                        SurveysConstants.RadioQuestionTypeIndex,
                        SurveysConstants.RadioQuestionText);

                case SurveyQuestionType.ValidWithMaxBoundaryCharactersNumber:
                    return new SurveyQuestion(
                        SurveysConstants.TextQuestionTypeIndex,
                        SurveysConstants.Valid2000CharacterQuestionText);

                case SurveyQuestionType.InvalidWithEmptyType:
                    return new SurveyQuestion(
                        0,
                        SurveysConstants.TextQuestionText);

                case SurveyQuestionType.InvalidWithEmptyText:
                    return new SurveyQuestion(
                        SurveysConstants.TextQuestionTypeIndex,
                        string.Empty);

                case SurveyQuestionType.InvalidWithHigherCharactersNumber:
                    return new SurveyQuestion(
                        SurveysConstants.TextQuestionTypeIndex,
                        SurveysConstants.Invalid2001CharacterQuestionText);

                case SurveyQuestionType.InvalidWithOneCharacter:
                    return new SurveyQuestion(
                        SurveysConstants.TextQuestionTypeIndex,
                        "?");

                default:
                    throw new ArgumentException();
            }
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="questionType"></param>
        /// <returns></returns>
        public Question NewQuestion(int surveyTemplateID, SurveyQuestionType questionType, int pageNo, string choices = "")
        {
            CheckDataSecurity();
            var question = CuteSurvey.SurveyFactory.Component.QuestionFactory.Create(
                new QuestionHanlderFactory(), surveyTemplateID, questionType);

            if (choices != "")
            {
                question.Choices.Add(choices.Split(Convert.ToChar(',')));
            }
            question.PageNo = pageNo;
            return(question);
        }
コード例 #5
0
ファイル: LikertGUI.cs プロジェクト: zookae/Microgames
    public LikertQuestion(string question, string[] options, SurveyQuestionType questionType)
    {
        this.Question     = question;
        this.Options      = options;
        this.QuestionType = questionType;

        // Bools all default to false
        optionsSelected = new bool[Options.Length];
        manualText      = "";

        // Need to set a default value for the single-selects
        // Defaults to the middle value
        if (QuestionType == SurveyQuestionType.SingleOptionSelect)
        {
            int index = Options.Length / 2;
            if (Options.Length % 2 != 0)
            {
                index = (Options.Length + 1) / 2;
            }
            index = (index <= 0) ? 0 : index - 1;
            optionsSelected[index] = true;
        }
    }
コード例 #6
0
 public IQuestionFactory CreateDefault(int surveyTemplateID, SurveyQuestionType questionType)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
 public static Question CreateDefault(IQuestionFactory factory, int surveyTemplateID, SurveyQuestionType surveyQuestionType)
 {
     return(factory.Create(surveyTemplateID, surveyQuestionType));
 }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectSurveyQuestion"/> class.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="type"></param>
 public SelectSurveyQuestion(string id, SurveyQuestionType type) : base(id, type)
 {
 }
コード例 #9
0
ファイル: SurveyModel.cs プロジェクト: xgalv/Cryptool2
        /// <summary>
        /// Extracts a numeric question from the given answerRoot.
        /// </summary>
        /// <param name="answerRoot">The answer root.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        private static SurveyQuestion ExtractNumericQuestion(XmlNode answerRoot, string id, SurveyQuestionType type)
        {
            //get given answer if pressent
            var answered     = -1;
            var answeredNode = answerRoot.SelectSingleNode("answered");

            if (answeredNode != null)
            {
                answered = int.Parse(answeredNode.InnerText);
            }

            // get question answer range
            if (answerRoot.Attributes == null || answerRoot.Attributes["from"] == null || answerRoot.Attributes["to"] == null)
            {
                return(null);
            }

            return(new NumericSurveyQuestion(id, type)
            {
                From = int.Parse(answerRoot.Attributes["from"].Value),
                To = int.Parse(answerRoot.Attributes["to"].Value),
                Answered = answered
            });
        }
コード例 #10
0
ファイル: SurveyModel.cs プロジェクト: xgalv/Cryptool2
        /// <summary>
        /// Extracts a selection question from the given answerRoot.
        /// </summary>
        /// <param name="answerRoot">The answer root.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        private static SurveyQuestion ExtractSelectionQuestion(XmlNode answerRoot, string id, SurveyQuestionType type)
        {
            //extract question answers from xml
            var answerList = new List <SelectSurveyAnswer>();
            var answer     = answerRoot.SelectNodes("answer");

            if (answer == null)
            {
                return(null);
            }

            // get all possible answers
            foreach (XmlNode answerNode in answer)
            {
                if (answerNode.Attributes == null)
                {
                    continue;
                }

                //has the answer been selected previously?
                var isSelected        = false;
                var selectedAttribute = answerNode.Attributes["selected"];
                if (selectedAttribute != null)
                {
                    isSelected = bool.Parse(selectedAttribute.Value);
                }

                //add answer to list
                answerList.Add(new SelectSurveyAnswer {
                    ID         = answerNode.Attributes["id"].Value,
                    Text       = ExtractI18NDictionary(answerNode, "text"),
                    Help       = ExtractI18NDictionary(answerNode, "help"),
                    IsSelected = isSelected
                });
            }

            return(new SelectSurveyQuestion(id, type)
            {
                Answers = answerList
            });
        }
コード例 #11
0
ファイル: SurveyQuestion.cs プロジェクト: xgalv/Cryptool2
 /// <summary>
 /// Initializes a new instance of the <see cref="SurveyQuestion"/> class.
 /// </summary>
 public SurveyQuestion(string id, SurveyQuestionType type)
 {
     ID   = id;
     Type = type;
 }
コード例 #12
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="NumericSurveyQuestion" /> class.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="type"></param>
 public NumericSurveyQuestion(string id, SurveyQuestionType type) : base(id, type)
 {
     Answered = -1;
 }