Search in sources :

Example 11 with SectionQuestionDetail

use of org.mifos.platform.questionnaire.service.SectionQuestionDetail 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;
}
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)

Example 12 with SectionQuestionDetail

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

the class QuestionGroupControllerTest method shouldGetAllSectionQuestionsWithoutExcludedQuestions.

@Test
public void shouldGetAllSectionQuestionsWithoutExcludedQuestions() {
    List<Integer> excludedQuestions = asList(3);
    List<QuestionDetail> questionDetails = asList(getQuestionDetail(1, "Q1", QuestionType.NUMERIC), getQuestionDetail(2, "Q2", QuestionType.DATE));
    when(questionnaireServiceFacade.getAllActiveQuestions(excludedQuestions)).thenReturn(questionDetails);
    QuestionGroupForm questionGroupForm = getQuestionGroupFormWithOneSectionQuestion("QG1", 3);
    List<SectionQuestionDetail> sectionQuestions = questionGroupController.getAllSectionQuestions(questionGroupForm);
    assertThat(sectionQuestions, Is.is(notNullValue()));
    assertThat(sectionQuestions.size(), Is.is(2));
    assertThat(sectionQuestions.get(0).getQuestionId(), Is.is(1));
    assertThat(sectionQuestions.get(0).getText(), Is.is("Q1"));
    assertThat(sectionQuestions.get(1).getQuestionId(), Is.is(2));
    assertThat(sectionQuestions.get(1).getText(), Is.is("Q2"));
    verify(questionnaireServiceFacade).getAllActiveQuestions(excludedQuestions);
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) Test(org.junit.Test)

Example 13 with SectionQuestionDetail

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

the class QuestionnaireMapperTest method getSectionDetailWithQuestions.

private SectionDetail getSectionDetailWithQuestions(int id, String name, List<QuestionDetail> questionDetails, String answer, List<String> answers) {
    SectionDetail sectionDetail = new SectionDetail();
    sectionDetail.setName(name);
    List<SectionQuestionDetail> sectionQuestionDetails = new ArrayList<SectionQuestionDetail>();
    for (QuestionDetail questionDetail : questionDetails) {
        SectionQuestionDetail sectionQuestionDetail = new SectionQuestionDetail(id, questionDetail, false, answer, getSelections(answers));
        sectionQuestionDetails.add(sectionQuestionDetail);
    }
    sectionDetail.setQuestionDetails(sectionQuestionDetails);
    return sectionDetail;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 14 with SectionQuestionDetail

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

the class QuestionnaireMapperTest method getSectionDetailWithQuestions.

private SectionDetail getSectionDetailWithQuestions(int id, String name, List<QuestionDetail> questionDetails, List<SelectionDetail> answers) {
    SectionDetail sectionDetail = new SectionDetail();
    sectionDetail.setName(name);
    List<SectionQuestionDetail> sectionQuestionDetails = new ArrayList<SectionQuestionDetail>();
    for (QuestionDetail questionDetail : questionDetails) {
        SectionQuestionDetail sectionQuestionDetail = new SectionQuestionDetail(id, questionDetail, false, null, answers);
        sectionQuestionDetails.add(sectionQuestionDetail);
    }
    sectionDetail.setQuestionDetails(sectionQuestionDetails);
    return sectionDetail;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 15 with SectionQuestionDetail

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

the class QuestionnaireMapperTest method getSectionQuestionDetail.

private SectionQuestionDetail getSectionQuestionDetail(int secQuesId, int quesId, String quesText) {
    SectionQuestionDetail sectionQuestionDetail1 = new SectionQuestionDetail();
    sectionQuestionDetail1.setId(secQuesId);
    QuestionDetail questionDetail = new QuestionDetail();
    questionDetail.setId(quesId);
    questionDetail.setText(quesText);
    questionDetail.setType(QuestionType.FREETEXT);
    sectionQuestionDetail1.setQuestionDetail(questionDetail);
    return sectionQuestionDetail1;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) 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