Skip to content

Commit 276ae5c

Browse files
committed
fix: set OptionFilter in the response
1 parent 0f131af commit 276ae5c

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

‎src/main/resources/xsd/Questionnaire.xsd‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,6 @@
233233
codeValue filtered according to a condition</xs:documentation>
234234
</xs:annotation>
235235
</xs:element>
236-
<xs:element name="OptionFilter" type="xs:string" minOccurs="0">
237-
<xs:annotation>
238-
<xs:documentation>
239-
OptionFilter defines a VTL expression used to dynamically filter
240-
response options when the choiceType is set to VARIABLE.
241-
For CODE_LIST questions, filtering must be defined at the individual
242-
option level.</xs:documentation>
243-
</xs:annotation>
244-
</xs:element>
245236
</xs:sequence>
246237
<xs:attribute name="questionType" type="QuestionTypeEnum"/>
247238
<xs:attribute name="mandatory" type="xs:boolean">
@@ -621,6 +612,15 @@
621612
</xs:documentation>
622613
</xs:annotation>
623614
</xs:element>
615+
<xs:element name="OptionFilter" type="xs:string" minOccurs="0">
616+
<xs:annotation>
617+
<xs:documentation>
618+
OptionFilter defines a VTL expression used to dynamically filter
619+
response options when the choiceType is set to VARIABLE.
620+
For CODE_LIST questions, filtering must be defined at the individual
621+
option level.</xs:documentation>
622+
</xs:annotation>
623+
</xs:element>
624624
<xs:element name="Datatype" type="DatatypeType"/>
625625
<xs:element name="Value" type="xs:anyType" minOccurs="0" maxOccurs="unbounded"/>
626626
<xs:element name="NonResponseModality" type="NonResponseModalityType" minOccurs="0"

‎src/test/java/fr/insee/pogues/model/UniqueChoiceVariableOptionsTest.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ void serializeUcqVariable_withFilter() throws JAXBException, UnsupportedEncoding
1919
// Given
2020
QuestionType question = new QuestionType();
2121
question.setQuestionType(QuestionTypeEnum.SINGLE_CHOICE);
22-
question.setOptionFilter("nvl($AGE$, 0) > 18");
2322

2423
ResponseType response = new ResponseType();
2524
response.setVariableReference("id-loop-variable");
25+
response.setOptionFilter("nvl($AGE$, 0) > 18");
2626
response.setChoiceType(ChoiceTypeEnum.VARIABLE);
2727

2828
question.getResponse().add(response);
@@ -40,10 +40,10 @@ void serializeUcqVariable_withFilter() throws JAXBException, UnsupportedEncoding
4040
{
4141
"type": "QuestionType",
4242
"questionType": "SINGLE_CHOICE",
43-
"OptionFilter": "nvl($AGE$, 0) > 18",
4443
"Response": [
4544
{
4645
"VariableReference": "id-loop-variable",
46+
"OptionFilter": "nvl($AGE$, 0) > 18",
4747
"choiceType": "VARIABLE"
4848
}
4949
]
@@ -100,7 +100,7 @@ void deserializeUcqVariable() throws JAXBException {
100100
QuestionType question = (QuestionType) questionnaire.getChild().getFirst();
101101
assertEquals(QuestionTypeEnum.SINGLE_CHOICE, question.getQuestionType());
102102
assertEquals(ChoiceTypeEnum.VARIABLE, question.getResponse().getFirst().getChoiceType());
103-
assertNull(question.getOptionFilter());
103+
assertNull(question.getResponse().getFirst().getOptionFilter());
104104
assertNotNull(question.getResponse());
105105
assertFalse(question.getResponse().isEmpty()) ;
106106
assertEquals("id-loop-variable", question.getResponse().getFirst().getVariableReference());
@@ -114,10 +114,10 @@ void deserializeUcqVariable_withFilter() throws JAXBException {
114114
{
115115
"type": "QuestionType",
116116
"questionType": "SINGLE_CHOICE",
117-
"OptionFilter": "nvl($AGE$, 0) > 18",
118117
"Response": {
119118
"choiceType": "VARIABLE",
120-
"VariableReference": "id-loop-variable"
119+
"VariableReference": "id-loop-variable",
120+
"OptionFilter": "nvl($AGE$, 0) > 18",
121121
}
122122
}
123123
]
@@ -130,7 +130,7 @@ void deserializeUcqVariable_withFilter() throws JAXBException {
130130
QuestionType question = (QuestionType) questionnaire.getChild().getFirst();
131131
assertEquals(QuestionTypeEnum.SINGLE_CHOICE, question.getQuestionType());
132132
assertEquals(ChoiceTypeEnum.VARIABLE, question.getResponse().getFirst().getChoiceType());
133-
assertEquals("nvl($AGE$, 0) > 18", question.getOptionFilter());
133+
assertEquals("nvl($AGE$, 0) > 18", question.getResponse().getFirst().getOptionFilter());
134134
assertNotNull(question.getResponse());
135135
assertFalse(question.getResponse().isEmpty()) ;
136136
assertEquals("id-loop-variable", question.getResponse().getFirst().getVariableReference());

0 commit comments

Comments
 (0)