@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,208 @@
1
+ const { Profile, FS } = require("../Profile");
2
+
3
+ class WAQ93 extends Profile {
4
+ // Number of pages
5
+ static pages = 1;
6
+
7
+ // Labels of the sample
8
+ labels = {
9
+ L1: { eng: "raw", fr: "نمره کل" },
10
+ L2: { eng: "relationship_with_god", fr: "خدا" },
11
+ L3: { eng: "relationship_with_self", fr: "خود" },
12
+ L4: { eng: "relationship_with_others", fr: "دیگران" },
13
+ L5: { eng: "relationship_with_wisdom", fr: "دانش و حکمت" },
14
+ L6: { eng: "relationship_with_religion", fr: "دین و مذهب" },
15
+ L7: { eng: "relationship_with_right_and_wrong", fr: "حق و باطل" },
16
+ L8: { eng: "relationship_with_hereafter", fr: "دین و آخرت" },
17
+ };
18
+
19
+ profileSpec = {
20
+ /* "sample" determines some important info about the sample and profile */
21
+ /* Default prerequisites: 1. gender, 2. age, 3. education */
22
+ /* "prerequisites" is synonym to "fields" in our program */
23
+ sample: {
24
+ name: "پرسشنامه سنجش عقل میردریکوندی" /* Name of the sample */,
25
+ multiProfile: false /* Whether the sample has multiple profiles or not */,
26
+ questions: false /* Determines whether to get questions from inital dataset or not */,
27
+ defaultFields: true /* Determines whether to have default prerequisites in the profile or not */,
28
+ fields: ["marital_status"] /* In case you want to get some additional fields and show in the profile */,
29
+ },
30
+ /* "profile" determines the dimensions of the drawn profile (to be used in svg tag viewbox) */
31
+ /* calculating its dimensions carefully is of great importance */
32
+ profile: {
33
+ get dimensions() {
34
+ return {
35
+ width: 701 + 2 * this.padding.x,
36
+ height: 646 + 2 * this.padding.y,
37
+ }
38
+ },
39
+ padding: {
40
+ x: 0,
41
+ y: 34,
42
+ },
43
+ },
44
+ /* "raw" is the general term used for total data element in the profile */
45
+ raw: {
46
+ maxValue: 900 /* Maximum value of raw mark provided by the dataset */,
47
+ fill: "#334155" /* Color used in the raw element */,
48
+ circle: {
49
+ R: 104.5 /* Radius of the outer circle of the raw element */,
50
+ r: 64.5 /* Radius of the inner circle of the raw element */,
51
+ brs: {
52
+ tl: 8.5 /* Top left border radius */,
53
+ bl: 8.5 /* Bottom left border radius */,
54
+ tr: 8.5 /* Top right border radius */,
55
+ br: 8.5 /* Bottom right border radius */,
56
+ } /* Border radiuses at each end of the gauge of the raw element */,
57
+ angles: {
58
+ start: FS.toRadians(-90),
59
+ end: FS.toRadians(180),
60
+ } /* Angles of each end of the raw element */,
61
+ direction: false /* Clockwise direction for the raw gauge element */,
62
+ get totalAngle() {
63
+ return this.direction
64
+ ? 2 * Math.PI - (this.angles.end - this.angles.start)
65
+ : this.angles.end - this.angles.start;
66
+ },
67
+ },
68
+ ticks: {
69
+ num: 2 /* Number of ticks */,
70
+ number: {
71
+ offset: 15 /* Offset from the line */,
72
+ },
73
+ },
74
+ label: {
75
+ offsetY: 30,
76
+ },
77
+ },
78
+ /* "items" is the general term used for independent data elements to be drawn in the profile */
79
+ items: {
80
+ offsetX1: 63 /* Horizontal offset between two top items */,
81
+ offsetX2: 70 /* Horizontal offset between two bottom items */,
82
+ offsetY1: 88 /* Vertical offset between items and raw */,
83
+ offsetY2: 70 /* Vertical offset between top and bottom items */,
84
+ get distanceX1() {
85
+ return this.offsetX1 + this.circle.R * 2;
86
+ } /* Horizontal distance between two top items */,
87
+ get distanceX2() {
88
+ return this.offsetX2 + this.circle.R * 2;
89
+ } /* Horizontal distance between two top items */,
90
+ maxValues: {
91
+ [this.labels.L2.eng]: 90,
92
+ [this.labels.L3.eng]: 335,
93
+ [this.labels.L4.eng]: 305,
94
+ [this.labels.L5.eng]: 55,
95
+ [this.labels.L6.eng]: 50,
96
+ [this.labels.L7.eng]: 25,
97
+ [this.labels.L8.eng]: 40,
98
+ } /* Maximum value of items */,
99
+ fills: {
100
+ [this.labels.L2.eng]: "#16A34A",
101
+ [this.labels.L3.eng]: "#F59E0B",
102
+ [this.labels.L4.eng]: "#E11D48",
103
+ [this.labels.L5.eng]: "#C026D3",
104
+ [this.labels.L6.eng]: "#7C3AED",
105
+ [this.labels.L7.eng]: "#14B8A6",
106
+ [this.labels.L8.eng]: "#0EA5E9",
107
+ } /* Color used in items */,
108
+ circle: {
109
+ R: 61.5 /* Radius of the outer circle of the items element */,
110
+ r: 36.5 /* Radius of the inner circle of the items element */,
111
+ brs: {
112
+ tl: 5 /* Top left border radius */,
113
+ bl: 5 /* Bottom left border radius */,
114
+ tr: 5 /* Top right border radius */,
115
+ br: 5 /* Bottom right border radius */,
116
+ } /* Border radiuses at each end of the gauge of the items element */,
117
+ angles: {
118
+ start: FS.toRadians(-90),
119
+ end: FS.toRadians(180),
120
+ } /* Angles of each end of the items element */,
121
+ direction: false /* Clockwise direction for the items gauge element */,
122
+ get totalAngle() {
123
+ return this.direction
124
+ ? 2 * Math.PI - (this.angles.end - this.angles.start)
125
+ : this.angles.end - this.angles.start;
126
+ },
127
+ },
128
+ ticks: {
129
+ num: 2 /* Number of ticks */,
130
+ number: {
131
+ offset: 12 /* Offset from the line */,
132
+ },
133
+ },
134
+ label: {
135
+ offsetY: 20,
136
+ },
137
+ },
138
+ /* "labels" part which has to be provided for each profile */
139
+ labels: Object.values(this.labels),
140
+ };
141
+
142
+ constructor(dataset, options, config = {}) {
143
+ super();
144
+ this._init(dataset, options, config);
145
+ }
146
+
147
+ _calcContext() {
148
+ const {
149
+ spec: { parameters: spec },
150
+ dataset,
151
+ } = this;
152
+
153
+ // Deconstructing the Spec of the Profile
154
+ const { raw: rawSpec, items: itemsSpec } = spec;
155
+
156
+ // Separate Raw Data from the Dataset
157
+ const rawData = dataset.score.shift();
158
+
159
+ // Calculate Ticks Numbers Array for Raw
160
+ const rawTicksNumbers = FS.createArithmeticSequence(
161
+ rawSpec.maxValue,
162
+ -rawSpec.maxValue / (rawSpec.ticks.num - 1),
163
+ rawSpec.ticks.num
164
+ ).reverse();
165
+
166
+ // Gather Required Info for Raw
167
+ const raw = {
168
+ label: rawData.label,
169
+ mark: rawData.mark,
170
+ zeta: (rawData.mark / rawSpec.maxValue) * rawSpec.circle.totalAngle + rawSpec.circle.angles.start,
171
+ fill: rawSpec.fill,
172
+ opacity: FS.roundTo2(0.5 * (1 + rawData.mark / rawSpec.maxValue)),
173
+ ticks: rawTicksNumbers.map((tick) => ({
174
+ number: tick,
175
+ angle: (tick / rawSpec.maxValue) * rawSpec.circle.totalAngle + rawSpec.circle.angles.start,
176
+ })),
177
+ };
178
+
179
+ // Calculate Ticks Numbers Object for Items
180
+ const itemsTicksNumbers = Object.fromEntries(
181
+ Object.entries(itemsSpec.maxValues).map((entry) => [
182
+ entry[0],
183
+ FS.createArithmeticSequence(entry[1], -entry[1] / (itemsSpec.ticks.num - 1), itemsSpec.ticks.num).reverse(),
184
+ ])
185
+ );
186
+
187
+ // Gather Required Info for Items
188
+ let items = dataset.score.map((data) => ({
189
+ label: data.label,
190
+ mark: data.mark,
191
+ zeta:
192
+ (data.mark / itemsSpec.maxValues[data.label.eng]) * itemsSpec.circle.totalAngle + itemsSpec.circle.angles.start,
193
+ fill: itemsSpec.fills[data.label.eng],
194
+ opacity: FS.roundTo2(0.5 * (1 + data.mark / itemsSpec.maxValues[data.label.eng])),
195
+ ticks: itemsTicksNumbers[data.label.eng].map((tick) => ({
196
+ number: tick,
197
+ angle:
198
+ (tick / itemsSpec.maxValues[data.label.eng]) * itemsSpec.circle.totalAngle + itemsSpec.circle.angles.start,
199
+ })),
200
+ }));
201
+
202
+ items = [items.slice(0, 4), items.slice(4)];
203
+
204
+ return [{ raw, items }];
205
+ }
206
+ }
207
+
208
+ module.exports = WAQ93;