public void loadStats(int currentCourseId) { if (currentCourseId != 0) { currentCourseStatsId = currentCourseId; try { List <Answer> stats = XmlHelpers.loadFromXML <List <Answer> >(Application.dataPath + "/Resources/xml/answers/" + currentCourseId + "/" + login + ".xml", "ArrayOfAnswer"); QuestionManager.AnswerKeeper answerKeeper; foreach (Answer a in stats) { answerKeeper = new QuestionManager.AnswerKeeper(); answerKeeper.question = new QuestionManager.QuestionKeeper(); answerKeeper.answerTime = a.answerTime; answerKeeper.rep = a.response; answerKeeper.result = a.result; answerKeeper.question.id = a.questionId; answers.Add(answerKeeper); } calcScore(); C3PONetworkManager.Instance.setScore(networkPlayer, score); } catch { } } }
public QuestionManager.AnswerKeeper lastAnswer() { if (answers.Count == 0) { QuestionManager.AnswerKeeper answerKeeper = new QuestionManager.AnswerKeeper(); answerKeeper.question = new QuestionManager.QuestionKeeper(); answerKeeper.answerTime = 40; answerKeeper.rep = 0; answerKeeper.result = false; answerKeeper.question.id = 0; answers.Add(answerKeeper); } return(answers[answers.Count - 1]); }
public void addAnswer(QuestionManager.AnswerKeeper a, int courseId) { if (currentCourseStatsId != courseId) { loadStats(courseId); } if (answers.Exists(x => x.question.id == a.question.id)) { answers.Remove(answers.Find(x => x.question.id == a.question.id)); answers.Add(a); calcScore(); } else if (a.result) { score++; answers.Add(a); } }