Search in sources :

Example 1 with SectionQuestionDetail

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

the class PPITestDataGenerator method createSurveyInstance.

private void createSurveyInstance(CustomerBO customer, Properties properties, QuestionGroupDetail qg, int surveyNum) {
    Integer creatorId = 1;
    QuestionGroupInstanceDtoBuilder instanceBuilder = new QuestionGroupInstanceDtoBuilder();
    instanceBuilder.withQuestionGroup(qg.getId()).withCompleted(true).withCreator(creatorId).withEventSource(1).withEntity(customer.getCustomerId()).withVersion(1);
    List<SectionQuestionDetail> questions = qg.getSectionDetail(0).getQuestions();
    for (SectionQuestionDetail question : questions) {
        String responseKey = "survey." + surveyNum + ".question." + question.getSequenceNumber() + ".response.text";
        String questionResponse = properties.getProperty(responseKey);
        QuestionGroupResponseDtoBuilder responseBuilder = new QuestionGroupResponseDtoBuilder();
        responseBuilder.withSectionQuestion(question.getQuestionId()).withResponse(questionResponse);
        instanceBuilder.addResponses(responseBuilder.build());
    }
    questionnaireServiceFacade.saveQuestionGroupInstance(instanceBuilder.build());
}
Also used : QuestionGroupResponseDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupResponseDtoBuilder) QuestionGroupInstanceDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupInstanceDtoBuilder) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 2 with SectionQuestionDetail

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

the class SavingsAccountActionTest 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 3 with SectionQuestionDetail

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

the class QuestionnaireFlowAdapterTest method getSectionDetailWithQuestions.

private SectionDetail getSectionDetailWithQuestions(String sectionName, List<QuestionDetail> questionDetails, String value, boolean mandatory) {
    SectionDetail section = new SectionDetail();
    section.setName(sectionName);
    List<SectionQuestionDetail> sectionQuestions = new ArrayList<SectionQuestionDetail>();
    for (QuestionDetail questionDetail : questionDetails) {
        SectionQuestionDetail sectionQuestion = new SectionQuestionDetail(questionDetail, mandatory);
        sectionQuestion.setValue(value);
        sectionQuestions.add(sectionQuestion);
    }
    section.setQuestionDetails(sectionQuestions);
    return section;
}
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 4 with SectionQuestionDetail

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

the class QuestionnaireServiceTest method getSectionDefinition.

private SectionDetail getSectionDefinition(String name) {
    SectionDetail section = new SectionDetail();
    section.setName(name);
    section.addQuestion(new SectionQuestionDetail(new QuestionDetail(11, null, QuestionType.INVALID, true, true), true));
    section.addQuestion(new SectionQuestionDetail(new QuestionDetail(12, null, QuestionType.INVALID, true, true), false));
    return section;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 5 with SectionQuestionDetail

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

the class QuestionGroupController method setSectionLinkDetail.

public SectionLinkDetail setSectionLinkDetail(QuestionGroupForm questionGroupForm, String sourceQuestionId, String affectedSectionName, String value, String additionalValue, String linkType, String linkTypeDisplay) {
    SectionLinkDetail sectionLinkDetail = new SectionLinkDetail();
    SectionQuestionDetail sourceQuestion = findQuestionDetailById(questionGroupForm.getQuestionGroupDetail(), sourceQuestionId);
    sectionLinkDetail.setSourceQuestion(sourceQuestion);
    SectionDetail affectedSection = findSectionDetailByName(questionGroupForm.getQuestionGroupDetail(), affectedSectionName);
    sectionLinkDetail.setAffectedSection(affectedSection);
    sectionLinkDetail.setValue(value);
    sectionLinkDetail.setLinkType(Integer.valueOf(linkType));
    sectionLinkDetail.setLinkTypeDisplay(linkTypeDisplay);
    sectionLinkDetail.setState(false);
    if (additionalValue != null)
        sectionLinkDetail.setAdditionalValue(additionalValue);
    return sectionLinkDetail;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) SectionLinkDetail(org.mifos.platform.questionnaire.service.SectionLinkDetail) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail)

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