public void checkDone(string output) { string copied = " "; //GameObject copiedText = transform.parent.GetChild (1).gameObject; //Debug.Log ((MathHWGenerateText)copiedText.GetComponent ("MathHWGenerateText")); MathHWGenerateText math = transform.GetChild(1).GetChild(0).GetChild(1).gameObject.GetComponent <MathHWGenerateText>(); EngHWGenerateText eng = transform.GetChild(1).GetChild(0).GetChild(1).gameObject.GetComponent <EngHWGenerateText> (); if (eng == null) { copied = math.getAnswer(); Debug.Log("math " + copied); checkHWCorrect(math, output); displayLetterGrade(); } else { copied = eng.getAnswer(); Debug.Log("eng: " + copied); checkHWCorrect(eng, output); displayLetterGrade(); } OwO.hwSubmitted(true); GameObject copiedText = transform.parent.GetChild(1).gameObject; }
void checkHWCorrect(EngHWGenerateText engHW, string answer) //ENGLISH { int score = 0; int totalAnswers = 0; string temp = " " + answer + " "; //adding spaces here makes the for loop so easy and means less lines of conditionals totalAnswers = 5; score = 5; Debug.Log("assignment length: " + engHW.assignmentWords.Length); for (int x = 0; x < engHW.assignmentWords.Length; x++) { string search = " " + engHW.assignmentWords[x] + " "; if (!temp.Contains(search)) { if (engHW.assignmentWords.Length == 1) { score = 2; //if the hw is one word, getting it wrong gets you a D } else if (engHW.assignmentWords.Length == 2) { if (score == 5) { score = 3; //if the hw is 2 words, one wrong is a C, two wrong is an F } else { score = 1; } } else if (engHW.assignmentWords.Length == 3 && score == 5) { score = score - 2; //if the hw is 3 words, A->C->D->F } else { score--; } } } /* * Original grading algorithm, gets percent of words correct * for (int x = 0; x < engHW.assignmentWords.Length; x++) * { * if (engHW.assignmentWords[x] != null) //assignmentWords is an array that holds all the words you have to copy * { * totalAnswers++; * string search = " " + engHW.assignmentWords[x] + " "; * * if (temp.Contains(search)) * { * score++; * } * } * } */ toCalcScores[0] = score; toCalcScores[1] = totalAnswers; Debug.Log("eng hw score: " + score + "/" + totalAnswers); }