package net.sourceforge.fenixedu.domain.onlineTests; import java.util.List; import net.sourceforge.fenixedu.util.tests.QuestionOption; import net.sourceforge.fenixedu.util.tests.QuestionType; import net.sourceforge.fenixedu.util.tests.ResponseProcessing; import org.apache.struts.util.LabelValueBean; public class SubQuestion { private String itemId; private String nextItemId; private String title; private List prePresentation; private List presentation; private List options; private List responseProcessingInstructions; private Double questionValue; private QuestionType questionType; private List subQuestions; private String[] shuffle; private Integer optionNumber; public String getItemId() { return itemId; } public void setItemId(String itemId) { this.itemId = itemId; } public String getNextItemId() { return nextItemId; } public void setNextItemId(String nextItemId) { this.nextItemId = nextItemId; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public List getOptions() { return options; } public void setOptions(List options) { this.options = options; } public List getPrePresentation() { return prePresentation; } public void setPrePresentation(List prePresentation) { this.prePresentation = prePresentation; } public List getPresentation() { return presentation; } public void setPresentation(List presentation) { this.presentation = presentation; } public QuestionType getQuestionType() { return questionType; } public void setQuestionType(QuestionType questionType) { this.questionType = questionType; } public Double getQuestionValue() { return questionValue; } public void setQuestionValue(Double questionValue) { this.questionValue = questionValue; } public List getResponseProcessingInstructions() { return responseProcessingInstructions; } public void setResponseProcessingInstructions(List responseProcessingInstructions) { this.responseProcessingInstructions = responseProcessingInstructions; } public String[] getShuffle() { return shuffle; } public void setShuffle(String[] shuffle) { this.shuffle = shuffle; } public Integer getOptionNumber() { return optionNumber; } public void setOptionNumber(Integer optionNumber) { this.optionNumber = optionNumber; } public String getShuffleString() { StringBuilder result = new StringBuilder(); result.append("["); for (int i = 0; i < getShuffle().length; i++) { result.append(getShuffle()[i]); if (i != getShuffle().length - 1) { result.append(","); } } result.append("]"); return result.toString(); } public List getSubQuestions() { return subQuestions; } public void setSubQuestions(List subQuestions) { this.subQuestions = subQuestions; } public String getImage(int imageId) { int imageIdAux = 1; for (LabelValueBean lvb : getPrePresentation()) { if (lvb.getLabel().startsWith("image/")) { if (imageIdAux == imageId) { return lvb.getValue(); } imageIdAux++; } } for (LabelValueBean lvb : getPresentation()) { if (lvb.getLabel().startsWith("image/")) { if (imageIdAux == imageId) { return lvb.getValue(); } imageIdAux++; } } for (QuestionOption qo : getOptions()) { for (LabelValueBean lvb : qo.getOptionContent()) { if (lvb.getLabel().startsWith("image/")) { if (imageIdAux == imageId) { return lvb.getValue(); } imageIdAux++; } } } for (ResponseProcessing responseProcessing : getResponseProcessingInstructions()) { for (LabelValueBean lvb : responseProcessing.getFeedback()) { if (lvb.getLabel().startsWith("image/")) { if (imageIdAux == imageId) { return lvb.getValue(); } imageIdAux++; } } } return null; } public Double getMaxValue() { Double maxValue = Double.valueOf(0); for (ResponseProcessing responseProcessing : getResponseProcessingInstructions()) { if (responseProcessing.getAction().intValue() == ResponseProcessing.SET || responseProcessing.getAction().intValue() == ResponseProcessing.ADD) if (maxValue.compareTo(responseProcessing.getResponseValue()) < 0) maxValue = responseProcessing.getResponseValue(); } return maxValue; } }