Exemplo n.º 1
0
        public void AddQuestionToEnd()
        {
            SurveyQuestion sq = new SurveyQuestion("AA004", "004");


            survey.AddQuestion(sq);

            Assert.IsTrue(survey.Questions[3].Qnum == "004");
        }
Exemplo n.º 2
0
        public Survey_InsertQnum()
        {
            s = new Survey("TS1");

            s1 = new SurveyQuestion("AA000", "001");

            s2      = new SurveyQuestion("AA001", "002");
            s2.PreP = "Ask if AA000=1.";
            s.AddQuestion(s1);
            s.AddQuestion(s2);
        }
Exemplo n.º 3
0
        // adds a question to the underlying survey's list of questions
        private void AddQuestion(string varname)
        {
            SurveyQuestion newQ = new SurveyQuestion();
            VariableName   newVar;
            string         newQnum = CurrentQuestion.Qnum;

            // get varname
            newQ.VarName.FullVarName = varname;
            // determine qnum
            if (CurrentQuestion.Qnum.Contains("!"))
            {
                newQnum += "00";
            }
            else
            {
                newQnum += "z";
            }

            if (newQnum.Length > 10)
            {
                MessageBox.Show("The Qnum for this new question is too long. Please limit the Qnum to 10 digits (including suffix). You may need to renumber the survey first.");
                return;
            }

            newQ.Qnum = newQnum;

            newVar = DBAction.GetVariable(newQ.VarName.FullVarName);
            if (newVar == null)
            {
                // if VarName does not exist, check refVarNames
                if (DBAction.RefVarNameExists(Utilities.ChangeCC(varname)))
                {
                    // display all the sets of the labels for this refVarName
                    VariableLabelSelector selector = new VariableLabelSelector(Utilities.ChangeCC(varname));
                    selector.frmParent = this;
                    selector.ShowDialog();
                }
            }
            else
            {
                // if VarName already exists, use those labels
                newQ.VarName.VarLabel = newVar.VarLabel;
                newQ.VarName.Domain   = new DomainLabel(newVar.Domain);
                newQ.VarName.Topic    = new TopicLabel(newVar.Topic);
                newQ.VarName.Content  = new ContentLabel(newVar.Content);
                newQ.VarName.Product  = new ProductLabel(newVar.Product);
            }

            // add to the list of questions, but after the current question
            CurrentSurvey.AddQuestion(newQ, bs.Position + 1);

            // go to the new question
            GoToQnum(newQ.Qnum);

            SaveRecord();

            Renumber = true;

            // TODO check for wave comments
        }
Exemplo n.º 4
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        // Dropdown Value...
        int QType  = Convert.ToInt32(drpType.SelectedValue);
        int Course = Convert.ToInt32(drpCourse.SelectedValue);

        // Add Question...
        _survey.QuestionType = QType;
        _survey.QuestionText = txtQuestion.Text.Trim();
        _survey.Course       = Course;
        Int64 QId = _survey.AddQuestion();

        // Add Options...
        string[] option       = txtOptions.Text.Split(',');
        int      optionlength = option.Length;

        for (int i = 0; i < optionlength; i++)
        {
            string opt = option[i].ToString().Trim();

            if (opt != "")
            {
                _survey.QuestionID = QId;
                _survey.Option     = opt;
                _survey.AddOption();
            }
        }
    }
Exemplo n.º 5
0
        public DisplaySurveyViewModel()
        {
            var survey = new Survey
            {
                #region Survey settup

                Title       = "Undersøkelse om folks do vaner",
                Description = "Dette er en test undersøkelse om folks do vaner",
            };

            var question = new SurveyQuestion {
                Question = "How Manny times do you go to the toilet in a day?"
            };

            question.AddAnswer(new SurveyAlternative("Never"));
            question.AddAnswer(new SurveyAlternative("Once"));
            question.AddAnswer(new SurveyAlternative("2 - 4"));
            question.AddAnswer(new SurveyAlternative("5 or more"));
            survey.AddQuestion(question);

            question = new SurveyQuestion {
                Question = "How Manny times do you use others toilet in a week?"
            };
            question.AddAnswer(new SurveyAlternative("Never"));
            question.AddAnswer(new SurveyAlternative("Once"));
            question.AddAnswer(new SurveyAlternative("2 - 4"));
            question.AddAnswer(new SurveyAlternative("5 or more"));
            survey.AddQuestion(question);

            question = new SurveyQuestion {
                Question = "How Manny times do you wach toilet in a month?"
            };
            question.AddAnswer(new SurveyAlternative("Never"));
            question.AddAnswer(new SurveyAlternative("Once"));
            question.AddAnswer(new SurveyAlternative("2 - 4"));
            question.AddAnswer(new SurveyAlternative("5 or more"));
            survey.AddQuestion(question);
            #endregion

            SetupSurvey(survey);
            NextQuestionCommand     = new DelegateCommand(NextQuestionAction);
            PreviousQuestionCommand = new DelegateCommand(PreviousQuestionAction);
        }
Exemplo n.º 6
0
    public static void Main()
    {
        var qone = new TextQuestion();

        qone.Label = "How old are you?";

        var qtwo = new TextQuestion();

        qtwo.Label = "Whats your name?";

        Survey one = new Survey("title1");

        one.AddQuestion(qone);
        one.AddQuestion(qtwo);


        int score = one.GetScore();

        Console.WriteLine("Your score: {0} ", score);
    }
Exemplo n.º 7
0
        public void CreateFilterList()
        {
            SurveyQuestion q1 = new SurveyQuestion("AA000", "001");

            q1.PreP = "Ask if FR326=1.";

            SurveyQuestion q2 = new SurveyQuestion("FR326", "002");

            q2.RespOptions      = "1  Yes\r\n2  No";
            q2.NRCodes          = "8  Refused\r\n9  Don't Know";
            q2.VarName.VarLabel = "Varlabel for FR326";

            Survey s = new Survey();

            s.AddQuestion(q1);
            s.AddQuestion(q2);

            s.MakeFilterList();

            Assert.IsTrue(s.Questions[0].Filters.Length > 0);
        }
Exemplo n.º 8
0
        public SurveyTests()
        {
            survey = new Survey("TS1");

            SurveyQuestion sq;

            sq = new SurveyQuestion("AA000", "001");

            survey.AddQuestion(sq);

            sq = new SurveyQuestion("AA001", "002");

            survey.AddQuestion(sq);

            sq = new SurveyQuestion("AA002", "003");

            survey.AddQuestion(sq);

            //
            // TODO: Add constructor logic here
            //
        }
Exemplo n.º 9
0
        public void AddQuestionAddsQuestionToList()
        {
            var  survey = new Survey();
            Guid questionId;

            var question = new SurveyQuestion {
                Question = "How Manny times do you go to the toilet in a day?"
            };

            questionId = question.QuestionId;
            question.AddAnswer(new SurveyAlternative("Never"));
            question.AddAnswer(new SurveyAlternative("Once"));
            question.AddAnswer(new SurveyAlternative("2 - 4"));
            question.AddAnswer(new SurveyAlternative("5 or more"));

            survey.AddQuestion(question);

            Assert.IsTrue(survey.Questions.Exists(surveyQuestion => surveyQuestion.QuestionId == questionId));
        }