@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,142 @@
1
+ const { Profile, FS, Mappings } = require("../Profile");
2
+
3
+ class GMIT93 extends Profile {
4
+ // Number of pages
5
+ static pages = 1;
6
+
7
+ // Labels of the sample
8
+ labels = {
9
+ L1: { eng: "linguistic", fr: "زبانی - کلامی" },
10
+ L2: { eng: "logical_mathematical", fr: "منطقی - ریاضی" },
11
+ L3: { eng: "visual_spatial", fr: "دیداری - فضایی" },
12
+ L4: { eng: "bodily_kinesthetic", fr: "بدنی - جنبشی" },
13
+ L5: { eng: "interpersonal", fr: "میان‌فردی" },
14
+ L6: { eng: "intrapersonal", fr: "درون‌فردی" },
15
+ L7: { eng: "musical", fr: "موسیقیایی" },
16
+ L8: { eng: "naturalist", 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: 634 + 2 * this.padding.x,
36
+ height: 610 + 2 * this.padding.y,
37
+ };
38
+ },
39
+ padding: {
40
+ x: 0,
41
+ y: 52,
42
+ },
43
+ },
44
+ /* "items" is the general term used for independent data elements to be drawn in the profile */
45
+ items: {
46
+ minValue: 10 /* Minimum value of items mark provided by the dataset */,
47
+ maxValue: 50 /* Maximum value of items mark provided by the dataset */,
48
+ offsetX: 134 /* Horizontal offset between items and left side of profile */,
49
+ offsetY: 30 /* Vertical offset between two consecutive item in the profile */,
50
+ get distanceY() {
51
+ return this.offsetY + this.rect.height;
52
+ } /* Distance between two consecutive item in the profile */,
53
+ totalHeight: "" /* To be calculated in the class with the function provided */,
54
+ calcTotalHeight: function (n) {
55
+ return this.distanceY * (n - 1) + this.rect.height;
56
+ } /* Method for calculating the total height of items */,
57
+ ticks: {
58
+ num: 5 /* Number of ticks */,
59
+ heightOffset: 40 /* Half length that the ticks lines of items is greater than items total heigth */,
60
+ numberOffset: {
61
+ x: 10 /* Horizontal distance from the line */,
62
+ y: 10 /* Vertical distance from the line */,
63
+ },
64
+ },
65
+ rect: {
66
+ height: 40 /* Height of the items rectangle */,
67
+ get borderRadius() {
68
+ return this.height / 2;
69
+ } /* Border Radius of the items rectangle */,
70
+ colors: [
71
+ "#8B5CF6",
72
+ "#EC4899",
73
+ "#10B981",
74
+ "#F59E0B",
75
+ "#007BA4",
76
+ "#F43F5E",
77
+ "#71717A",
78
+ "#047857",
79
+ ] /* Colors used for theming items body parts */,
80
+ opacityMappings: new Mappings()
81
+ .addMapping("10-19", 0.7)
82
+ .addMapping("20-29", 0.8)
83
+ .addMapping("30-39", 0.9)
84
+ .addMapping("40-50", 1) /* Opacity mapping for marks */,
85
+ },
86
+ widthCoeff: 10 /* Used for converting mark to the width */,
87
+ label: {
88
+ offsetX: 20 /* Horizontal offset of label from item */,
89
+ },
90
+ },
91
+ /* "labels" part which has to be provided for each profile */
92
+ labels: Object.values(this.labels),
93
+ };
94
+
95
+ constructor(dataset, options, config = {}) {
96
+ super();
97
+ this._init(dataset, options, config);
98
+ }
99
+
100
+ _calcContext() {
101
+ const {
102
+ spec: { parameters: spec },
103
+ dataset,
104
+ } = this;
105
+
106
+ const { items: itemsSpec } = spec;
107
+
108
+ // ّInit Spec
109
+ spec.items.totalHeight = spec.items.calcTotalHeight(dataset.score.length);
110
+
111
+ // Gather Required Info for Items
112
+ const items = dataset.score.map((data, index) => ({
113
+ label: data.label,
114
+ mark: data.mark,
115
+ width: data.mark * itemsSpec.widthCoeff,
116
+ fill: itemsSpec.rect.colors[index],
117
+ opacity: itemsSpec.rect.opacityMappings.map(data.mark),
118
+ }));
119
+
120
+ // Calculate Ticks Numbers Array for Items
121
+ const itemsTicksNumbers = FS.createArithmeticSequence(
122
+ itemsSpec.minValue,
123
+ (itemsSpec.maxValue - itemsSpec.minValue) / (itemsSpec.ticks.num - 1),
124
+ itemsSpec.ticks.num
125
+ );
126
+
127
+ // Gather Required Info for Items Ticks
128
+ const itemsTicks = itemsTicksNumbers.map((tick) => ({
129
+ number: tick,
130
+ leftPos: tick * itemsSpec.widthCoeff,
131
+ }));
132
+
133
+ return [
134
+ {
135
+ items,
136
+ itemsTicks,
137
+ },
138
+ ];
139
+ }
140
+ }
141
+
142
+ module.exports = GMIT93;
@@ -0,0 +1,132 @@
1
+ const { Profile, FS } = require("../Profile");
2
+
3
+ class HPL93 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: "spritual_growth", fr: "رشد معنوی و شکوفایی" },
11
+ L3: { eng: "nutrition", fr: "تغذیه" },
12
+ L4: { eng: "stress_management", fr: "مدیریت استرس" },
13
+ L5: { eng: "physical_activity", fr: "ورزش و فعالیت بدنی" },
14
+ L6: { eng: "health_self_responsibility", fr: "مسئولیت‌پذیری در مورد سلامت" },
15
+ L7: { eng: "interpersonal_relationships", 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: false /* Determines whether to get questions from inital dataset or not */,
26
+ defaultFields: true /* Determines whether to have default prerequisites in the profile or not */,
27
+ fields: ["marital_status"] /* In case you want to get some additional fields and show in the profile */,
28
+ },
29
+ /* "profile" determines the dimensions of the drawn profile (to be used in svg tag viewbox) */
30
+ /* calculating its dimensions carefully is of great importance */
31
+ profile: {
32
+ get dimensions() {
33
+ return {
34
+ width: 770 + 2 * this.padding.x,
35
+ height: 600 + 2 * this.padding.y,
36
+ }
37
+ },
38
+ padding: {
39
+ x: 50,
40
+ y: 0,
41
+ },
42
+ },
43
+ /* Spec for the polygons drawn in the profile */
44
+ polygons: {
45
+ n: 6 /* Number of vertices of the polygons */,
46
+ get theta() {
47
+ return (2 * Math.PI) / this.n;
48
+ },
49
+ startAngle: FS.toRadians(-60) /* Start angle of the polygon */,
50
+ radius: 270 /* Radius of the peripheral circle of the main polygon */,
51
+ centerOffset: 67 /* Radius of the peropheral circle of the smallest polygon */,
52
+ },
53
+ /* "raw" is the general term used for total data element in the profile */
54
+ raw: {
55
+ maxValue: 216,
56
+ mark: {
57
+ paddingY: 18,
58
+ },
59
+ },
60
+ /* "items" is the general term used for independent data elements to be drawn in the profile */
61
+ items: {
62
+ maxValues: {
63
+ [this.labels.L2.eng]: 40,
64
+ [this.labels.L3.eng]: 28,
65
+ [this.labels.L4.eng]: 24,
66
+ [this.labels.L5.eng]: 36,
67
+ [this.labels.L6.eng]: 56,
68
+ [this.labels.L7.eng]: 28,
69
+ } /* Maximum value of marks provided by the dataset */,
70
+ labels: {
71
+ offset: 50 /* Offset of the label from the vertice of the polygon */,
72
+ paddingY: 12 /* Half distance between two parts of the label */,
73
+ },
74
+ dataPoints: {
75
+ radius: 12 /* Radius of the circle of the data point */,
76
+ fills: {
77
+ [this.labels.L2.eng]: "#C026D3",
78
+ [this.labels.L3.eng]: "#EA580C",
79
+ [this.labels.L4.eng]: "#52525B",
80
+ [this.labels.L5.eng]: "#2563EB",
81
+ [this.labels.L6.eng]: "#059669",
82
+ [this.labels.L7.eng]: "#E11D48",
83
+ } /* Colors used for theming data points */,
84
+ },
85
+ },
86
+ /* "labels" part which has to be provided for each profile */
87
+ labels: Object.values(this.labels)
88
+ };
89
+
90
+ constructor(dataset, options, config = {}) {
91
+ super();
92
+ this._init(dataset, options, config);
93
+ }
94
+
95
+ _calcContext() {
96
+ const {
97
+ spec: { parameters: spec },
98
+ dataset,
99
+ } = this;
100
+
101
+ // Deconstructing the Spec of the Profile
102
+ let { polygons: polygonsSpec, items: itemsSpec } = spec;
103
+
104
+ const rawData = dataset.score.shift();
105
+
106
+ const raw = {
107
+ label: rawData.label,
108
+ mark: rawData.mark,
109
+ };
110
+
111
+ // Gather Required Info for Items
112
+ const items = dataset.score.map((data, index) => ({
113
+ label: data.label,
114
+ mark: data.mark,
115
+ maxValue: itemsSpec.maxValues[data.label.eng],
116
+ angle: polygonsSpec.startAngle - index * polygonsSpec.theta,
117
+ radius:
118
+ (data.mark / itemsSpec.maxValues[data.label.eng]) * (polygonsSpec.radius - polygonsSpec.centerOffset) +
119
+ polygonsSpec.centerOffset,
120
+ fill: itemsSpec.dataPoints.fills[data.label.eng],
121
+ }));
122
+
123
+ return [
124
+ {
125
+ raw,
126
+ items,
127
+ },
128
+ ];
129
+ }
130
+ }
131
+
132
+ module.exports = HPL93;
@@ -0,0 +1,99 @@
1
+ const { Mappings } = require("../Profile");
2
+ const PIES93 = require("./PIES93");
3
+
4
+ const labels = {
5
+ L1: { eng: "da", fr: "توقع تأیید از دیگران", abbr: "DA" },
6
+ L2: { eng: "hse", fr: "انتظارات بیش از حد خود", abbr: "HSE" },
7
+ L3: { eng: "bp", fr: "سرزنش خود", abbr: "BP" },
8
+ L4: { eng: "fr", fr: "واکنش همراه با ناکامی", abbr: "FR" },
9
+ L5: { eng: "ei", fr: "بی‌مسئولیتی هیجانی", abbr: "EI" },
10
+ L6: { eng: "ao", fr: "بیش دلواپسی اضطرابی", abbr: "AO" },
11
+ L7: { eng: "pa", fr: "اجتناب از مشکل", abbr: "PA" },
12
+ L8: { eng: "d", fr: "وابستگی", abbr: "D" },
13
+ L9: { eng: "hc", fr: "درماندگی برای تغییر", abbr: "HC" },
14
+ L10: { eng: "p", fr: "کمال‌گرایی", abbr: "P" },
15
+ L11: { eng: "raw", fr: "نمره کل", abbr: "#" },
16
+ };
17
+
18
+ const customConfig = {
19
+ sample: {
20
+ name: "پرسشنامه باورهای غیرمنطقی جونز" /* Name of the sample */,
21
+ },
22
+ profile: {
23
+ get dimensions() {
24
+ return {
25
+ width: 834 + 2 * this.padding.x,
26
+ height: 670 + 2 * this.padding.y,
27
+ }
28
+ },
29
+ padding: {
30
+ x: 40,
31
+ y: 8,
32
+ },
33
+ },
34
+ raw: {
35
+ maxValue: 500,
36
+ offsetX: 80,
37
+ ticks: {
38
+ num: 5 /* Number of ticks */,
39
+ },
40
+ rect: {
41
+ height: 670,
42
+ },
43
+ },
44
+ items: {
45
+ maxValue: 50,
46
+ offsetY: 21,
47
+ ticks: {
48
+ num: 5 /* Number of ticks */,
49
+ },
50
+ body: {
51
+ colors: [
52
+ "#06B6D4",
53
+ "#0EA5E9",
54
+ "#6366F1",
55
+ "#7C3AED",
56
+ "#A855F7",
57
+ "#D946EF",
58
+ "#EC4899",
59
+ "#F43F5E",
60
+ "#F97316",
61
+ "#FBBF24",
62
+ ],
63
+ opacityMappings: new Mappings()
64
+ .addMapping("10", 0.6)
65
+ .addMapping("11-20", 0.7)
66
+ .addMapping("21-30", 0.8)
67
+ .addMapping("31-40", 0.9)
68
+ .addMapping("41-50", 1),
69
+ },
70
+ base: {
71
+ rect: {
72
+ width: 272,
73
+ },
74
+ colors: [
75
+ "#39C5DE",
76
+ "#3EB7EC",
77
+ "#8385F4",
78
+ "#9661F1",
79
+ "#B978FA",
80
+ "#E16BF3",
81
+ "#F06EAE",
82
+ "#F7647E",
83
+ "#FB8F46",
84
+ "#FCCC50",
85
+ ],
86
+ },
87
+ },
88
+ labels: Object.values(labels),
89
+ };
90
+
91
+ // This profile is completely identical to MMFAD9A
92
+
93
+ class IBT93 extends PIES93 {
94
+ constructor(dataset, options, config = customConfig) {
95
+ super(dataset, options, config);
96
+ }
97
+ }
98
+
99
+ module.exports = IBT93;
@@ -0,0 +1,204 @@
1
+ const { Profile, FS } = require("../Profile");
2
+
3
+ class IUS93 extends Profile {
4
+ // Number of pages
5
+ static pages = 1;
6
+
7
+ // Labels of the sample
8
+ labels = {
9
+ L1: { eng: "raw", title: "نمره کل", desc: "" },
10
+ L2: { eng: "factor_1", title: "عامل ۱", desc: "بلاتکلیفی تلویحات خودارجاعی و رفتار منفی دارد" },
11
+ L3: { eng: "factor_2", title: "عامل ۲", desc: "بلاتکلیفی غیرمنصفانه است و همه چیز را تباه می‌کند" },
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: 506 + 2 * this.padding.x,
31
+ height: 627 + 2 * this.padding.y,
32
+ }
33
+ },
34
+ padding: {
35
+ x: 10,
36
+ y: 45,
37
+ },
38
+ },
39
+ /* "raw" is the general term used for total data element in the profile */
40
+ raw: {
41
+ maxValue: 135 /* Maximum value of raw mark provided by the dataset */,
42
+ fill: "#B91C1C" /* Color used in the raw element */,
43
+ circle: {
44
+ R: 140 /* Radius of the outer circle of the raw element */,
45
+ r: 85 /* Radius of the inner circle of the raw element */,
46
+ brs: {
47
+ tl: 0 /* Top left border radius */,
48
+ bl: 0 /* Bottom left border radius */,
49
+ tr: 12 /* Top right border radius */,
50
+ br: 12 /* Bottom right border radius */,
51
+ } /* Border radiuses at each end of the gauge of the raw element */,
52
+ angles: {
53
+ start: FS.toRadians(-90),
54
+ end: FS.toRadians(180),
55
+ } /* Angles of each end of the raw element */,
56
+ direction: false /* Clockwise direction for the raw gauge element */,
57
+ get totalAngle() {
58
+ return this.direction
59
+ ? 2 * Math.PI - (this.angles.end - this.angles.start)
60
+ : this.angles.end - this.angles.start;
61
+ },
62
+ },
63
+ rect: {
64
+ width: 135 /* Width of the label rect of the raw element */,
65
+ height: 55 /* Height of the label rect of the raw element */,
66
+ rb: 8 /* Border radius of the label rect of the raw element */,
67
+ offsetX: 5 /* Offset between rectangle and the beginning of the gauge */,
68
+ },
69
+ ticks: {
70
+ num: 2 /* Number of ticks */,
71
+ line: {
72
+ width: 12 /* Width of the tick line */,
73
+ offset: 4 /* Offset from the element */,
74
+ },
75
+ number: {
76
+ offset: 8 /* Offset from the line */,
77
+ },
78
+ },
79
+ },
80
+ /* "items" is the general term used for independent data elements to be drawn in the profile */
81
+ items: {
82
+ offsetX: 102 /* Horizontal offset between two items */,
83
+ offsetY: 63 /* Vertical offset between items and raw */,
84
+ get distanceX() {
85
+ return this.offsetX + this.circle.R * 2;
86
+ } /* Horizontal distance between two items */,
87
+ maxValues: {
88
+ factor_1: 75,
89
+ factor_2: 60,
90
+ } /* Maximum value of items */,
91
+ fills: {
92
+ factor_1: "#D97706",
93
+ factor_2: "#1E3A8A",
94
+ } /* Color used in items */,
95
+ circle: {
96
+ R: 90 /* Radius of the outer circle of the items element */,
97
+ r: 50 /* Radius of the inner circle of the items element */,
98
+ brs: {
99
+ tl: 0 /* Top left border radius */,
100
+ bl: 0 /* Bottom left border radius */,
101
+ tr: 12 /* Top right border radius */,
102
+ br: 12 /* Bottom right border radius */,
103
+ } /* Border radiuses at each end of the gauge of the items element */,
104
+ angles: {
105
+ start: FS.toRadians(-90),
106
+ end: FS.toRadians(180),
107
+ } /* Angles of each end of the items element */,
108
+ direction: false /* Clockwise direction for the items gauge element */,
109
+ get totalAngle() {
110
+ return this.direction
111
+ ? 2 * Math.PI - (this.angles.end - this.angles.start)
112
+ : this.angles.end - this.angles.start;
113
+ },
114
+ },
115
+ rect: {
116
+ width: 85 /* Width of the label rect of the items element */,
117
+ height: 40 /* Width of the label rect of the items element */,
118
+ rb: 8 /* Width of the label rect of the items element */,
119
+ offsetX: 5 /* Offset between rectangle and the beginning of the gauge */,
120
+ },
121
+ ticks: {
122
+ num: 2 /* Number of ticks */,
123
+ line: {
124
+ width: 12 /* Width of the tick line */,
125
+ offset: 4 /* Offset from the element */,
126
+ },
127
+ number: {
128
+ offset: 8 /* Offset from the line */,
129
+ },
130
+ },
131
+ label: {
132
+ offsetY: 30,
133
+ lineHeight: 25,
134
+ },
135
+ },
136
+ /* "labels" part which has to be provided for each profile */
137
+ labels: Object.values(this.labels),
138
+ };
139
+
140
+ constructor(dataset, options, config = {}) {
141
+ super();
142
+ this._init(dataset, options, config);
143
+ }
144
+
145
+ _calcContext() {
146
+ const {
147
+ spec: { parameters: spec },
148
+ dataset,
149
+ } = this;
150
+
151
+ // Deconstructing the Spec of the Profile
152
+ const { raw: rawSpec, items: itemsSpec } = spec;
153
+
154
+ // Separate Raw Data from the Dataset
155
+ const rawData = dataset.score.shift();
156
+
157
+ // Calculate Ticks Numbers Array for Raw
158
+ const rawTicksNumbers = FS.createArithmeticSequence(
159
+ rawSpec.maxValue,
160
+ -rawSpec.maxValue / (rawSpec.ticks.num - 1),
161
+ rawSpec.ticks.num
162
+ ).reverse();
163
+
164
+ // Gather Required Info for Raw
165
+ const raw = {
166
+ label: rawData.label,
167
+ mark: rawData.mark,
168
+ zeta: (rawData.mark / rawSpec.maxValue) * rawSpec.circle.totalAngle + rawSpec.circle.angles.start,
169
+ fill: rawSpec.fill,
170
+ opacity: FS.roundTo2(0.5 * (1 + rawData.mark / rawSpec.maxValue)),
171
+ ticks: rawTicksNumbers.map((tick) => ({
172
+ number: tick,
173
+ angle: (tick / rawSpec.maxValue) * rawSpec.circle.totalAngle + rawSpec.circle.angles.start,
174
+ })),
175
+ };
176
+
177
+ // Calculate Ticks Numbers Object for Items
178
+ const itemsTicksNumbers = Object.fromEntries(
179
+ Object.entries(itemsSpec.maxValues).map((entry) => [
180
+ entry[0],
181
+ FS.createArithmeticSequence(entry[1], -entry[1] / (itemsSpec.ticks.num - 1), itemsSpec.ticks.num).reverse(),
182
+ ])
183
+ );
184
+
185
+ // Gather Required Info for Items
186
+ const items = dataset.score.map((data) => ({
187
+ label: data.label,
188
+ mark: data.mark,
189
+ zeta:
190
+ (data.mark / itemsSpec.maxValues[data.label.eng]) * itemsSpec.circle.totalAngle + itemsSpec.circle.angles.start,
191
+ fill: itemsSpec.fills[data.label.eng],
192
+ opacity: FS.roundTo2(0.5 * (1 + data.mark / itemsSpec.maxValues[data.label.eng])),
193
+ ticks: itemsTicksNumbers[data.label.eng].map((tick) => ({
194
+ number: tick,
195
+ angle:
196
+ (tick / itemsSpec.maxValues[data.label.eng]) * itemsSpec.circle.totalAngle + itemsSpec.circle.angles.start,
197
+ })),
198
+ }));
199
+
200
+ return [{ raw, items }];
201
+ }
202
+ }
203
+
204
+ module.exports = IUS93;