use of org.mifos.platform.questionnaire.domain.QuestionGroupResponse in project head by mifos.
the class QuestionGroupInstanceDaoIntegrationTest method getQuestionGroupResponse.
private QuestionGroupResponse getQuestionGroupResponse(String responses, QuestionGroupInstance questionGroupInstance, SectionQuestion sectionQuestion) {
QuestionGroupResponse response = new QuestionGroupResponse();
response.setResponse(responses);
response.setQuestionGroupInstance(questionGroupInstance);
response.setSectionQuestion(sectionQuestion);
return response;
}
use of org.mifos.platform.questionnaire.domain.QuestionGroupResponse in project head by mifos.
the class QuestionGroupInstanceDaoIntegrationTest method shouldGetLatestQuestionGroupInstancesBasedOnQuestionGroupAndEntity.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldGetLatestQuestionGroupInstancesBasedOnQuestionGroupAndEntity() {
String title = "QG1" + currentTimeMillis();
List<SectionDetail> details = asList(getSection("S1"), getSection("S2"));
QuestionGroupDetail questionGroupDetail = defineQuestionGroup(title, "Create", "Client", details, false);
QuestionGroup questionGroup = questionGroupDao.getDetails(questionGroupDetail.getId());
QuestionGroupInstance instance1 = getQuestionGroupInstance(1, questionGroup, 101, "Foo Bar1", "Foo Bar2");
QuestionGroupInstance instance2 = getQuestionGroupInstance(2, questionGroup, 101, "Hello World1", "Hello World2");
questionGroupInstanceDao.saveOrUpdateAll(asList(instance1, instance2));
List<QuestionGroupInstance> instances = questionGroupInstanceDao.retrieveLatestQuestionGroupInstanceByQuestionGroupAndEntity(101, questionGroupDetail.getId());
assertThat(instances, is(notNullValue()));
assertThat(instances.size(), is(1));
QuestionGroupInstance qGInst = instances.get(0);
assertThat(qGInst.getVersionNum(), is(2));
assertThat(qGInst.getEntityId(), is(101));
assertThat(qGInst.getQuestionGroup().getId(), is(questionGroupDetail.getId()));
List<QuestionGroupResponse> qGResponses = qGInst.getQuestionGroupResponses();
assertThat(qGResponses, is(notNullValue()));
assertThat(qGResponses.size(), is(2));
assertThat(qGResponses.get(0).getResponse(), is("Hello World1"));
assertThat(qGResponses.get(1).getResponse(), is("Hello World2"));
}
use of org.mifos.platform.questionnaire.domain.QuestionGroupResponse in project head by mifos.
the class QuestionGroupInstanceDaoIntegrationTest method getQuestionGroupInstance.
private QuestionGroupInstance getQuestionGroupInstance(int version, QuestionGroup questionGroup, int entityId, String... responses) {
QuestionGroupInstance questionGroupInstance = new QuestionGroupInstance();
questionGroupInstance.setCompletedStatus(1);
questionGroupInstance.setQuestionGroup(questionGroup);
questionGroupInstance.setDateConducted(Calendar.getInstance().getTime());
questionGroupInstance.setCreatorId(122);
questionGroupInstance.setVersionNum(version);
questionGroupInstance.setEntityId(entityId);
List<QuestionGroupResponse> questionGroupResponses = new ArrayList<QuestionGroupResponse>();
for (int index = 0; index < responses.length; index++) {
SectionQuestion sectionQuestion = questionGroup.getSections().get(index).getQuestions().get(0);
questionGroupResponses.add(getQuestionGroupResponse(responses[index], questionGroupInstance, sectionQuestion));
}
questionGroupInstance.setQuestionGroupResponses(questionGroupResponses);
return questionGroupInstance;
}
use of org.mifos.platform.questionnaire.domain.QuestionGroupResponse in project head by mifos.
the class QuestionnaireMapperImpl method setMultiChoiceResponses.
private void setMultiChoiceResponses(List<QuestionGroupResponse> questionGroupResponses, SectionQuestionDetail sectionQuestionDetail) {
List<SelectionDetail> answers = new ArrayList<SelectionDetail>();
for (QuestionGroupResponse questionGroupResponse : questionGroupResponses) {
if (questionGroupResponse.getSectionQuestion().getId() == sectionQuestionDetail.getId()) {
answers.add(mapToSelectionDetail(questionGroupResponse));
}
}
sectionQuestionDetail.setSelections(answers);
}
use of org.mifos.platform.questionnaire.domain.QuestionGroupResponse in project head by mifos.
the class QuestionnaireMapperTest method getQuestionGroupInstanceWithSingleMultiSelectQuestion.
private QuestionGroupInstance getQuestionGroupInstanceWithSingleMultiSelectQuestion(int entityId, int version, QuestionGroup questionGroup, String... responses) {
QuestionGroupInstance questionGroupInstance = new QuestionGroupInstance();
questionGroupInstance.setQuestionGroup(questionGroup);
questionGroupInstance.setCompletedStatus(1);
questionGroupInstance.setCreatorId(122);
questionGroupInstance.setDateConducted(Calendar.getInstance().getTime());
questionGroupInstance.setEntityId(entityId);
questionGroupInstance.setVersionNum(version);
List<QuestionGroupResponse> groupResponses = new ArrayList<QuestionGroupResponse>();
for (String response : responses) {
groupResponses.add(getQuestionGroupResponse(response, questionGroupInstance, questionGroup.getSections().get(0).getQuestions().get(0)));
}
questionGroupInstance.setQuestionGroupResponses(groupResponses);
return questionGroupInstance;
}
Aggregations