use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.
the class QuestionnaireMapperImpl method mapToQuestionDetail.
private QuestionDetail mapToQuestionDetail(QuestionEntity question, QuestionType type) {
List<ChoiceDto> answerChoices = mapToQuestionChoices(question.getChoices());
QuestionDetail questionDetail = new QuestionDetail(question.getQuestionId(), question.getQuestionText(), type, question.isActive(), question.isEditable());
questionDetail.setNickname(question.getNickname());
questionDetail.setAnswerChoices(answerChoices);
mapBoundsForNumericQuestion(question, questionDetail);
return questionDetail;
}
use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.
the class Question method addAnswerChoice.
public void addAnswerChoice() {
questionDetail.addAnswerChoice(new ChoiceDto(getCurrentChoice()));
setCurrentChoice(null);
currentSmartChoiceTags.add(EMPTY);
}
use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.
the class QuestionnaireValidatorImpl method allChoicesHaveUniqueOrders.
private boolean allChoicesHaveUniqueOrders(List<ChoiceDto> choiceDtos) {
boolean result = true;
Set<Integer> choiceOrders = new HashSet<Integer>();
for (ChoiceDto choiceDto : choiceDtos) {
Integer order = choiceDto.getOrder();
if (choiceOrders.contains(order)) {
result = false;
break;
} else {
choiceOrders.add(order);
}
}
return result;
}
use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.
the class QuestionnaireValidatorImpl method allChoicesHaveUniqueValues.
private boolean allChoicesHaveUniqueValues(List<ChoiceDto> choiceDtos) {
boolean result = true;
Set<String> choiceValues = new HashSet<String>();
for (ChoiceDto choiceDto : choiceDtos) {
String value = choiceDto.getValue().toLowerCase(Locale.getDefault());
if (choiceValues.contains(value)) {
result = false;
break;
} else {
choiceValues.add(value);
}
}
return result;
}
use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.
the class GroupCustActionTest method getSectionDetail.
private SectionDetail getSectionDetail(String name, String title, List<String> answerChoices) {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName(name);
QuestionDetail questionDetail = new QuestionDetail(111, title, QuestionType.SINGLE_SELECT, true, true);
List<ChoiceDto> choiceDtos = new ArrayList<ChoiceDto>();
for (String answerChoice : answerChoices) {
choiceDtos.add(new ChoiceDto(answerChoice));
}
questionDetail.setAnswerChoices(choiceDtos);
sectionDetail.setQuestionDetails(asList(new SectionQuestionDetail(questionDetail, true)));
return sectionDetail;
}
Aggregations