Search in sources :

Example 41 with SectionQuestionDetail

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);
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList)

Example 42 with SectionQuestionDetail

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;
        }
    }
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 43 with SectionQuestionDetail

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);
    }
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 44 with SectionQuestionDetail

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;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Aggregations

SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)44 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)25 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)21 ArrayList (java.util.ArrayList)16 Test (org.junit.Test)7 QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)6 ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)5 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)3 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)3 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)2 QuestionLinkDetail (org.mifos.platform.questionnaire.service.QuestionLinkDetail)2 SectionLinkDetail (org.mifos.platform.questionnaire.service.SectionLinkDetail)2 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)2 HashSet (java.util.HashSet)1 PersonnelBusinessService (org.mifos.customers.personnel.business.service.PersonnelBusinessService)1 AuditLog (org.mifos.framework.components.audit.business.AuditLog)1 AuditLogRecord (org.mifos.framework.components.audit.business.AuditLogRecord)1 ServiceException (org.mifos.framework.exceptions.ServiceException)1 DateTimeService (org.mifos.framework.util.DateTimeService)1 QuestionGroupInstanceDtoBuilder (org.mifos.platform.questionnaire.builders.QuestionGroupInstanceDtoBuilder)1