@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.
Files changed (200) hide show
  1. package/.github/workflows/push.yml +14 -0
  2. package/.prettierrc +16 -0
  3. package/.yarn/releases/yarn-1.22.19.cjs +147529 -0
  4. package/.yarnrc.yml +1 -0
  5. package/README.md +98 -0
  6. package/bin/risloo.js +9 -0
  7. package/package.json +44 -0
  8. package/src/Gift.js +29 -0
  9. package/src/Profile.js +405 -0
  10. package/src/cli-commands/Executor.js +118 -0
  11. package/src/cli-commands/ExtractExecutor.js +194 -0
  12. package/src/cli-commands/GiftExecutor.js +56 -0
  13. package/src/cli-commands/utilities/BaseOps.js +71 -0
  14. package/src/cli-commands/utilities/Benchmarker.js +88 -0
  15. package/src/cli-commands/utilities/CustomErrors.js +14 -0
  16. package/src/cli-commands/utilities/Response.js +59 -0
  17. package/src/cli-commands/utilities/STATUSES.js +16 -0
  18. package/src/cli-commands/utilities/Status.js +9 -0
  19. package/src/cli.js +125 -0
  20. package/src/handlebars/helpers/abs.js +8 -0
  21. package/src/handlebars/helpers/addCommas.js +8 -0
  22. package/src/handlebars/helpers/array.js +8 -0
  23. package/src/handlebars/helpers/assignGlobal.js +9 -0
  24. package/src/handlebars/helpers/boolean.js +19 -0
  25. package/src/handlebars/helpers/ceil.js +8 -0
  26. package/src/handlebars/helpers/concat.js +8 -0
  27. package/src/handlebars/helpers/cos.js +8 -0
  28. package/src/handlebars/helpers/displacePoint.js +11 -0
  29. package/src/handlebars/helpers/ellipsisChars.js +10 -0
  30. package/src/handlebars/helpers/ellipsisLines.js +11 -0
  31. package/src/handlebars/helpers/first.js +11 -0
  32. package/src/handlebars/helpers/floor.js +8 -0
  33. package/src/handlebars/helpers/forLoop.js +15 -0
  34. package/src/handlebars/helpers/getArrOfProp.js +8 -0
  35. package/src/handlebars/helpers/isArray.js +8 -0
  36. package/src/handlebars/helpers/join.js +10 -0
  37. package/src/handlebars/helpers/last.js +11 -0
  38. package/src/handlebars/helpers/lineWrap.js +28 -0
  39. package/src/handlebars/helpers/math.js +24 -0
  40. package/src/handlebars/helpers/modulo.js +8 -0
  41. package/src/handlebars/helpers/normalizeAngle.js +7 -0
  42. package/src/handlebars/helpers/object.js +8 -0
  43. package/src/handlebars/helpers/objectEntries.js +8 -0
  44. package/src/handlebars/helpers/polarToCartesian.js +14 -0
  45. package/src/handlebars/helpers/prepend.js +10 -0
  46. package/src/handlebars/helpers/profiles/bar.js +45 -0
  47. package/src/handlebars/helpers/profiles/calcGaugeSidePoints.js +34 -0
  48. package/src/handlebars/helpers/profiles/gauge.js +61 -0
  49. package/src/handlebars/helpers/profiles/polygon.js +40 -0
  50. package/src/handlebars/helpers/reverse.js +9 -0
  51. package/src/handlebars/helpers/roundToTwo.js +8 -0
  52. package/src/handlebars/helpers/setVar.js +8 -0
  53. package/src/handlebars/helpers/sin.js +8 -0
  54. package/src/handlebars/helpers/split.js +8 -0
  55. package/src/handlebars/helpers/tan.js +8 -0
  56. package/src/handlebars/helpers/ternary.js +9 -0
  57. package/src/handlebars/helpers/toDeg.js +8 -0
  58. package/src/handlebars/helpers/toRad.js +8 -0
  59. package/src/handlebars/helpers/withGroup.js +20 -0
  60. package/src/handlebars/helpers/wrapOnNewline.js +11 -0
  61. package/src/handlebars/helpers.js +86 -0
  62. package/src/handlebars/importPartials.js +40 -0
  63. package/src/handlebars/init.js +15 -0
  64. package/src/publish/bot.js +91 -0
  65. package/src/publish/json/gift/gift.json +16 -0
  66. package/src/publish/json/profiles/16PF93.json +201 -0
  67. package/src/publish/json/profiles/AEQ93.json +96 -0
  68. package/src/publish/json/profiles/AMS93.json +102 -0
  69. package/src/publish/json/profiles/AMS9A.json +102 -0
  70. package/src/publish/json/profiles/BAOMEIS93.json +99 -0
  71. package/src/publish/json/profiles/BEQI93.json +1589 -0
  72. package/src/publish/json/profiles/CAATS93.json +11355 -0
  73. package/src/publish/json/profiles/CADS93.json +351 -0
  74. package/src/publish/json/profiles/CARSP93.json +96 -0
  75. package/src/publish/json/profiles/CERQ93.json +106 -0
  76. package/src/publish/json/profiles/CRAAS93.json +98 -0
  77. package/src/publish/json/profiles/CSI93.json +143 -0
  78. package/src/publish/json/profiles/DSWLS93.json +93 -0
  79. package/src/publish/json/profiles/EMSS93.json +116 -0
  80. package/src/publish/json/profiles/FACES93.json +106 -0
  81. package/src/publish/json/profiles/FTEPT93.json +102 -0
  82. package/src/publish/json/profiles/GMIT93.json +98 -0
  83. package/src/publish/json/profiles/HPL93.json +102 -0
  84. package/src/publish/json/profiles/IBT93.json +106 -0
  85. package/src/publish/json/profiles/IUS93.json +93 -0
  86. package/src/publish/json/profiles/JCSI93.json +102 -0
  87. package/src/publish/json/profiles/JPFQ93.json +1 -0
  88. package/src/publish/json/profiles/KJGI93.json +100 -0
  89. package/src/publish/json/profiles/LMIQ93.json +109 -0
  90. package/src/publish/json/profiles/MMFAD93.json +103 -0
  91. package/src/publish/json/profiles/MMFAD9A.json +103 -0
  92. package/src/publish/json/profiles/MOCI93.json +100 -0
  93. package/src/publish/json/profiles/OBQ4493.json +96 -0
  94. package/src/publish/json/profiles/PIES93.json +104 -0
  95. package/src/publish/json/profiles/PIES9A.json +104 -0
  96. package/src/publish/json/profiles/PMCIEF93.json +1 -0
  97. package/src/publish/json/profiles/PSWQ93.json +97 -0
  98. package/src/publish/json/profiles/RIASEC93.json +2511 -0
  99. package/src/publish/json/profiles/SAFE93.json +110 -0
  100. package/src/publish/json/profiles/SASQ93.json +92 -0
  101. package/src/publish/json/profiles/SCASP93.json +611 -0
  102. package/src/publish/json/profiles/SDCAQ93.json +96 -0
  103. package/src/publish/json/profiles/STAIY93.json +98 -0
  104. package/src/publish/json/profiles/WAQ93.json +100 -0
  105. package/src/publish/json/profiles/YBOCS93.json +1322 -0
  106. package/src/publish/json/profiles/empty.json +139 -0
  107. package/src/publish/new-version.hbs +11 -0
  108. package/src/publish/test.js +109 -0
  109. package/src/qrcode/qrCodeGenerator.js +14 -0
  110. package/src/qrcode/qrRender.js +229 -0
  111. package/src/samples/16PF93.js +158 -0
  112. package/src/samples/AEQ93.js +121 -0
  113. package/src/samples/AMS93.js +139 -0
  114. package/src/samples/AMS9A.js +9 -0
  115. package/src/samples/BAOMEIS93.js +146 -0
  116. package/src/samples/BEQI93.js +255 -0
  117. package/src/samples/CAATS93.js +218 -0
  118. package/src/samples/CADS93.js +161 -0
  119. package/src/samples/CARSP93.js +134 -0
  120. package/src/samples/CERQ93.js +195 -0
  121. package/src/samples/CRAAS93.js +141 -0
  122. package/src/samples/CSI93.js +315 -0
  123. package/src/samples/DSWLS93.js +112 -0
  124. package/src/samples/EMSS93.js +178 -0
  125. package/src/samples/FACES93.js +225 -0
  126. package/src/samples/FTEPT93.js +167 -0
  127. package/src/samples/GMIT93.js +142 -0
  128. package/src/samples/HPL93.js +132 -0
  129. package/src/samples/IBT93.js +99 -0
  130. package/src/samples/IUS93.js +204 -0
  131. package/src/samples/JCSI93.js +174 -0
  132. package/src/samples/JPFQ93.js +74 -0
  133. package/src/samples/KJGI93.js +136 -0
  134. package/src/samples/LMIQ93.js +188 -0
  135. package/src/samples/MMFAD93.js +135 -0
  136. package/src/samples/MMFAD9A.js +31 -0
  137. package/src/samples/MOCI93.js +128 -0
  138. package/src/samples/OBQ4493.js +132 -0
  139. package/src/samples/PIES93.js +228 -0
  140. package/src/samples/PIES9A.js +32 -0
  141. package/src/samples/PMCIEF93.js +64 -0
  142. package/src/samples/PSWQ93.js +126 -0
  143. package/src/samples/RIASEC93.js +144 -0
  144. package/src/samples/SAFE93.js +64 -0
  145. package/src/samples/SASQ93.js +130 -0
  146. package/src/samples/SCASP93.js +207 -0
  147. package/src/samples/SDCAQ93.js +174 -0
  148. package/src/samples/STAIY93.js +159 -0
  149. package/src/samples/WAQ93.js +208 -0
  150. package/src/samples/YBOCS93.js +583 -0
  151. package/src/samples/empty.js +53 -0
  152. package/views/gift.hbs +160 -0
  153. package/views/profiles/fonts.css +18 -0
  154. package/views/profiles/layout.hbs +27 -0
  155. package/views/profiles/samples/16PF93.hbs +54 -0
  156. package/views/profiles/samples/AEQ93.hbs +31 -0
  157. package/views/profiles/samples/AMS93.hbs +97 -0
  158. package/views/profiles/samples/AMS9A.hbs +1 -0
  159. package/views/profiles/samples/BAOMEIS93.hbs +48 -0
  160. package/views/profiles/samples/BEQI93.hbs +118 -0
  161. package/views/profiles/samples/CAATS93.hbs +251 -0
  162. package/views/profiles/samples/CADS93.hbs +104 -0
  163. package/views/profiles/samples/CARSP93.hbs +26 -0
  164. package/views/profiles/samples/CERQ93.hbs +115 -0
  165. package/views/profiles/samples/CRAAS93.hbs +88 -0
  166. package/views/profiles/samples/CSI93_1.hbs +110 -0
  167. package/views/profiles/samples/CSI93_2.hbs +76 -0
  168. package/views/profiles/samples/DSWLS93.hbs +26 -0
  169. package/views/profiles/samples/EMSS93.hbs +101 -0
  170. package/views/profiles/samples/FACES93_1.hbs +107 -0
  171. package/views/profiles/samples/FACES93_2.hbs +51 -0
  172. package/views/profiles/samples/FTEPT93.hbs +67 -0
  173. package/views/profiles/samples/GMIT93.hbs +45 -0
  174. package/views/profiles/samples/HPL93.hbs +36 -0
  175. package/views/profiles/samples/IBT93.hbs +67 -0
  176. package/views/profiles/samples/IUS93.hbs +123 -0
  177. package/views/profiles/samples/JCSI93.hbs +65 -0
  178. package/views/profiles/samples/JPFQ93.hbs +44 -0
  179. package/views/profiles/samples/KJGI93.hbs +57 -0
  180. package/views/profiles/samples/LMIQ93.hbs +82 -0
  181. package/views/profiles/samples/MMFAD93.hbs +35 -0
  182. package/views/profiles/samples/MMFAD9A.hbs +1 -0
  183. package/views/profiles/samples/MOCI93.hbs +60 -0
  184. package/views/profiles/samples/OBQ4493.hbs +61 -0
  185. package/views/profiles/samples/PIES93.hbs +67 -0
  186. package/views/profiles/samples/PIES9A.hbs +1 -0
  187. package/views/profiles/samples/PMCIEF93.hbs +8 -0
  188. package/views/profiles/samples/PSWQ93.hbs +32 -0
  189. package/views/profiles/samples/RIASEC93.hbs +38 -0
  190. package/views/profiles/samples/SAFE93.hbs +118 -0
  191. package/views/profiles/samples/SASQ93.hbs +45 -0
  192. package/views/profiles/samples/SCASP93.hbs +94 -0
  193. package/views/profiles/samples/SDCAQ93.hbs +68 -0
  194. package/views/profiles/samples/STAIY93.hbs +67 -0
  195. package/views/profiles/samples/WAQ93.hbs +74 -0
  196. package/views/profiles/samples/YBOCS93_1.hbs +96 -0
  197. package/views/profiles/samples/YBOCS93_2.hbs +115 -0
  198. package/views/profiles/samples/YBOCS93_3.hbs +93 -0
  199. package/views/profiles/samples/empty.hbs +10 -0
  200. package/views/profiles/sidebar.hbs +193 -0
@@ -0,0 +1,195 @@
1
+ const { Profile, FS, Mappings } = require("../Profile");
2
+
3
+ class CERQ93 extends Profile {
4
+ // Number of pages
5
+ static pages = 1;
6
+
7
+ // Labels of the sample
8
+ labels = {
9
+ L1: { eng: "acceptance", fr: "پذیرش" },
10
+ L2: { eng: "positive_refocusing", fr: "تمرکز مجدد مثبت" },
11
+ L3: { eng: "refocusing_on_planing", fr: "تمرکز مجدد برنامه‌ریزی" },
12
+ L4: { eng: "positive_reappraisal", fr: "ارزیابی مجدد مثبت" },
13
+ L5: { eng: "putting_to_perspective", fr: "دیدگاه‌گیری" },
14
+ L6: { eng: "self_blame", fr: "ملامت خویش" },
15
+ L7: { eng: "rumination", fr: "نشخوارگی" },
16
+ L8: { eng: "catastrophizing", fr: "فاجعه‌سازی" },
17
+ L9: { eng: "other_blame", fr: "ملامت دیگران" },
18
+ L10: { eng: "adaptive_regulation", fr: "نظم‌جویی انطباقی" },
19
+ L11: { eng: "unadaptive_regulation", fr: "نظم‌جویی غیرانطباقی" },
20
+ };
21
+
22
+ profileSpec = {
23
+ /* "sample" determines some important info about the sample and profile */
24
+ /* Default prerequisites: 1. gender, 2. age, 3. education */
25
+ /* "prerequisites" is synonym to "fields" in our program */
26
+ sample: {
27
+ name: "پرسشنامه نظم‌جویی شناختی - هیجانی (فرم کوتاه)" /* Name of the sample */,
28
+ multiProfile: false /* Whether the sample has multiple profiles or not */,
29
+ questions: false /* Determines whether to get questions from inital dataset or not */,
30
+ defaultFields: true /* Determines whether to have default prerequisites in the profile or not */,
31
+ fields: ["marital_status"] /* In case you want to get some additional fields and show in the profile */,
32
+ },
33
+ /* "profile" determines the dimensions of the drawn profile (to be used in svg tag viewbox) */
34
+ /* calculating its dimensions carefully is of great importance */
35
+ profile: {
36
+ get dimensions() {
37
+ return {
38
+ width: 828 + 2 * this.padding.x,
39
+ height: 580 + 2 * this.padding.y,
40
+ }
41
+ },
42
+ padding: {
43
+ x: 38,
44
+ y: 0,
45
+ },
46
+ },
47
+ /* "raw" is the general term used for total data element in the profile */
48
+ raw: {
49
+ minValues: [10, 8] /* Minimum values of raw marks provided by the dataset */,
50
+ maxValues: [50, 40] /* Maximum values of raw marks provided by the dataset */,
51
+ offsetX: 110 /* Horizontal offset from items */,
52
+ ticks: {
53
+ num: 2 /* Number of ticks */,
54
+ line: {
55
+ width: 10 /* Width of the tick line */,
56
+ offsetX: 7 /* Horizontal offset from the rectangle */,
57
+ },
58
+ number: {
59
+ offsetX: 4 /* Horizontal Offset from the line */,
60
+ },
61
+ },
62
+ rect: {
63
+ width: 35 /* Width of the raw rectangle */,
64
+ get borderRadius() {
65
+ return this.width / 2;
66
+ } /* Border radius of the raw rectangle */,
67
+ },
68
+ heightCoeff: 5 /* Used for converting mark to the height */,
69
+ },
70
+ /* "items" is the general term used for independent data elements to be drawn in the profile */
71
+ items: {
72
+ minValue: 2 /* Minimum value of items mark provided by the dataset */,
73
+ maxValue: 10 /* Maximum value of items mark provided by the dataset */,
74
+ offsetX: 200 /* Horizontal offset between items and category label rectangle */,
75
+ offsetY1: 10 /* Vertical offset between two consecutive item in the profile */,
76
+ offsetY2: 105 /* Vertical offset between two categories of items */,
77
+ get distanceY() {
78
+ return this.offsetY1 + this.rect.height;
79
+ } /* Distance between two consecutive item in the profile */,
80
+ totalHeights: [] /* To be calculated in the class with the function provided */,
81
+ calcTotalHeight: function (n) {
82
+ return this.distanceY * (n - 1) + this.rect.height;
83
+ } /* Method for calculating the total height of items */,
84
+ ticks: {
85
+ num: 5 /* Number of ticks */,
86
+ heightOffset: 45 /* Half length that the ticks lines of items is greater than items total heigth */,
87
+ numberOffset: {
88
+ x: 10 /* Horizontal distance from the line */,
89
+ y: 10 /* Vertical distance from the line */,
90
+ },
91
+ },
92
+ rect: {
93
+ height: 35 /* Height of the items rectangle */,
94
+ get borderRadius() {
95
+ return this.height / 2;
96
+ } /* Border Radius of the items rectangle */,
97
+ colors: ["#047857", "#EF4444"] /* Colors used for theming items body parts */,
98
+ opacityMappings: new Mappings()
99
+ .addMapping("2", 0.6)
100
+ .addMapping("3-4", 0.7)
101
+ .addMapping("5-6", 0.8)
102
+ .addMapping("7-8", 0.9)
103
+ .addMapping("9-10", 1) /* Opacity mapping for marks */,
104
+ },
105
+ widthCoeff: 40 /* Used for converting mark to the width */,
106
+ label: {
107
+ offsetX: 10 /* Horizontal offset of label from item */,
108
+ rect: {
109
+ width: 42 /* Width of the category label rectangle of the items */,
110
+ borderRadius: 5 /* Border radius of the category label rectangle of the items */,
111
+ },
112
+ colors: ["#369379", "#F26969"] /* Colors used for theming items label rectangle */,
113
+ },
114
+ },
115
+ /* "labels" part which has to be provided for each profile */
116
+ labels: Object.values(this.labels)
117
+ };
118
+
119
+ constructor(dataset, options, config = {}) {
120
+ super();
121
+ this._init(dataset, options, config);
122
+ }
123
+
124
+ _calcContext() {
125
+ const {
126
+ spec: { parameters: spec },
127
+ dataset,
128
+ } = this;
129
+
130
+ const { raw: rawSpec, items: itemsSpec } = spec;
131
+
132
+ // Remove Last Two Element to Separate Raw Dataset
133
+ const rawDataset = dataset.score.splice(-2, 2);
134
+
135
+ // Categorize Items Dataset
136
+ const itemsDatasets = [dataset.score.slice(0, 5), dataset.score.slice(5)];
137
+
138
+ // ّInit Spec
139
+ spec.items.totalHeights = itemsDatasets.map((dataset) => spec.items.calcTotalHeight(dataset.length));
140
+
141
+ // Gather Required Info for Raw
142
+ const raw = rawDataset.map((data) => ({
143
+ label: data.label,
144
+ mark: data.mark,
145
+ height: data.mark * rawSpec.heightCoeff,
146
+ }));
147
+
148
+ // Calculate Ticks Numbers Array for Raw
149
+ const rawTicksNumbers = [];
150
+ for (let i = 0; i < raw.length; i++)
151
+ rawTicksNumbers.push(
152
+ FS.createArithmeticSequence(
153
+ rawSpec.minValues[i],
154
+ (rawSpec.maxValues[i] - rawSpec.minValues[i]) / (rawSpec.ticks.num - 1),
155
+ rawSpec.ticks.num
156
+ )
157
+ );
158
+
159
+ // Gather Required Info for Raw Ticks
160
+ const rawTicks = rawTicksNumbers.map((ticks) =>
161
+ ticks.map((tick) => ({
162
+ number: tick,
163
+ bottomPos: tick * rawSpec.heightCoeff,
164
+ }))
165
+ );
166
+
167
+ // Gather Required Info for Items
168
+ const items = itemsDatasets.map((dataset, datasetIndex) =>
169
+ dataset.map((data) => ({
170
+ label: data.label,
171
+ mark: data.mark,
172
+ width: data.mark * itemsSpec.widthCoeff,
173
+ fill: itemsSpec.rect.colors[datasetIndex],
174
+ opacity: itemsSpec.rect.opacityMappings.map(data.mark),
175
+ }))
176
+ );
177
+
178
+ // Calculate Ticks Numbers Array for Items
179
+ const itemsTicksNumbers = FS.createArithmeticSequence(
180
+ itemsSpec.minValue,
181
+ (itemsSpec.maxValue - itemsSpec.minValue) / (itemsSpec.ticks.num - 1),
182
+ itemsSpec.ticks.num
183
+ );
184
+
185
+ // Gather Required Info for Items Ticks
186
+ const itemsTicks = itemsTicksNumbers.map((tick) => ({
187
+ number: tick,
188
+ leftPos: tick * itemsSpec.widthCoeff,
189
+ }));
190
+
191
+ return [{ raw, items, rawTicks, itemsTicks }];
192
+ }
193
+ }
194
+
195
+ module.exports = CERQ93;
@@ -0,0 +1,141 @@
1
+ const { Profile, FS } = require("../Profile");
2
+
3
+ class CRAAS93 extends Profile {
4
+ // Number of pages
5
+ static pages = 1;
6
+
7
+ // Labels of the sample
8
+ labels = {
9
+ L1: { eng: "closeness", name: "نزدیک بودن", type: "دلبستگی ایمن" },
10
+ L2: { eng: "dependance", name: "وابستگی", type: "دلبستگی اجتنابی" },
11
+ L3: { eng: "anxiety", name: "اضطراب", type: "دلبستگی اضطرابی-دوسوگرا" },
12
+ };
13
+
14
+ profileSpec = {
15
+ /* "sample" determines some important info about the sample and profile */
16
+ /* Default prerequisites: 1. gender, 2. age, 3. education */
17
+ /* "prerequisites" is synonym to "fields" in our program */
18
+ sample: {
19
+ name: "پرسشنامه دلبستگی کولینز و رید" /* Name of the sample */,
20
+ multiProfile: false /* Whether the sample has multiple profiles or not */,
21
+ questions: false /* Determines whether to get questions from inital dataset or not */,
22
+ defaultFields: true /* Determines whether to have default prerequisites in the profile or not */,
23
+ fields: ["marital_status"] /* In case you want to get some additional fields and show in the profile */,
24
+ },
25
+ /* "profile" determines the dimensions of the drawn profile (to be used in svg tag viewbox) */
26
+ /* calculating its dimensions carefully is of great importance */
27
+ profile: {
28
+ get dimensions() {
29
+ return {
30
+ width: 1050 + 2 * this.padding.x,
31
+ height: 798 + 2 * this.padding.y,
32
+ }
33
+ },
34
+ padding: {
35
+ x: 0,
36
+ y: 0,
37
+ },
38
+ },
39
+ /* Spec for the polygons drawn in the profile */
40
+ polygons: {
41
+ n: 3 /* Number of vertices of the polygons */,
42
+ get theta() {
43
+ return (2 * Math.PI) / this.n;
44
+ },
45
+ startAngle: FS.toRadians(-90) /* Start angle of the polygon */,
46
+ radius: 450 /* Radius of the peripheral circle of the main polygon */,
47
+ centerOffset: 40 /* Radius of the peropheral circle of the smallest polygon */,
48
+ },
49
+ /* "items" is the general term used for independent data elements to be drawn in the profile */
50
+ items: {
51
+ maxValue: 20 /* Maximum value of marks provided by the dataset */,
52
+ labels: {
53
+ offset: 50 /* Offset of the label from the vertice of the polygon */,
54
+ paddingY: 12 /* Half distance between two parts of the label */,
55
+ },
56
+ dataPoints: {
57
+ radius: 12 /* Radius of the circle of the data point */,
58
+ fills: ["#166534", "#D97706", "#DC2626"] /* Colors used for theming data points */,
59
+ },
60
+ ticks: {
61
+ num: 5 /* Number of ticks */,
62
+ rectDim: 12 /* The dimension of the rectangle the tick number is placed in */,
63
+ side: 2 /* Which side of the polygon the ticks are going to be placed on */,
64
+ /* The arithmetic sequence used for displacing ticks on the side direction */
65
+ displacement: {
66
+ initialTerm: 30 /* Initial term of the arithmetic sequence */,
67
+ commonDiff: 10 /* Common difference of the arithmetic sequence */,
68
+ },
69
+ },
70
+ },
71
+ /* "labels" part which has to be provided for each profile */
72
+ labels: Object.values(this.labels)
73
+ };
74
+
75
+ constructor(dataset, options, config = {}) {
76
+ super();
77
+ this._init(dataset, options, config);
78
+ }
79
+
80
+ _calcContext() {
81
+ const {
82
+ spec: { parameters: spec },
83
+ dataset,
84
+ } = this;
85
+
86
+ // Deconstructing the Spec of the Profile
87
+ let { polygons: polygonsSpec, items: itemsSpec } = spec;
88
+
89
+ // Gather Required Info for Items
90
+ const items = dataset.score.map((data, index) => ({
91
+ label: data.label,
92
+ mark: data.mark,
93
+ angle: polygonsSpec.startAngle - index * polygonsSpec.theta,
94
+ radius:
95
+ (data.mark / itemsSpec.maxValue) * (polygonsSpec.radius - polygonsSpec.centerOffset) +
96
+ polygonsSpec.centerOffset,
97
+ fill: itemsSpec.dataPoints.fills[index],
98
+ }));
99
+
100
+ // In Case Ticks Side is Greater than n
101
+ itemsSpec.ticks.side = ((itemsSpec.ticks.side - 1) % polygonsSpec.n) + 1;
102
+
103
+ // Calculate Ticks Array and Angle to Place On
104
+ const ticksNumbers = FS.createArithmeticSequence(
105
+ 0,
106
+ itemsSpec.maxValue / (itemsSpec.ticks.num - 1),
107
+ itemsSpec.ticks.num
108
+ );
109
+ const ticksRadiuses = FS.createArithmeticSequence(
110
+ polygonsSpec.centerOffset,
111
+ (polygonsSpec.radius - polygonsSpec.centerOffset) / (itemsSpec.ticks.num - 1),
112
+ itemsSpec.ticks.num
113
+ );
114
+
115
+ // Displace Ticks Points (Defining Displacement Vector and Displacement Value)
116
+ const alpha = 0;
117
+ const disVector = { x: Math.cos(alpha), y: Math.sin(alpha) };
118
+ const disValue = FS.createArithmeticSequence(
119
+ itemsSpec.ticks.displacement.initialTerm,
120
+ itemsSpec.ticks.displacement.commonDiff,
121
+ itemsSpec.ticks.num
122
+ );
123
+
124
+ const ticks = ticksNumbers.map((number, index) => ({
125
+ number,
126
+ angle: polygonsSpec.startAngle - (itemsSpec.ticks.side - 1) * polygonsSpec.theta,
127
+ radius: ticksRadiuses[index],
128
+ disVector,
129
+ disValue: disValue[index],
130
+ }));
131
+
132
+ return [
133
+ {
134
+ items,
135
+ ticks,
136
+ },
137
+ ];
138
+ }
139
+ }
140
+
141
+ module.exports = CRAAS93;
@@ -0,0 +1,315 @@
1
+ const { Profile } = require("../Profile");
2
+
3
+ class CSI93 extends Profile {
4
+ // Number of pages
5
+ static pages = 2;
6
+
7
+ // Labels of the sample
8
+ labels = {
9
+ L1: {
10
+ eng: "attention_deficity_and_hyper_activity_disorder_total",
11
+ fr: "بیش فعالی / اختلال توجه نوع مرکب",
12
+ group: "A",
13
+ },
14
+ L2: {
15
+ eng: "attention_deficity_and_hyper_activity_disorder_type_a",
16
+ fr: "سؤالات 1 تا 9",
17
+ group: "A",
18
+ },
19
+ L3: {
20
+ eng: "attention_deficity_and_hyper_activity_disorder_type_b",
21
+ fr: "سؤالات 10 تا 18",
22
+ group: "A",
23
+ },
24
+ L4: {
25
+ eng: "oppositional_defant_disorder",
26
+ fr: "اختلال نافرمانی مقابله‌ای",
27
+ group: "B",
28
+ },
29
+ L5: {
30
+ eng: "conduct_disorder",
31
+ fr: "اختلال سلوک",
32
+ group: "C",
33
+ },
34
+ L6: {
35
+ eng: "generalized_anxiety_disorder_total",
36
+ fr: "اختلال اضطراب تعمیم‌یافته",
37
+ group: "D",
38
+ },
39
+ L7: {
40
+ eng: "generalized_anxiety_disorder_type_a",
41
+ fr: "سؤال 42",
42
+ group: "D",
43
+ },
44
+ L8: {
45
+ eng: "generalized_anxiety_disorder_type_b",
46
+ fr: "سؤال 43",
47
+ group: "D",
48
+ },
49
+ L9: {
50
+ eng: "generalized_anxiety_disorder_type_c",
51
+ fr: "سؤال 62، 2، 46، 45، 44",
52
+ group: "D",
53
+ },
54
+ L10: {
55
+ eng: "special_phobia",
56
+ fr: "ترس‌های مرضی خاص",
57
+ group: "E049",
58
+ },
59
+ L11: {
60
+ eng: "obssesive",
61
+ fr: "افکار وسواسی",
62
+ group: "E050",
63
+ },
64
+ L12: {
65
+ eng: "compulsive",
66
+ fr: "اعمال وسواسی",
67
+ group: "E051",
68
+ },
69
+ L13: {
70
+ eng: "post_terumatic_stress_disorder",
71
+ fr: "اختلال استرس پس از حادثه",
72
+ group: "E052",
73
+ },
74
+ L14: {
75
+ eng: "motor_tics",
76
+ fr: "تیک‌های حرکتی",
77
+ group: "E053",
78
+ },
79
+ L15: {
80
+ eng: "vocal_tics",
81
+ fr: "تیک‌های صورتی",
82
+ group: "E054",
83
+ },
84
+ L16: {
85
+ eng: "schizophernia",
86
+ fr: "اسکیزوفرنیا",
87
+ group: "F",
88
+ },
89
+ L17: {
90
+ eng: "major_depression_total",
91
+ fr: "اختلال افسردگی شدید",
92
+ group: "G_1",
93
+ },
94
+ L18: {
95
+ eng: "major_depression_type_a",
96
+ fr: "الف",
97
+ group: "G_1",
98
+ },
99
+ L19: {
100
+ eng: "major_depression_type_b",
101
+ fr: "ب",
102
+ group: "G_1",
103
+ },
104
+ L20: {
105
+ eng: "dysthymia_total",
106
+ fr: "اختلال افسردگی خویی",
107
+ group: "G_2",
108
+ },
109
+ L21: {
110
+ eng: "dysthymia_type_a",
111
+ fr: "الف",
112
+ group: "G_2",
113
+ },
114
+ L22: {
115
+ eng: "dysthymia_type_b",
116
+ fr: "سؤالات 62 تا 66 و 68",
117
+ group: "G_2",
118
+ },
119
+ L23: {
120
+ eng: "autistic_disorder_total",
121
+ fr: "اختلال آتیستیک",
122
+ group: "H_1",
123
+ },
124
+ L24: {
125
+ eng: "autistic_disorder_type_a",
126
+ fr: "سؤالات 70 تا 73",
127
+ group: "H_1",
128
+ },
129
+ L25: {
130
+ eng: "autistic_disorder_type_b",
131
+ fr: "سؤالات 74 تا 77",
132
+ group: "H_1",
133
+ },
134
+ L26: {
135
+ eng: "autistic_disorder_type_c",
136
+ fr: "سؤالات 78 تا 81",
137
+ group: "H_1",
138
+ },
139
+ L27: {
140
+ eng: "asperger_disorder_total",
141
+ fr: "اختلال اسپرگر",
142
+ group: "H_2",
143
+ },
144
+ L28: {
145
+ eng: "asperger_disorder_type_a",
146
+ fr: "سؤالات 70 تا 73",
147
+ group: "H_2",
148
+ },
149
+ L29: {
150
+ eng: "asperger_disorder_type_b",
151
+ fr: "سؤالات 78 تا 81",
152
+ group: "H_2",
153
+ },
154
+ L30: {
155
+ eng: "social_phobia",
156
+ fr: "ترس مرضی اجتماعی",
157
+ group: "I",
158
+ },
159
+ L31: {
160
+ eng: "seperation_anxiety_disorder",
161
+ fr: "اختلال اضطراب جدایی",
162
+ group: "J",
163
+ },
164
+ L32: {
165
+ eng: "enuresis",
166
+ fr: "شب ادراری",
167
+ group: "-",
168
+ },
169
+ L33: {
170
+ eng: "encopresis",
171
+ fr: "ادرار یا دفع بی‌موقع در حالت بیداری",
172
+ group: "-",
173
+ },
174
+ };
175
+
176
+ profileSpec = {
177
+ /* "sample" determines some important info about the sample and profile */
178
+ /* Default prerequisites: 1. gender, 2. age, 3. education */
179
+ /* "prerequisites" is synonym to "fields" in our program */
180
+ sample: {
181
+ name: "پرسشنامه ارزیابی سلامت روانی کودکان" /* Name of the sample */,
182
+ multiProfile: true /* Whether the sample has multiple profiles or not */,
183
+ questions: false /* Determines whether to get questions from inital dataset or not */,
184
+ defaultFields: false /* Determines whether to have default prerequisites in the profile or not */,
185
+ fields: [
186
+ "child_gender",
187
+ "child_age",
188
+ "child_education",
189
+ { eng: "parent_role", fr: "نسبت پاسخ‌دهنده با کودک" },
190
+ ] /* In case you want to get some additional fields and show in the profile */,
191
+ },
192
+ /* "profile" determines the dimensions of the drawn profile (to be used in svg tag viewbox) */
193
+ /* calculating its dimensions carefully is of great importance */
194
+ profile: {
195
+ get dimensions() {
196
+ return {
197
+ width: 903 + 2 * this.padding.x,
198
+ height: 704 + 2 * this.padding.y,
199
+ };
200
+ },
201
+ padding: {
202
+ x: 0,
203
+ y: 0,
204
+ },
205
+ },
206
+ /* "items" is the general term used for independent data elements to be drawn in the profile */
207
+ items: {
208
+ minValue: 0,
209
+ maxValues: {
210
+ [this.labels.L1.eng]: 18,
211
+ [this.labels.L2.eng]: 9,
212
+ [this.labels.L3.eng]: 9,
213
+ [this.labels.L4.eng]: 8,
214
+ [this.labels.L5.eng]: 15,
215
+ [this.labels.L6.eng]: 7,
216
+ [this.labels.L7.eng]: 1,
217
+ [this.labels.L8.eng]: 1,
218
+ [this.labels.L9.eng]: 5,
219
+ [this.labels.L10.eng]: 1,
220
+ [this.labels.L11.eng]: 1,
221
+ [this.labels.L12.eng]: 1,
222
+ [this.labels.L13.eng]: 1,
223
+ [this.labels.L14.eng]: 1,
224
+ [this.labels.L15.eng]: 1,
225
+ [this.labels.L16.eng]: 5,
226
+ [this.labels.L17.eng]: 10,
227
+ [this.labels.L18.eng]: 3,
228
+ [this.labels.L19.eng]: 7,
229
+ [this.labels.L20.eng]: 8,
230
+ [this.labels.L21.eng]: 2,
231
+ [this.labels.L22.eng]: 6,
232
+ [this.labels.L23.eng]: 12,
233
+ [this.labels.L24.eng]: 4,
234
+ [this.labels.L25.eng]: 4,
235
+ [this.labels.L26.eng]: 4,
236
+ [this.labels.L27.eng]: 8,
237
+ [this.labels.L28.eng]: 4,
238
+ [this.labels.L29.eng]: 4,
239
+ [this.labels.L30.eng]: 4,
240
+ [this.labels.L31.eng]: 8,
241
+ [this.labels.L32.eng]: 1,
242
+ [this.labels.L33.eng]: 1,
243
+ },
244
+ relatedGroups: {
245
+ A: "D تا J",
246
+ B: ["C", "F", "G"],
247
+ C: "-",
248
+ D: ["E52", "F", "G", "I", "J", "D", "E50", "E51"],
249
+ E049: ["E50", "E51", "E52", "F", "J"],
250
+ E050: ["D", "E49", "E53", "E54", "F", "I", "G"],
251
+ E051: ["D", "E49", "E53", "E54", "F", "I", "G"],
252
+ E052: ["E50", "E51", "F"],
253
+ E053: "-",
254
+ E054: "-",
255
+ F: ["A", "G", "H"],
256
+ G_1: ["A", "F", "دستایمی (اختلال خلقی خفیف)"],
257
+ G_2: ["F", "اختلال افسردگی شدید"],
258
+ H_1: ["F"],
259
+ H_2: ["F", "E51", "E50", "آتیسم"],
260
+ I: ["J", "H", "G", "F", "E49", "D"],
261
+ J: ["H", "F", "D"],
262
+ "-": "-",
263
+ },
264
+ rightPosArr: [10, 92, 399, 759, 893] /* Right position array of items table cells */,
265
+ rect: {
266
+ width: 903,
267
+ height: 30,
268
+ br: 4,
269
+ offsetY: 10,
270
+ get distanceY() {
271
+ return this.height + this.offsetY;
272
+ },
273
+ colors: ["#F4F4F5", "#F1F5F9"],
274
+ itemBar: {
275
+ width: 75,
276
+ height: 6,
277
+ br: 3,
278
+ defaultFill: "#D4D4D8",
279
+ fill: "#BE185D",
280
+ },
281
+ },
282
+ },
283
+ /* "labels" part which has to be provided for each profile */
284
+ labels: Object.values(this.labels),
285
+ };
286
+
287
+ constructor(dataset, options, config = {}) {
288
+ super();
289
+ this._init(dataset, options, config);
290
+ }
291
+
292
+ _calcContext() {
293
+ const {
294
+ spec: { parameters: spec },
295
+ dataset,
296
+ } = this;
297
+
298
+ const { items: itemsSpec } = spec;
299
+
300
+ const datasetGroups = dataset.groupBy("group");
301
+
302
+ const itemsGroups = datasetGroups.map((dataset) =>
303
+ dataset.map((data) => ({
304
+ label: data.label,
305
+ mark: data.mark,
306
+ width: (data.mark / itemsSpec.maxValues[data.label.eng]) * itemsSpec.rect.itemBar.width,
307
+ relatedGroups: itemsSpec.relatedGroups[data.label.group],
308
+ }))
309
+ );
310
+
311
+ return [{ itemsGroups: itemsGroups.slice(0, 10) }, { itemsGroups: itemsGroups.slice(10) }];
312
+ }
313
+ }
314
+
315
+ module.exports = CSI93;