Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>fr.insee.pogues</groupId>
<artifactId>pogues-model</artifactId>
<version>1.15.0</version>
<version>1.15.1</version>
<packaging>jar</packaging>

<name>Pogues Model</name>
Expand Down
18 changes: 9 additions & 9 deletions src/main/resources/xsd/Questionnaire.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,6 @@
</xs:element>
</xs:sequence>
<xs:attribute name="questionType" type="QuestionTypeEnum"/>
<xs:attribute name="choiceType" type="ChoiceTypeEnum" default="CODE_LIST">
<xs:annotation>
<xs:documentation>
choiceType specifies whether the response options are defined by a static
code list (CODE_LIST) or dynamically generated from a collected variable
(VARIABLE). The default value is CODE_LIST.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="mandatory" type="xs:boolean">
<xs:annotation>
<xs:documentation>Whether the question is mandatory. Only used by multiple choice question for now:
Expand Down Expand Up @@ -664,6 +655,15 @@
to a single response.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="choiceType" type="ChoiceTypeEnum" default="CODE_LIST">
<xs:annotation>
<xs:documentation>
choiceType specifies whether the response options are defined by a static
code list (CODE_LIST) or dynamically generated from a collected variable
(VARIABLE). The default value is CODE_LIST.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>

<xs:complexType name="NonResponseModalityType">
Expand Down
25 changes: 17 additions & 8 deletions src/test/java/fr/insee/pogues/test/JSONDeserializerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,18 @@ void testChoiceTypeVariableResponses() throws JAXBException {
"Child": [
{
"type": "QuestionType",
"choiceType": "VARIABLE"
"Response": [
{
"choiceType": "VARIABLE"
}
]
}
]
}
""";
JSONDeserializer deserializer = new JSONDeserializer();
Questionnaire questionnaire = deserializer.deserializeString(json);
assertEquals(ChoiceTypeEnum.VARIABLE, ((QuestionType) questionnaire.getChild().getFirst()).getChoiceType());
assertEquals(ChoiceTypeEnum.VARIABLE, ((QuestionType) questionnaire.getChild().getFirst()).getResponse().getFirst().getChoiceType());
}

@Test
Expand All @@ -434,15 +438,19 @@ void testChoiceTypeSuggester() throws JAXBException {
"Child": [
{
"type": "QuestionType",
"choiceType": "SUGGESTER"
"Response": [
{
"choiceType": "SUGGESTER"
}
]
}
]
}
""";

JSONDeserializer deserializer = new JSONDeserializer();
Questionnaire questionnaire = deserializer.deserializeString(json);
assertEquals(ChoiceTypeEnum.SUGGESTER, ((QuestionType) questionnaire.getChild().getFirst()).getChoiceType());
assertEquals(ChoiceTypeEnum.SUGGESTER, ((QuestionType) questionnaire.getChild().getFirst()).getResponse().getFirst().getChoiceType());
}

@Test
Expand All @@ -451,14 +459,15 @@ void testChoiceTypeDefaultValue() throws JAXBException {
{
"Child": [
{
"type": "QuestionType"
"type": "QuestionType",
"Response": [{}]
}
]
}
""";
JSONDeserializer deserializer = new JSONDeserializer();
Questionnaire questionnaire = deserializer.deserializeString(json);
assertEquals(ChoiceTypeEnum.CODE_LIST, ((QuestionType) questionnaire.getChild().getFirst()).getChoiceType());
assertEquals(ChoiceTypeEnum.CODE_LIST, ((QuestionType) questionnaire.getChild().getFirst()).getResponse().getFirst().getChoiceType());
}

@Test
Expand Down Expand Up @@ -508,9 +517,9 @@ void testVariableResponsesFullConfiguration() throws JAXBException {
{
"type": "QuestionType",
"questionType": "SINGLE_CHOICE",
"choiceType": "VARIABLE",
"OptionFilter": "nvl($AGE$, 0) > 18",
"Response": {
"choiceType": "VARIABLE",
"VariableReference": "id-loop-variable"
}
}
Expand All @@ -526,7 +535,7 @@ void testVariableResponsesFullConfiguration() throws JAXBException {


assertEquals(QuestionTypeEnum.SINGLE_CHOICE, question.getQuestionType());
assertEquals(ChoiceTypeEnum.VARIABLE, question.getChoiceType());
assertEquals(ChoiceTypeEnum.VARIABLE, question.getResponse().getFirst().getChoiceType());
assertEquals("nvl($AGE$, 0) > 18", question.getOptionFilter());
assertNotNull(question.getResponse());
assertFalse(question.getResponse().isEmpty());
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/fr/insee/pogues/test/JSONSerializerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,11 @@ void serializePairwiseSourceVariableReferences() throws JAXBException, Unsupport
void testSerializeVariableResponsesFullConfiguration() throws Exception {
QuestionType question = new QuestionType();
question.setQuestionType(QuestionTypeEnum.SINGLE_CHOICE);
question.setChoiceType(ChoiceTypeEnum.VARIABLE);
question.setOptionFilter("nvl($AGE$, 0) > 18");

ResponseType response = new ResponseType();
response.setVariableReference("id-loop-variable");
response.setChoiceType(ChoiceTypeEnum.VARIABLE);

question.getResponse().add(response);

Expand All @@ -700,11 +700,11 @@ void testSerializeVariableResponsesFullConfiguration() throws Exception {
{
"type": "QuestionType",
"questionType": "SINGLE_CHOICE",
"choiceType": "VARIABLE",
"OptionFilter": "nvl($AGE$, 0) > 18",
"Response": [
{
"VariableReference": "id-loop-variable"
"VariableReference": "id-loop-variable",
"choiceType": "VARIABLE"
}
]
}
Expand Down