@constructor-io/constructorio-client-javascript 2.35.0 → 2.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/modules/quizzes.js +20 -10
- package/lib/types/quizzes.d.ts +5 -2
- package/package.json +1 -1
package/lib/modules/quizzes.js
CHANGED
|
@@ -53,18 +53,24 @@ function createQuizUrl(quizId, parameters, options, path) {
|
|
|
53
53
|
if (parameters) {
|
|
54
54
|
var section = parameters.section,
|
|
55
55
|
answers = parameters.answers,
|
|
56
|
-
|
|
56
|
+
quizSessionId = parameters.quizSessionId,
|
|
57
|
+
quizVersionId = parameters.quizVersionId,
|
|
57
58
|
page = parameters.page,
|
|
58
59
|
resultsPerPage = parameters.resultsPerPage,
|
|
59
60
|
filters = parameters.filters; // Pull section from parameters
|
|
60
61
|
|
|
61
62
|
if (section) {
|
|
62
63
|
queryParams.section = section;
|
|
63
|
-
} // Pull
|
|
64
|
+
} // Pull quiz_version_id from parameters
|
|
64
65
|
|
|
65
66
|
|
|
66
|
-
if (
|
|
67
|
-
queryParams.
|
|
67
|
+
if (quizVersionId) {
|
|
68
|
+
queryParams.quiz_version_id = quizVersionId;
|
|
69
|
+
} // Pull quiz_session_id from parameters
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if (quizSessionId) {
|
|
73
|
+
queryParams.quiz_session_id = quizSessionId;
|
|
68
74
|
} // Pull a (answers) from parameters and transform
|
|
69
75
|
|
|
70
76
|
|
|
@@ -120,7 +126,8 @@ var Quizzes = /*#__PURE__*/function () {
|
|
|
120
126
|
* @param {string} [parameters] - Additional parameters to refine result set
|
|
121
127
|
* @param {string} [parameters.section] - Product catalog section
|
|
122
128
|
* @param {array} [parameters.answers] - An array of answers in the format [[1,2],[1]]
|
|
123
|
-
* @param {string} [parameters.
|
|
129
|
+
* @param {string} [parameters.quizVersionId] - Version identifier for the quiz. Version ID will be returned with the first request and it should be passed with subsequent requests. More information can be found: https://docs.constructor.io/rest_api/quiz/using_quizzes/#quiz-versioning
|
|
130
|
+
* @param {string} [parameters.quizSessionId] - Session identifier for the quiz. Session ID will be returned with the first request and it should be passed with subsequent requests. More information can be found: https://docs.constructor.io/rest_api/quiz/using_quizzes/#quiz-sessions
|
|
124
131
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
125
132
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
126
133
|
* @returns {Promise}
|
|
@@ -129,7 +136,8 @@ var Quizzes = /*#__PURE__*/function () {
|
|
|
129
136
|
* constructorio.quizzes.getQuizNextQuestion('quizId', {
|
|
130
137
|
* answers: [[1,2],[1]],
|
|
131
138
|
* section: '123',
|
|
132
|
-
*
|
|
139
|
+
* quizVersionId: '123',
|
|
140
|
+
* quizSessionId: '1234',
|
|
133
141
|
* });
|
|
134
142
|
*/
|
|
135
143
|
|
|
@@ -162,7 +170,7 @@ var Quizzes = /*#__PURE__*/function () {
|
|
|
162
170
|
|
|
163
171
|
return helpers.throwHttpErrorFromResponse(new Error(), response);
|
|
164
172
|
}).then(function (json) {
|
|
165
|
-
if (json.
|
|
173
|
+
if (json.quiz_version_id) {
|
|
166
174
|
_this.eventDispatcher.queue('quizzes.getQuizNextQuestion.completed', json);
|
|
167
175
|
|
|
168
176
|
return json;
|
|
@@ -180,7 +188,8 @@ var Quizzes = /*#__PURE__*/function () {
|
|
|
180
188
|
* @param {string} parameters - Additional parameters to refine result set
|
|
181
189
|
* @param {array} parameters.answers - An array of answers in the format [[1,2],[1]]
|
|
182
190
|
* @param {string} [parameters.section] - Product catalog section
|
|
183
|
-
* @param {string} [parameters.
|
|
191
|
+
* @param {string} [parameters.quizVersionId] - Version identifier for the quiz. Version ID will be returned with the first request and it should be passed with subsequent requests. More information can be found: https://docs.constructor.io/rest_api/quiz/using_quizzes/#quiz-versioning
|
|
192
|
+
* @param {string} [parameters.quizSessionId] - Session identifier for the quiz. Session ID will be returned with the first request and it should be passed with subsequent requests. More information can be found: https://docs.constructor.io/rest_api/quiz/using_quizzes/#quiz-sessions
|
|
184
193
|
* @param {number} [parameters.page] - The page number of the results
|
|
185
194
|
* @param {number} [parameters.resultsPerPage] - The number of results per page to return
|
|
186
195
|
* @param {object} [parameters.filters] - Key / value mapping (dictionary) of filters used to refine results
|
|
@@ -192,7 +201,8 @@ var Quizzes = /*#__PURE__*/function () {
|
|
|
192
201
|
* constructorio.quizzes.getQuizResults('quizId', {
|
|
193
202
|
* answers: [[1,2],[1]],
|
|
194
203
|
* section: '123',
|
|
195
|
-
*
|
|
204
|
+
* quizVersionId: '123',
|
|
205
|
+
* quizSessionId: '234'
|
|
196
206
|
* });
|
|
197
207
|
*/
|
|
198
208
|
|
|
@@ -224,7 +234,7 @@ var Quizzes = /*#__PURE__*/function () {
|
|
|
224
234
|
|
|
225
235
|
return helpers.throwHttpErrorFromResponse(new Error(), response);
|
|
226
236
|
}).then(function (json) {
|
|
227
|
-
if (json.
|
|
237
|
+
if (json.quiz_version_id) {
|
|
228
238
|
_this2.eventDispatcher.queue('quizzes.getQuizResults.completed', json);
|
|
229
239
|
|
|
230
240
|
return json;
|
package/lib/types/quizzes.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ export default Quizzes;
|
|
|
17
17
|
export interface QuizzesParameters {
|
|
18
18
|
section?: string;
|
|
19
19
|
answers?: any[];
|
|
20
|
-
|
|
20
|
+
quizVersionId?: string;
|
|
21
|
+
quizSessionId?: string;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export interface QuizzesResultsParameters extends QuizzesParameters {
|
|
@@ -50,6 +51,8 @@ export interface NextQuestionResponse extends Record<string, any> {
|
|
|
50
51
|
next_question: Question;
|
|
51
52
|
is_last_question?: boolean;
|
|
52
53
|
version_id?: string;
|
|
54
|
+
quiz_id?: string;
|
|
55
|
+
quiz_session_id?: string;
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
export interface QuizResultsResponse extends Record<string, any> {
|
|
@@ -77,7 +80,7 @@ export interface QuizResultsResponse extends Record<string, any> {
|
|
|
77
80
|
features: Partial<Feature>[];
|
|
78
81
|
};
|
|
79
82
|
result_id?: string;
|
|
80
|
-
|
|
83
|
+
quiz_version_id: string;
|
|
81
84
|
quiz_session_id: string;
|
|
82
85
|
quiz_id: string;
|
|
83
86
|
}
|