Esempio n. 1
0
    private void InitQuestions(JSONArray questionsArray)
    {
        foreach (JSONNode node in questionsArray)
        {
            string type = node["type"];

            IQuestion question;

            switch (type)
            {
            case "input":
                question = new InputQuestion(node);
                Questions.Add(question);
                break;

            case "one":
                question = new OneQuestion(node);
                Questions.Add(question);
                break;

            case "multiple":
                question = new MultipleQuestion(node);
                Questions.Add(question);
                break;

            case "image-input":
                break;
            }
        }
    }
Esempio n. 2
0
    public void PreviewQuestion(IQuestion question)
    {
        _Question         = (MultipleQuestion)question;
        questionText.text = _Question.Question;

        for (int i = 0; i < _Question.values.Length; i++)
        {
            Labels[i].text = _Question.values[i];
        }
        InitChecker();
    }
Esempio n. 3
0
        public void TestSurveySerialization()
        {
            string expected = "{\"survey\":{\"id\":\"12344134\",\"len\":\"4\",\"questions\":[{\"type\":\"single\"," +
                              "\"question\":\"How well do the professors teach at this university?\",\"options\":[{\"1\":\"Extremely well\"}," +
                              "{\"2\":\"Very well\"}]},{\"type\":\"multiple\",\"question\":\"How effective is the teaching outside yur major at the univesrity?\"," +
                              "\"options\":[{\"1\":\"Extremetly effective\"},{\"2\":\"Very effective\"},{\"3\":\"Somewhat effective\"},{\"4\":\"Not so effective\"}," +
                              "{\"5\":\"Not at all effective\"}]},{\"type\":\"text\",\"question\":\"Some question\"},{\"type\":\"starRate\",\"question\":\"Star rating question\"}]}}";

            IQuestion[] questions = new IQuestion[4];
            questions[0] = new SingleQuestion()
            {
                Question = "How well do the professors teach at this university?",
                Options  = new[]
                {
                    "Extremely well",
                    "Very well"
                }
            };
            questions[1] = new MultipleQuestion()
            {
                Question = "How effective is the teaching outside yur major at the univesrity?",
                Options  = new[]
                {
                    "Extremetly effective",
                    "Very effective",
                    "Somewhat effective",
                    "Not so effective",
                    "Not at all effective"
                }
            };
            questions[2] = new TextQuestion()
            {
                Question = "Some question"
            };
            questions[3] = new StarRateQuestion()
            {
                Question = "Star rating question"
            };

            Survey survey = new Survey()
            {
                Id        = "12344134",
                Questions = questions
            };

            Assert.Equal(expected, survey.GetJson());
        }