public void deleteQuestion(int id) { IntHierarchy hi = searcher.getQuestionPosition(store, id); if (!hi.getLastListType().Equals(new Question().GetType())) { throw new GoTestObjectNotFound(); } else { store.ElementAt(hi.value).Tests.ElementAt(hi.getChild().value). Questions.ElementAt(hi.getChild().getChild().value).IsDeleted = true; notifyObservers(); } }
public void update(int id, Question newVersion) { int questionIndex = -1; IntHierarchy hi = searcher.getQuestionPosition(store, id); if (!hi.getLastListType().Equals(new Question().GetType())) { throw new GoTestObjectNotFound(); } else { questionIndex = hi.getChild().getChild().value; } newVersion.Id = store.ElementAt(hi.value).Tests.ElementAt(hi.getChild().value). Questions.ElementAt(questionIndex).Id; store.ElementAt(hi.value).Tests.ElementAt(hi.getChild().value). Questions.RemoveAt(questionIndex); store.ElementAt(hi.value).Tests.ElementAt(hi.getChild().value). Questions.Insert(questionIndex, newVersion); notifyObservers(); }
public void update(int id, Test test) { try { IntHierarchy hi = searcher.getTestPosition(store, id); if (!hi.getLastListType().Equals(new Test().GetType())) { throw new GoTestObjectNotFound(); } else { test.Id = store.ElementAt(hi.value).Tests.ElementAt(hi.getChild().value).Id; store.ElementAt(hi.value).Tests.RemoveAt(hi.getChild().value); store.ElementAt(hi.value).Tests.Insert(hi.getChild().value, test); notifyObservers(); } } catch (Exception ex) { ExceptionHandler.getInstance().processing(ex); } }
public void update(int id, Unswer newVersion) { IntHierarchy hi = searcher.getQuestionPosition(store, id); int questionIndex = -1; int unswerIndex = -1; if (!hi.getLastListType().Equals(new Unswer().GetType())) { throw new GoTestObjectNotFound(); } else { questionIndex = hi.getChild().getChild().value; unswerIndex = hi.getChild().getChild().getChild().value; } int rightUnswersCount = 1; Question question = store.ElementAt(hi.value).Tests.ElementAt(hi.getChild().value). Questions.ElementAt(questionIndex); for (int i = 0; i < question.Unswers.Count; i++) { if (question.Unswers.ElementAt(i).IsRight) { rightUnswersCount++; } } if (rightUnswersCount > 1) { question.QuestionsType = QuestionTypes.multiplyAnswer; } else { question.QuestionsType = QuestionTypes.singleAnswer; } newVersion.Id = store.ElementAt(hi.value).Tests.ElementAt(hi.getChild().value). Questions.ElementAt(questionIndex).Unswers.ElementAt(unswerIndex).Id; store.ElementAt(hi.value).Tests.ElementAt(hi.getChild().value). Questions.ElementAt(questionIndex).Unswers. RemoveAt(unswerIndex); store.ElementAt(hi.value).Tests.ElementAt(hi.getChild().value). Questions.ElementAt(questionIndex).Unswers. Insert(unswerIndex, newVersion); notifyObservers(); }