@wg-npm/survey-response 0.5.165 → 0.5.167
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.
|
@@ -875,8 +875,8 @@ var script$c = Vue.extend({
|
|
|
875
875
|
});
|
|
876
876
|
this.value.score = score;
|
|
877
877
|
},
|
|
878
|
-
toggleAnswer(subValue, subIndex) {
|
|
879
|
-
if (this.responseStatus == this.$consts.STATUS_DRAFT) {
|
|
878
|
+
toggleAnswer(subValue, subIndex, disabled) {
|
|
879
|
+
if (this.responseStatus == this.$consts.STATUS_DRAFT && !disabled) {
|
|
880
880
|
let subAnswer = this.value.answer[subIndex].answer;
|
|
881
881
|
this.value.answer[subIndex].answer = _.isEmpty(subAnswer)
|
|
882
882
|
? subValue
|
|
@@ -893,7 +893,11 @@ const __vue_script__$c = script$c;
|
|
|
893
893
|
var __vue_render__$c = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',_vm._l((_vm.question.subQuestions),function(subQuestion,subIndex){return _c('div',{key:subIndex,staticClass:"sub-question"},[_c('span',{staticClass:"number"},[_vm._v("\n "+_vm._s(_vm.question.header.number)+"-"+_vm._s(subQuestion.number)+".")]),_vm._v(" "),_c('span',{staticClass:"title"},[_vm._v(" "+_vm._s(_vm.i18nText(subQuestion.text))+" ")]),_vm._v(" "),_c('FormItem',{attrs:{"prop":_vm.answerProp(subIndex),"rules":{
|
|
894
894
|
required: _vm.question.options.required && !_vm.question.options.disabled,
|
|
895
895
|
message: _vm.t('survey_response.question.question_required'),
|
|
896
|
-
}}},[_c('RadioGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer[subIndex].answer),callback:function ($$v) {_vm.$set(_vm.value.answer[subIndex], "answer", $$v);},expression:"value.answer[subIndex].answer"}},[_c('Row',{attrs:{"type":"flex","justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout},[_c('Radio',{key:choice.id,attrs:{"label":choice.id,"disabled":subQuestion.options.readonly || _vm.question.options.disabled},nativeOn:{"click":function($event){return _vm.toggleAnswer(
|
|
896
|
+
}}},[_c('RadioGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer[subIndex].answer),callback:function ($$v) {_vm.$set(_vm.value.answer[subIndex], "answer", $$v);},expression:"value.answer[subIndex].answer"}},[_c('Row',{attrs:{"type":"flex","justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout},[_c('Radio',{key:choice.id,attrs:{"label":choice.id,"disabled":subQuestion.options.readonly || _vm.question.options.disabled},nativeOn:{"click":function($event){return _vm.toggleAnswer(
|
|
897
|
+
choice.id,
|
|
898
|
+
subIndex,
|
|
899
|
+
subQuestion.options.readonly || _vm.question.options.disabled
|
|
900
|
+
)}}},[_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))])])],1)}),1)],1)],1)],1)}),0)};
|
|
897
901
|
var __vue_staticRenderFns__$c = [];
|
|
898
902
|
|
|
899
903
|
/* style */
|
|
@@ -1205,96 +1209,113 @@ var __vue_staticRenderFns__$9 = [];
|
|
|
1205
1209
|
|
|
1206
1210
|
var Star = __vue_component__$9;
|
|
1207
1211
|
|
|
1208
|
-
class ExprEvaluationQuestion {
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1212
|
+
class ExprEvaluationQuestion {
|
|
1213
|
+
questions;
|
|
1214
|
+
scope;
|
|
1215
|
+
questionMap;
|
|
1216
|
+
|
|
1217
|
+
constructor(questions, scope) {
|
|
1218
|
+
this.questions = questions;
|
|
1219
|
+
this.scope = _.sortBy(scope);
|
|
1220
|
+
|
|
1221
|
+
this.questionMap = this.buildQuestionMap();
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
calculateNumbers() {
|
|
1225
|
+
const checkedQuestions = this.checkedQuestion();
|
|
1226
|
+
const checkedNumberElements = new Array();
|
|
1227
|
+
this.recurs(checkedQuestions, checkedNumberElements);
|
|
1228
|
+
|
|
1229
|
+
return checkedNumberElements;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
buildQuestionMap() {
|
|
1233
|
+
const questionMap = {};
|
|
1234
|
+
_.forEach(this.questions, (question) => {
|
|
1235
|
+
questionMap[question.id] = question;
|
|
1236
|
+
if (question.type == "MATRIX") {
|
|
1237
|
+
_.forEach(_.get(question, "subQuestions", []), (subQuestion) => {
|
|
1238
|
+
questionMap[subQuestion.id] = subQuestion;
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
return questionMap;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
checkedQuestion() {
|
|
1246
|
+
const questions = new Array();
|
|
1247
|
+
_.forEach(this.questions, (question) => {
|
|
1248
|
+
if (_.get(question, "type") == "MATRIX") {
|
|
1249
|
+
const markedQuestions = new Array();
|
|
1250
|
+
_.forEach(_.get(question, "subQuestions", []), (subQuestion) => {
|
|
1251
|
+
if (_.includes(this.scope, subQuestion.id)) {
|
|
1252
|
+
const newSubQuestion = _.cloneDeep(subQuestion);
|
|
1253
|
+
_.set(newSubQuestion, "type", "MATRIX");
|
|
1254
|
+
_.set(newSubQuestion, "parentId", _.get(question, "id"));
|
|
1255
|
+
markedQuestions.push(newSubQuestion);
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
if (!_.isEmpty(markedQuestions)) {
|
|
1259
|
+
questions.push(markedQuestions);
|
|
1260
|
+
}
|
|
1261
|
+
} else if (_.includes(this.scope, question.id)) {
|
|
1262
|
+
questions.push(question);
|
|
1263
|
+
}
|
|
1264
|
+
});
|
|
1265
|
+
return questions;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
recurs(elements, numbers) {
|
|
1269
|
+
for (let i = 0; i < elements.length; i++) {
|
|
1270
|
+
const element = elements[i];
|
|
1271
|
+
if (_.isArray(element)) {
|
|
1272
|
+
numbers.push(new Array());
|
|
1273
|
+
this.recurs(element, numbers[numbers.length - 1]);
|
|
1274
|
+
} else {
|
|
1275
|
+
const temp = new Array();
|
|
1276
|
+
temp.push(this.getFullNumber(element));
|
|
1277
|
+
if (i == elements.length - 1) {
|
|
1278
|
+
numbers.push(temp);
|
|
1279
|
+
continue;
|
|
1280
|
+
}
|
|
1281
|
+
for (let j = i + 1; ; j++) {
|
|
1282
|
+
if (
|
|
1283
|
+
j == elements.length ||
|
|
1284
|
+
!this.isContinuous(elements[j - 1], elements[j])
|
|
1285
|
+
) {
|
|
1286
|
+
numbers.push(temp);
|
|
1287
|
+
i = j - 1;
|
|
1288
|
+
break;
|
|
1289
|
+
}
|
|
1290
|
+
if (_.size(temp) > 1) {
|
|
1291
|
+
temp.pop();
|
|
1292
|
+
}
|
|
1293
|
+
temp.push(this.getFullNumber(elements[j]));
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
isContinuous(front, hind) {
|
|
1300
|
+
return (
|
|
1301
|
+
!_.isArray(hind) && this.getNumber(hind) - this.getNumber(front) == 1
|
|
1302
|
+
);
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
getFullNumber(question) {
|
|
1306
|
+
if (question.type == "MATRIX") {
|
|
1307
|
+
return (
|
|
1308
|
+
this.questionMap[question.parentId].header.number +
|
|
1309
|
+
"." +
|
|
1310
|
+
this.getNumber(question)
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
return this.getNumber(question).toString();
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
getNumber(question) {
|
|
1317
|
+
return question.type == "MATRIX" ? question.number : question.header.number;
|
|
1318
|
+
}
|
|
1298
1319
|
}
|
|
1299
1320
|
|
|
1300
1321
|
const SPLIT_LENGTH = 50;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wg-npm/survey-response",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.167",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"lint-fix": "eslint \"**/*.ts\" \"**/*.vue\" --fix --no-error-on-unmatched-pattern"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@wg-npm/survey-core": "0.5.
|
|
16
|
-
"@wg-npm/survey-service-api": "0.5.
|
|
15
|
+
"@wg-npm/survey-core": "0.5.167",
|
|
16
|
+
"@wg-npm/survey-service-api": "0.5.167",
|
|
17
17
|
"axios": "^0.19.2",
|
|
18
18
|
"deepmerge": "^4.2.2",
|
|
19
19
|
"lodash": "^4.17.15",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"@typescript-eslint/parser": "^3.6.0",
|
|
35
35
|
"@vue/eslint-config-prettier": "^6.0.0",
|
|
36
36
|
"@vue/eslint-config-typescript": "^5.0.2",
|
|
37
|
-
"@wg-npm/survey-core": "0.5.
|
|
38
|
-
"@wg-npm/survey-service-api": "0.5.
|
|
37
|
+
"@wg-npm/survey-core": "0.5.167",
|
|
38
|
+
"@wg-npm/survey-service-api": "0.5.167",
|
|
39
39
|
"acorn": "^7.3.1",
|
|
40
40
|
"axios": "^0.19.2",
|
|
41
41
|
"babelrc-rollup": "^3.0.0",
|
|
@@ -29,7 +29,13 @@
|
|
|
29
29
|
<Radio
|
|
30
30
|
:label="choice.id"
|
|
31
31
|
:key="choice.id"
|
|
32
|
-
@click.native="
|
|
32
|
+
@click.native="
|
|
33
|
+
toggleAnswer(
|
|
34
|
+
choice.id,
|
|
35
|
+
subIndex,
|
|
36
|
+
subQuestion.options.readonly || question.options.disabled
|
|
37
|
+
)
|
|
38
|
+
"
|
|
33
39
|
:disabled="
|
|
34
40
|
subQuestion.options.readonly || question.options.disabled
|
|
35
41
|
"
|
|
@@ -138,8 +144,8 @@ export default Vue.extend({
|
|
|
138
144
|
// @ts-ignore
|
|
139
145
|
this.value.score = score;
|
|
140
146
|
},
|
|
141
|
-
toggleAnswer(subValue, subIndex) {
|
|
142
|
-
if (this.responseStatus == this.$consts.STATUS_DRAFT) {
|
|
147
|
+
toggleAnswer(subValue, subIndex, disabled) {
|
|
148
|
+
if (this.responseStatus == this.$consts.STATUS_DRAFT && !disabled) {
|
|
143
149
|
let subAnswer = this.value.answer[subIndex].answer;
|
|
144
150
|
this.value.answer[subIndex].answer = _.isEmpty(subAnswer)
|
|
145
151
|
? subValue
|