Search in sources :

Example 21 with ChoiceDto

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

the class Question method addAnswerSmartChoice.

public void addAnswerSmartChoice() {
    questionDetail.addAnswerChoice(new ChoiceDto(getCurrentSmartChoice()));
    currentSmartChoiceTags.add(EMPTY);
    setCurrentSmartChoice(null);
}
Also used : ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto)

Example 22 with ChoiceDto

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

the class QuestionnaireMapperImpl method mapToChoiceDetail.

private ChoiceDto mapToChoiceDetail(QuestionChoiceEntity questionChoice) {
    ChoiceDto choiceDto = new ChoiceDto(questionChoice.getChoiceText());
    mapToChoiceTags(choiceDto, questionChoice.getTags());
    return choiceDto;
}
Also used : ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto)

Example 23 with ChoiceDto

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

the class ClientCustActionTest 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 24 with ChoiceDto

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

the class QuestionFormTest method testAddCurrentQuestion.

@Test
public void testAddCurrentQuestion() {
    QuestionForm questionForm = getQuestionForm("  Q1 ", "freeText", "choice1");
    List<Question> questionList = questionForm.getQuestions();
    assertThat(questionList.size(), is(1));
    String text = questionList.get(0).getText();
    String type = questionList.get(0).getType();
    List<ChoiceDto> choices = questionList.get(0).getChoices();
    assertNotSame(text, questionForm.getCurrentQuestion().getText());
    assertNotSame(type, questionForm.getCurrentQuestion().getType());
    assertThat(text, is("Q1"));
    assertThat(type, is("freeText"));
    assertThat(choices.size(), is(0));
}
Also used : QuestionForm(org.mifos.platform.questionnaire.ui.model.QuestionForm) Question(org.mifos.platform.questionnaire.ui.model.Question) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) Test(org.junit.Test)

Example 25 with ChoiceDto

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

the class QuestionFormTest method testAddCurrentSingleSelectQuestion.

@Test
public void testAddCurrentSingleSelectQuestion() {
    QuestionForm questionForm = getQuestionForm("title1", "singleSelect", "choice");
    List<Question> questionList = questionForm.getQuestions();
    assertThat(questionList.size(), is(1));
    String text = questionList.get(0).getText();
    String type = questionList.get(0).getType();
    List<ChoiceDto> choices = questionList.get(0).getChoices();
    assertNotSame(text, questionForm.getCurrentQuestion().getText());
    assertNotSame(type, questionForm.getCurrentQuestion().getType());
    assertThat(choices.get(0).getValue(), is("choice"));
    assertThat(text, is("title1"));
    assertThat(type, is("singleSelect"));
}
Also used : QuestionForm(org.mifos.platform.questionnaire.ui.model.QuestionForm) Question(org.mifos.platform.questionnaire.ui.model.Question) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) Test(org.junit.Test)

Aggregations

ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)33 Test (org.junit.Test)14 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)13 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)11 QuestionDto (org.mifos.platform.questionnaire.service.dtos.QuestionDto)7 ArrayList (java.util.ArrayList)6 QuestionDtoBuilder (org.mifos.platform.questionnaire.builders.QuestionDtoBuilder)6 ChoiceDetailBuilder (org.mifos.platform.questionnaire.builders.ChoiceDetailBuilder)5 QuestionGroupDtoBuilder (org.mifos.platform.questionnaire.builders.QuestionGroupDtoBuilder)5 SectionDtoBuilder (org.mifos.platform.questionnaire.builders.SectionDtoBuilder)5 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)5 SectionDto (org.mifos.platform.questionnaire.service.dtos.SectionDto)5 Question (org.mifos.platform.questionnaire.ui.model.Question)5 QuestionForm (org.mifos.platform.questionnaire.ui.model.QuestionForm)4 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)3 QuestionChoicesMatcher (org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher)3 QuestionGroupDto (org.mifos.platform.questionnaire.service.dtos.QuestionGroupDto)3 HashSet (java.util.HashSet)2 SystemException (org.mifos.framework.exceptions.SystemException)2 QuestionChoiceEntity (org.mifos.platform.questionnaire.domain.QuestionChoiceEntity)2