Example #1
0
        Question GenerateQuestion(JSONObject json)
        {
            print("question:" + json.ToString());
            string questiontype = json["questiontype"].Str;

            Question question = null;

            switch (questiontype)
            {
            case QuestionTypeNames.radiogrid:
                question = new RadioGridQuestion(json);
                break;

            case QuestionTypeNames.radiolist:
                question = new RadioListQuestion(json);
                break;

            case QuestionTypeNames.checklist:
                question = new CheckListQuestion(json);
                break;

            case QuestionTypeNames.slider:
                question = new SliderQuestion(json);
                break;

            case QuestionTypeNames.field:
                question = new FieldQuestion(json);
                break;

            case QuestionTypeNames.num_field:
                question = new NumFieldQuestion(json);
                break;

            case QuestionTypeNames.multi_field:
                question = new MultiFieldQuestion(json);
                break;

            case QuestionTypeNames.drop_down:
                question = new DropDownQuestion(json);
                break;

            case QuestionTypeNames.textview:
                question = new TextViewQuestion(json);
                break;

            default:
                question = new TextViewQuestion(json);
                break;
            }
            return(question);
        }
Example #2
0
        public override void SetQuestion(Question q, UnityAction <Question> answeredEvent, UISkinData skinData)
        {
            base.SetQuestion(q, answeredEvent, skinData);
            inputField.enableWordWrapping = false;
            numFieldQuestion      = question as NumFieldQuestion;
            instructionsText.text = question.instructions;
            idText.text           = question.id;

            //switch(question.datatype) {
            //case QuestionDataType.Integer:
            //	inputField.contentType = TMP_InputField.ContentType.IntegerNumber;
            //	break;
            //case QuestionDataType.Float:
            //	inputField.contentType = TMP_InputField.ContentType.DecimalNumber;
            //	break;
            //}

            //incrementButton.gameObject.SetActive(numFieldQuestion.spinbutton);
            //decrementButton.gameObject.SetActive(numFieldQuestion.spinbutton);

            //if(numFieldQuestion.spinbutton) {
            //	incrementButton.onClick.AddListener(IncrementValue);
            //	//decrementButton.onClick.AddListener(DecrementValue);
            //}

            //inputField.onSelect.AddListener(OnFieldSelected);

            //inputField.onValueChanged.AddListener(OnNumFieldSubmitted);
            //inputField.onSubmit.AddListener(OnNumFieldSubmitted);
            //inputField.onDeselect.AddListener(OnNumFieldSubmitted);


            if (numberPad)
            {
                numberPad.OnNumberSelected += NumberPad_OnNumberSelected;
                //numberPad.OnConfirm += NumberPad_OnConfirm;
                numberPad.OnDelete += NumberPad_OnDelete;
            }
        }