protected Map<String, String> getMapRepresentingASingleIncorrectlyChosenChoice(Question q) { Map<String, String> map = new HashMap<>(); Set<Choice> set = q.getChoices(); for (Choice c : set) { if (map.size() == 0 && c.getIscorrect() == Choice.NOT_CORRECT) { map.put(q.getId() + "," + c.getId(), c.getText()); } } return map; }
protected Map<String, String> getMapRepresentingCorrectChoices(Question q) { Map<String, String> map = new HashMap<>(); Set<Choice> set = q.getChoices(); for (Choice c : set) { if (c.getIscorrect() == Choice.CORRECT) { map.put(q.getId() + "," + c.getId(), c.getText()); } } return map; }
protected Map<String, String> getMapRepresentingACorrectChoiceAndAnIncorrectChoice(Question q) { Map<String, String> map = new HashMap<>(); Set<Choice> set = q.getChoices(); boolean correctAdded = false; boolean incorrectAdded = false; for (Choice c : set) { if (!correctAdded && c.getIscorrect() == Choice.CORRECT) { map.put(q.getId() + "," + c.getId(), c.getText()); correctAdded = true; } if (!incorrectAdded && c.getIscorrect() == Choice.NOT_CORRECT) { map.put(q.getId() + "," + c.getId(), c.getText()); incorrectAdded = true; } } return map; }