use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class QuestionGroupForm method addSelectedQuestionsToCurrentSection.
private void addSelectedQuestionsToCurrentSection() {
List<SectionQuestionDetail> addedQuestions = new ArrayList<SectionQuestionDetail>();
for (SectionQuestionDetail questionDetail : questionPool) {
if (selectedQuestionIds.contains(String.valueOf(questionDetail.getQuestionId()))) {
questionDetail.setSequenceNumber(currentSection.getSectionQuestionDetails().size());
currentSection.addSectionQuestion(questionDetail);
addedQuestions.add(questionDetail);
questionsToAdd.add(questionDetail.getQuestionId());
}
}
questionPool.removeAll(addedQuestions);
}
use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class QuestionGroupForm method moveQuestionUp.
public void moveQuestionUp(String sectionName, String questionId) {
for (SectionDetailForm section : sections) {
if (StringUtils.equalsIgnoreCase(sectionName, section.getName())) {
List<SectionQuestionDetail> questions = section.getSectionQuestionDetails();
for (SectionQuestionDetail question : questions) {
if (Integer.parseInt(questionId) == question.getQuestionId()) {
int actualSeqNumber = question.getSequenceNumber();
if (actualSeqNumber > 0) {
SectionQuestionDetail questionToSwap = questions.get(actualSeqNumber - 1);
question.setSequenceNumber(questionToSwap.getSequenceNumber());
questionToSwap.setSequenceNumber(actualSeqNumber);
questions.set(actualSeqNumber, questionToSwap);
questions.set(actualSeqNumber - 1, question);
}
break;
}
}
break;
}
}
}
use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class QuestionGroupForm method removeQuestionFromSection.
private void removeQuestionFromSection(String questionId, SectionDetail section) {
SectionQuestionDetail questionToRemove = null;
List<SectionQuestionDetail> questions = section.getQuestions();
for (SectionQuestionDetail question : questions) {
if (StringUtils.equals(questionId, String.valueOf(question.getQuestionId()))) {
questionToRemove = question;
break;
}
}
if (questionToRemove != null) {
questionToRemove.setMandatory(false);
questionToRemove.setSequenceNumber(0);
questions.remove(questionToRemove);
int sequence = 0;
for (SectionQuestionDetail sectionQuestionDetail : questions) {
sectionQuestionDetail.setSequenceNumber(sequence++);
}
questionPool.add(questionToRemove);
}
}
use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class CenterCustActionTest 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