case-editor-tools 1.0.0-beta.4 → 1.0.0-beta.40
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/{build/constants → constants}/key-definitions.d.ts +3 -0
- package/{build/constants → constants}/key-definitions.js +7 -1
- package/{build/constants → constants}/key-definitions.js.map +1 -1
- package/exporter/index.d.ts +2 -0
- package/exporter/index.js +99 -0
- package/exporter/index.js.map +1 -0
- package/{build/expression-utils → expression-utils}/expressionGen.d.ts +1 -1
- package/{build/expression-utils → expression-utils}/expressionGen.js +0 -0
- package/{build/expression-utils → expression-utils}/expressionGen.js.map +0 -0
- package/{build/expression-utils → expression-utils}/studyEngineExpressions.d.ts +86 -13
- package/{build/expression-utils → expression-utils}/studyEngineExpressions.js +189 -19
- package/{build/expression-utils → expression-utils}/studyEngineExpressions.js.map +1 -1
- package/{build/index.d.ts → index.d.ts} +0 -0
- package/{build/index.js → index.js} +0 -0
- package/{build/index.js.map → index.js.map} +0 -0
- package/{build/item-editor-8fd24b61.js → item-editor-59f51ecc.js} +72 -51
- package/item-editor-59f51ecc.js.map +1 -0
- package/logger/index.d.ts +1 -0
- package/logger/index.js +10 -0
- package/logger/index.js.map +1 -0
- package/{build/logger → logger}/logger.d.ts +0 -0
- package/{build/logger → logger}/logger.js +0 -0
- package/{build/logger → logger}/logger.js.map +0 -0
- package/package.json +7 -8
- package/surveys/index.d.ts +3 -0
- package/surveys/index.js +29 -0
- package/surveys/index.js.map +1 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.d.ts +27 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.js +350 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.js.map +1 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.d.ts +49 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.js +100 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.js.map +1 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.d.ts +7 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.js +129 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.js.map +1 -0
- package/{build → surveys}/survey-editor/component-editor.d.ts +1 -1
- package/{build → surveys}/survey-editor/component-editor.js +0 -0
- package/{build → surveys}/survey-editor/component-editor.js.map +0 -0
- package/{build → surveys}/survey-editor/data-types.d.ts +1 -1
- package/{build → surveys}/survey-editor/data-types.js +0 -0
- package/{build → surveys}/survey-editor/data-types.js.map +0 -0
- package/{build → surveys}/survey-editor/item-editor.d.ts +2 -1
- package/{build → surveys}/survey-editor/item-editor.js +3 -2
- package/{build → surveys}/survey-editor/item-editor.js.map +1 -1
- package/{build → surveys}/survey-editor/survey-editor.d.ts +6 -1
- package/{build → surveys}/survey-editor/survey-editor.js +15 -8
- package/{build → surveys}/survey-editor/survey-editor.js.map +1 -1
- package/{build/expression-utils/surveyEngineExpressions.d.ts → surveys/survey-engine-expressions.d.ts} +12 -2
- package/{build/expression-utils/surveyEngineExpressions.js → surveys/survey-engine-expressions.js} +45 -4
- package/{build/expression-utils/surveyEngineExpressions.js.map → surveys/survey-engine-expressions.js.map} +1 -1
- package/surveys/survey-items.d.ts +68 -0
- package/surveys/survey-items.js +384 -0
- package/surveys/survey-items.js.map +1 -0
- package/{build → surveys}/types/group.d.ts +1 -1
- package/{build → surveys}/types/group.js +6 -5
- package/{build → surveys}/types/group.js.map +1 -1
- package/surveys/types/index.d.ts +4 -0
- package/surveys/types/index.js +22 -0
- package/surveys/types/index.js.map +1 -0
- package/surveys/types/item-properties.d.ts +223 -0
- package/surveys/types/item-properties.js +10 -0
- package/surveys/types/item-properties.js.map +1 -0
- package/{build → surveys}/types/item.d.ts +1 -1
- package/{build → surveys}/types/item.js +0 -0
- package/{build → surveys}/types/item.js.map +0 -0
- package/{build/types/surveyDefinition.d.ts → surveys/types/survey-definition.d.ts} +7 -3
- package/{build/types/surveyDefinition.js → surveys/types/survey-definition.js} +20 -11
- package/surveys/types/survey-definition.js.map +1 -0
- package/{build → surveys}/utils/componentGenerators.d.ts +2 -13
- package/surveys/utils/componentGenerators.js +59 -0
- package/{build → surveys}/utils/componentGenerators.js.map +1 -1
- package/surveys/utils/optionDefGenerators.d.ts +83 -0
- package/surveys/utils/optionDefGenerators.js +210 -0
- package/surveys/utils/optionDefGenerators.js.map +1 -0
- package/{build → surveys}/utils/randomKeyGenerator.d.ts +0 -0
- package/{build → surveys}/utils/randomKeyGenerator.js +0 -0
- package/{build → surveys}/utils/randomKeyGenerator.js.map +0 -0
- package/{build → surveys}/utils/simple-generators.d.ts +4 -3
- package/{build → surveys}/utils/simple-generators.js +34 -5
- package/{build → surveys}/utils/simple-generators.js.map +1 -1
- package/surveys/utils/simple-question-editor.d.ts +14 -0
- package/{build → surveys}/utils/simple-question-editor.js +10 -7
- package/{build → surveys}/utils/simple-question-editor.js.map +1 -1
- package/{build/types → types}/duration.d.ts +0 -0
- package/{build/types → types}/duration.js +0 -0
- package/{build/types → types}/duration.js.map +0 -0
- package/{build/types → types}/expression.d.ts +1 -1
- package/{build/types → types}/expression.js +0 -0
- package/{build/types → types}/expression.js.map +0 -0
- package/{build/types → types}/study.d.ts +2 -2
- package/{build/types → types}/study.js +0 -0
- package/{build/types → types}/study.js.map +0 -0
- package/{build/types → types}/studyRules.d.ts +3 -2
- package/{build/types → types}/studyRules.js +5 -1
- package/types/studyRules.js.map +1 -0
- package/.babelrc.js +0 -7
- package/.editorconfig +0 -13
- package/LICENSE +0 -202
- package/build/item-editor-8fd24b61.js.map +0 -1
- package/build/package.json +0 -26
- package/build/types/studyRules.js.map +0 -1
- package/build/types/surveyDefinition.js.map +0 -1
- package/build/utils/componentGenerators.js +0 -92
- package/build/utils/question-type-generator.d.ts +0 -283
- package/build/utils/question-type-generator.js +0 -949
- package/build/utils/question-type-generator.js.map +0 -1
- package/build/utils/simple-question-editor.d.ts +0 -14
- package/rollup.config.js +0 -53
- package/src/constants/key-definitions.ts +0 -13
- package/src/expression-utils/expressionGen.ts +0 -28
- package/src/expression-utils/studyEngineExpressions.ts +0 -359
- package/src/expression-utils/surveyEngineExpressions.ts +0 -483
- package/src/index.ts +0 -1
- package/src/logger/logger.ts +0 -31
- package/src/survey-editor/component-editor.ts +0 -133
- package/src/survey-editor/data-types.ts +0 -18
- package/src/survey-editor/item-editor.ts +0 -528
- package/src/survey-editor/survey-editor.ts +0 -260
- package/src/types/duration.ts +0 -32
- package/src/types/expression.ts +0 -22
- package/src/types/group.ts +0 -73
- package/src/types/item.ts +0 -42
- package/src/types/study.ts +0 -17
- package/src/types/studyRules.ts +0 -39
- package/src/types/surveyDefinition.ts +0 -83
- package/src/utils/componentGenerators.ts +0 -122
- package/src/utils/question-type-generator.ts +0 -1516
- package/src/utils/randomKeyGenerator.ts +0 -11
- package/src/utils/simple-generators.ts +0 -106
- package/src/utils/simple-question-editor.ts +0 -52
- package/tsconfig.json +0 -100
|
@@ -10,4 +10,7 @@ export declare const sliderCategoricalKey = "scc";
|
|
|
10
10
|
export declare const inputKey = "ic";
|
|
11
11
|
export declare const numericInputKey = "num";
|
|
12
12
|
export declare const datePickerKey = "date";
|
|
13
|
+
export declare const timeInputKey = "time";
|
|
13
14
|
export declare const matrixKey = "mat";
|
|
15
|
+
export declare const clozeKey = "cloze";
|
|
16
|
+
export declare const consentKey = "con";
|
|
@@ -14,8 +14,13 @@ const sliderCategoricalKey = "scc";
|
|
|
14
14
|
const inputKey = "ic";
|
|
15
15
|
const numericInputKey = "num";
|
|
16
16
|
const datePickerKey = "date";
|
|
17
|
-
const
|
|
17
|
+
const timeInputKey = "time";
|
|
18
|
+
const matrixKey = "mat";
|
|
19
|
+
const clozeKey = "cloze";
|
|
20
|
+
const consentKey = "con";
|
|
18
21
|
|
|
22
|
+
exports.clozeKey = clozeKey;
|
|
23
|
+
exports.consentKey = consentKey;
|
|
19
24
|
exports.datePickerKey = datePickerKey;
|
|
20
25
|
exports.dropDownKey = dropDownKey;
|
|
21
26
|
exports.inputKey = inputKey;
|
|
@@ -29,4 +34,5 @@ exports.responsiveBipolarLikertArrayKey = responsiveBipolarLikertArrayKey;
|
|
|
29
34
|
exports.responsiveSingleChoiceArrayKey = responsiveSingleChoiceArrayKey;
|
|
30
35
|
exports.singleChoiceKey = singleChoiceKey;
|
|
31
36
|
exports.sliderCategoricalKey = sliderCategoricalKey;
|
|
37
|
+
exports.timeInputKey = timeInputKey;
|
|
32
38
|
//# sourceMappingURL=key-definitions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-definitions.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"key-definitions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var fs = require('fs');
|
|
6
|
+
var logger_logger = require('../logger/logger.js');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
11
|
+
|
|
12
|
+
const generateFilesForStudy = (study, pretty) => {
|
|
13
|
+
const outputName = study.outputFolderName ? study.outputFolderName : study.studyKey;
|
|
14
|
+
const outputRoot = `./output/${outputName}`;
|
|
15
|
+
logger_logger.Logger.log(`Start generating files for study ${outputName}.`);
|
|
16
|
+
if (!fs__default["default"].existsSync(outputRoot)) {
|
|
17
|
+
fs__default["default"].mkdirSync(outputRoot, { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
// Surveys:
|
|
20
|
+
generateSurveyFiles(study, outputRoot, pretty);
|
|
21
|
+
// Study rules:
|
|
22
|
+
generateStudyRuleFile(study, outputRoot, pretty);
|
|
23
|
+
// Custom Study rules: (manually triggered rules)
|
|
24
|
+
generateCustomStudyRules(study, outputRoot, pretty);
|
|
25
|
+
};
|
|
26
|
+
const generateSurveyFiles = (study, outputPath, pretty) => {
|
|
27
|
+
if (study.surveys.length > 0) {
|
|
28
|
+
logger_logger.Logger.log(`\tSurveys:`);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
logger_logger.Logger.log(`\tNo surveys in the study.`);
|
|
32
|
+
}
|
|
33
|
+
const surveyOutPath = `${outputPath}/surveys`;
|
|
34
|
+
if (!fs__default["default"].existsSync(surveyOutPath)) {
|
|
35
|
+
fs__default["default"].mkdirSync(surveyOutPath, { recursive: true });
|
|
36
|
+
}
|
|
37
|
+
study.surveys.forEach(survey => {
|
|
38
|
+
const fileName = `${surveyOutPath}/${survey.key}.json`;
|
|
39
|
+
const outputObject = {
|
|
40
|
+
studyKey: study.studyKey,
|
|
41
|
+
survey: survey.getSurvey()
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
fs__default["default"].writeFileSync(fileName, JSON.stringify(outputObject, undefined, pretty ? 2 : undefined));
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
logger_logger.Logger.error(err);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
logger_logger.Logger.success(`\t\t${survey.key} saved`);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const generateStudyRuleFile = (study, outputPath, pretty) => {
|
|
54
|
+
if (!study.studyRules) {
|
|
55
|
+
logger_logger.Logger.log(`\tNo study rules in the study.`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
logger_logger.Logger.log(`\tStudy rule:`);
|
|
60
|
+
}
|
|
61
|
+
const fileName = `${outputPath}/studyRules.json`;
|
|
62
|
+
const outputObject = study.studyRules.get();
|
|
63
|
+
try {
|
|
64
|
+
fs__default["default"].writeFileSync(fileName, JSON.stringify(outputObject, undefined, pretty ? 2 : undefined));
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
logger_logger.Logger.error(err);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
logger_logger.Logger.success(`\t\tStudy rules saved`);
|
|
71
|
+
};
|
|
72
|
+
const generateCustomStudyRules = (study, outputPath, pretty) => {
|
|
73
|
+
if (!study.customStudyRules || study.customStudyRules.length < 0) {
|
|
74
|
+
logger_logger.Logger.log(`\tNo custom study rules in the study.`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
logger_logger.Logger.log(`\tCustom study rules:`);
|
|
79
|
+
}
|
|
80
|
+
const customRulePath = `${outputPath}/customRules`;
|
|
81
|
+
if (!fs__default["default"].existsSync(customRulePath)) {
|
|
82
|
+
fs__default["default"].mkdirSync(customRulePath, { recursive: true });
|
|
83
|
+
}
|
|
84
|
+
study.customStudyRules.forEach(studyRule => {
|
|
85
|
+
const fileName = `${customRulePath}/${studyRule.name}.json`;
|
|
86
|
+
const outputObject = studyRule.rules;
|
|
87
|
+
try {
|
|
88
|
+
fs__default["default"].writeFileSync(fileName, JSON.stringify(outputObject, undefined, pretty ? 2 : undefined));
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
logger_logger.Logger.error(err);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
logger_logger.Logger.success(`\t\tRule ${studyRule.name} saved`);
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
exports.generateFilesForStudy = generateFilesForStudy;
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Expression, ExpressionName } from "survey-engine/
|
|
1
|
+
import { Expression, ExpressionName } from "survey-engine/data_types";
|
|
2
2
|
export declare const generateExpression: (name: ExpressionName, returnType?: "string" | "float" | undefined, ...args: any[]) => Expression;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { Expression } from "survey-engine/
|
|
1
|
+
import { Expression } from "survey-engine/data_types";
|
|
2
2
|
import { Duration } from "../types/duration";
|
|
3
3
|
export declare const NativeStudyEngineExpressions: {
|
|
4
|
-
checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER') => Expression;
|
|
4
|
+
checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE') => Expression;
|
|
5
5
|
checkSurveyResponseKey: (surveyKey: string) => Expression;
|
|
6
6
|
responseHasKeysAny: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
|
|
7
7
|
responseHasOnlyKeysOtherThan: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
|
|
8
8
|
getResponseValueAsNum: (itemKey: string, responseKey: string) => Expression;
|
|
9
9
|
getResponseValueAsStr: (itemKey: string, responseKey: string) => Expression;
|
|
10
|
+
hasResponseKey: (itemKey: string, responseKey: string) => Expression;
|
|
11
|
+
hasResponseKeyWithValue: (itemKey: string, responseKey: string, value: string) => Expression;
|
|
10
12
|
countResponseItems: (itemKey: string, responseKey: string) => Expression;
|
|
11
13
|
checkConditionForOldResponses: (condition: Expression, checkType?: number | "all" | "any" | undefined, surveyKey?: string | undefined, querySince?: number | Expression | undefined, queryUntil?: number | Expression | undefined) => Expression;
|
|
12
14
|
participantState: {
|
|
@@ -15,8 +17,23 @@ export declare const NativeStudyEngineExpressions: {
|
|
|
15
17
|
getSurveyKeyAssignedFrom: (surveyKey: string) => Expression;
|
|
16
18
|
getSurveyKeyAssignedUntil: (surveyKey: string) => Expression;
|
|
17
19
|
hasStudyStatus: (status: string) => Expression;
|
|
18
|
-
|
|
20
|
+
hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
|
|
21
|
+
hasParticipantFlagKey: (key: string) => Expression;
|
|
19
22
|
lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string | undefined) => Expression;
|
|
23
|
+
hasMessageTypeAssigned: (messageType: string) => Expression;
|
|
24
|
+
getMessageNextTime: (messageType: string) => Expression;
|
|
25
|
+
incomingParticipantState: {
|
|
26
|
+
getStudyEntryTime: () => Expression;
|
|
27
|
+
hasSurveyKeyAssigned: (surveyKey: string) => Expression;
|
|
28
|
+
getSurveyKeyAssignedFrom: (surveyKey: string) => Expression;
|
|
29
|
+
getSurveyKeyAssignedUntil: (surveyKey: string) => Expression;
|
|
30
|
+
hasStudyStatus: (status: string) => Expression;
|
|
31
|
+
hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
|
|
32
|
+
hasParticipantFlagKey: (key: string) => Expression;
|
|
33
|
+
lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string | undefined) => Expression;
|
|
34
|
+
hasMessageTypeAssigned: (messageType: string) => Expression;
|
|
35
|
+
getMessageNextTime: (messageType: string) => Expression;
|
|
36
|
+
};
|
|
20
37
|
};
|
|
21
38
|
eq: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
|
|
22
39
|
lt: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
|
|
@@ -34,17 +51,30 @@ export declare const StudyEngineActions: {
|
|
|
34
51
|
ifThen: (condition: Expression, ...args: Expression[]) => Expression;
|
|
35
52
|
participantActions: {
|
|
36
53
|
updateStudyStatus: (status: string) => Expression;
|
|
37
|
-
updateFlag: (key: string, newValue: string) => Expression;
|
|
54
|
+
updateFlag: (key: string, newValue: string | number | Expression) => Expression;
|
|
38
55
|
removeFlag: (key: string) => Expression;
|
|
39
56
|
assignedSurveys: {
|
|
40
|
-
add: (surveyKey: string, category: 'prio' | 'normal' | 'optional', activeFrom?: number | Expression | undefined, activeUntil?: number | Expression | undefined) => Expression;
|
|
57
|
+
add: (surveyKey: string, category: 'immediate' | 'prio' | 'normal' | 'optional', activeFrom?: number | Expression | undefined, activeUntil?: number | Expression | undefined) => Expression;
|
|
41
58
|
removeAll: () => Expression;
|
|
42
59
|
remove: (surveyKey: string, selector: 'first' | 'last' | 'all') => Expression;
|
|
43
60
|
};
|
|
44
61
|
reports: {
|
|
45
|
-
|
|
62
|
+
init: (reportKey: string) => Expression;
|
|
63
|
+
cancel: (reportKey: string) => Expression;
|
|
64
|
+
updateData: (reportKey: string, attributeKey: string, value: number | string | Expression, dtype?: "string" | "date" | "float" | "int" | "rawMessage" | undefined) => Expression;
|
|
65
|
+
removeData: (reportKey: string, attributeKey: string) => Expression;
|
|
66
|
+
setReportIcon: (reportKey: string, icon: string) => Expression;
|
|
67
|
+
setReportMessage: (reportKey: string, content: string, asTranslationKey?: boolean | undefined) => Expression;
|
|
68
|
+
setReportSummary: (reportKey: string, content: string, asTranslationKey?: boolean | undefined) => Expression;
|
|
69
|
+
};
|
|
70
|
+
messages: {
|
|
71
|
+
add: (messageType: string, scheduledFor: number | Expression) => Expression;
|
|
72
|
+
removeAll: () => Expression;
|
|
73
|
+
remove: (messageType: string) => Expression;
|
|
74
|
+
};
|
|
75
|
+
confidentialResponses: {
|
|
76
|
+
removeByKey: (key: string) => Expression;
|
|
46
77
|
removeAll: () => Expression;
|
|
47
|
-
remove: (surveyKey: string, selector: 'first' | 'last' | 'all') => Expression;
|
|
48
78
|
};
|
|
49
79
|
stopParticipation: () => Expression;
|
|
50
80
|
finishParticipation: () => Expression;
|
|
@@ -60,37 +90,65 @@ export declare const StudyEngine: {
|
|
|
60
90
|
none: (itemKey: string, ...optionKeys: string[]) => Expression;
|
|
61
91
|
all: (itemKey: string, ...optionKeys: string[]) => Expression;
|
|
62
92
|
};
|
|
93
|
+
consent: {
|
|
94
|
+
accepted: (itemKey: string) => Expression;
|
|
95
|
+
};
|
|
63
96
|
survey: {
|
|
64
97
|
isActive: (surveyKey: string) => Expression;
|
|
65
98
|
validFromOlderThan: (surveyKey: string, delta: Duration, reference?: number | Expression | undefined) => Expression;
|
|
66
99
|
validUntilSoonerThan: (surveyKey: string, delta: Duration, reference?: number | Expression | undefined) => Expression;
|
|
67
100
|
};
|
|
101
|
+
prefillRules: {
|
|
102
|
+
GET_LAST_SURVEY_ITEM: (surveyKey: string, itemKey: string, submittedLaterThan?: Duration | undefined) => Expression;
|
|
103
|
+
};
|
|
104
|
+
contextRules: {
|
|
105
|
+
previousResponses: {
|
|
106
|
+
LAST_RESPONSES_BY_KEY: (surveyKey: string, limit: number) => Expression;
|
|
107
|
+
ALL_RESPONSES_SINCE: (sinceTimestamp: number) => Expression;
|
|
108
|
+
RESPONSES_SINCE_BY_KEY: (sinceTimestamp: number, surveyKey: string) => Expression;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
68
111
|
if: (condition: Expression, actionIfTrue: Expression, actionIfFalse?: Expression | undefined) => Expression;
|
|
69
112
|
do: (...args: Expression[]) => Expression;
|
|
70
113
|
ifThen: (condition: Expression, ...args: Expression[]) => Expression;
|
|
71
114
|
participantActions: {
|
|
72
115
|
updateStudyStatus: (status: string) => Expression;
|
|
73
|
-
updateFlag: (key: string, newValue: string) => Expression;
|
|
116
|
+
updateFlag: (key: string, newValue: string | number | Expression) => Expression;
|
|
74
117
|
removeFlag: (key: string) => Expression;
|
|
75
118
|
assignedSurveys: {
|
|
76
|
-
add: (surveyKey: string, category: 'prio' | 'normal' | 'optional', activeFrom?: number | Expression | undefined, activeUntil?: number | Expression | undefined) => Expression;
|
|
119
|
+
add: (surveyKey: string, category: 'immediate' | 'prio' | 'normal' | 'optional', activeFrom?: number | Expression | undefined, activeUntil?: number | Expression | undefined) => Expression;
|
|
77
120
|
removeAll: () => Expression;
|
|
78
121
|
remove: (surveyKey: string, selector: 'first' | 'last' | 'all') => Expression;
|
|
79
122
|
};
|
|
80
123
|
reports: {
|
|
81
|
-
|
|
124
|
+
init: (reportKey: string) => Expression;
|
|
125
|
+
cancel: (reportKey: string) => Expression;
|
|
126
|
+
updateData: (reportKey: string, attributeKey: string, value: number | string | Expression, dtype?: "string" | "date" | "float" | "int" | "rawMessage" | undefined) => Expression;
|
|
127
|
+
removeData: (reportKey: string, attributeKey: string) => Expression;
|
|
128
|
+
setReportIcon: (reportKey: string, icon: string) => Expression;
|
|
129
|
+
setReportMessage: (reportKey: string, content: string, asTranslationKey?: boolean | undefined) => Expression;
|
|
130
|
+
setReportSummary: (reportKey: string, content: string, asTranslationKey?: boolean | undefined) => Expression;
|
|
131
|
+
};
|
|
132
|
+
messages: {
|
|
133
|
+
add: (messageType: string, scheduledFor: number | Expression) => Expression;
|
|
134
|
+
removeAll: () => Expression;
|
|
135
|
+
remove: (messageType: string) => Expression;
|
|
136
|
+
};
|
|
137
|
+
confidentialResponses: {
|
|
138
|
+
removeByKey: (key: string) => Expression;
|
|
82
139
|
removeAll: () => Expression;
|
|
83
|
-
remove: (surveyKey: string, selector: 'first' | 'last' | 'all') => Expression;
|
|
84
140
|
};
|
|
85
141
|
stopParticipation: () => Expression;
|
|
86
142
|
finishParticipation: () => Expression;
|
|
87
143
|
};
|
|
88
|
-
checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER') => Expression;
|
|
144
|
+
checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE') => Expression;
|
|
89
145
|
checkSurveyResponseKey: (surveyKey: string) => Expression;
|
|
90
146
|
responseHasKeysAny: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
|
|
91
147
|
responseHasOnlyKeysOtherThan: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
|
|
92
148
|
getResponseValueAsNum: (itemKey: string, responseKey: string) => Expression;
|
|
93
149
|
getResponseValueAsStr: (itemKey: string, responseKey: string) => Expression;
|
|
150
|
+
hasResponseKey: (itemKey: string, responseKey: string) => Expression;
|
|
151
|
+
hasResponseKeyWithValue: (itemKey: string, responseKey: string, value: string) => Expression;
|
|
94
152
|
countResponseItems: (itemKey: string, responseKey: string) => Expression;
|
|
95
153
|
checkConditionForOldResponses: (condition: Expression, checkType?: number | "all" | "any" | undefined, surveyKey?: string | undefined, querySince?: number | Expression | undefined, queryUntil?: number | Expression | undefined) => Expression;
|
|
96
154
|
participantState: {
|
|
@@ -99,8 +157,23 @@ export declare const StudyEngine: {
|
|
|
99
157
|
getSurveyKeyAssignedFrom: (surveyKey: string) => Expression;
|
|
100
158
|
getSurveyKeyAssignedUntil: (surveyKey: string) => Expression;
|
|
101
159
|
hasStudyStatus: (status: string) => Expression;
|
|
102
|
-
|
|
160
|
+
hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
|
|
161
|
+
hasParticipantFlagKey: (key: string) => Expression;
|
|
103
162
|
lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string | undefined) => Expression;
|
|
163
|
+
hasMessageTypeAssigned: (messageType: string) => Expression;
|
|
164
|
+
getMessageNextTime: (messageType: string) => Expression;
|
|
165
|
+
incomingParticipantState: {
|
|
166
|
+
getStudyEntryTime: () => Expression;
|
|
167
|
+
hasSurveyKeyAssigned: (surveyKey: string) => Expression;
|
|
168
|
+
getSurveyKeyAssignedFrom: (surveyKey: string) => Expression;
|
|
169
|
+
getSurveyKeyAssignedUntil: (surveyKey: string) => Expression;
|
|
170
|
+
hasStudyStatus: (status: string) => Expression;
|
|
171
|
+
hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
|
|
172
|
+
hasParticipantFlagKey: (key: string) => Expression;
|
|
173
|
+
lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string | undefined) => Expression;
|
|
174
|
+
hasMessageTypeAssigned: (messageType: string) => Expression;
|
|
175
|
+
getMessageNextTime: (messageType: string) => Expression;
|
|
176
|
+
};
|
|
104
177
|
};
|
|
105
178
|
eq: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
|
|
106
179
|
lt: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
|
|
@@ -11,7 +11,7 @@ const and = (...args) => expressionUtils_expressionGen.generateExpression('and',
|
|
|
11
11
|
const not = (arg) => expressionUtils_expressionGen.generateExpression('not', undefined, arg);
|
|
12
12
|
/**
|
|
13
13
|
* Check if the current event has the given type
|
|
14
|
-
* @param equalsType string with the possible values: 'ENTER', 'SUBMIT', 'TIMER
|
|
14
|
+
* @param equalsType string with the possible values: 'ENTER', 'SUBMIT', 'TIMER', 'MERGE'
|
|
15
15
|
* @returns if event type matches the argument, return true otherwise false
|
|
16
16
|
*/
|
|
17
17
|
const checkEventType = (equalsType) => expressionUtils_expressionGen.generateExpression('checkEventType', undefined, equalsType);
|
|
@@ -37,6 +37,25 @@ const responseHasKeysAny = (itemKey, responseSlotKey, ...optionKeys) => expressi
|
|
|
37
37
|
* @returns true if a response key is present, but is not in the list defined by optionKeys. If item or the response group is not found, returns false.
|
|
38
38
|
*/
|
|
39
39
|
const responseHasOnlyKeysOtherThan = (itemKey, responseSlotKey, ...optionKeys) => expressionUtils_expressionGen.generateExpression('responseHasOnlyKeysOtherThan', undefined, itemKey, responseSlotKey, ...optionKeys);
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param itemKey full key to the survey item, in the form, e.g., <surveyKey>.<groupKey>.<itemKey>
|
|
43
|
+
* @param responseKey full key to the response that should exists
|
|
44
|
+
* @returns if item contains responseKey return true
|
|
45
|
+
*/
|
|
46
|
+
const hasResponseKey = (itemKey, responseKey) => {
|
|
47
|
+
return expressionUtils_expressionGen.generateExpression('hasResponseKey', undefined, itemKey, responseKey);
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param itemKey full key to the survey item, in the form, e.g., <surveyKey>.<groupKey>.<itemKey>
|
|
52
|
+
* @param responseKey full key to the response that should exists
|
|
53
|
+
* @param value the response object with the above key should have this value
|
|
54
|
+
* @returns if the response object exists and has the value return true
|
|
55
|
+
*/
|
|
56
|
+
const hasResponseKeyWithValue = (itemKey, responseKey, value) => {
|
|
57
|
+
return expressionUtils_expressionGen.generateExpression('hasResponseKeyWithValue', undefined, itemKey, responseKey, value);
|
|
58
|
+
};
|
|
40
59
|
const getResponseValueAsNum = (itemKey, responseKey) => {
|
|
41
60
|
return expressionUtils_expressionGen.generateExpression('getResponseValueAsNum', 'float', itemKey, responseKey);
|
|
42
61
|
};
|
|
@@ -61,37 +80,64 @@ const checkConditionForOldResponses = (condition, checkType, surveyKey, querySin
|
|
|
61
80
|
* @returns timestamp
|
|
62
81
|
*/
|
|
63
82
|
const getStudyEntryTime = () => expressionUtils_expressionGen.generateExpression('getStudyEntryTime');
|
|
83
|
+
const getStudyEntryTimeForIncoming = () => expressionUtils_expressionGen.generateExpression('incomingState:getStudyEntryTime');
|
|
64
84
|
/**
|
|
65
85
|
* Determines if a specific survey key is currently assigned to the participant.
|
|
66
86
|
* @param surveyKey - string - key of the survey to check for.
|
|
67
87
|
* @returns true if the participant has a survey with this surveyKey assigned, otherwise false.
|
|
68
88
|
*/
|
|
69
89
|
const hasSurveyKeyAssigned = (surveyKey) => expressionUtils_expressionGen.generateExpression('hasSurveyKeyAssigned', undefined, surveyKey);
|
|
90
|
+
const hasSurveyKeyAssignedForIncoming = (surveyKey) => expressionUtils_expressionGen.generateExpression('incomingState:hasSurveyKeyAssigned', undefined, surveyKey);
|
|
70
91
|
/**
|
|
71
92
|
* Method to access the timestamp for a surveyKey is assigned from
|
|
72
93
|
* @param surveyKey - string - key of the survey to check for.
|
|
73
94
|
* @returns timestamp
|
|
74
95
|
*/
|
|
75
96
|
const getSurveyKeyAssignedFrom = (surveyKey) => expressionUtils_expressionGen.generateExpression('getSurveyKeyAssignedFrom', undefined, surveyKey);
|
|
97
|
+
const getSurveyKeyAssignedFromForIncoming = (surveyKey) => expressionUtils_expressionGen.generateExpression('incomingState:getSurveyKeyAssignedFrom', undefined, surveyKey);
|
|
76
98
|
/**
|
|
77
99
|
* Method to access the timestamp for a surveyKey is assigned until
|
|
78
100
|
* @param surveyKey - string - key of the survey to check for.
|
|
79
101
|
* @returns timestamp
|
|
80
102
|
*/
|
|
81
103
|
const getSurveyKeyAssignedUntil = (surveyKey) => expressionUtils_expressionGen.generateExpression('getSurveyKeyAssignedUntil', undefined, surveyKey);
|
|
104
|
+
const getSurveyKeyAssignedUntilForIncoming = (surveyKey) => expressionUtils_expressionGen.generateExpression('incomingState:getSurveyKeyAssignedUntil', undefined, surveyKey);
|
|
82
105
|
/**
|
|
83
106
|
* Check if a participant has a specific study status
|
|
84
107
|
* @param status - string
|
|
85
108
|
* @returns true/false
|
|
86
109
|
*/
|
|
87
110
|
const hasStudyStatus = (status) => expressionUtils_expressionGen.generateExpression('getSurveyKeyAssignedUntil', undefined, status);
|
|
111
|
+
const hasStudyStatusForIncoming = (status) => expressionUtils_expressionGen.generateExpression('incomingState:getSurveyKeyAssignedUntil', undefined, status);
|
|
88
112
|
/**
|
|
89
|
-
* Check if a participant flag is present
|
|
113
|
+
* Check if a participant flag with specific value is present
|
|
90
114
|
* @param key look up this flag
|
|
91
115
|
* @param value and for this value
|
|
92
116
|
* @returns return true if key - value pair (with case sensitive matching for both key and value) is present. If any of the two is different, or participant flags is empty, it returns false.
|
|
93
117
|
*/
|
|
94
|
-
const
|
|
118
|
+
const hasParticipantFlagKeyAndValue = (key, value) => expressionUtils_expressionGen.generateExpression('hasParticipantFlag', undefined, key, value);
|
|
119
|
+
const hasParticipantFlagKeyAndValueForIncoming = (key, value) => expressionUtils_expressionGen.generateExpression('incomingState:hasParticipantFlag', undefined, key, value);
|
|
120
|
+
/**
|
|
121
|
+
* Check if a participant flag is present
|
|
122
|
+
* @param key look up this flag
|
|
123
|
+
* @returns return true if key is present. If any of the two is different, or participant flags is empty, it returns false.
|
|
124
|
+
*/
|
|
125
|
+
const hasParticipantFlagKey = (key) => expressionUtils_expressionGen.generateExpression('hasParticipantFlagKey', undefined, key);
|
|
126
|
+
const hasParticipantFlagKeyForIncoming = (key) => expressionUtils_expressionGen.generateExpression('incomingState:hasParticipantFlagKey', undefined, key);
|
|
127
|
+
/**
|
|
128
|
+
* Checks if the participant has a message type assigned (at least one)
|
|
129
|
+
* @param messageType
|
|
130
|
+
* @returns return true if a message with the given message type is assigned
|
|
131
|
+
*/
|
|
132
|
+
const hasMessageTypeAssigned = (messageType) => expressionUtils_expressionGen.generateExpression('hasMessageTypeAssigned', undefined, messageType);
|
|
133
|
+
const hasMessageTypeAssignedForIncoming = (messageType) => expressionUtils_expressionGen.generateExpression('incomingState:hasMessageTypeAssigned', undefined, messageType);
|
|
134
|
+
/**
|
|
135
|
+
* Retrieve the timestamp (scheduledFor) for a particular message type. Return 0 if not assigned.
|
|
136
|
+
* @param messageType
|
|
137
|
+
* @returns timestamp value or zero
|
|
138
|
+
*/
|
|
139
|
+
const getMessageNextTime = (messageType) => expressionUtils_expressionGen.generateExpression('getMessageNextTime', undefined, messageType);
|
|
140
|
+
const getMessageNextTimeForIncoming = (messageType) => expressionUtils_expressionGen.generateExpression('incomingState:getMessageNextTime', undefined, messageType);
|
|
95
141
|
/**
|
|
96
142
|
* Check if the last submission is older than the reference timestamp
|
|
97
143
|
* @param reference look up this flag
|
|
@@ -99,6 +145,7 @@ const hasParticipantFlag = (key, value) => expressionUtils_expressionGen.generat
|
|
|
99
145
|
* @returns boolean
|
|
100
146
|
*/
|
|
101
147
|
const lastSubmissionDateOlderThan = (reference, surveyKey) => expressionUtils_expressionGen.generateExpression('lastSubmissionDateOlderThan', undefined, reference, surveyKey);
|
|
148
|
+
const lastSubmissionDateOlderThanForIncoming = (reference, surveyKey) => expressionUtils_expressionGen.generateExpression('incomingState:lastSubmissionDateOlderThan', undefined, reference, surveyKey);
|
|
102
149
|
const eq = (val1, val2) => expressionUtils_expressionGen.generateExpression('eq', undefined, val1, val2);
|
|
103
150
|
const lt = (val1, val2) => expressionUtils_expressionGen.generateExpression('lt', undefined, val1, val2);
|
|
104
151
|
const lte = (val1, val2) => expressionUtils_expressionGen.generateExpression('lte', undefined, val1, val2);
|
|
@@ -141,7 +188,7 @@ const UPDATE_STUDY_STATUS = (status) => expressionUtils_expressionGen.generateEx
|
|
|
141
188
|
/**
|
|
142
189
|
* Add or update a participant flag
|
|
143
190
|
* @param key
|
|
144
|
-
* @param newValue
|
|
191
|
+
* @param newValue: string, number or expression where result should be written in the flag's value
|
|
145
192
|
* @returns
|
|
146
193
|
*/
|
|
147
194
|
const UPDATE_FLAG = (key, newValue) => expressionUtils_expressionGen.generateExpression('UPDATE_FLAG', undefined, key, newValue);
|
|
@@ -149,11 +196,23 @@ const REMOVE_FLAG = (key) => expressionUtils_expressionGen.generateExpression('R
|
|
|
149
196
|
const ADD_NEW_SURVEY = (surveyKey, category, activeFrom, activeUntil) => expressionUtils_expressionGen.generateExpression('ADD_NEW_SURVEY', undefined, surveyKey, activeFrom !== undefined ? activeFrom : 0, activeUntil !== undefined ? activeUntil : 0, category);
|
|
150
197
|
const REMOVE_ALL_SURVEYS = () => expressionUtils_expressionGen.generateExpression('REMOVE_ALL_SURVEYS');
|
|
151
198
|
/**
|
|
152
|
-
*
|
|
153
|
-
* @param
|
|
199
|
+
* Add participant message
|
|
200
|
+
* @param messageType message type
|
|
201
|
+
* @param scheduledFor timestamp or expression returning a timestamp
|
|
202
|
+
* @returns
|
|
203
|
+
*/
|
|
204
|
+
const ADD_MESSAGE = (messageType, scheduledFor) => expressionUtils_expressionGen.generateExpression('ADD_MESSAGE', undefined, messageType, scheduledFor);
|
|
205
|
+
/**
|
|
206
|
+
* Remove all messages scheduled for the participant
|
|
154
207
|
* @returns
|
|
155
208
|
*/
|
|
156
|
-
const
|
|
209
|
+
const REMOVE_ALL_MESSAGES = () => expressionUtils_expressionGen.generateExpression('REMOVE_ALL_MESSAGES', undefined);
|
|
210
|
+
/**
|
|
211
|
+
* Remove all messages with this message type
|
|
212
|
+
* @param messageType message type
|
|
213
|
+
* @returns
|
|
214
|
+
*/
|
|
215
|
+
const REMOVE_MESSAGES_BY_TYPE = (messageType) => expressionUtils_expressionGen.generateExpression('REMOVE_MESSAGES_BY_TYPE', undefined, messageType);
|
|
157
216
|
const REMOVE_SURVEY_BY_KEY = (surveyKey, selector) => {
|
|
158
217
|
if (selector === 'all') {
|
|
159
218
|
return expressionUtils_expressionGen.generateExpression('REMOVE_SURVEYS_BY_KEY', undefined, surveyKey);
|
|
@@ -162,14 +221,80 @@ const REMOVE_SURVEY_BY_KEY = (surveyKey, selector) => {
|
|
|
162
221
|
return expressionUtils_expressionGen.generateExpression('REMOVE_SURVEY_BY_KEY', undefined, surveyKey, selector);
|
|
163
222
|
}
|
|
164
223
|
};
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Initialises or resets a report for the current event
|
|
226
|
+
* @param reportKey key to be used for the report
|
|
227
|
+
*/
|
|
228
|
+
const INIT_REPORT = (reportKey) => {
|
|
229
|
+
return expressionUtils_expressionGen.generateExpression('INIT_REPORT', undefined, reportKey);
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Remove the report from the list of reports to be added at the end of the event
|
|
233
|
+
* @param reportKey key of the report that should be removed
|
|
234
|
+
* @returns
|
|
235
|
+
*/
|
|
236
|
+
const CANCEL_REPORT = (reportKey) => {
|
|
237
|
+
return expressionUtils_expressionGen.generateExpression('CANCEL_REPORT', undefined, reportKey);
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Remove the confidential responses with this key for the participant
|
|
241
|
+
* @param key key of the confidential responses that should be removed
|
|
242
|
+
* @returns
|
|
243
|
+
*/
|
|
244
|
+
const REMOVE_CONFIDENTIAL_RESPONSE_BY_KEY = (key) => {
|
|
245
|
+
return expressionUtils_expressionGen.generateExpression('REMOVE_CONFIDENTIAL_RESPONSE_BY_KEY', undefined, key);
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Remove all confidential responses for the participant
|
|
249
|
+
* @returns
|
|
250
|
+
*/
|
|
251
|
+
const REMOVE_ALL_CONFIDENTIAL_RESPONSES = () => {
|
|
252
|
+
return expressionUtils_expressionGen.generateExpression('REMOVE_ALL_CONFIDENTIAL_RESPONSES', undefined);
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Update one value attribute in a report. If report was not initialized, one will be added to the list.
|
|
256
|
+
* @param reportKey
|
|
257
|
+
* @param attributeKey update / create this attribute in the report
|
|
258
|
+
* @param value this should be the value for the given attribute
|
|
259
|
+
* @param dtype optional dtype to set info for the app how to render this data.
|
|
260
|
+
* @returns
|
|
261
|
+
*/
|
|
262
|
+
const UPDATE_REPORT_DATA = (reportKey, attributeKey, value, dtype) => {
|
|
263
|
+
return expressionUtils_expressionGen.generateExpression('UPDATE_REPORT_DATA', undefined, reportKey, attributeKey, value, dtype);
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Method to remove one attribute (key and value) from the report
|
|
267
|
+
* @param reportKey
|
|
268
|
+
* @param attributeKey
|
|
269
|
+
* @returns
|
|
270
|
+
*/
|
|
271
|
+
const REMOVE_REPORT_DATA = (reportKey, attributeKey) => {
|
|
272
|
+
return expressionUtils_expressionGen.generateExpression('REMOVE_REPORT_DATA', undefined, reportKey, attributeKey);
|
|
273
|
+
};
|
|
274
|
+
const setReportIcon = (reportKey, icon) => {
|
|
275
|
+
return UPDATE_REPORT_DATA(reportKey, 'icon', icon);
|
|
276
|
+
};
|
|
277
|
+
const setReportMessage = (reportKey, content, asTranslationKey) => {
|
|
278
|
+
return UPDATE_REPORT_DATA(reportKey, 'message', content, asTranslationKey ? undefined : 'rawMessage');
|
|
279
|
+
};
|
|
280
|
+
const setReportSummary = (reportKey, content, asTranslationKey) => {
|
|
281
|
+
return UPDATE_REPORT_DATA(reportKey, 'summary', content, asTranslationKey ? undefined : 'rawMessage');
|
|
282
|
+
};
|
|
283
|
+
// ##################
|
|
284
|
+
// Prefill rule methods:
|
|
285
|
+
const GET_LAST_SURVEY_ITEM = (surveyKey, itemKey, submittedLaterThan) => {
|
|
286
|
+
return expressionUtils_expressionGen.generateExpression('GET_LAST_SURVEY_ITEM', undefined, surveyKey, itemKey, submittedLaterThan ? types_duration.durationObjectToSeconds(submittedLaterThan) : undefined);
|
|
287
|
+
};
|
|
288
|
+
// ##################
|
|
289
|
+
// Context previous responses methods:
|
|
290
|
+
const LAST_RESPONSES_BY_KEY = (surveyKey, limit) => {
|
|
291
|
+
return expressionUtils_expressionGen.generateExpression('LAST_RESPONSES_BY_KEY', undefined, surveyKey, limit);
|
|
292
|
+
};
|
|
293
|
+
const ALL_RESPONSES_SINCE = (sinceTimestamp) => {
|
|
294
|
+
return expressionUtils_expressionGen.generateExpression('ALL_RESPONSES_SINCE', undefined, sinceTimestamp);
|
|
295
|
+
};
|
|
296
|
+
const RESPONSES_SINCE_BY_KEY = (sinceTimestamp, surveyKey) => {
|
|
297
|
+
return expressionUtils_expressionGen.generateExpression('RESPONSES_SINCE_BY_KEY', undefined, sinceTimestamp, surveyKey);
|
|
173
298
|
};
|
|
174
299
|
// ##################
|
|
175
300
|
// Extra methods:
|
|
@@ -178,6 +303,9 @@ const multipleChoiceOptionsSelected = (itemKey, ...optionKeys) => expressionUtil
|
|
|
178
303
|
const multipleChoiceAllOfTheseSelected = (itemKey, ...optionKeys) => and(...optionKeys.map(option => expressionUtils_expressionGen.generateExpression('responseHasKeysAny', undefined, itemKey, [constants_keyDefinitions.responseGroupKey, constants_keyDefinitions.multipleChoiceKey].join('.'), option)));
|
|
179
304
|
const multipleChoiceOnlyOtherKeysSelected = (itemKey, ...optionKeys) => expressionUtils_expressionGen.generateExpression('responseHasOnlyKeysOtherThan', undefined, itemKey, [constants_keyDefinitions.responseGroupKey, constants_keyDefinitions.multipleChoiceKey].join('.'), ...optionKeys);
|
|
180
305
|
const singleChoiceOnlyOtherOptionSelected = (itemKey, ...optionKeys) => expressionUtils_expressionGen.generateExpression('responseHasOnlyKeysOtherThan', undefined, itemKey, [constants_keyDefinitions.responseGroupKey, constants_keyDefinitions.singleChoiceKey].join('.'), ...optionKeys);
|
|
306
|
+
const consentAcceptedCondition = (itemKey) => {
|
|
307
|
+
return hasResponseKey(itemKey, [constants_keyDefinitions.responseGroupKey, constants_keyDefinitions.consentKey].join('.'));
|
|
308
|
+
};
|
|
181
309
|
const stopParticipation = () => UPDATE_STUDY_STATUS('inactive');
|
|
182
310
|
const finishParticipation = () => UPDATE_STUDY_STATUS('finished');
|
|
183
311
|
/**
|
|
@@ -216,6 +344,8 @@ const NativeStudyEngineExpressions = {
|
|
|
216
344
|
responseHasOnlyKeysOtherThan,
|
|
217
345
|
getResponseValueAsNum,
|
|
218
346
|
getResponseValueAsStr,
|
|
347
|
+
hasResponseKey,
|
|
348
|
+
hasResponseKeyWithValue,
|
|
219
349
|
countResponseItems,
|
|
220
350
|
// Old responses
|
|
221
351
|
checkConditionForOldResponses,
|
|
@@ -226,8 +356,24 @@ const NativeStudyEngineExpressions = {
|
|
|
226
356
|
getSurveyKeyAssignedFrom,
|
|
227
357
|
getSurveyKeyAssignedUntil,
|
|
228
358
|
hasStudyStatus,
|
|
229
|
-
|
|
359
|
+
hasParticipantFlagKeyAndValue,
|
|
360
|
+
hasParticipantFlagKey,
|
|
230
361
|
lastSubmissionDateOlderThan,
|
|
362
|
+
hasMessageTypeAssigned,
|
|
363
|
+
getMessageNextTime,
|
|
364
|
+
incomingParticipantState: {
|
|
365
|
+
// for merge event
|
|
366
|
+
getStudyEntryTime: getStudyEntryTimeForIncoming,
|
|
367
|
+
hasSurveyKeyAssigned: hasSurveyKeyAssignedForIncoming,
|
|
368
|
+
getSurveyKeyAssignedFrom: getSurveyKeyAssignedFromForIncoming,
|
|
369
|
+
getSurveyKeyAssignedUntil: getSurveyKeyAssignedUntilForIncoming,
|
|
370
|
+
hasStudyStatus: hasStudyStatusForIncoming,
|
|
371
|
+
hasParticipantFlagKeyAndValue: hasParticipantFlagKeyAndValueForIncoming,
|
|
372
|
+
hasParticipantFlagKey: hasParticipantFlagKeyForIncoming,
|
|
373
|
+
lastSubmissionDateOlderThan: lastSubmissionDateOlderThanForIncoming,
|
|
374
|
+
hasMessageTypeAssigned: hasMessageTypeAssignedForIncoming,
|
|
375
|
+
getMessageNextTime: getMessageNextTimeForIncoming,
|
|
376
|
+
}
|
|
231
377
|
},
|
|
232
378
|
// logical and comparision
|
|
233
379
|
eq,
|
|
@@ -255,9 +401,23 @@ const StudyEngineActions = {
|
|
|
255
401
|
remove: REMOVE_SURVEY_BY_KEY,
|
|
256
402
|
},
|
|
257
403
|
reports: {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
404
|
+
init: INIT_REPORT,
|
|
405
|
+
cancel: CANCEL_REPORT,
|
|
406
|
+
updateData: UPDATE_REPORT_DATA,
|
|
407
|
+
removeData: REMOVE_REPORT_DATA,
|
|
408
|
+
// Extra methods:
|
|
409
|
+
setReportIcon,
|
|
410
|
+
setReportMessage,
|
|
411
|
+
setReportSummary,
|
|
412
|
+
},
|
|
413
|
+
messages: {
|
|
414
|
+
add: ADD_MESSAGE,
|
|
415
|
+
removeAll: REMOVE_ALL_MESSAGES,
|
|
416
|
+
remove: REMOVE_MESSAGES_BY_TYPE,
|
|
417
|
+
},
|
|
418
|
+
confidentialResponses: {
|
|
419
|
+
removeByKey: REMOVE_CONFIDENTIAL_RESPONSE_BY_KEY,
|
|
420
|
+
removeAll: REMOVE_ALL_CONFIDENTIAL_RESPONSES,
|
|
261
421
|
},
|
|
262
422
|
// Extra methods:
|
|
263
423
|
stopParticipation,
|
|
@@ -271,10 +431,20 @@ const StudyEngine = Object.assign(Object.assign(Object.assign({}, NativeStudyEng
|
|
|
271
431
|
any: multipleChoiceOptionsSelected,
|
|
272
432
|
none: multipleChoiceOnlyOtherKeysSelected,
|
|
273
433
|
all: multipleChoiceAllOfTheseSelected,
|
|
434
|
+
}, consent: {
|
|
435
|
+
accepted: consentAcceptedCondition,
|
|
274
436
|
}, survey: {
|
|
275
437
|
isActive: hasSurveyKeyActive,
|
|
276
438
|
validFromOlderThan: hasSurveyKeyValidFromOlderThan,
|
|
277
439
|
validUntilSoonerThan: hasSurveyKeyValidUntilSoonerThan,
|
|
440
|
+
}, prefillRules: {
|
|
441
|
+
GET_LAST_SURVEY_ITEM,
|
|
442
|
+
}, contextRules: {
|
|
443
|
+
previousResponses: {
|
|
444
|
+
LAST_RESPONSES_BY_KEY,
|
|
445
|
+
ALL_RESPONSES_SINCE,
|
|
446
|
+
RESPONSES_SINCE_BY_KEY,
|
|
447
|
+
}
|
|
278
448
|
} });
|
|
279
449
|
|
|
280
450
|
exports.NativeStudyEngineExpressions = NativeStudyEngineExpressions;
|