// Start is called before the first frame update void Start() { var tmpDict = JsonConvert.DeserializeObject <List <ItemClass> >(questionsFile.text); int randObjInd = Random.Range(0, tmpDict.Count); ItemClass currentObj = tmpDict[randObjInd]; randItemIndex = Random.Range(0, 5); // TMP SOLUTION!!!! foreach (int ind in GlobalVariables.genUniqueNumbers(0, tmpDict[randObjInd].tfQuestionsList.Count, 5)) { tfQuestionList.Add(currentObj.tfQuestionsList[ind]); } FieldInfo[] fieldsList = currentObj.mapQuestions.GetType().GetFields(); for (int i = 0; i < fieldsList.Length; i++) { string path = "Earth/" + fieldsList[i].Name.Substring(0, fieldsList[i].Name.Length - 13); GlobalVariables.iconSprites.Add(fieldsList[i].Name, Resources.Load <Sprite>(path)); List <MapQuestion> currentList = (List <MapQuestion>)fieldsList[i].GetValue(currentObj.mapQuestions); List <MapQuestion> currentAddList = (List <MapQuestion>)mapQuestions.GetType().GetFields()[i].GetValue(mapQuestions); List <int> randIndexList = GlobalVariables.genUniqueNumbers(0, currentList.Count, 3); foreach (int j in randIndexList) { currentAddList.Add(currentList[j]); } } GlobalVariables.iconSprites.Add("right", Resources.Load <Sprite>("Earth/AnswerRightIcon")); GlobalVariables.iconSprites.Add("wrong", Resources.Load <Sprite>("Earth/AnswerWrongIcon")); earthScript.myQuestions = mapQuestions; startAngle = Random.Range(0, 20) * 18.0f + 9.0f; trueFalseScript = GameObject.Find("SecondScene").GetComponent <TrueFalseQuestions>(); myWheel.transform.rotation = Quaternion.Euler(new Vector3(startAngle, 90, -90)); gameObject.GetComponent <OnClickScript>().clickFunctionList.Add(onClick); GlobalVariables.gameScore = 0; }
public void TrueFalseQuestionTest(string response, bool expectedIsValid, double expectedCorrectness) { Question question = new TrueFalseQuestions("A True Question", "true"); // Question should be NOT complete Assert.IsFalse(question.IsComplete); bool isValid = question.ValidateAnswerAndSetResponse(response); Assert.AreEqual(expectedIsValid, isValid); if (isValid) { // Question should be correct (1.0) and Complete Assert.IsTrue(question.IsComplete); Assert.AreEqual(expectedCorrectness, question.Correctness); } else { // Question should not be Complete Assert.IsFalse(question.IsComplete); } }