@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,64 @@
1
+ const { Profile, FS } = require("../Profile");
2
+
3
+ class PMCIEF93 extends Profile {
4
+ // Number of pages
5
+ static pages = 1;
6
+
7
+ // Labels of the sample
8
+ labels = {
9
+ L1: { eng: "me_and_my_partner", fr: "رابطه با شریک جنسی / همسر" },
10
+ L2: { eng: "me_and_my_children", fr: "رابطه با فرزندان" },
11
+ L3: { eng: "me_and_my_parents", fr: "رابطه با والدین" },
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: ["family_role"] /* 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: 903 + 2 * this.padding.x,
31
+ height: 714 + 2 * this.padding.y,
32
+ };
33
+ },
34
+ padding: {
35
+ x: 20,
36
+ y: 20,
37
+ },
38
+ },
39
+ /* "labels" part which has to be provided for each profile */
40
+ labels: Object.values(this.labels),
41
+ };
42
+
43
+ constructor(dataset, options, config = {}) {
44
+ super();
45
+ this._init(dataset, options, config);
46
+ }
47
+
48
+ _calcContext() {
49
+ const { dataset } = this;
50
+
51
+ // const items = dataset.score.map((data) => ({
52
+ // label: data.label,
53
+ // mark: data.mark,
54
+ // coordinates: {
55
+ // x: (data.mark.interaction - 6) * 25,
56
+ // y: (data.mark.structure - 6) * 25,
57
+ // },
58
+ // }));
59
+
60
+ return [{ }];
61
+ }
62
+ }
63
+
64
+ module.exports = PMCIEF93;
@@ -0,0 +1,126 @@
1
+ const { Profile, FS } = require("../Profile");
2
+
3
+ class PSWQ93 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: "interpretation", 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: 656 + 2 * this.padding.x,
30
+ height: 587 + 2 * this.padding.y,
31
+ }
32
+ },
33
+ padding: {
34
+ x: 0,
35
+ y: 70,
36
+ },
37
+ },
38
+ /* "raw" is the general term used for total data element in the profile */
39
+ raw: {
40
+ minValue: 0 /* Minimum value of the item mark */,
41
+ maxValue: 80 /* Maximum value of the item mark */,
42
+ stops: [15, 32, 48, 80] /* Stops array of the item mark */,
43
+ circle: {
44
+ R: 230 /* Radius of the outer circle of the item element */,
45
+ r: 40 /* Radius of the inner circle of the item element */,
46
+ brs: {
47
+ tl: 0 /* Top left border radius */,
48
+ bl: 0 /* Bottom left border radius */,
49
+ tr: 0 /* Top right border radius */,
50
+ br: 0 /* Bottom right border radius */,
51
+ } /* Border radiuses at each end of the gauge of the item element */,
52
+ angles: {
53
+ start: FS.toRadians(-90),
54
+ end: FS.toRadians(270),
55
+ } /* Angles of each end of the item element */,
56
+ direction: false /* Clockwise direction for the item gauge element */,
57
+ },
58
+ interprets: [
59
+ { fill: "#FBBF24", eng: "mild", fr: "نگرانی کم" },
60
+ { fill: "#EA580C", eng: "moderate", fr: "نگرانی متوسط" },
61
+ { fill: "#DC2626", eng: "severe", fr: "نگرانی زیاد" },
62
+ ],
63
+ },
64
+ /* "labels" part which has to be provided for each profile */
65
+ labels: Object.values(this.labels),
66
+ };
67
+
68
+ constructor(dataset, options, config = {}) {
69
+ super();
70
+ this._init(dataset, options, config);
71
+ }
72
+
73
+ _calcContext() {
74
+ const {
75
+ spec: { parameters: spec },
76
+ dataset,
77
+ } = this;
78
+
79
+ // Deconstructing the Spec of the Profile
80
+ const { raw: rawSpec } = spec;
81
+
82
+ const rawData = dataset.score[0];
83
+ const interpret = dataset.score[1].mark;
84
+
85
+ const raw = {
86
+ label: rawData.label,
87
+ mark: rawData.mark,
88
+ interpret: rawSpec.interprets.find((interpretation) => interpretation.eng === interpret),
89
+ angle: this._markToAngle(
90
+ rawData.mark,
91
+ rawSpec.minValue,
92
+ rawSpec.maxValue,
93
+ rawSpec.circle.angles,
94
+ rawSpec.circle.direction
95
+ ),
96
+ stops: rawSpec.stops.map((stop) => ({
97
+ mark: stop,
98
+ angle: this._markToAngle(
99
+ stop,
100
+ rawSpec.minValue,
101
+ rawSpec.maxValue,
102
+ rawSpec.circle.angles,
103
+ rawSpec.circle.direction
104
+ ),
105
+ })),
106
+ };
107
+
108
+ return [{ raw }];
109
+ }
110
+
111
+ _markToAngle(mark, min, max, angles, direction) {
112
+ const totalAngle = this._calcDiffAngle(angles.end, angles.start, direction);
113
+ const deltaTheta = ((mark - min) / (max - min)) * totalAngle;
114
+ return this._calcDistAngle(deltaTheta, angles.start, direction);
115
+ }
116
+
117
+ _calcDiffAngle(theta, theta0, direction) {
118
+ return direction ? 2 * Math.PI - (theta - theta0) : theta - theta0;
119
+ }
120
+
121
+ _calcDistAngle(deltaTheta, theta0, direction) {
122
+ return direction ? 2 * Math.PI - deltaTheta + theta0 : deltaTheta + theta0;
123
+ }
124
+ }
125
+
126
+ module.exports = PSWQ93;
@@ -0,0 +1,144 @@
1
+ const { Profile, Mappings } = require("../Profile");
2
+
3
+ class RIASEC93 extends Profile {
4
+ // Number of pages
5
+ static pages = 1;
6
+
7
+ // Labels of the sample
8
+ labels = {
9
+ L1: { eng: "realistic", fr: "واقع‌گرا (و)" },
10
+ L2: { eng: "investigative", fr: "جستجوگر (ج)" },
11
+ L3: { eng: "artistic", fr: "هنری (ه)" },
12
+ L4: { eng: "social", fr: "اجتماعی (الف)" },
13
+ L5: { eng: "enterprising", fr: "متهور (م)" },
14
+ L6: { eng: "conventional", 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: true /* 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: 602 + 2 * this.padding.x,
34
+ height: 595 + 2 * this.padding.y,
35
+ };
36
+ },
37
+ padding: {
38
+ x: 0,
39
+ y: 51,
40
+ },
41
+ },
42
+ /* "items" is the general term used for independent data elements to be drawn in the profile */
43
+ items: {
44
+ offsetY: 32 /* Horizontal offset between two top items */,
45
+ get distanceY() {
46
+ return this.offsetY + this.rect.body.height;
47
+ } /* Horizontal distance between two top items */,
48
+ maxValue: 50 /* Maximum value of items */,
49
+ rect: {
50
+ base: {
51
+ height: 4,
52
+ },
53
+ body: {
54
+ height: 8,
55
+ brs: {
56
+ tl: 0,
57
+ tr: 4,
58
+ bl: 0,
59
+ br: 0,
60
+ },
61
+ },
62
+ widthCoeff: 10,
63
+ opacityMappings: new Mappings()
64
+ .addMapping("1-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) /* Opacity mapping for marks */,
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
+ const { items: itemsSpec } = spec;
88
+
89
+ dataset.score.sort((item1, item2) => item2.mark - item1.mark);
90
+
91
+ // Gathering required info for page 1 items
92
+ const items = dataset.score.map((data) => ({
93
+ label: data.label,
94
+ mark: data.mark,
95
+ width: data.mark * itemsSpec.rect.widthCoeff,
96
+ opacity: itemsSpec.rect.opacityMappings.map(data.mark),
97
+ }));
98
+
99
+ const questionItems = [
100
+ {
101
+ label: "فعالیت‌ها",
102
+ marks: Array(6)
103
+ .fill(11)
104
+ .map((n, index) =>
105
+ dataset.questions
106
+ .slice(index * n, (index + 1) * n)
107
+ .reduce((sum, { user_answered }) => sum + (+user_answered !== 2 ? 1 : 0), 0)
108
+ ),
109
+ },
110
+ {
111
+ label: "تجربه‌ها",
112
+ marks: Array(6)
113
+ .fill(11)
114
+ .map((n, index) =>
115
+ dataset.questions
116
+ .slice(66 + index * n, 66 + (index + 1) * n)
117
+ .reduce((sum, { user_answered }) => sum + (+user_answered !== 2 ? 1 : 0), 0)
118
+ ),
119
+ },
120
+ {
121
+ label: "مشاغل",
122
+ marks: Array(6)
123
+ .fill(14)
124
+ .map((n, index) =>
125
+ dataset.questions
126
+ .slice(132 + index * n, 132 + (index + 1) * n)
127
+ .reduce((sum, { user_answered }) => sum + (+user_answered !== 2 ? 1 : 0), 0)
128
+ ),
129
+ },
130
+ {
131
+ label: "خودسنجی ۱",
132
+ marks: dataset.questions.slice(216, 216 + 6).map((q) => +q.user_answered),
133
+ },
134
+ {
135
+ label: "خودسنجی ۲",
136
+ marks: dataset.questions.slice(222, 222 + 6).map((q) => +q.user_answered),
137
+ },
138
+ ];
139
+
140
+ return [{ items, questionItems }];
141
+ }
142
+ }
143
+
144
+ module.exports = RIASEC93;
@@ -0,0 +1,64 @@
1
+ const { Profile, FS } = require("../Profile");
2
+
3
+ class SAFE93 extends Profile {
4
+ // Number of pages
5
+ static pages = 1;
6
+
7
+ // Labels of the sample
8
+ labels = {
9
+ L1: { eng: "me_and_my_partner", fr: "رابطه با شریک جنسی / همسر" },
10
+ L2: { eng: "me_and_my_children", fr: "رابطه با فرزندان" },
11
+ L3: { eng: "me_and_my_parents", fr: "رابطه با والدین" },
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: "پرسشنامه SAFE" /* 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: ["family_role"] /* 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: 851 + 2 * this.padding.x,
31
+ height: 691 + 2 * this.padding.y,
32
+ };
33
+ },
34
+ padding: {
35
+ x: 70,
36
+ y: 0,
37
+ },
38
+ },
39
+ /* "labels" part which has to be provided for each profile */
40
+ labels: Object.values(this.labels),
41
+ };
42
+
43
+ constructor(dataset, options, config = {}) {
44
+ super();
45
+ this._init(dataset, options, config);
46
+ }
47
+
48
+ _calcContext() {
49
+ const { dataset } = this;
50
+
51
+ const items = dataset.score.map((data) => ({
52
+ label: data.label,
53
+ mark: data.mark,
54
+ coordinates: {
55
+ x: (data.mark.interaction - 6) * 25,
56
+ y: (data.mark.structure - 6) * 25,
57
+ },
58
+ }));
59
+
60
+ return [{ items }];
61
+ }
62
+ }
63
+
64
+ module.exports = SAFE93;
@@ -0,0 +1,130 @@
1
+ const { Profile, FS } = require("../Profile");
2
+
3
+ class SASQ93 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: "interpretation", 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: 723 + 2 * this.padding.x,
30
+ height: 350 + 2 * this.padding.y,
31
+ }
32
+ },
33
+ padding: {
34
+ x: 70,
35
+ y: 0,
36
+ },
37
+ },
38
+ /* "raw" is the general term used for total data element in the profile */
39
+ raw: {
40
+ minValue: 34 /* Minimum value of items data element */,
41
+ maxValue: 175 /* Maximum value of items data element */,
42
+ get range() {
43
+ return this.maxValue - this.minValue;
44
+ },
45
+ stops: [34, 69, 105, 175],
46
+ fill: "#BE185D",
47
+ circle: {
48
+ R: 307 /* Radius of the outer circle of the items element */,
49
+ r: 230 /* Radius of the inner circle of the items element */,
50
+ brs: {
51
+ tl: 0 /* Top left border radius */,
52
+ bl: 0 /* Bottom left border radius */,
53
+ tr: 0 /* Top right border radius */,
54
+ br: 0 /* Bottom right border radius */,
55
+ } /* Border radiuses at each end of the gauge of the items element */,
56
+ angles: {
57
+ start: FS.toRadians(-180),
58
+ end: FS.toRadians(0),
59
+ } /* Angles of each end of the items element */,
60
+ direction: false /* Clockwise direction for the items gauge element */,
61
+ },
62
+ interprets: [
63
+ { opacity: 0.6, eng: "mild", fr: "سطح پایین" },
64
+ { opacity: 0.8, eng: "moderate", fr: "سطح متوسط" },
65
+ { opacity: 1, eng: "severe", fr: "سطح شدید" },
66
+ ],
67
+ },
68
+ /* "labels" part which has to be provided for each profile */
69
+ labels: Object.values(this.labels),
70
+ };
71
+
72
+ constructor(dataset, options, config = {}) {
73
+ super();
74
+ this._init(dataset, options, config);
75
+ }
76
+
77
+ _calcContext() {
78
+ const {
79
+ spec: { parameters: spec },
80
+ dataset,
81
+ } = this;
82
+
83
+ // Deconstructing the Spec of the Profile
84
+ const { raw: rawSpec } = spec;
85
+
86
+ const rawData = dataset.score[0];
87
+ const interpretData = dataset.score[1];
88
+
89
+ const raw = {
90
+ label: rawData.label,
91
+ mark: rawData.mark,
92
+ interpretation: interpretData.mark,
93
+ angle: this._markToAngle(
94
+ rawData.mark,
95
+ rawSpec.minValue,
96
+ rawSpec.maxValue,
97
+ rawSpec.circle.angles,
98
+ rawSpec.circle.direction
99
+ ),
100
+ stops: rawSpec.stops.map((stop) => ({
101
+ mark: stop,
102
+ angle: this._markToAngle(
103
+ stop,
104
+ rawSpec.minValue,
105
+ rawSpec.maxValue,
106
+ rawSpec.circle.angles,
107
+ rawSpec.circle.direction
108
+ ),
109
+ })),
110
+ };
111
+
112
+ return [{ raw }];
113
+ }
114
+
115
+ _markToAngle(mark, min, max, angles, direction) {
116
+ const totalAngle = this._calcDiffAngle(angles.end, angles.start, direction);
117
+ const deltaTheta = ((mark - min) / (max - min)) * totalAngle;
118
+ return this._calcDistAngle(deltaTheta, angles.start, direction);
119
+ }
120
+
121
+ _calcDiffAngle(theta, theta0, direction) {
122
+ return direction ? 2 * Math.PI - (theta - theta0) : theta - theta0;
123
+ }
124
+
125
+ _calcDistAngle(deltaTheta, theta0, direction) {
126
+ return direction ? 2 * Math.PI - deltaTheta + theta0 : deltaTheta + theta0;
127
+ }
128
+ }
129
+
130
+ module.exports = SASQ93;