AssessmentAnswer a; for(Iterator i = questionNodes.iterator();i.hasNext();) { q = new AssessmentQuestion(); answers = new HashMap(); questionNode = (Node)i.next(); String questionId = XPathHelper.getNodeValue("./@id", questionNode); int questionPosition = XPathHelper.selectNodes("../QUESTIONLIST/QUESTION[@id='" + questionId + "']/preceding-sibling::QUESTION", questionNode).size() + 1; q.setPosition(new Integer(questionPosition)); List answerNodes = XPathHelper.selectNodes("./ANSWER", questionNode); for (Iterator j = answerNodes.iterator();j.hasNext();) { q.setChoices(choices); q.setQuestionType(questionType); q.setAnswers(answers); String questionTextString = XPathHelper.getNodeValue("./BODY/TEXT", questionNode); q.setQuestionText(questionTextString); try { Double pointValue = Double.parseDouble(XPathHelper.getNodeValue("../QUESTIONLIST/QUESTION[@id='" + questionId + "']/@points", questionNode)); q.setPointValue(pointValue); } catch (NumberFormatException e) { q.setPointValue(new Double(1.0)); q.setCorrectAnswerIDs(correctAnswerIDs); q.setFeedbackWhenCorrect(cleanUpCharacters(XPathHelper.getNodeValue("./GRADABLE/FEEDBACK_WHEN_CORRECT", questionNode))); q.setFeedbackWhenIncorrect(cleanUpCharacters(XPathHelper.getNodeValue("./GRADABLE/FEEDBACK_WHEN_INCORRECT", questionNode))); rv.add(q);
Set correctAnswerIDs; for(Iterator i = questionNodes.iterator();i.hasNext();) { q = new AssessmentQuestion(); answers = new HashMap(); correctAnswerIDs = new HashSet(); questionNode = (Node)i.next(); int questionPosition = XPathHelper.selectNodes("./preceding-sibling::item", questionNode).size() + 1; q.setPosition(new Integer(questionPosition)); List answerNodes = null; if (questionType == AssessmentQuestion.MATCHING) { q.setChoices(choices); } else if (questionType == AssessmentQuestion.ESSAY) { a = new AssessmentAnswer(); q.setQuestionType(questionType); q.setAnswers(answers); String questionTextString = XPathHelper.getNodeValue("./presentation//flow[@class='FORMATTED_TEXT_BLOCK']//mat_formattedtext[1]", questionNode); q.setQuestionText(stripHTMLComments(questionTextString + questionResourceEmbed)); try { double pointValue = Double.parseDouble(XPathHelper.getNodeValue("./itemmetadata/qmd_absolutescore_max", questionNode)); q.setPointValue(pointValue); } catch (NumberFormatException e) { q.setCorrectAnswerIDs(correctAnswerIDs); q.setFeedbackWhenCorrect(stripHTMLComments(XPathHelper.getNodeValue("./itemfeedback[@ident = 'correct']//mat_formattedtext[1]", questionNode))); q.setFeedbackWhenIncorrect(stripHTMLComments(XPathHelper.getNodeValue("./itemfeedback[@ident = 'incorrect']//mat_formattedtext[1]", questionNode)));