@baravak/risloo-profile-cli 3.1.0
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/.github/workflows/push.yml +14 -0
- package/.prettierrc +16 -0
- package/.yarn/releases/yarn-1.22.19.cjs +147529 -0
- package/.yarnrc.yml +1 -0
- package/README.md +98 -0
- package/bin/risloo.js +9 -0
- package/package.json +44 -0
- package/src/Gift.js +29 -0
- package/src/Profile.js +405 -0
- package/src/cli-commands/Executor.js +118 -0
- package/src/cli-commands/ExtractExecutor.js +194 -0
- package/src/cli-commands/GiftExecutor.js +56 -0
- package/src/cli-commands/utilities/BaseOps.js +71 -0
- package/src/cli-commands/utilities/Benchmarker.js +88 -0
- package/src/cli-commands/utilities/CustomErrors.js +14 -0
- package/src/cli-commands/utilities/Response.js +59 -0
- package/src/cli-commands/utilities/STATUSES.js +16 -0
- package/src/cli-commands/utilities/Status.js +9 -0
- package/src/cli.js +125 -0
- package/src/handlebars/helpers/abs.js +8 -0
- package/src/handlebars/helpers/addCommas.js +8 -0
- package/src/handlebars/helpers/array.js +8 -0
- package/src/handlebars/helpers/assignGlobal.js +9 -0
- package/src/handlebars/helpers/boolean.js +19 -0
- package/src/handlebars/helpers/ceil.js +8 -0
- package/src/handlebars/helpers/concat.js +8 -0
- package/src/handlebars/helpers/cos.js +8 -0
- package/src/handlebars/helpers/displacePoint.js +11 -0
- package/src/handlebars/helpers/ellipsisChars.js +10 -0
- package/src/handlebars/helpers/ellipsisLines.js +11 -0
- package/src/handlebars/helpers/first.js +11 -0
- package/src/handlebars/helpers/floor.js +8 -0
- package/src/handlebars/helpers/forLoop.js +15 -0
- package/src/handlebars/helpers/getArrOfProp.js +8 -0
- package/src/handlebars/helpers/isArray.js +8 -0
- package/src/handlebars/helpers/join.js +10 -0
- package/src/handlebars/helpers/last.js +11 -0
- package/src/handlebars/helpers/lineWrap.js +28 -0
- package/src/handlebars/helpers/math.js +24 -0
- package/src/handlebars/helpers/modulo.js +8 -0
- package/src/handlebars/helpers/normalizeAngle.js +7 -0
- package/src/handlebars/helpers/object.js +8 -0
- package/src/handlebars/helpers/objectEntries.js +8 -0
- package/src/handlebars/helpers/polarToCartesian.js +14 -0
- package/src/handlebars/helpers/prepend.js +10 -0
- package/src/handlebars/helpers/profiles/bar.js +45 -0
- package/src/handlebars/helpers/profiles/calcGaugeSidePoints.js +34 -0
- package/src/handlebars/helpers/profiles/gauge.js +61 -0
- package/src/handlebars/helpers/profiles/polygon.js +40 -0
- package/src/handlebars/helpers/reverse.js +9 -0
- package/src/handlebars/helpers/roundToTwo.js +8 -0
- package/src/handlebars/helpers/setVar.js +8 -0
- package/src/handlebars/helpers/sin.js +8 -0
- package/src/handlebars/helpers/split.js +8 -0
- package/src/handlebars/helpers/tan.js +8 -0
- package/src/handlebars/helpers/ternary.js +9 -0
- package/src/handlebars/helpers/toDeg.js +8 -0
- package/src/handlebars/helpers/toRad.js +8 -0
- package/src/handlebars/helpers/withGroup.js +20 -0
- package/src/handlebars/helpers/wrapOnNewline.js +11 -0
- package/src/handlebars/helpers.js +86 -0
- package/src/handlebars/importPartials.js +40 -0
- package/src/handlebars/init.js +15 -0
- package/src/publish/bot.js +91 -0
- package/src/publish/json/gift/gift.json +16 -0
- package/src/publish/json/profiles/16PF93.json +201 -0
- package/src/publish/json/profiles/AEQ93.json +96 -0
- package/src/publish/json/profiles/AMS93.json +102 -0
- package/src/publish/json/profiles/AMS9A.json +102 -0
- package/src/publish/json/profiles/BAOMEIS93.json +99 -0
- package/src/publish/json/profiles/BEQI93.json +1589 -0
- package/src/publish/json/profiles/CAATS93.json +11355 -0
- package/src/publish/json/profiles/CADS93.json +351 -0
- package/src/publish/json/profiles/CARSP93.json +96 -0
- package/src/publish/json/profiles/CERQ93.json +106 -0
- package/src/publish/json/profiles/CRAAS93.json +98 -0
- package/src/publish/json/profiles/CSI93.json +143 -0
- package/src/publish/json/profiles/DSWLS93.json +93 -0
- package/src/publish/json/profiles/EMSS93.json +116 -0
- package/src/publish/json/profiles/FACES93.json +106 -0
- package/src/publish/json/profiles/FTEPT93.json +102 -0
- package/src/publish/json/profiles/GMIT93.json +98 -0
- package/src/publish/json/profiles/HPL93.json +102 -0
- package/src/publish/json/profiles/IBT93.json +106 -0
- package/src/publish/json/profiles/IUS93.json +93 -0
- package/src/publish/json/profiles/JCSI93.json +102 -0
- package/src/publish/json/profiles/JPFQ93.json +1 -0
- package/src/publish/json/profiles/KJGI93.json +100 -0
- package/src/publish/json/profiles/LMIQ93.json +109 -0
- package/src/publish/json/profiles/MMFAD93.json +103 -0
- package/src/publish/json/profiles/MMFAD9A.json +103 -0
- package/src/publish/json/profiles/MOCI93.json +100 -0
- package/src/publish/json/profiles/OBQ4493.json +96 -0
- package/src/publish/json/profiles/PIES93.json +104 -0
- package/src/publish/json/profiles/PIES9A.json +104 -0
- package/src/publish/json/profiles/PMCIEF93.json +1 -0
- package/src/publish/json/profiles/PSWQ93.json +97 -0
- package/src/publish/json/profiles/RIASEC93.json +2511 -0
- package/src/publish/json/profiles/SAFE93.json +110 -0
- package/src/publish/json/profiles/SASQ93.json +92 -0
- package/src/publish/json/profiles/SCASP93.json +611 -0
- package/src/publish/json/profiles/SDCAQ93.json +96 -0
- package/src/publish/json/profiles/STAIY93.json +98 -0
- package/src/publish/json/profiles/WAQ93.json +100 -0
- package/src/publish/json/profiles/YBOCS93.json +1322 -0
- package/src/publish/json/profiles/empty.json +139 -0
- package/src/publish/new-version.hbs +11 -0
- package/src/publish/test.js +109 -0
- package/src/qrcode/qrCodeGenerator.js +14 -0
- package/src/qrcode/qrRender.js +229 -0
- package/src/samples/16PF93.js +158 -0
- package/src/samples/AEQ93.js +121 -0
- package/src/samples/AMS93.js +139 -0
- package/src/samples/AMS9A.js +9 -0
- package/src/samples/BAOMEIS93.js +146 -0
- package/src/samples/BEQI93.js +255 -0
- package/src/samples/CAATS93.js +218 -0
- package/src/samples/CADS93.js +161 -0
- package/src/samples/CARSP93.js +134 -0
- package/src/samples/CERQ93.js +195 -0
- package/src/samples/CRAAS93.js +141 -0
- package/src/samples/CSI93.js +315 -0
- package/src/samples/DSWLS93.js +112 -0
- package/src/samples/EMSS93.js +178 -0
- package/src/samples/FACES93.js +225 -0
- package/src/samples/FTEPT93.js +167 -0
- package/src/samples/GMIT93.js +142 -0
- package/src/samples/HPL93.js +132 -0
- package/src/samples/IBT93.js +99 -0
- package/src/samples/IUS93.js +204 -0
- package/src/samples/JCSI93.js +174 -0
- package/src/samples/JPFQ93.js +74 -0
- package/src/samples/KJGI93.js +136 -0
- package/src/samples/LMIQ93.js +188 -0
- package/src/samples/MMFAD93.js +135 -0
- package/src/samples/MMFAD9A.js +31 -0
- package/src/samples/MOCI93.js +128 -0
- package/src/samples/OBQ4493.js +132 -0
- package/src/samples/PIES93.js +228 -0
- package/src/samples/PIES9A.js +32 -0
- package/src/samples/PMCIEF93.js +64 -0
- package/src/samples/PSWQ93.js +126 -0
- package/src/samples/RIASEC93.js +144 -0
- package/src/samples/SAFE93.js +64 -0
- package/src/samples/SASQ93.js +130 -0
- package/src/samples/SCASP93.js +207 -0
- package/src/samples/SDCAQ93.js +174 -0
- package/src/samples/STAIY93.js +159 -0
- package/src/samples/WAQ93.js +208 -0
- package/src/samples/YBOCS93.js +583 -0
- package/src/samples/empty.js +53 -0
- package/views/gift.hbs +160 -0
- package/views/profiles/fonts.css +18 -0
- package/views/profiles/layout.hbs +27 -0
- package/views/profiles/samples/16PF93.hbs +54 -0
- package/views/profiles/samples/AEQ93.hbs +31 -0
- package/views/profiles/samples/AMS93.hbs +97 -0
- package/views/profiles/samples/AMS9A.hbs +1 -0
- package/views/profiles/samples/BAOMEIS93.hbs +48 -0
- package/views/profiles/samples/BEQI93.hbs +118 -0
- package/views/profiles/samples/CAATS93.hbs +251 -0
- package/views/profiles/samples/CADS93.hbs +104 -0
- package/views/profiles/samples/CARSP93.hbs +26 -0
- package/views/profiles/samples/CERQ93.hbs +115 -0
- package/views/profiles/samples/CRAAS93.hbs +88 -0
- package/views/profiles/samples/CSI93_1.hbs +110 -0
- package/views/profiles/samples/CSI93_2.hbs +76 -0
- package/views/profiles/samples/DSWLS93.hbs +26 -0
- package/views/profiles/samples/EMSS93.hbs +101 -0
- package/views/profiles/samples/FACES93_1.hbs +107 -0
- package/views/profiles/samples/FACES93_2.hbs +51 -0
- package/views/profiles/samples/FTEPT93.hbs +67 -0
- package/views/profiles/samples/GMIT93.hbs +45 -0
- package/views/profiles/samples/HPL93.hbs +36 -0
- package/views/profiles/samples/IBT93.hbs +67 -0
- package/views/profiles/samples/IUS93.hbs +123 -0
- package/views/profiles/samples/JCSI93.hbs +65 -0
- package/views/profiles/samples/JPFQ93.hbs +44 -0
- package/views/profiles/samples/KJGI93.hbs +57 -0
- package/views/profiles/samples/LMIQ93.hbs +82 -0
- package/views/profiles/samples/MMFAD93.hbs +35 -0
- package/views/profiles/samples/MMFAD9A.hbs +1 -0
- package/views/profiles/samples/MOCI93.hbs +60 -0
- package/views/profiles/samples/OBQ4493.hbs +61 -0
- package/views/profiles/samples/PIES93.hbs +67 -0
- package/views/profiles/samples/PIES9A.hbs +1 -0
- package/views/profiles/samples/PMCIEF93.hbs +8 -0
- package/views/profiles/samples/PSWQ93.hbs +32 -0
- package/views/profiles/samples/RIASEC93.hbs +38 -0
- package/views/profiles/samples/SAFE93.hbs +118 -0
- package/views/profiles/samples/SASQ93.hbs +45 -0
- package/views/profiles/samples/SCASP93.hbs +94 -0
- package/views/profiles/samples/SDCAQ93.hbs +68 -0
- package/views/profiles/samples/STAIY93.hbs +67 -0
- package/views/profiles/samples/WAQ93.hbs +74 -0
- package/views/profiles/samples/YBOCS93_1.hbs +96 -0
- package/views/profiles/samples/YBOCS93_2.hbs +115 -0
- package/views/profiles/samples/YBOCS93_3.hbs +93 -0
- package/views/profiles/samples/empty.hbs +10 -0
- package/views/profiles/sidebar.hbs +193 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
const { Profile, Dataset } = require("../Profile");
|
|
2
|
+
|
|
3
|
+
class SCASP93 extends Profile {
|
|
4
|
+
// Number of pages
|
|
5
|
+
static pages = 1;
|
|
6
|
+
|
|
7
|
+
// Labels of the sample
|
|
8
|
+
labels = {
|
|
9
|
+
L1: { eng: "total", fr: "نمره کل" },
|
|
10
|
+
L2: { eng: "panic_attack_and_agorophobia", fr: "اختلال هراس و ترس از فضای باز" },
|
|
11
|
+
L3: { eng: "separation_anxiety", fr: "اضطراب جدایی" },
|
|
12
|
+
L4: { eng: "physical_injury_fears", fr: "ترس از آسیب فیزیکی" },
|
|
13
|
+
L5: { eng: "social_phobia", fr: "ترس اجتماعی" },
|
|
14
|
+
L6: { eng: "obsessive_compulsive", fr: "وسواس فکری - عملی" },
|
|
15
|
+
L7: { eng: "generalized_anxiety_disorder", fr: "اضطراب عمومی (فراگیر)" },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
profileSpec = {
|
|
19
|
+
/* "sample" determines some important info about the sample and profile */
|
|
20
|
+
/* Default prerequisites: 1. gender, 2. age, 3. education */
|
|
21
|
+
/* "prerequisites" is synonym to "fields" in our program */
|
|
22
|
+
sample: {
|
|
23
|
+
name: "پرسشنامه اضطراب کودکان اسپنس - نسخه والدین" /* Name of the sample */,
|
|
24
|
+
multiProfile: false /* Whether the sample has multiple profiles or not */,
|
|
25
|
+
questions: true /* Determines whether to get questions from inital dataset or not */,
|
|
26
|
+
defaultFields: false /* Determines whether to have default prerequisites in the profile or not */,
|
|
27
|
+
fields: [
|
|
28
|
+
"child_name",
|
|
29
|
+
{ merge: ["child_age", "child_gender"], fr: "سن کودک / جنسیت", valueFormat: "{0} / {1}" },
|
|
30
|
+
{ eng: "birth_order", fr: "فرزند چندم" },
|
|
31
|
+
{ merge: ["sons", "daughters"], fr: "تعداد فرزندان (دختر / پسر)", valueFormat: "{1} دختر / {0} پسر" },
|
|
32
|
+
"father_education",
|
|
33
|
+
"father_job",
|
|
34
|
+
"mother_education",
|
|
35
|
+
"mother_job",
|
|
36
|
+
] /* In case you want to get some additional fields and show in the profile */,
|
|
37
|
+
},
|
|
38
|
+
/* "profile" determines the dimensions of the drawn profile (to be used in svg tag viewbox) */
|
|
39
|
+
/* calculating its dimensions carefully is of great importance */
|
|
40
|
+
profile: {
|
|
41
|
+
get dimensions() {
|
|
42
|
+
return {
|
|
43
|
+
width: 840 + 2 * this.padding.x,
|
|
44
|
+
height: 679 + 2 * this.padding.y,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
padding: {
|
|
48
|
+
x: 0,
|
|
49
|
+
y: 13,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
/* "raw" is the general term used for total data element in the profile */
|
|
53
|
+
raw: {
|
|
54
|
+
maxValue: 114 /* Maximum value of raw */,
|
|
55
|
+
offsetY: 80 /* Vertical offset between last item and raw */,
|
|
56
|
+
leftPos: 73 /* Left position of the raw rectangle */,
|
|
57
|
+
rect: {
|
|
58
|
+
width: 740 /* Width of the raw rectangle */,
|
|
59
|
+
height: 40 /* Height of the raw rectangle */,
|
|
60
|
+
br: 5 /* Border radius of the raw rectangle */,
|
|
61
|
+
},
|
|
62
|
+
label: {
|
|
63
|
+
offsetX: 23 /* Horizontal offset between label and raw rectangle */,
|
|
64
|
+
},
|
|
65
|
+
mark: {
|
|
66
|
+
maxValueOffsetX: 10 /* Horizontal offset between maximum value and raw rectangle */,
|
|
67
|
+
line: {
|
|
68
|
+
offsetY: 5 /* Vertical offset between mark line and raw rectangle */,
|
|
69
|
+
length: 10 /* Length of mark line */,
|
|
70
|
+
},
|
|
71
|
+
number: {
|
|
72
|
+
offsetY: 13 /* Vertical offset between mark line and mark number */,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
/* "descAnswer" determines the geometrical properties for the descriptive answer part */
|
|
77
|
+
descAnswer: {
|
|
78
|
+
offsetY: 40 /* Vertical offset between raw and descriptive answer rectangle */,
|
|
79
|
+
rect: {
|
|
80
|
+
width: 840 /* Width of the descriptive answer rectangle */,
|
|
81
|
+
height: 100 /* Height of the descriptive answer rectangle */,
|
|
82
|
+
br: 8 /* Border radius of the descriptive answer rectangle */,
|
|
83
|
+
padding: 20 /* Padding of the descriptive answer rectangle */,
|
|
84
|
+
},
|
|
85
|
+
content: {
|
|
86
|
+
lineHeight: 25 /* Line height of the descriptive answer */,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
/* "items" is the general term used for independent data elements to be drawn in the profile */
|
|
90
|
+
items: {
|
|
91
|
+
header: {
|
|
92
|
+
offsetY1: 17,
|
|
93
|
+
offsetY2: 42,
|
|
94
|
+
get height() {
|
|
95
|
+
return this.offsetY1 + this.offsetY2;
|
|
96
|
+
} /* Height of header row */,
|
|
97
|
+
legend: {
|
|
98
|
+
leftPos: 756 /* Left position of legend part of header */,
|
|
99
|
+
rect: {
|
|
100
|
+
width: 12 /* Width of legend rectangle */,
|
|
101
|
+
height: 12 /* Height of legend rectangle */,
|
|
102
|
+
br: 2 /* Border radius of legend rectangle */,
|
|
103
|
+
offsetX: 10 /* Horizontal offset between legend rectangles */,
|
|
104
|
+
get distanceX() {
|
|
105
|
+
return this.width + this.offsetX;
|
|
106
|
+
} /* Horizontal distance between legend rectangles */,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
} /* Header part of the items table */,
|
|
110
|
+
separatorLine: {
|
|
111
|
+
length: 840 /* Length of separator line between each row of the items table */,
|
|
112
|
+
},
|
|
113
|
+
maxValues: {
|
|
114
|
+
[this.labels.L2.eng]: 27,
|
|
115
|
+
[this.labels.L3.eng]: 18,
|
|
116
|
+
[this.labels.L4.eng]: 15,
|
|
117
|
+
[this.labels.L5.eng]: 18,
|
|
118
|
+
[this.labels.L6.eng]: 18,
|
|
119
|
+
[this.labels.L7.eng]: 18,
|
|
120
|
+
} /* Maximum value of items */,
|
|
121
|
+
questionNumbers: {
|
|
122
|
+
[this.labels.L2.eng]: [12, 19, 25, 27, 28, 30, 32, 33, 34],
|
|
123
|
+
[this.labels.L3.eng]: [5, 8, 11, 14, 15, 38],
|
|
124
|
+
[this.labels.L4.eng]: [2, 16, 21, 23, 29],
|
|
125
|
+
[this.labels.L5.eng]: [6, 7, 9, 10, 26, 31],
|
|
126
|
+
[this.labels.L6.eng]: [13, 17, 24, 35, 36, 37],
|
|
127
|
+
[this.labels.L7.eng]: [1, 3, 4, 18, 20, 22],
|
|
128
|
+
} /* Questions numbers array of each item */,
|
|
129
|
+
offsetY: 60 /* Vertical offset between two items */,
|
|
130
|
+
leftPosArr: [50, 282, 312] /* Left position array of items table cells */,
|
|
131
|
+
paddingY: 10 /* Vertical padding inside items table cell */,
|
|
132
|
+
rect: {
|
|
133
|
+
width: 50 /* Width of the items rectangle */,
|
|
134
|
+
height: 40 /* Height of the items rectangle */,
|
|
135
|
+
br: 4 /* Border radius of the items rectangle */,
|
|
136
|
+
offsetX: 9 /* Horizontal offset between two items rectangles */,
|
|
137
|
+
get distanceX() {
|
|
138
|
+
return this.width + this.offsetX;
|
|
139
|
+
} /* Horizontal distance between two items rectangles */,
|
|
140
|
+
intensities: {
|
|
141
|
+
0: {
|
|
142
|
+
fill: "white",
|
|
143
|
+
stroke: "#D6D3D1",
|
|
144
|
+
textFill: "#A8A29E",
|
|
145
|
+
},
|
|
146
|
+
1: {
|
|
147
|
+
fill: "#FCA5A5",
|
|
148
|
+
stroke: "none",
|
|
149
|
+
textFill: "white",
|
|
150
|
+
},
|
|
151
|
+
2: {
|
|
152
|
+
fill: "#EF4444",
|
|
153
|
+
stroke: "none",
|
|
154
|
+
textFill: "white",
|
|
155
|
+
},
|
|
156
|
+
3: {
|
|
157
|
+
fill: "#B91C1C",
|
|
158
|
+
stroke: "none",
|
|
159
|
+
textFill: "white",
|
|
160
|
+
} /* Fill and stroke of different intensities of items rectangles */,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
/* "labels" part which has to be provided for each profile */
|
|
165
|
+
labels: Object.values(this.labels),
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
constructor(dataset, options, config = {}) {
|
|
169
|
+
super();
|
|
170
|
+
this._init(dataset, options, config);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
_calcContext() {
|
|
174
|
+
const {
|
|
175
|
+
spec: { parameters: spec },
|
|
176
|
+
dataset,
|
|
177
|
+
} = this;
|
|
178
|
+
|
|
179
|
+
// Deconstructing the Spec of the Profile
|
|
180
|
+
const { raw: rawSpec, items: itemsSpec } = spec;
|
|
181
|
+
|
|
182
|
+
// Separate Raw Data from the Dataset
|
|
183
|
+
const rawData = dataset.score.shift();
|
|
184
|
+
|
|
185
|
+
const raw = {
|
|
186
|
+
mark: rawData.mark,
|
|
187
|
+
label: rawData.label,
|
|
188
|
+
width: (rawData.mark / rawSpec.maxValue) * rawSpec.rect.width,
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const items = dataset.score.map((data) => ({
|
|
192
|
+
mark: data.mark,
|
|
193
|
+
label: data.label,
|
|
194
|
+
maxValue: itemsSpec.maxValues[data.label.eng],
|
|
195
|
+
questions: itemsSpec.questionNumbers[data.label.eng].map((number) => ({
|
|
196
|
+
number,
|
|
197
|
+
intensity: itemsSpec.rect.intensities[dataset.questions[number - 1].user_answered - 1],
|
|
198
|
+
})),
|
|
199
|
+
}));
|
|
200
|
+
|
|
201
|
+
const descAnswer = dataset.questions[dataset.questions.length - 1].user_answered;
|
|
202
|
+
|
|
203
|
+
return [{ raw, items, descAnswer }];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
module.exports = SCASP93;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
const { Profile, FS } = require("../Profile");
|
|
2
|
+
|
|
3
|
+
class SDCAQ93 extends Profile {
|
|
4
|
+
// Number of pages
|
|
5
|
+
static pages = 1;
|
|
6
|
+
|
|
7
|
+
// Labels of the sample
|
|
8
|
+
labels = {
|
|
9
|
+
L1: { eng: "thought_suppression", fr: "واپس زنی\nافکار نگرانکننده" },
|
|
10
|
+
L2: { eng: "thought_substitution", fr: "جانشینی افکار مثبت\nبه جای افکار نگرانکننده" },
|
|
11
|
+
L3: { eng: "distraction_subscale", fr: "استفاده از توجه برگردانی\nبرای قطع روند نگرانی (حواسپرتی)" },
|
|
12
|
+
L4: { eng: "avoidance_of_threatening_stimuli", fr: "اجتناب از موقعیتها و فعالیتهای\nفعالساز افکار نگرانکننده" },
|
|
13
|
+
L5: { eng: "transformation_of_images_into_thoughts", fr: "تغییر تصاویر ذهنی\nبه افکار کلامی" },
|
|
14
|
+
L6: { eng: "raw", fr: "نمره کل" },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
profileSpec = {
|
|
18
|
+
/* "sample" determines some important info about the sample and profile */
|
|
19
|
+
/* Default prerequisites: 1. gender, 2. age, 3. education */
|
|
20
|
+
/* "prerequisites" is synonym to "fields" in our program */
|
|
21
|
+
sample: {
|
|
22
|
+
name: "پرسشنامه اجتناب شناختی سکستون وداگاس" /* Name of the sample */,
|
|
23
|
+
multiProfile: false /* Whether the sample has multiple profiles or not */,
|
|
24
|
+
questions: false /* Determines whether to get questions from inital dataset or not */,
|
|
25
|
+
defaultFields: true /* Determines whether to have default prerequisites in the profile or not */,
|
|
26
|
+
fields: ["marital_status"] /* In case you want to get some additional fields and show in the profile */,
|
|
27
|
+
},
|
|
28
|
+
/* "profile" determines the dimensions of the drawn profile (to be used in svg tag viewbox) */
|
|
29
|
+
/* calculating its dimensions carefully is of great importance */
|
|
30
|
+
profile: {
|
|
31
|
+
get dimensions() {
|
|
32
|
+
return {
|
|
33
|
+
width: 832 + 2 * this.padding.x,
|
|
34
|
+
height: 500 + 2 * this.padding.y,
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
padding: {
|
|
38
|
+
x: 35,
|
|
39
|
+
y: 15,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
/* "raw" is the general term used for total data element in the profile */
|
|
43
|
+
raw: {
|
|
44
|
+
minValue: 25 /* Minimum values of raw marks provided by the dataset */,
|
|
45
|
+
maxValue: 125 /* Maximum values of raw marks provided by the dataset */,
|
|
46
|
+
offsetX: 110 /* Horizontal offset from items */,
|
|
47
|
+
ticks: {
|
|
48
|
+
num: 5 /* Number of ticks */,
|
|
49
|
+
line: {
|
|
50
|
+
width: 10 /* Width of the tick line */,
|
|
51
|
+
offsetX: 7 /* Horizontal offset from the rectangle */,
|
|
52
|
+
},
|
|
53
|
+
number: {
|
|
54
|
+
offsetX: 4 /* Horizontal Offset from the line */,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
rect: {
|
|
58
|
+
width: 50 /* Width of the raw rectangle */,
|
|
59
|
+
get borderRadius() {
|
|
60
|
+
return this.width / 2;
|
|
61
|
+
} /* Border radius of the raw rectangle */,
|
|
62
|
+
},
|
|
63
|
+
heightCoeff: 4 /* Used for converting mark to the height */,
|
|
64
|
+
},
|
|
65
|
+
/* "items" is the general term used for independent data elements to be drawn in the profile */
|
|
66
|
+
items: {
|
|
67
|
+
minValue: 5 /* Minimum value of items mark provided by the dataset */,
|
|
68
|
+
maxValue: 25 /* Maximum value of items mark provided by the dataset */,
|
|
69
|
+
offsetX: 228 /* Horizontal offset between items and left side of profile */,
|
|
70
|
+
offsetY: 40 /* Vertical offset between two consecutive item in the profile */,
|
|
71
|
+
get distanceY() {
|
|
72
|
+
return this.offsetY + this.rect.height;
|
|
73
|
+
} /* Distance between two consecutive item in the profile */,
|
|
74
|
+
totalHeight: "" /* To be calculated in the class with the function provided */,
|
|
75
|
+
calcTotalHeight: function (n) {
|
|
76
|
+
return this.distanceY * (n - 1) + this.rect.height;
|
|
77
|
+
} /* Method for calculating the total height of items */,
|
|
78
|
+
ticks: {
|
|
79
|
+
num: 5 /* Number of ticks */,
|
|
80
|
+
heightOffset: 45 /* Half length that the ticks lines of items is greater than items total heigth */,
|
|
81
|
+
numberOffset: {
|
|
82
|
+
x: 10 /* Horizontal distance from the line */,
|
|
83
|
+
y: 10 /* Vertical distance from the line */,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
rect: {
|
|
87
|
+
height: 50 /* Height of the items rectangle */,
|
|
88
|
+
get borderRadius() {
|
|
89
|
+
return this.height / 2;
|
|
90
|
+
} /* Border Radius of the items rectangle */,
|
|
91
|
+
colors: ["#A78BFA", "#10B981", "#EC4899", "#F59E0B", "#007BA4"] /* Colors used for theming items body parts */,
|
|
92
|
+
},
|
|
93
|
+
widthCoeff: 16 /* Used for converting mark to the width */,
|
|
94
|
+
label: {
|
|
95
|
+
offsetX: 10 /* Horizontal offset of label from item */,
|
|
96
|
+
offsetY: 13 /* Half vertical offset between two lines of label */,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
/* "labels" part which has to be provided for each profile */
|
|
100
|
+
labels: Object.values(this.labels),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
constructor(dataset, options, config = {}) {
|
|
104
|
+
super();
|
|
105
|
+
this._init(dataset, options, config);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
_calcContext() {
|
|
109
|
+
const {
|
|
110
|
+
spec: { parameters: spec },
|
|
111
|
+
dataset,
|
|
112
|
+
} = this;
|
|
113
|
+
|
|
114
|
+
const { raw: rawSpec, items: itemsSpec } = spec;
|
|
115
|
+
|
|
116
|
+
// Separate Raw Data from the Dataset
|
|
117
|
+
const rawData = dataset.score.pop();
|
|
118
|
+
|
|
119
|
+
// ّInit Spec
|
|
120
|
+
spec.items.totalHeight = spec.items.calcTotalHeight(dataset.score.length);
|
|
121
|
+
|
|
122
|
+
// Gather Required Info for Raw
|
|
123
|
+
const raw = {
|
|
124
|
+
label: rawData.label,
|
|
125
|
+
mark: rawData.mark,
|
|
126
|
+
height: rawData.mark * rawSpec.heightCoeff,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Gather Required Info for Items
|
|
130
|
+
const items = dataset.score.map((data, index) => ({
|
|
131
|
+
label: data.label,
|
|
132
|
+
mark: data.mark,
|
|
133
|
+
width: data.mark * itemsSpec.widthCoeff,
|
|
134
|
+
fill: itemsSpec.rect.colors[index],
|
|
135
|
+
}));
|
|
136
|
+
|
|
137
|
+
// Calculate Ticks Numbers Array for Raw
|
|
138
|
+
const rawTicksNumbers = FS.createArithmeticSequence(
|
|
139
|
+
rawSpec.minValue,
|
|
140
|
+
(rawSpec.maxValue - rawSpec.minValue) / (rawSpec.ticks.num - 1),
|
|
141
|
+
rawSpec.ticks.num
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
// Gather Required Info for Raw Ticks
|
|
145
|
+
const rawTicks = rawTicksNumbers.map((tick) => ({
|
|
146
|
+
number: tick,
|
|
147
|
+
bottomPos: tick * rawSpec.heightCoeff,
|
|
148
|
+
}));
|
|
149
|
+
|
|
150
|
+
// Calculate Ticks Numbers Array for Items
|
|
151
|
+
const itemsTicksNumbers = FS.createArithmeticSequence(
|
|
152
|
+
itemsSpec.minValue,
|
|
153
|
+
(itemsSpec.maxValue - itemsSpec.minValue) / (itemsSpec.ticks.num - 1),
|
|
154
|
+
itemsSpec.ticks.num
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
// Gather Required Info for Items Ticks
|
|
158
|
+
const itemsTicks = itemsTicksNumbers.map((tick) => ({
|
|
159
|
+
number: tick,
|
|
160
|
+
leftPos: tick * itemsSpec.widthCoeff,
|
|
161
|
+
}));
|
|
162
|
+
|
|
163
|
+
return [
|
|
164
|
+
{
|
|
165
|
+
raw,
|
|
166
|
+
items,
|
|
167
|
+
rawTicks,
|
|
168
|
+
itemsTicks,
|
|
169
|
+
},
|
|
170
|
+
];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
module.exports = SDCAQ93;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
const { Profile, FS } = require("../Profile");
|
|
2
|
+
|
|
3
|
+
class STAIY93 extends Profile {
|
|
4
|
+
// Number of pages
|
|
5
|
+
static pages = 1;
|
|
6
|
+
|
|
7
|
+
// Labels of the sample
|
|
8
|
+
labels = {
|
|
9
|
+
L1: { eng: "trait", fr: "رگه اضطراب" },
|
|
10
|
+
L2: { eng: "state", fr: "حالت اضطراب" },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
profileSpec = {
|
|
14
|
+
/* "sample" determines some important info about the sample and profile */
|
|
15
|
+
/* Default prerequisites: 1. gender, 2. age, 3. education */
|
|
16
|
+
/* "prerequisites" is synonym to "fields" in our program */
|
|
17
|
+
sample: {
|
|
18
|
+
name: "پرسشنامه حالت - رگه اضطراب اسپیلبرگر" /* Name of the sample */,
|
|
19
|
+
multiProfile: false /* Whether the sample has multiple profiles or not */,
|
|
20
|
+
questions: false /* Determines whether to get questions from inital dataset or not */,
|
|
21
|
+
defaultFields: true /* Determines whether to have default prerequisites in the profile or not */,
|
|
22
|
+
fields: ["marital_status"] /* In case you want to get some additional fields and show in the profile */,
|
|
23
|
+
},
|
|
24
|
+
/* "profile" determines the dimensions of the drawn profile (to be used in svg tag viewbox) */
|
|
25
|
+
/* calculating its dimensions carefully is of great importance */
|
|
26
|
+
profile: {
|
|
27
|
+
get dimensions() {
|
|
28
|
+
return {
|
|
29
|
+
width: 550 + 2 * this.padding.x,
|
|
30
|
+
height: 476 + 2 * this.padding.y,
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
padding: {
|
|
34
|
+
x: 70,
|
|
35
|
+
y: 70,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
/* "items" is the general term used for independent data elements to be drawn in the profile */
|
|
39
|
+
items: {
|
|
40
|
+
rect: {
|
|
41
|
+
width: 180 /* Width of label rectangle */,
|
|
42
|
+
height: 42 /* Height of label rectangle */,
|
|
43
|
+
br: 10 /* Border radius of label rectangle */,
|
|
44
|
+
offsetX: 190 /* Horizontal offset between label rectangles */,
|
|
45
|
+
offsetY: 84 /* Vetical offset between label rectangles and items */,
|
|
46
|
+
get distanceY() {
|
|
47
|
+
return this.height + this.offsetY;
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
offsetX: 2 /* Horizontal offset between two items element */,
|
|
51
|
+
minValue: 20 /* Minimum value of items data element */,
|
|
52
|
+
maxValue: 80 /* Maximum value of items data element */,
|
|
53
|
+
get range() {
|
|
54
|
+
return this.maxValue - this.minValue;
|
|
55
|
+
},
|
|
56
|
+
trait: {
|
|
57
|
+
stops: [20, 34, 45, 56, 80],
|
|
58
|
+
fill: "#581C87",
|
|
59
|
+
circle: {
|
|
60
|
+
R: 175 /* Radius of the outer circle of the items element */,
|
|
61
|
+
r: 130 /* Radius of the inner circle of the items element */,
|
|
62
|
+
brs: {
|
|
63
|
+
tl: 0 /* Top left border radius */,
|
|
64
|
+
bl: 0 /* Bottom left border radius */,
|
|
65
|
+
tr: 0 /* Top right border radius */,
|
|
66
|
+
br: 0 /* Bottom right border radius */,
|
|
67
|
+
} /* Border radiuses at each end of the gauge of the items element */,
|
|
68
|
+
angles: {
|
|
69
|
+
start: FS.toRadians(-90),
|
|
70
|
+
end: FS.toRadians(90),
|
|
71
|
+
} /* Angles of each end of the items element */,
|
|
72
|
+
direction: false /* Clockwise direction for the items gauge element */,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
state: {
|
|
76
|
+
stops: [20, 30, 42, 53, 80],
|
|
77
|
+
fill: "#BE185D",
|
|
78
|
+
circle: {
|
|
79
|
+
R: 175 /* Radius of the outer circle of the items element */,
|
|
80
|
+
r: 130 /* Radius of the inner circle of the items element */,
|
|
81
|
+
brs: {
|
|
82
|
+
tl: 0 /* Top left border radius */,
|
|
83
|
+
bl: 0 /* Bottom left border radius */,
|
|
84
|
+
tr: 0 /* Top right border radius */,
|
|
85
|
+
br: 0 /* Bottom right border radius */,
|
|
86
|
+
} /* Border radiuses at each end of the gauge of the items element */,
|
|
87
|
+
angles: {
|
|
88
|
+
start: FS.toRadians(-90),
|
|
89
|
+
end: FS.toRadians(90),
|
|
90
|
+
} /* Angles of each end of the items element */,
|
|
91
|
+
direction: true /* Clockwise direction for the items gauge element */,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
interprets: [
|
|
95
|
+
{ opacity: 0.4, eng: "none", fr: "هیچ یا کمترین حد" },
|
|
96
|
+
{ opacity: 0.6, eng: "mild", fr: "خفیف" },
|
|
97
|
+
{ opacity: 0.8, eng: "moderate", fr: "متوسط" },
|
|
98
|
+
{ opacity: 1, eng: "severe", fr: "شدید" },
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
/* "labels" part which has to be provided for each profile */
|
|
102
|
+
labels: Object.values(this.labels),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
constructor(dataset, options, config = {}) {
|
|
106
|
+
super();
|
|
107
|
+
this._init(dataset, options, config);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_calcContext() {
|
|
111
|
+
const {
|
|
112
|
+
spec: { parameters: spec },
|
|
113
|
+
dataset,
|
|
114
|
+
} = this;
|
|
115
|
+
|
|
116
|
+
// Deconstructing the Spec of the Profile
|
|
117
|
+
const { items: itemsSpec } = spec;
|
|
118
|
+
|
|
119
|
+
const items = dataset.score.map((data) => ({
|
|
120
|
+
label: data.label,
|
|
121
|
+
mark: data.mark,
|
|
122
|
+
angle: this._markToAngle(
|
|
123
|
+
data.mark.value,
|
|
124
|
+
itemsSpec.minValue,
|
|
125
|
+
itemsSpec.maxValue,
|
|
126
|
+
itemsSpec[data.label.eng].circle.angles,
|
|
127
|
+
itemsSpec[data.label.eng].circle.direction
|
|
128
|
+
),
|
|
129
|
+
stops: itemsSpec[data.label.eng].stops.map((stop) => ({
|
|
130
|
+
mark: stop,
|
|
131
|
+
angle: this._markToAngle(
|
|
132
|
+
stop,
|
|
133
|
+
itemsSpec.minValue,
|
|
134
|
+
itemsSpec.maxValue,
|
|
135
|
+
itemsSpec[data.label.eng].circle.angles,
|
|
136
|
+
itemsSpec[data.label.eng].circle.direction
|
|
137
|
+
),
|
|
138
|
+
})),
|
|
139
|
+
}));
|
|
140
|
+
|
|
141
|
+
return [{ items }];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
_markToAngle(mark, min, max, angles, direction) {
|
|
145
|
+
const totalAngle = this._calcDiffAngle(angles.end, angles.start, direction);
|
|
146
|
+
const deltaTheta = ((mark - min) / (max - min)) * totalAngle;
|
|
147
|
+
return this._calcDistAngle(deltaTheta, angles.start, direction);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
_calcDiffAngle(theta, theta0, direction) {
|
|
151
|
+
return direction ? 2 * Math.PI - (theta - theta0) : theta - theta0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_calcDistAngle(deltaTheta, theta0, direction) {
|
|
155
|
+
return direction ? 2 * Math.PI - deltaTheta + theta0 : deltaTheta + theta0;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
module.exports = STAIY93;
|