QAClass ReadQuestionAndAnswer(GameObject questionGroup) { QAClass result = new QAClass(); GameObject q = questionGroup.transform.Find("Question").gameObject; GameObject a = questionGroup.transform.Find("Answer").gameObject; result.Question = q.GetComponent <Text>().text; if (a.GetComponent <ToggleGroup>() != null) { for (int i = 0; i < a.transform.childCount; i++) { if (a.transform.GetChild(i).GetComponent <Toggle>().isOn) { result.Answer = a.transform.GetChild(i).Find("Label").GetComponent <Text>().text; break; } } } else if (a.GetComponent <InputField>() != null) { result.Answer = a.transform.Find("Text").GetComponent <Text>().text; if (first == 0) { patient_name = result.Answer; first++; } } else if (a.GetComponent <ToggleGroup>() == null && a.GetComponent <InputField>() == null) { string s = ""; int counter = 0; for (int i = 0; i < a.transform.childCount; i++) { if (a.transform.GetChild(i).GetComponent <Toggle>().isOn) { if (counter != 0) { s = s + ", "; } s = s + a.transform.GetChild(i).Find("Label").GetComponent <Text>().text; counter++; } if (i == a.transform.childCount - 1) { s = s + "."; } } result.Answer = s; } return(result); }
void ReadQuestionAndAnswer(GameObject questionGroup) { QAClass result = new QAClass(); GameObject a = questionGroup.transform.Find("InputField").gameObject; result.Answer = a.transform.Find("Text").GetComponent <Text>().text; FileInfo fi = new FileInfo(Application.dataPath + "/StreamingAssets/" + result.Answer + ".txt"); patient_id = result.Answer; Real_id = result.Answer; }
QAClass ReadQuestionAndAnswer(GameObject QuestionGroup) { QAClass result = new QAClass(); GameObject Q = QuestionGroup.transform.Find("Question").gameObject; GameObject A = QuestionGroup.transform.Find("Answer").gameObject; result.question = Q.GetComponent <Text>().text; result.answer = A.transform.Find("Text").GetComponent <Text>().text; return(result); }
QAClass ReadQuestionAndAnswer(GameObject questionGroup) //whatever value is read by the QuestionAndAnswer is returned and used to populate the length of qArr. It takes in a parameter GameObject questionGroup { QAClass result = new QAClass(); GameObject q = questionGroup.transform.Find("Question").gameObject; //We are looking for a gameobject called question within the question group object. If found set the reference in GameObject q. GameObject a = questionGroup.transform.Find("Answer").gameObject; //We are looking for a gameobject called answer within the question group object.If found set the reference in GameObject a. result.Question = q.GetComponent <Text>().text; //reading the question. All are of type text if (_checkForSlider == false) { if (a.GetComponent <ToggleGroup>() != null) //Check Box, Toggle Group (Only one answared is allowd) { for (int i = 0; i < a.transform.childCount; i++) { if (a.transform.GetChild(i).GetComponent <Toggle>().isOn) { result.Answer = a.transform.GetChild(i).Find("Label").GetComponent <Text>().text; break; } } } else if (a.GetComponent <InputField>() != null) //For Input Feild Survey { result.Answer = a.transform.Find("Text").GetComponent <Text>().text; } else if (a.GetComponent <ToggleGroup>() == null && a.GetComponent <InputField>() == null) //check box (allows for multiple toggle) { string s = ""; int counter = 0; for (int i = 0; i < a.transform.childCount; i++) { if (a.transform.GetChild(i).GetComponent <Toggle>().isOn) { if (counter != 0) { s = s + " , "; } s = s + a.transform.GetChild(i).Find("Label").GetComponent <Text>().text; //extending the string not overwriting it counter++; } if (i == a.transform.childCount - 1) { s = s + " . "; } } result.Answer = s; } } else { if (a.GetComponentInChildren <Slider>() != null) { if (a.GetComponentInChildren <Slider>().value.ToString() == "0") { result.Answer = ""; } else { result.Answer = a.GetComponentInChildren <Slider>().value.ToString(); } } } return(result); }