@wg-npm/survey-creator 0.5.161 → 0.5.164
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/dist/survey-creator.esm.js +571 -507
- package/package.json +5 -5
- package/src/components/common/question-title-dynamic.vue +55 -0
- package/src/components/common/question-title.vue +4 -35
- package/src/components/editor/question-default-layout.vue +2 -5
- package/src/components/survey-previewer.vue +2 -3
|
@@ -303,318 +303,328 @@ function currentLang() {
|
|
|
303
303
|
}
|
|
304
304
|
var locale = { use, t, i18n, currentLang };
|
|
305
305
|
|
|
306
|
-
class QuestionFactory {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
const defaultText = function getText(locale) {
|
|
371
|
-
return _.set({}, locale, "");
|
|
372
|
-
};
|
|
373
|
-
class ChoiceOptionModel {
|
|
374
|
-
constructor() {
|
|
375
|
-
this.score = null;
|
|
376
|
-
this.star = false;
|
|
377
|
-
this.starCount = null;
|
|
378
|
-
this.exclusiveEnabled = false;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
class ChoiceModel {
|
|
382
|
-
constructor(locale) {
|
|
383
|
-
this.id = ChoiceModel.createChoiceId();
|
|
384
|
-
this.text = defaultText(locale);
|
|
385
|
-
this.options = new ChoiceOptionModel();
|
|
386
|
-
}
|
|
387
|
-
static createChoiceId() {
|
|
388
|
-
return `Choice-${_.now()}-${_.random(0, 9999999)}`;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
class ExclusiveChoiceModel extends ChoiceModel {
|
|
392
|
-
constructor(locale) {
|
|
393
|
-
super(locale);
|
|
394
|
-
if (!_.isEmpty(this.options)) {
|
|
395
|
-
_.set(this.options, "exclusiveEnabled", true);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
class EvaluationItemModel {
|
|
400
|
-
constructor(locale) {
|
|
401
|
-
this.id = EvaluationItemModel.createChoiceId();
|
|
402
|
-
this.text = defaultText(locale);
|
|
403
|
-
}
|
|
404
|
-
static createChoiceId() {
|
|
405
|
-
return `Evaluation-Item-${_.now()}-${_.random(0, 9999999)}`;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
class StarEvaluationItemModel extends EvaluationItemModel {
|
|
409
|
-
constructor(locale) {
|
|
410
|
-
super(locale);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
class QuestionOptionsModel {
|
|
414
|
-
constructor(required) {
|
|
415
|
-
this.inputMinLength = 10;
|
|
416
|
-
this.required = required;
|
|
417
|
-
this.visible = true;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
class QuestionHeaderModel {
|
|
421
|
-
constructor(locale) {
|
|
422
|
-
this.text = defaultText(locale);
|
|
423
|
-
this.number = null;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
class SubQuestionModel {
|
|
427
|
-
constructor(locale) {
|
|
428
|
-
this.id = `SubQ-${_.now()}-${_.random(0, 9999999)}`;
|
|
429
|
-
this.text = defaultText(locale);
|
|
430
|
-
this.number = null;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
class BaseQuestionModel {
|
|
434
|
-
constructor(type, locale) {
|
|
435
|
-
this.id = BaseQuestionModel.createQuestionId();
|
|
436
|
-
this.type = type;
|
|
437
|
-
this.header = new QuestionHeaderModel(locale);
|
|
438
|
-
this.options = new QuestionOptionsModel(false);
|
|
439
|
-
}
|
|
440
|
-
static getMaxScore(question) {
|
|
441
|
-
if (question.type == "SINGLE_SELECTION") {
|
|
442
|
-
return _.max(_.map(question.choices, choice => parseFloat(_.get(choice, "options.score", 0) || 0))) || 0;
|
|
443
|
-
} else if (question.type == "MULTI_SELECTION") {
|
|
444
|
-
return _.sumBy(question.choices, item => parseFloat(_.get(item, "options.score") || 0));
|
|
445
|
-
} else if (question.type == "MATRIX") {
|
|
446
|
-
const score = _.max(_.map(question.choices, choice => parseFloat(_.get(choice, "options.score", 0) || 0))) || 0;
|
|
447
|
-
return score * question.subQuestions.length;
|
|
448
|
-
} else if (question.type == "SCORING") {
|
|
449
|
-
const score = question.options.maxRange;
|
|
450
|
-
return score * (_.isEmpty(question.subQuestions) ? 1 : question.subQuestions.length);
|
|
451
|
-
}
|
|
452
|
-
return 0;
|
|
453
|
-
}
|
|
454
|
-
static getScoreRange(question) {
|
|
455
|
-
if (question.type == "SCORING") {
|
|
456
|
-
const minRange = question.options.minRange;
|
|
457
|
-
const maxRange = question.options.maxRange;
|
|
458
|
-
return minRange + " - " + maxRange;
|
|
459
|
-
}
|
|
460
|
-
return "";
|
|
461
|
-
}
|
|
462
|
-
static createQuestionId() {
|
|
463
|
-
return `Q-${_.now()}-${_.random(0, 9999999)}`;
|
|
464
|
-
}
|
|
465
|
-
static getNumber(preNumber, question) {
|
|
466
|
-
return preNumber + 1;
|
|
467
|
-
}
|
|
468
|
-
static refreshSurvey(survey) {
|
|
469
|
-
this.rebuildQuestionNumber(survey.questions);
|
|
470
|
-
this.deleteUnusedProperties(survey.questions);
|
|
471
|
-
survey.statistics.maxScore = this.calculationAllQuestionMaxScore(survey.questions);
|
|
472
|
-
survey.statistics.questionCount = this.calculationAllQuestionCount(survey.questions);
|
|
473
|
-
}
|
|
474
|
-
static calculationAllQuestionCount(questions) {
|
|
475
|
-
let count = 0;
|
|
476
|
-
const exclude = ["TEXT_TITLE"];
|
|
477
|
-
_.forEach(questions, question => {
|
|
478
|
-
if (!_.includes(exclude, question.type)) {
|
|
479
|
-
count++;
|
|
480
|
-
}
|
|
481
|
-
});
|
|
482
|
-
return count;
|
|
483
|
-
}
|
|
484
|
-
static calculationAllQuestionMaxScore(questions) {
|
|
485
|
-
let maxScore = 0;
|
|
486
|
-
_.forEach(questions, question => {
|
|
487
|
-
maxScore += this.getMaxScore(question);
|
|
488
|
-
});
|
|
489
|
-
return maxScore;
|
|
490
|
-
}
|
|
491
|
-
static setActiveQuestion(currentQuestion, questions) {
|
|
492
|
-
_.forEach(questions, question => {
|
|
493
|
-
if (question.id == currentQuestion.id) {
|
|
494
|
-
question.active = true;
|
|
495
|
-
} else {
|
|
496
|
-
question.active = false;
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
static rebuildQuestionNumber(questions) {
|
|
501
|
-
let preNumber = 0;
|
|
502
|
-
_.forEach(questions, function (question) {
|
|
503
|
-
let number;
|
|
504
|
-
if (question.type === "TEXT_TITLE") {
|
|
505
|
-
number = QuestionTextTitleModel.getNumber(preNumber, question);
|
|
506
|
-
} else if (question.type === "MATRIX") {
|
|
507
|
-
number = QuestionMatrixModel.getNumber(preNumber, question);
|
|
508
|
-
} else if (question.type === "SCORING") {
|
|
509
|
-
number = QuestionScoringModel.getNumber(preNumber, question);
|
|
510
|
-
} else {
|
|
511
|
-
number = BaseQuestionModel.getNumber(preNumber, question);
|
|
512
|
-
}
|
|
513
|
-
question.header.number = number;
|
|
514
|
-
if (number) {
|
|
515
|
-
preNumber = number;
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
static deleteUnusedProperties(questions) {
|
|
520
|
-
_.forEach(questions, function (question) {
|
|
521
|
-
if (question.type === "SCORING") {
|
|
522
|
-
QuestionScoringModel.removeUnusedProperty(question);
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
class QuestionCheckBoxModel extends BaseQuestionModel {
|
|
528
|
-
constructor(type, locale) {
|
|
529
|
-
super(type, locale);
|
|
530
|
-
this.choices = QuestionFactory.createSelectionQuestionChoices(locale);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
class QuestionEvaluationModel extends BaseQuestionModel {
|
|
534
|
-
constructor(type, locale) {
|
|
535
|
-
super(type, locale);
|
|
536
|
-
this.evaluationItems = QuestionFactory.createEvaluationItems(locale);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
class QuestionTextTitleModel extends BaseQuestionModel {
|
|
540
|
-
constructor(type, locale) {
|
|
541
|
-
super(type, locale);
|
|
542
|
-
}
|
|
543
|
-
static getNumber(preNumber, question) {
|
|
544
|
-
return null;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
class QuestionMatrixModel extends BaseQuestionModel {
|
|
548
|
-
constructor(type, locale) {
|
|
549
|
-
super(type, locale);
|
|
550
|
-
this.choices = QuestionFactory.createMatrixQuestionChoices(locale);
|
|
551
|
-
this.subQuestions = [QuestionFactory.createSubQuestion(locale)];
|
|
552
|
-
}
|
|
553
|
-
static getNumber(preNumber, question) {
|
|
554
|
-
const number = preNumber + 1;
|
|
555
|
-
_.forEach(question.subQuestions, (sq, index) => {
|
|
556
|
-
sq.number = index + 1;
|
|
557
|
-
});
|
|
558
|
-
return number;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
class QuestionScoringModel extends BaseQuestionModel {
|
|
562
|
-
constructor(type, locale) {
|
|
563
|
-
super(type, locale);
|
|
564
|
-
this.subQuestions = [];
|
|
565
|
-
}
|
|
566
|
-
static getNumber(preNumber, question) {
|
|
567
|
-
const number = preNumber + 1;
|
|
568
|
-
_.forEach(question.subQuestions, (sq, index) => {
|
|
569
|
-
sq.number = index + 1;
|
|
570
|
-
});
|
|
571
|
-
return number;
|
|
572
|
-
}
|
|
573
|
-
static removeUnusedProperty(question) {
|
|
574
|
-
const options = question.options;
|
|
575
|
-
delete options.sliderValue;
|
|
576
|
-
_.forEach(question.subQuestions, subQuestion => {
|
|
577
|
-
delete subQuestion.sliderValue;
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
const ZH_CN = _.camelCase("zh-CN");
|
|
582
|
-
const EN_US = _.camelCase("en-US");
|
|
583
|
-
const ZH_TW = _.camelCase("zh-TW");
|
|
584
|
-
function getValue(obj, locale) {
|
|
585
|
-
const value = _.get(obj, _.camelCase(locale), "");
|
|
586
|
-
if (!_.isEmpty(value)) {
|
|
587
|
-
return value;
|
|
588
|
-
}
|
|
589
|
-
return _.get(obj, locale, "");
|
|
590
|
-
}
|
|
591
|
-
function translate(obj, locale, prettyMath = false) {
|
|
592
|
-
const value = getValue(obj, locale);
|
|
593
|
-
if (!_.isEmpty(value) || !prettyMath) {
|
|
594
|
-
return value;
|
|
595
|
-
}
|
|
596
|
-
return obj[ZH_CN] || obj["zh-CN"] || obj[EN_US] || obj["en-US"] || obj[ZH_TW] || obj["zh-TW"];
|
|
306
|
+
class QuestionFactory {
|
|
307
|
+
constructor(locale) {
|
|
308
|
+
this.creatorHash = {};
|
|
309
|
+
this.locale = locale;
|
|
310
|
+
this.registerQuestion("FILL_BLANK", (locale) => {
|
|
311
|
+
return new BaseQuestionModel("FILL_BLANK", locale);
|
|
312
|
+
});
|
|
313
|
+
this.registerQuestion("SHORT_ANSWER", (locale) => {
|
|
314
|
+
return new BaseQuestionModel("SHORT_ANSWER", locale);
|
|
315
|
+
});
|
|
316
|
+
this.registerQuestion("MATRIX", (locale) => {
|
|
317
|
+
return new QuestionMatrixModel("MATRIX", locale);
|
|
318
|
+
});
|
|
319
|
+
this.registerQuestion("SCORING", (locale) => {
|
|
320
|
+
return new QuestionScoringModel("SCORING", locale);
|
|
321
|
+
});
|
|
322
|
+
this.registerQuestion("TEXT_TITLE", (locale) => {
|
|
323
|
+
return new QuestionTextTitleModel("TEXT_TITLE", locale);
|
|
324
|
+
});
|
|
325
|
+
this.registerQuestion("SINGLE_SELECTION", (locale) => {
|
|
326
|
+
return new QuestionCheckBoxModel("SINGLE_SELECTION", locale);
|
|
327
|
+
});
|
|
328
|
+
this.registerQuestion("MULTI_SELECTION", (locale) => {
|
|
329
|
+
return new QuestionCheckBoxModel("MULTI_SELECTION", locale);
|
|
330
|
+
});
|
|
331
|
+
this.registerQuestion("EVALUATION", (locale) => {
|
|
332
|
+
return new QuestionEvaluationModel("EVALUATION", locale);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
static getInstance(locale) {
|
|
336
|
+
if (!QuestionFactory.instance) {
|
|
337
|
+
QuestionFactory.instance = new QuestionFactory(locale);
|
|
338
|
+
}
|
|
339
|
+
return QuestionFactory.instance;
|
|
340
|
+
}
|
|
341
|
+
static createDefault(locale) {
|
|
342
|
+
return new ChoiceModel(locale);
|
|
343
|
+
}
|
|
344
|
+
static createSubQuestion(locale) {
|
|
345
|
+
return new SubQuestionModel(locale);
|
|
346
|
+
}
|
|
347
|
+
static createEvaluationItem(locale) {
|
|
348
|
+
return new StarEvaluationItemModel(locale);
|
|
349
|
+
}
|
|
350
|
+
static createSelectionQuestionChoices(locale) {
|
|
351
|
+
return _.range(4).map(() => this.createDefault(locale));
|
|
352
|
+
}
|
|
353
|
+
static createMatrixQuestionChoices(locale) {
|
|
354
|
+
return _.range(5).map(() => this.createDefault(locale));
|
|
355
|
+
}
|
|
356
|
+
static createEvaluationItems(locale) {
|
|
357
|
+
return _.range(5).map(() => this.createEvaluationItem(locale));
|
|
358
|
+
}
|
|
359
|
+
registerQuestion(questionType, questionCreator) {
|
|
360
|
+
this.creatorHash[questionType] = questionCreator;
|
|
361
|
+
}
|
|
362
|
+
createQuestion(questionType) {
|
|
363
|
+
const creator = this.creatorHash[questionType];
|
|
364
|
+
return creator(this.locale);
|
|
365
|
+
}
|
|
366
|
+
static createExclusiveChoice(locale) {
|
|
367
|
+
return new ExclusiveChoiceModel(locale);
|
|
368
|
+
}
|
|
597
369
|
}
|
|
598
|
-
|
|
599
|
-
function
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
370
|
+
|
|
371
|
+
const defaultText = function getText(locale) {
|
|
372
|
+
return _.set({}, locale, "");
|
|
373
|
+
};
|
|
374
|
+
class ChoiceOptionModel {
|
|
375
|
+
constructor() {
|
|
376
|
+
this.score = null;
|
|
377
|
+
this.star = false;
|
|
378
|
+
this.starCount = null;
|
|
379
|
+
this.exclusiveEnabled = false;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
class ChoiceModel {
|
|
383
|
+
constructor(locale) {
|
|
384
|
+
this.id = ChoiceModel.createChoiceId();
|
|
385
|
+
this.text = defaultText(locale);
|
|
386
|
+
this.options = new ChoiceOptionModel();
|
|
387
|
+
}
|
|
388
|
+
static createChoiceId() {
|
|
389
|
+
return `Choice-${_.now()}-${_.random(0, 9999999)}`;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
class ExclusiveChoiceModel extends ChoiceModel {
|
|
393
|
+
constructor(locale) {
|
|
394
|
+
super(locale);
|
|
395
|
+
if (!_.isEmpty(this.options)) {
|
|
396
|
+
_.set(this.options, "exclusiveEnabled", true);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
class EvaluationItemModel {
|
|
401
|
+
constructor(locale) {
|
|
402
|
+
this.id = EvaluationItemModel.createChoiceId();
|
|
403
|
+
this.text = defaultText(locale);
|
|
404
|
+
}
|
|
405
|
+
static createChoiceId() {
|
|
406
|
+
return `Evaluation-Item-${_.now()}-${_.random(0, 9999999)}`;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
class StarEvaluationItemModel extends EvaluationItemModel {
|
|
410
|
+
constructor(locale) {
|
|
411
|
+
super(locale);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
class QuestionOptionsModel {
|
|
415
|
+
constructor(required) {
|
|
416
|
+
this.inputMinLength = 10;
|
|
417
|
+
this.required = required;
|
|
418
|
+
this.visible = true;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
class QuestionHeaderModel {
|
|
422
|
+
constructor(locale) {
|
|
423
|
+
this.text = defaultText(locale);
|
|
424
|
+
this.number = null;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
class SubQuestionModel {
|
|
428
|
+
constructor(locale) {
|
|
429
|
+
this.id = `SubQ-${_.now()}-${_.random(0, 9999999)}`;
|
|
430
|
+
this.text = defaultText(locale);
|
|
431
|
+
this.number = null;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
class BaseQuestionModel {
|
|
435
|
+
constructor(type, locale) {
|
|
436
|
+
this.id = BaseQuestionModel.createQuestionId();
|
|
437
|
+
this.type = type;
|
|
438
|
+
this.header = new QuestionHeaderModel(locale);
|
|
439
|
+
this.options = new QuestionOptionsModel(false);
|
|
440
|
+
}
|
|
441
|
+
static getMaxScore(question) {
|
|
442
|
+
if (question.type == "SINGLE_SELECTION") {
|
|
443
|
+
return (_.max(_.map(question.choices, (choice) => parseFloat(_.get(choice, "options.score", 0) || 0))) || 0);
|
|
444
|
+
}
|
|
445
|
+
else if (question.type == "MULTI_SELECTION") {
|
|
446
|
+
return _.sumBy(question.choices, (item) => parseFloat(_.get(item, "options.score") || 0));
|
|
447
|
+
}
|
|
448
|
+
else if (question.type == "MATRIX") {
|
|
449
|
+
const score = _.max(_.map(question.choices, (choice) => parseFloat(_.get(choice, "options.score", 0) || 0))) || 0;
|
|
450
|
+
return score * question.subQuestions.length;
|
|
451
|
+
}
|
|
452
|
+
else if (question.type == "SCORING") {
|
|
453
|
+
const score = question.options.maxRange;
|
|
454
|
+
return (score *
|
|
455
|
+
(_.isEmpty(question.subQuestions) ? 1 : question.subQuestions.length));
|
|
456
|
+
}
|
|
457
|
+
return 0;
|
|
458
|
+
}
|
|
459
|
+
static getScoreRange(question) {
|
|
460
|
+
if (question.type == "SCORING") {
|
|
461
|
+
const minRange = question.options.minRange;
|
|
462
|
+
const maxRange = question.options.maxRange;
|
|
463
|
+
return minRange + " - " + maxRange;
|
|
464
|
+
}
|
|
465
|
+
return "";
|
|
466
|
+
}
|
|
467
|
+
static createQuestionId() {
|
|
468
|
+
return `Q-${_.now()}-${_.random(0, 9999999)}`;
|
|
469
|
+
}
|
|
470
|
+
static getNumber(preNumber, question) {
|
|
471
|
+
return preNumber + 1;
|
|
472
|
+
}
|
|
473
|
+
static refreshSurvey(survey) {
|
|
474
|
+
this.rebuildQuestionNumber(survey.questions);
|
|
475
|
+
this.deleteUnusedProperties(survey.questions);
|
|
476
|
+
survey.statistics.maxScore = this.calculationAllQuestionMaxScore(survey.questions);
|
|
477
|
+
survey.statistics.questionCount = this.calculationAllQuestionCount(survey.questions);
|
|
478
|
+
}
|
|
479
|
+
static calculationAllQuestionCount(questions) {
|
|
480
|
+
let count = 0;
|
|
481
|
+
const exclude = ["TEXT_TITLE"];
|
|
482
|
+
_.forEach(questions, (question) => {
|
|
483
|
+
if (!_.includes(exclude, question.type)) {
|
|
484
|
+
count++;
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
return count;
|
|
488
|
+
}
|
|
489
|
+
static calculationAllQuestionMaxScore(questions) {
|
|
490
|
+
let maxScore = 0;
|
|
491
|
+
_.forEach(questions, (question) => {
|
|
492
|
+
maxScore += this.getMaxScore(question);
|
|
493
|
+
});
|
|
494
|
+
return maxScore;
|
|
495
|
+
}
|
|
496
|
+
static setActiveQuestion(currentQuestion, questions) {
|
|
497
|
+
_.forEach(questions, (question) => {
|
|
498
|
+
if (question.id == currentQuestion.id) {
|
|
499
|
+
question.active = true;
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
question.active = false;
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
static rebuildQuestionNumber(questions) {
|
|
507
|
+
let preNumber = 0;
|
|
508
|
+
_.forEach(questions, function (question) {
|
|
509
|
+
let number;
|
|
510
|
+
if (question.type === "TEXT_TITLE") {
|
|
511
|
+
number = QuestionTextTitleModel.getNumber(preNumber, question);
|
|
512
|
+
}
|
|
513
|
+
else if (question.type === "MATRIX") {
|
|
514
|
+
number = QuestionMatrixModel.getNumber(preNumber, question);
|
|
515
|
+
}
|
|
516
|
+
else if (question.type === "SCORING") {
|
|
517
|
+
number = QuestionScoringModel.getNumber(preNumber, question);
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
number = BaseQuestionModel.getNumber(preNumber, question);
|
|
521
|
+
}
|
|
522
|
+
question.header.number = number;
|
|
523
|
+
if (number) {
|
|
524
|
+
preNumber = number;
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
static deleteUnusedProperties(questions) {
|
|
529
|
+
_.forEach(questions, function (question) {
|
|
530
|
+
if (question.type === "SCORING") {
|
|
531
|
+
QuestionScoringModel.removeUnusedProperty(question);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
class QuestionCheckBoxModel extends BaseQuestionModel {
|
|
537
|
+
constructor(type, locale) {
|
|
538
|
+
super(type, locale);
|
|
539
|
+
this.choices = QuestionFactory.createSelectionQuestionChoices(locale);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
class QuestionEvaluationModel extends BaseQuestionModel {
|
|
543
|
+
constructor(type, locale) {
|
|
544
|
+
super(type, locale);
|
|
545
|
+
this.evaluationItems = QuestionFactory.createEvaluationItems(locale);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
class QuestionTextTitleModel extends BaseQuestionModel {
|
|
549
|
+
constructor(type, locale) {
|
|
550
|
+
super(type, locale);
|
|
551
|
+
}
|
|
552
|
+
static getNumber(preNumber, question) {
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
class QuestionMatrixModel extends BaseQuestionModel {
|
|
557
|
+
constructor(type, locale) {
|
|
558
|
+
super(type, locale);
|
|
559
|
+
this.choices = QuestionFactory.createMatrixQuestionChoices(locale);
|
|
560
|
+
this.subQuestions = [QuestionFactory.createSubQuestion(locale)];
|
|
561
|
+
}
|
|
562
|
+
static getNumber(preNumber, question) {
|
|
563
|
+
const number = preNumber + 1;
|
|
564
|
+
_.forEach(question.subQuestions, (sq, index) => {
|
|
565
|
+
sq.number = index + 1;
|
|
566
|
+
});
|
|
567
|
+
return number;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
class QuestionScoringModel extends BaseQuestionModel {
|
|
571
|
+
constructor(type, locale) {
|
|
572
|
+
super(type, locale);
|
|
573
|
+
this.subQuestions = [];
|
|
574
|
+
}
|
|
575
|
+
static getNumber(preNumber, question) {
|
|
576
|
+
const number = preNumber + 1;
|
|
577
|
+
_.forEach(question.subQuestions, (sq, index) => {
|
|
578
|
+
sq.number = index + 1;
|
|
579
|
+
});
|
|
580
|
+
return number;
|
|
581
|
+
}
|
|
582
|
+
static removeUnusedProperty(question) {
|
|
583
|
+
const options = question.options;
|
|
584
|
+
delete options.sliderValue;
|
|
585
|
+
_.forEach(question.subQuestions, (subQuestion) => {
|
|
586
|
+
delete subQuestion.sliderValue;
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
const ZH_CN = _.camelCase("zh-CN");
|
|
592
|
+
const EN_US = _.camelCase("en-US");
|
|
593
|
+
const ZH_TW = _.camelCase("zh-TW");
|
|
594
|
+
function getValue(obj, locale) {
|
|
595
|
+
const value = _.get(obj, _.camelCase(locale), "");
|
|
596
|
+
if (!_.isEmpty(value)) {
|
|
597
|
+
return value;
|
|
598
|
+
}
|
|
599
|
+
return _.get(obj, locale, "");
|
|
600
|
+
}
|
|
601
|
+
function translate(obj, locale, prettyMath = false) {
|
|
602
|
+
const value = getValue(obj, locale);
|
|
603
|
+
if (!_.isEmpty(value) || !prettyMath) {
|
|
604
|
+
return value;
|
|
605
|
+
}
|
|
606
|
+
return (obj[ZH_CN] ||
|
|
607
|
+
obj["zh-CN"] ||
|
|
608
|
+
obj[EN_US] ||
|
|
609
|
+
obj["en-US"] ||
|
|
610
|
+
obj[ZH_TW] ||
|
|
611
|
+
obj["zh-TW"]);
|
|
612
612
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
613
|
+
|
|
614
|
+
const CUSTOM_INPUT_REG = /(_{5,})/g;
|
|
615
|
+
function formatTitle(question, locale) {
|
|
616
|
+
const title = translate(question.header.text, locale, true);
|
|
617
|
+
if (!_.get(question, "options.richTextEnabled", false)) {
|
|
618
|
+
return [title];
|
|
619
|
+
}
|
|
620
|
+
const trimmedTitles = title.split(CUSTOM_INPUT_REG);
|
|
621
|
+
if (trimmedTitles[0] === "") {
|
|
622
|
+
trimmedTitles.splice(0, 1);
|
|
623
|
+
}
|
|
624
|
+
if (trimmedTitles[trimmedTitles.length - 1] === "") {
|
|
625
|
+
trimmedTitles.splice(trimmedTitles.length - 1, 1);
|
|
626
|
+
}
|
|
627
|
+
return trimmedTitles;
|
|
618
628
|
}
|
|
619
629
|
|
|
620
630
|
var LocaleMixin = Vue.extend({
|
|
@@ -718,7 +728,7 @@ const questionTypes = [
|
|
|
718
728
|
"TEXT_TITLE",
|
|
719
729
|
"EVALUATION",
|
|
720
730
|
];
|
|
721
|
-
var script$
|
|
731
|
+
var script$N = Vue.extend({
|
|
722
732
|
name: "create-question-dropdown",
|
|
723
733
|
mixins: [LocaleMixin],
|
|
724
734
|
inject: ["$rootComponent"],
|
|
@@ -822,20 +832,20 @@ function normalizeComponent(template, style, script, scopeId, isFunctionalTempla
|
|
|
822
832
|
}
|
|
823
833
|
|
|
824
834
|
/* script */
|
|
825
|
-
const __vue_script__$
|
|
835
|
+
const __vue_script__$N = script$N;
|
|
826
836
|
|
|
827
837
|
/* template */
|
|
828
838
|
var __vue_render__$M = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Dropdown',{attrs:{"transfer":true}},[_c('Button',{attrs:{"icon":"md-add","type":"primary"}},[_vm._v(_vm._s(_vm.t("survey_creator.question.create")))]),_vm._v(" "),_c('DropdownMenu',{attrs:{"slot":"list"},slot:"list"},_vm._l((_vm.questionTypes),function(questionType){return _c('DropdownItem',{key:questionType,staticClass:"dropdown_item",nativeOn:{"click":function($event){return _vm.onCreate(questionType)}}},[_vm._v(_vm._s(_vm.t(("survey_creator.question.types." + questionType))))])}),1)],1)};
|
|
829
839
|
var __vue_staticRenderFns__$M = [];
|
|
830
840
|
|
|
831
841
|
/* style */
|
|
832
|
-
const __vue_inject_styles__$
|
|
842
|
+
const __vue_inject_styles__$N = undefined;
|
|
833
843
|
/* scoped */
|
|
834
|
-
const __vue_scope_id__$
|
|
844
|
+
const __vue_scope_id__$N = undefined;
|
|
835
845
|
/* module identifier */
|
|
836
|
-
const __vue_module_identifier__$
|
|
846
|
+
const __vue_module_identifier__$N = undefined;
|
|
837
847
|
/* functional template */
|
|
838
|
-
const __vue_is_functional_template__$
|
|
848
|
+
const __vue_is_functional_template__$N = false;
|
|
839
849
|
/* style inject */
|
|
840
850
|
|
|
841
851
|
/* style inject SSR */
|
|
@@ -844,22 +854,22 @@ var __vue_staticRenderFns__$M = [];
|
|
|
844
854
|
|
|
845
855
|
|
|
846
856
|
|
|
847
|
-
const __vue_component__$
|
|
857
|
+
const __vue_component__$N = /*#__PURE__*/normalizeComponent(
|
|
848
858
|
{ render: __vue_render__$M, staticRenderFns: __vue_staticRenderFns__$M },
|
|
849
|
-
__vue_inject_styles__$
|
|
850
|
-
__vue_script__$
|
|
851
|
-
__vue_scope_id__$
|
|
852
|
-
__vue_is_functional_template__$
|
|
853
|
-
__vue_module_identifier__$
|
|
859
|
+
__vue_inject_styles__$N,
|
|
860
|
+
__vue_script__$N,
|
|
861
|
+
__vue_scope_id__$N,
|
|
862
|
+
__vue_is_functional_template__$N,
|
|
863
|
+
__vue_module_identifier__$N,
|
|
854
864
|
false,
|
|
855
865
|
undefined,
|
|
856
866
|
undefined,
|
|
857
867
|
undefined
|
|
858
868
|
);
|
|
859
869
|
|
|
860
|
-
var CreateQuestionDropdown = __vue_component__$
|
|
870
|
+
var CreateQuestionDropdown = __vue_component__$N;
|
|
861
871
|
|
|
862
|
-
var script$
|
|
872
|
+
var script$M = Vue.extend({
|
|
863
873
|
name: "change-language",
|
|
864
874
|
mixins: [LocaleMixin],
|
|
865
875
|
inject: ["$rootComponent"],
|
|
@@ -884,20 +894,20 @@ var script$L = Vue.extend({
|
|
|
884
894
|
});
|
|
885
895
|
|
|
886
896
|
/* script */
|
|
887
|
-
const __vue_script__$
|
|
897
|
+
const __vue_script__$M = script$M;
|
|
888
898
|
|
|
889
899
|
/* template */
|
|
890
900
|
var __vue_render__$L = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Dropdown',[_c('Button',{attrs:{"type":"primary"}},[_vm._v("\n "+_vm._s(_vm.t(("survey_creator.common.languages." + (this.language))))+"\n "),_c('Icon',{attrs:{"type":"ios-arrow-down"}})],1),_vm._v(" "),_c('DropdownMenu',{attrs:{"slot":"list"},slot:"list"},_vm._l((_vm.languages),function(language){return _c('DropdownItem',{key:language,attrs:{"transfer":true},nativeOn:{"click":function($event){return _vm.onChangeLanguage(language)}}},[_vm._v(_vm._s(_vm.t(("survey_creator.common.languages." + language))))])}),1)],1)};
|
|
891
901
|
var __vue_staticRenderFns__$L = [];
|
|
892
902
|
|
|
893
903
|
/* style */
|
|
894
|
-
const __vue_inject_styles__$
|
|
904
|
+
const __vue_inject_styles__$M = undefined;
|
|
895
905
|
/* scoped */
|
|
896
|
-
const __vue_scope_id__$
|
|
906
|
+
const __vue_scope_id__$M = undefined;
|
|
897
907
|
/* module identifier */
|
|
898
|
-
const __vue_module_identifier__$
|
|
908
|
+
const __vue_module_identifier__$M = undefined;
|
|
899
909
|
/* functional template */
|
|
900
|
-
const __vue_is_functional_template__$
|
|
910
|
+
const __vue_is_functional_template__$M = false;
|
|
901
911
|
/* style inject */
|
|
902
912
|
|
|
903
913
|
/* style inject SSR */
|
|
@@ -906,22 +916,22 @@ var __vue_staticRenderFns__$L = [];
|
|
|
906
916
|
|
|
907
917
|
|
|
908
918
|
|
|
909
|
-
const __vue_component__$
|
|
919
|
+
const __vue_component__$M = /*#__PURE__*/normalizeComponent(
|
|
910
920
|
{ render: __vue_render__$L, staticRenderFns: __vue_staticRenderFns__$L },
|
|
911
|
-
__vue_inject_styles__$
|
|
912
|
-
__vue_script__$
|
|
913
|
-
__vue_scope_id__$
|
|
914
|
-
__vue_is_functional_template__$
|
|
915
|
-
__vue_module_identifier__$
|
|
921
|
+
__vue_inject_styles__$M,
|
|
922
|
+
__vue_script__$M,
|
|
923
|
+
__vue_scope_id__$M,
|
|
924
|
+
__vue_is_functional_template__$M,
|
|
925
|
+
__vue_module_identifier__$M,
|
|
916
926
|
false,
|
|
917
927
|
undefined,
|
|
918
928
|
undefined,
|
|
919
929
|
undefined
|
|
920
930
|
);
|
|
921
931
|
|
|
922
|
-
var ChangeLanguage = __vue_component__$
|
|
932
|
+
var ChangeLanguage = __vue_component__$M;
|
|
923
933
|
|
|
924
|
-
var script$
|
|
934
|
+
var script$L = Vue.extend({
|
|
925
935
|
name: "toolbar",
|
|
926
936
|
mixins: [LocaleMixin],
|
|
927
937
|
inject: ["$rootComponent"],
|
|
@@ -955,20 +965,20 @@ var script$K = Vue.extend({
|
|
|
955
965
|
});
|
|
956
966
|
|
|
957
967
|
/* script */
|
|
958
|
-
const __vue_script__$
|
|
968
|
+
const __vue_script__$L = script$L;
|
|
959
969
|
|
|
960
970
|
/* template */
|
|
961
971
|
var __vue_render__$K = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Row',{staticClass:"toolbar-wrapper",attrs:{"type":"flex","justify":"end","align":"middle","gutter":20}},[(_vm.preview)?_c('Col',[_c('Button',{attrs:{"icon":"ios-search","type":"primary"},on:{"click":this.$rootComponent.onPreview}},[_vm._v(_vm._s(_vm.t("survey_creator.common.settings.preview"))+"\n ")])],1):_vm._e(),_vm._v(" "),(_vm.changeLanguage)?_c('Col',[_c('change-language',{attrs:{"languages":_vm.survey.options.languages}})],1):_vm._e()],1)};
|
|
962
972
|
var __vue_staticRenderFns__$K = [];
|
|
963
973
|
|
|
964
974
|
/* style */
|
|
965
|
-
const __vue_inject_styles__$
|
|
975
|
+
const __vue_inject_styles__$L = undefined;
|
|
966
976
|
/* scoped */
|
|
967
|
-
const __vue_scope_id__$
|
|
977
|
+
const __vue_scope_id__$L = undefined;
|
|
968
978
|
/* module identifier */
|
|
969
|
-
const __vue_module_identifier__$
|
|
979
|
+
const __vue_module_identifier__$L = undefined;
|
|
970
980
|
/* functional template */
|
|
971
|
-
const __vue_is_functional_template__$
|
|
981
|
+
const __vue_is_functional_template__$L = false;
|
|
972
982
|
/* style inject */
|
|
973
983
|
|
|
974
984
|
/* style inject SSR */
|
|
@@ -977,68 +987,59 @@ var __vue_staticRenderFns__$K = [];
|
|
|
977
987
|
|
|
978
988
|
|
|
979
989
|
|
|
980
|
-
const __vue_component__$
|
|
990
|
+
const __vue_component__$L = /*#__PURE__*/normalizeComponent(
|
|
981
991
|
{ render: __vue_render__$K, staticRenderFns: __vue_staticRenderFns__$K },
|
|
982
|
-
__vue_inject_styles__$
|
|
983
|
-
__vue_script__$
|
|
984
|
-
__vue_scope_id__$
|
|
985
|
-
__vue_is_functional_template__$
|
|
986
|
-
__vue_module_identifier__$
|
|
992
|
+
__vue_inject_styles__$L,
|
|
993
|
+
__vue_script__$L,
|
|
994
|
+
__vue_scope_id__$L,
|
|
995
|
+
__vue_is_functional_template__$L,
|
|
996
|
+
__vue_module_identifier__$L,
|
|
987
997
|
false,
|
|
988
998
|
undefined,
|
|
989
999
|
undefined,
|
|
990
1000
|
undefined
|
|
991
1001
|
);
|
|
992
1002
|
|
|
993
|
-
var Toolbar = __vue_component__$
|
|
1003
|
+
var Toolbar = __vue_component__$L;
|
|
994
1004
|
|
|
995
|
-
var script$
|
|
996
|
-
|
|
997
|
-
components: { Icon, Input },
|
|
998
|
-
mixins: [LocaleMixin],
|
|
999
|
-
inject: ["$rootComponent"],
|
|
1005
|
+
var script$K = Vue.component("question-title-dynamic", {
|
|
1006
|
+
components: { Input },
|
|
1000
1007
|
props: {
|
|
1001
|
-
|
|
1002
|
-
type:
|
|
1008
|
+
splitedTitles: {
|
|
1009
|
+
type: Array,
|
|
1003
1010
|
required: true,
|
|
1004
1011
|
},
|
|
1005
|
-
|
|
1006
|
-
type:
|
|
1012
|
+
customFilledTitle: {
|
|
1013
|
+
type: Array,
|
|
1007
1014
|
required: false,
|
|
1008
1015
|
},
|
|
1009
1016
|
},
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
return showInput(index, formatTitle);
|
|
1037
|
-
},
|
|
1038
|
-
getTitle(question) {
|
|
1039
|
-
return formatTitle(question, Vue.$surveyLanguage);
|
|
1040
|
-
},
|
|
1041
|
-
},
|
|
1017
|
+
render(createElement) {
|
|
1018
|
+
let childArr = [];
|
|
1019
|
+
const self = this;
|
|
1020
|
+
console.log(typeof Input);
|
|
1021
|
+
_.forEach(this.splitedTitles, (title, index) => {
|
|
1022
|
+
if (CUSTOM_INPUT_REG.test(title)) {
|
|
1023
|
+
let corespondTitle = _.find(self.customFilledTitle, (title) => {
|
|
1024
|
+
return title.index === index;
|
|
1025
|
+
});
|
|
1026
|
+
childArr.push(createElement(Input, {
|
|
1027
|
+
domProps: {
|
|
1028
|
+
value: corespondTitle.title
|
|
1029
|
+
},
|
|
1030
|
+
on: {
|
|
1031
|
+
input: function (value) {
|
|
1032
|
+
corespondTitle.title = value;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}));
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
childArr.push(title);
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1041
|
+
return createElement("div", { class: "content pl-sm" }, childArr);
|
|
1042
|
+
}
|
|
1042
1043
|
});
|
|
1043
1044
|
|
|
1044
1045
|
const isOldIE = typeof navigator !== 'undefined' &&
|
|
@@ -1094,14 +1095,95 @@ function addStyle(id, css) {
|
|
|
1094
1095
|
}
|
|
1095
1096
|
}
|
|
1096
1097
|
|
|
1098
|
+
/* script */
|
|
1099
|
+
const __vue_script__$K = script$K;
|
|
1100
|
+
|
|
1101
|
+
/* template */
|
|
1102
|
+
|
|
1103
|
+
/* style */
|
|
1104
|
+
const __vue_inject_styles__$K = function (inject) {
|
|
1105
|
+
if (!inject) return
|
|
1106
|
+
inject("data-v-452a49b2_0", { source: "[data-v-452a49b2] .ivu-input-wrapper{width:auto}", map: undefined, media: undefined });
|
|
1107
|
+
|
|
1108
|
+
};
|
|
1109
|
+
/* scoped */
|
|
1110
|
+
const __vue_scope_id__$K = "data-v-452a49b2";
|
|
1111
|
+
/* module identifier */
|
|
1112
|
+
const __vue_module_identifier__$K = undefined;
|
|
1113
|
+
/* functional template */
|
|
1114
|
+
const __vue_is_functional_template__$K = undefined;
|
|
1115
|
+
/* style inject SSR */
|
|
1116
|
+
|
|
1117
|
+
/* style inject shadow dom */
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
const __vue_component__$K = /*#__PURE__*/normalizeComponent(
|
|
1122
|
+
{},
|
|
1123
|
+
__vue_inject_styles__$K,
|
|
1124
|
+
__vue_script__$K,
|
|
1125
|
+
__vue_scope_id__$K,
|
|
1126
|
+
__vue_is_functional_template__$K,
|
|
1127
|
+
__vue_module_identifier__$K,
|
|
1128
|
+
false,
|
|
1129
|
+
createInjector,
|
|
1130
|
+
undefined,
|
|
1131
|
+
undefined
|
|
1132
|
+
);
|
|
1133
|
+
|
|
1134
|
+
var QuestionTitleDynamic = __vue_component__$K;
|
|
1135
|
+
|
|
1136
|
+
var script$J = Vue.extend({
|
|
1137
|
+
name: "question-title",
|
|
1138
|
+
components: { Icon, Input, QuestionTitleDynamic },
|
|
1139
|
+
mixins: [LocaleMixin],
|
|
1140
|
+
inject: ["$rootComponent"],
|
|
1141
|
+
props: {
|
|
1142
|
+
question: {
|
|
1143
|
+
type: Object,
|
|
1144
|
+
required: true,
|
|
1145
|
+
},
|
|
1146
|
+
customQuestion: {
|
|
1147
|
+
type: Object,
|
|
1148
|
+
required: false,
|
|
1149
|
+
},
|
|
1150
|
+
},
|
|
1151
|
+
computed: {
|
|
1152
|
+
customFilledTitle() {
|
|
1153
|
+
return this.customQuestion?.filledTitle;
|
|
1154
|
+
},
|
|
1155
|
+
maxScore() {
|
|
1156
|
+
return BaseQuestionModel.getMaxScore(this.question);
|
|
1157
|
+
},
|
|
1158
|
+
haveScoreRange() {
|
|
1159
|
+
return this.question.type == "SCORING";
|
|
1160
|
+
},
|
|
1161
|
+
scoreRange() {
|
|
1162
|
+
return BaseQuestionModel.getScoreRange(this.question);
|
|
1163
|
+
},
|
|
1164
|
+
haveMaxScore() {
|
|
1165
|
+
return (_.get(this.question, "options.scoringEnabled", false) &&
|
|
1166
|
+
this.question.type != "SCORING");
|
|
1167
|
+
},
|
|
1168
|
+
haveStar() {
|
|
1169
|
+
return _.get(this.question, "options.starEnabled", false);
|
|
1170
|
+
},
|
|
1171
|
+
isSingleSelection() {
|
|
1172
|
+
return this.question.type == "SINGLE_SELECTION";
|
|
1173
|
+
},
|
|
1174
|
+
},
|
|
1175
|
+
methods: {
|
|
1176
|
+
getTitle(question) {
|
|
1177
|
+
return formatTitle(question, Vue.$surveyLanguage);
|
|
1178
|
+
}
|
|
1179
|
+
},
|
|
1180
|
+
});
|
|
1181
|
+
|
|
1097
1182
|
/* script */
|
|
1098
1183
|
const __vue_script__$J = script$J;
|
|
1099
1184
|
|
|
1100
1185
|
/* template */
|
|
1101
|
-
var __vue_render__$J = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"question-title"},[_c('label',{staticClass:"star"},[_vm._v(_vm._s(_vm.question.options.required ? "*" : ""))]),_vm._v(" "),(_vm.question.header.number)?_c('span',{staticClass:"number pl-sm"},[_vm._v(_vm._s(_vm.question.header.number)+".")]):_vm._e(),_vm._v(" "),_vm.
|
|
1102
|
-
_vm.getShowInput(index, _vm.getTitle(_vm.question)) &&
|
|
1103
|
-
index === customTitle.index
|
|
1104
|
-
)?_c('Input',{staticClass:"pl-sm",model:{value:(customTitle.title),callback:function ($$v) {_vm.$set(customTitle, "title", (typeof $$v === 'string'? $$v.trim(): $$v));},expression:"customTitle.title"}}):_vm._e()],1)],1)})],2)}),_vm._v(" "),(_vm.haveMaxScore)?_c('span',{staticClass:"options-explain pl-sm title-score-related"},[_vm._v("("+_vm._s(_vm.t("survey_creator.question.max_score", _vm.$rootComponent.currentLanguage))+_vm._s(_vm.maxScore)+")\n ")]):_vm._e(),_vm._v(" "),(_vm.haveScoreRange)?_c('span',{staticClass:"options-explain pl-sm title-score-related"},[_vm._v("("+_vm._s(_vm.t(
|
|
1186
|
+
var __vue_render__$J = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"question-title"},[_c('label',{staticClass:"star"},[_vm._v(_vm._s(_vm.question.options.required ? "*" : ""))]),_vm._v(" "),(_vm.question.header.number)?_c('span',{staticClass:"number pl-sm"},[_vm._v(_vm._s(_vm.question.header.number)+".")]):_vm._e(),_vm._v(" "),(_vm.question)?_c('question-title-dynamic',{attrs:{"splitedTitles":_vm.getTitle(_vm.question),"customFilledTitle":_vm.customFilledTitle}}):_vm._e(),_vm._v(" "),(_vm.haveMaxScore)?_c('span',{staticClass:"options-explain pl-sm title-score-related"},[_vm._v("("+_vm._s(_vm.t("survey_creator.question.max_score", _vm.$rootComponent.currentLanguage))+_vm._s(_vm.maxScore)+")\n ")]):_vm._e(),_vm._v(" "),(_vm.haveScoreRange)?_c('span',{staticClass:"options-explain pl-sm title-score-related"},[_vm._v("("+_vm._s(_vm.t(
|
|
1105
1187
|
"survey_creator.question.scoring.scoreRange",
|
|
1106
1188
|
_vm.$rootComponent.currentLanguage
|
|
1107
1189
|
))+_vm._s(_vm.scoreRange)+")\n ")]):_vm._e(),_vm._v(" "),(_vm.haveStar)?_c('span',{staticClass:"options-explain pl-sm"},[(_vm.isSingleSelection)?_c('span',[_vm._v("\n ("+_vm._s(_vm.t(
|
|
@@ -1116,17 +1198,17 @@ var __vue_render__$J = function () {var _vm=this;var _h=_vm.$createElement;var _
|
|
|
1116
1198
|
))+"\n "+_vm._s(_vm.question.options.starMinCount)+"\n "+_vm._s(_vm.t(
|
|
1117
1199
|
"survey_creator.question.star_multi_suffix",
|
|
1118
1200
|
_vm.$rootComponent.currentLanguage
|
|
1119
|
-
))+"\n )\n ")],1)]):_vm._e()],
|
|
1201
|
+
))+"\n )\n ")],1)]):_vm._e()],1)};
|
|
1120
1202
|
var __vue_staticRenderFns__$J = [];
|
|
1121
1203
|
|
|
1122
1204
|
/* style */
|
|
1123
1205
|
const __vue_inject_styles__$J = function (inject) {
|
|
1124
1206
|
if (!inject) return
|
|
1125
|
-
inject("data-v-
|
|
1207
|
+
inject("data-v-cb42d2bc_0", { source: ".flex[data-v-cb42d2bc]{display:flex;align-items:center}.pl-sm[data-v-cb42d2bc]{padding-left:4px}.title-score-related[data-v-cb42d2bc]{min-width:90px}", map: undefined, media: undefined });
|
|
1126
1208
|
|
|
1127
1209
|
};
|
|
1128
1210
|
/* scoped */
|
|
1129
|
-
const __vue_scope_id__$J = "data-v-
|
|
1211
|
+
const __vue_scope_id__$J = "data-v-cb42d2bc";
|
|
1130
1212
|
/* module identifier */
|
|
1131
1213
|
const __vue_module_identifier__$J = undefined;
|
|
1132
1214
|
/* functional template */
|
|
@@ -1345,8 +1427,7 @@ var script$G = Vue.extend({
|
|
|
1345
1427
|
customQuestion() {
|
|
1346
1428
|
let input_titles = [];
|
|
1347
1429
|
_.each(formatTitle(this.question, Vue.$surveyLanguage), (t, index) => {
|
|
1348
|
-
if (t
|
|
1349
|
-
showInput(index, formatTitle(this.question, Vue.$surveyLanguage))) {
|
|
1430
|
+
if (CUSTOM_INPUT_REG.test(t)) {
|
|
1350
1431
|
let title = {
|
|
1351
1432
|
title: "",
|
|
1352
1433
|
index: index,
|
|
@@ -1956,113 +2037,96 @@ var __vue_staticRenderFns__$z = [];
|
|
|
1956
2037
|
|
|
1957
2038
|
var Star$1 = __vue_component__$z;
|
|
1958
2039
|
|
|
1959
|
-
class ExprEvaluationQuestion {
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
_.
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
);
|
|
2050
|
-
}
|
|
2051
|
-
|
|
2052
|
-
getFullNumber(question) {
|
|
2053
|
-
if (question.type == "MATRIX") {
|
|
2054
|
-
return (
|
|
2055
|
-
this.questionMap[question.parentId].header.number +
|
|
2056
|
-
"." +
|
|
2057
|
-
this.getNumber(question)
|
|
2058
|
-
);
|
|
2059
|
-
}
|
|
2060
|
-
return this.getNumber(question).toString();
|
|
2061
|
-
}
|
|
2062
|
-
|
|
2063
|
-
getNumber(question) {
|
|
2064
|
-
return question.type == "MATRIX" ? question.number : question.header.number;
|
|
2065
|
-
}
|
|
2040
|
+
class ExprEvaluationQuestion {
|
|
2041
|
+
constructor(questions, scope) {
|
|
2042
|
+
this.questions = questions;
|
|
2043
|
+
this.scope = _.sortBy(scope);
|
|
2044
|
+
this.questionMap = this.buildQuestionMap();
|
|
2045
|
+
}
|
|
2046
|
+
calculateNumbers() {
|
|
2047
|
+
const checkedQuestions = this.checkedQuestion();
|
|
2048
|
+
const checkedNumberElements = new Array();
|
|
2049
|
+
this.recurs(checkedQuestions, checkedNumberElements);
|
|
2050
|
+
return checkedNumberElements;
|
|
2051
|
+
}
|
|
2052
|
+
buildQuestionMap() {
|
|
2053
|
+
const questionMap = {};
|
|
2054
|
+
_.forEach(this.questions, (question) => {
|
|
2055
|
+
questionMap[question.id] = question;
|
|
2056
|
+
if (question.type == "MATRIX") {
|
|
2057
|
+
_.forEach(_.get(question, "subQuestions", []), (subQuestion) => {
|
|
2058
|
+
questionMap[subQuestion.id] = subQuestion;
|
|
2059
|
+
});
|
|
2060
|
+
}
|
|
2061
|
+
});
|
|
2062
|
+
return questionMap;
|
|
2063
|
+
}
|
|
2064
|
+
checkedQuestion() {
|
|
2065
|
+
const questions = new Array();
|
|
2066
|
+
_.forEach(this.questions, (question) => {
|
|
2067
|
+
if (_.get(question, "type") == "MATRIX") {
|
|
2068
|
+
const markedQuestions = new Array();
|
|
2069
|
+
_.forEach(_.get(question, "subQuestions", []), (subQuestion) => {
|
|
2070
|
+
if (_.includes(this.scope, subQuestion.id)) {
|
|
2071
|
+
const newSubQuestion = _.cloneDeep(subQuestion);
|
|
2072
|
+
_.set(newSubQuestion, "type", "MATRIX");
|
|
2073
|
+
_.set(newSubQuestion, "parentId", _.get(question, "id"));
|
|
2074
|
+
markedQuestions.push(newSubQuestion);
|
|
2075
|
+
}
|
|
2076
|
+
});
|
|
2077
|
+
if (!_.isEmpty(markedQuestions)) {
|
|
2078
|
+
questions.push(markedQuestions);
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
else if (_.includes(this.scope, question.id)) {
|
|
2082
|
+
questions.push(question);
|
|
2083
|
+
}
|
|
2084
|
+
});
|
|
2085
|
+
return questions;
|
|
2086
|
+
}
|
|
2087
|
+
recurs(elements, numbers) {
|
|
2088
|
+
for (let i = 0; i < elements.length; i++) {
|
|
2089
|
+
const element = elements[i];
|
|
2090
|
+
if (_.isArray(element)) {
|
|
2091
|
+
numbers.push(new Array());
|
|
2092
|
+
this.recurs(element, numbers[numbers.length - 1]);
|
|
2093
|
+
}
|
|
2094
|
+
else {
|
|
2095
|
+
const temp = new Array();
|
|
2096
|
+
temp.push(this.getFullNumber(element));
|
|
2097
|
+
if (i == elements.length - 1) {
|
|
2098
|
+
numbers.push(temp);
|
|
2099
|
+
continue;
|
|
2100
|
+
}
|
|
2101
|
+
for (let j = i + 1;; j++) {
|
|
2102
|
+
if (j == elements.length ||
|
|
2103
|
+
!this.isContinuous(elements[j - 1], elements[j])) {
|
|
2104
|
+
numbers.push(temp);
|
|
2105
|
+
i = j - 1;
|
|
2106
|
+
break;
|
|
2107
|
+
}
|
|
2108
|
+
if (_.size(temp) > 1) {
|
|
2109
|
+
temp.pop();
|
|
2110
|
+
}
|
|
2111
|
+
temp.push(this.getFullNumber(elements[j]));
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
isContinuous(front, hind) {
|
|
2117
|
+
return (!_.isArray(hind) && this.getNumber(hind) - this.getNumber(front) == 1);
|
|
2118
|
+
}
|
|
2119
|
+
getFullNumber(question) {
|
|
2120
|
+
if (question.type == "MATRIX") {
|
|
2121
|
+
return (this.questionMap[question.parentId].header.number +
|
|
2122
|
+
"." +
|
|
2123
|
+
this.getNumber(question));
|
|
2124
|
+
}
|
|
2125
|
+
return this.getNumber(question).toString();
|
|
2126
|
+
}
|
|
2127
|
+
getNumber(question) {
|
|
2128
|
+
return question.type == "MATRIX" ? question.number : question.header.number;
|
|
2129
|
+
}
|
|
2066
2130
|
}
|
|
2067
2131
|
|
|
2068
2132
|
const SPLIT_LENGTH = 60;
|
|
@@ -5970,7 +6034,7 @@ var script = Vue.extend({
|
|
|
5970
6034
|
let input_titles = [];
|
|
5971
6035
|
let formatTitleStr = formatTitle(q, Vue.$surveyLanguage);
|
|
5972
6036
|
_.each(formatTitleStr, (t, index) => {
|
|
5973
|
-
if (t
|
|
6037
|
+
if (CUSTOM_INPUT_REG.test(t)) {
|
|
5974
6038
|
let title = {
|
|
5975
6039
|
title: "",
|
|
5976
6040
|
index: index,
|