/// <summary> /// Updates a FigurePanel and its variables to hold the text that was entered into the different inputfields /// </summary> /// <param name="panel">FigurePanel to update</param> /// <returns>Updated version of panel</returns> public FigurePanel UpdateParameters(FigurePanel panel) { questionsAndAnswers.Clear(); Dictionary <InputField, bool> answers = new Dictionary <InputField, bool>(); panel.task = panel.GetComponent <Dropdown>(); foreach (Transform go in panel.transform) { if (go.tag == "Information") { panel.informationFile = go.GetComponent <InputField>().text; } } foreach (Transform question in questionsPrefabParent.transform) { foreach (Transform answer in question) { if (answer.gameObject.tag == "Answer") { answers.Add(answer.GetComponent <InputField>(), answer.GetComponentInChildren <Toggle>().isOn); } } if (question.gameObject.tag == "Question") { panel.questionsAndAnswers.Add(question.GetComponentInChildren <InputField>(), answers); } } return(panel); }
private void Start() { // Set necessary references panelHandler = DBConnector.MainCanvas.GetComponent <PanelHandler>(); figurePanelRef = DBConnector.MainCanvas.GetComponent <FigurePanel>(); // Initialize lists propertiesPanels = new Dictionary <GameObject, FigurePanel>(); toBeRemovedPanels = new Dictionary <GameObject, FigurePanel>(); if (Scenario.CurrentScenarioFigures == null) { Scenario.CurrentScenarioFigures = new Dictionary <int, ScenarioFigure>(); } }
/// <summary> /// Gets hidden values and additional info of a scenario necessary for updating the database /// </summary> /// <param name="fp">FigurePanel to use for formatting information</param> /// <returns></returns> private Dictionary <ScenarioQuestion, List <ScenarioAnswer> > QnATranslator(FigurePanel fp) { Dictionary <ScenarioQuestion, List <ScenarioAnswer> > result = new Dictionary <ScenarioQuestion, List <ScenarioAnswer> >(); foreach (var question in fp.questionsAndAnswers) { List <ScenarioAnswer> answersTemp = new List <ScenarioAnswer>(); foreach (var answer in question.Value) { int trueOrFalse = 0; if (answer.Value) { trueOrFalse = 1; } if (answer.Key.GetComponentInChildren <Slider>().gameObject.GetComponent <Text>().text != "") { int answerHiddenId = int.Parse(answer.Key.GetComponentInChildren <Slider>().gameObject.GetComponent <Text>().text); int answerQuestionHiddenId = int.Parse(answer.Key.GetComponentInChildren <Dropdown>().gameObject.GetComponent <Text>().text); answersTemp.Add(new ScenarioAnswer(answerHiddenId, answerQuestionHiddenId, answer.Key.text, trueOrFalse)); } else { answersTemp.Add(new ScenarioAnswer(answer.Key.text, trueOrFalse)); } } if (question.Key.transform.parent.GetComponentInChildren <Slider>().gameObject.GetComponent <Text>().text != "") { int questionHiddenId = int.Parse(question.Key.transform.parent.GetComponentInChildren <Slider>().gameObject.GetComponent <Text>().text); int questionFigureHiddenId = int.Parse(question.Key.transform.parent.GetComponentInChildren <Dropdown>().gameObject.GetComponent <Text>().text); result.Add(new ScenarioQuestion(questionHiddenId, questionFigureHiddenId, question.Key.text), answersTemp); } else { result.Add(new ScenarioQuestion(question.Key.text), answersTemp); } } return(result); }
/// <summary> /// Initializes a figures and then its questions and answers /// </summary> /// <param name="figure">Figure to instantiate</param> /// <param name="QuestionsAndAnswers">Dictionary of questions and answers to instantiate</param> private void InitializeScenarioFigure(ScenarioFigure figure, Dictionary <ScenarioQuestion, List <ScenarioAnswer> > QuestionsAndAnswers) { GameObject newPanel = AddFigure(figure.Figure_Id.ToString(), figure); FigurePanel fp = newPanel.GetComponent <FigurePanel>(); foreach (var QnA in QuestionsAndAnswers) { GameObject questionTemp = fp.InstantiateQuestion(QnA.Key.Question_Text, QnA.Key.Scenario_Figure_Id, QnA.Key.Id); Dictionary <GameObject, ScenarioAnswer> answers = new Dictionary <GameObject, ScenarioAnswer>(); foreach (var answer in QnA.Value) { answers.Add(fp.InstantiateAnswer(questionTemp.transform, answer.Answer_Text, answer.Scenario_Question_Id, answer.Id), answer); } foreach (var answerGOPair in answers) { if (answerGOPair.Value.Correct_Answer == 1) { answerGOPair.Key.GetComponentInChildren <Toggle>().isOn = true; } } } figurePanelRef.resetPanelsFunc(); }
private void Start() { figurePanel = DBConnector.MainCanvas.GetComponent <FigurePanel>(); question = transform.parent.GetComponent <QuestionListHandler>(); resetPanel = transform.parent.parent.parent; }
private void Start() { figurePanel = DBConnector.MainCanvas.GetComponent <FigurePanel>(); translator = DBConnector.MainCanvas.GetComponent <UITranslator>(); }