Search in sources :

Example 6 with SectionQuestionDetail

use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.

the class QuestionnaireMapperImpl method mapToSectionQuestion.

private SectionQuestion mapToSectionQuestion(SectionQuestionDetail sectionQuestionDetail, int seqNum, Section section) {
    QuestionDetail questionDetail = sectionQuestionDetail.getQuestionDetail();
    SectionQuestion sectionQuestion = getSectionQuestion(questionDetail, section);
    sectionQuestion.setRequired(sectionQuestionDetail.isMandatory());
    sectionQuestion.setShowOnPage(sectionQuestionDetail.isShowOnPage());
    sectionQuestion.setSequenceNumber(sectionQuestionDetail.getSequenceNumber());
    if (sectionQuestion.isNewSectionQuestion()) {
        sectionQuestion.setQuestion(mapToQuestion(questionDetail));
        sectionQuestion.setSequenceNumber(seqNum);
        sectionQuestion.setSection(section);
    }
    return sectionQuestion;
}
Also used : SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 7 with SectionQuestionDetail

use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.

the class QuestionGroupController method getAllSectionQuestions.

public List<SectionQuestionDetail> getAllSectionQuestions(QuestionGroupForm questionGroupForm) {
    List<SectionQuestionDetail> sectionQuestionDetails = new ArrayList<SectionQuestionDetail>();
    List<Integer> questionIds = questionGroupForm.getQuestionGroupDetail().getAllQuestionIds();
    List<QuestionDetail> questionDetails = questionnaireServiceFacade.getAllActiveQuestions(questionIds);
    if (questionDetails != null) {
        for (QuestionDetail questionDetail : questionDetails) {
            sectionQuestionDetails.add(new SectionQuestionDetail(questionDetail, false));
        }
    }
    return sectionQuestionDetails;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 8 with SectionQuestionDetail

use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.

the class QuestionGroupForm method addNewQuestion.

private void addNewQuestion() {
    currentQuestion.setChoices();
    SectionQuestionDetail sectionQuestionDetail = new SectionQuestionDetail(currentQuestion.getQuestionDetail(), false);
    currentSection.addSectionQuestion(sectionQuestionDetail);
    Integer newQuestionId = getNewQuestionId();
    sectionQuestionDetail.getQuestionDetail().setId(newQuestionId);
    currentQuestion = new Question(new QuestionDetail());
    questionsToAdd.add(newQuestionId);
    updateSequenceNumbers();
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 9 with SectionQuestionDetail

use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.

the class QuestionGroupForm method getNewQuestionId.

private Integer getNewQuestionId() {
    Integer minId = 0;
    List<SectionQuestionDetail> sectionQuestionDetails = currentSection.getSectionQuestionDetails();
    for (SectionQuestionDetail sectionQuestionDetail : sectionQuestionDetails) {
        if (sectionQuestionDetail.getQuestionId() < minId) {
            minId = sectionQuestionDetail.getQuestionId();
        }
    }
    return minId - 1;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 10 with SectionQuestionDetail

use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.

the class QuestionGroupForm method markQuestionsOptionalAndReturnToPool.

private void markQuestionsOptionalAndReturnToPool(SectionDetail sectionDetail) {
    List<SectionQuestionDetail> sectionQuestionDetails = sectionDetail.getQuestions();
    for (SectionQuestionDetail sectionQuestionDetail : sectionQuestionDetails) {
        sectionQuestionDetail.setMandatory(false);
        questionPool.add(sectionQuestionDetail);
    }
}
Also used : 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