@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,139 @@
1
+ {
2
+ "id": "$X1HQ2G3J3",
3
+ "scale": {
4
+ "id": "$PIES-93",
5
+ "title": "آزمون دلبستگی کولینز و رید"
6
+ },
7
+ "version": "1",
8
+ "edition": "",
9
+ "edition_version": null,
10
+ "client": {
11
+ "id": "GH96666D7",
12
+ "name": "نام کاربر در این اتاق"
13
+ },
14
+ "filler": "client",
15
+ "description": "## دستور اجرای آزمون\n\nعبارات زیر جملاتی هستند که ممکن است افراد از آن‌ها برای توصیف خود استفاده کنند. خواهشمند است هر عبارت را به دقت بخوانید و تعیین کنید تا چه میزانی آن عبارت می‌تواند شما را توصیف کند. سپس میزان درست بودن آن عبارت را بر اساس درجه‌بندی در ستون مقابل علامت بزنید.",
16
+ "room": {
17
+ "manager": {
18
+ "name": "نام اتاق / درمانگر که از قضا طولانی هم شده است!"
19
+ }
20
+ },
21
+ "center": {
22
+ "detail": {
23
+ "title": "اتاق درمانی شخصی یا نام مرکز درمانی"
24
+ }
25
+ },
26
+ "started_at": 1630907666,
27
+ "closed_at": 1711907666,
28
+ "scored_at": 1731907666,
29
+ "prerequisites": [
30
+ {
31
+ "type": "text",
32
+ "label": "gender",
33
+ "text": "جنسیت",
34
+ "answer": {
35
+ "type": "select",
36
+ "options": ["زن", "مرد"]
37
+ },
38
+ "alias": "gender",
39
+ "force": true,
40
+ "user_answered": "2"
41
+ },
42
+ {
43
+ "type": "text",
44
+ "label": "marital_status",
45
+ "text": "وضعیت تأهل",
46
+ "answer": {
47
+ "type": "select",
48
+ "options": ["مجرد", "متأهل"]
49
+ },
50
+ "alias": "marital_status",
51
+ "force": true,
52
+ "user_answered": "2"
53
+ },
54
+ {
55
+ "type": "text",
56
+ "label": "age",
57
+ "text": "سن",
58
+ "answer": {
59
+ "type": "number"
60
+ },
61
+ "alias": "age",
62
+ "force": true,
63
+ "user_answered": "35"
64
+ },
65
+ {
66
+ "type": "text",
67
+ "label": "education",
68
+ "text": "تحصیلات",
69
+ "answer": {
70
+ "type": "select",
71
+ "options": [
72
+ "ابتدایی اول",
73
+ "ابتدایی دوم",
74
+ "متوسطه اول",
75
+ "متوسطه دوم",
76
+ "دیپلم",
77
+ "کارشناسی",
78
+ "کارشناسی ارشد",
79
+ "پزشکی عمومی",
80
+ "متخصص",
81
+ "دکتری تخصصی",
82
+ "حوزوی مقدمات",
83
+ "حوزوی سطح۱",
84
+ "حوزوی سطح۲",
85
+ "حوزوی سطح۳",
86
+ "حوزوی سطح۴"
87
+ ]
88
+ },
89
+ "alias": "education",
90
+ "force": true,
91
+ "user_answered": "6"
92
+ },
93
+ {
94
+ "type": "text",
95
+ "label": "job",
96
+ "text": "شغل",
97
+ "answer": {
98
+ "type": "text"
99
+ },
100
+ "alias": "job",
101
+ "force": true,
102
+ "user_answered": "آزاد"
103
+ },
104
+ {
105
+ "type": "text",
106
+ "label": "reason",
107
+ "text": "علت مراجعه",
108
+ "answer": {
109
+ "type": "text"
110
+ },
111
+ "alias": "reason",
112
+ "force": true,
113
+ "user_answered": "مشکلات خانوادگی و زناشویی"
114
+ },
115
+ {
116
+ "type": "text",
117
+ "label": "economical_situation",
118
+ "text": "وضعیت اقتصادی",
119
+ "answer": {
120
+ "type": "text"
121
+ },
122
+ "alias": "economical_situation",
123
+ "force": true,
124
+ "user_answered": "بسیار خوب"
125
+ },
126
+ {
127
+ "type": "text",
128
+ "label": "number",
129
+ "text": "تعداد روز بستری بودن",
130
+ "answer": {
131
+ "type": "number"
132
+ },
133
+ "alias": "number",
134
+ "force": true,
135
+ "user_answered": "10"
136
+ }
137
+ ],
138
+ "score": {}
139
+ }
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 400" font-family="Dana">
3
+ <rect x="0" y="0" width="500" height="400" fill="#EA6B13"/>
4
+ <g transform="translate(250, 200)">
5
+ <text x="0" y="-75" fill="white" fill-opacity="0.25" font-size="36" font-weight="800" text-anchor="middle">RISLOO EXTRACTOR CLI</text>
6
+ <g transform="translate(0, 65)">
7
+ <text x="0" y="0" fill="black" fill-opacity="0.25" font-size="88" font-weight="900" text-anchor="middle">v {{version}}</text>
8
+ <text x="0" y="0" fill="white" font-size="96" font-weight="900" text-anchor="middle">v {{version}}</text>
9
+ </g>
10
+ </g>
11
+ </svg>
@@ -0,0 +1,109 @@
1
+ const chalk = require("chalk");
2
+ const { readdir, rm } = require("fs/promises");
3
+ const path = require("path");
4
+ const ExtractExecutor = require("../cli-commands/ExtractExecutor");
5
+ const GiftExecutor = require("../cli-commands/GiftExecutor");
6
+
7
+ const jsonDir = path.join(__dirname, "json");
8
+ const samplesJSDir = path.join(__dirname, "..", "samples");
9
+ const outputDir = path.join(__dirname, "output");
10
+
11
+ let errors = 0;
12
+
13
+ async function loadSampleNames() {
14
+ return readdir(samplesJSDir).then((sampleNames) =>
15
+ sampleNames.map((name) => name.split(".")[0]).filter((name) => name !== "empty")
16
+ );
17
+ }
18
+
19
+ async function testExtract() {
20
+ // Number of samples resulted in error
21
+ let erroneousSamples = 0;
22
+
23
+ // Profile variants different choices
24
+ const profileVariants = ["raw", "with-sidebar"];
25
+
26
+ // Input data
27
+ let inputData = "";
28
+
29
+ // Initial Extract Command Options
30
+ let extractOptions = {
31
+ sampleName: "",
32
+ sampleOutputs: ["profile"],
33
+ profileVariant: "",
34
+ inputType: "local",
35
+ outputType: "local",
36
+ inputData: "",
37
+ measure: false,
38
+ benchmark: true,
39
+ watch: false,
40
+ outputAddress: outputDir,
41
+ };
42
+
43
+ return loadSampleNames().then(async (sampleNames) => {
44
+ const numProfiles = sampleNames.length * profileVariants.length;
45
+ for (let sampleName of sampleNames) {
46
+ for (let profileVariant of profileVariants) {
47
+ inputData = path.join(jsonDir, "profiles", `${sampleName}.json`);
48
+ extractOptions = {
49
+ ...extractOptions,
50
+ sampleName,
51
+ profileVariant,
52
+ inputData,
53
+ };
54
+
55
+ await new ExtractExecutor(extractOptions)
56
+ .getFinalPromise()
57
+ .then(() =>
58
+ console.log(
59
+ chalk`{green.bold ${sampleName}} Profile of {italic ${profileVariant}} Variant Created With {green.bold Success}!`
60
+ )
61
+ )
62
+ .catch(() => {
63
+ erroneousSamples++;
64
+ errors++;
65
+ console.log(
66
+ chalk`{red.bold ${sampleName}} Profile of {italic ${profileVariant}} Variant Created With {red.bold Error}!`
67
+ );
68
+ });
69
+ }
70
+ }
71
+ console.log(
72
+ chalk`*** {green.bgGrey.bold ${
73
+ numProfiles - erroneousSamples
74
+ } } Profiles Created With {green.bold Success} Out of {blue.bgGrey.bold ${numProfiles} } Profiles! ***`
75
+ );
76
+ });
77
+ }
78
+
79
+ async function testGift() {
80
+ // Initial Gift Command Options
81
+ let giftOptions = {
82
+ inputType: "local",
83
+ outputType: "local",
84
+ inputData: path.join(jsonDir, "gift", "gift.json"),
85
+ benchmark: true,
86
+ outputAddress: outputDir,
87
+ };
88
+
89
+ await new GiftExecutor(giftOptions)
90
+ .getFinalPromise()
91
+ .then(() => console.log(chalk`{green.bold Gift} Created With {green.bold Success}!`))
92
+ .catch(() => {
93
+ errors++;
94
+ console.log(chalk`{red.bold Gift} Created With {red.bold Error}!`);
95
+ });
96
+ }
97
+
98
+ const test = async () =>
99
+ testExtract()
100
+ .then(() => testGift())
101
+ .then(() => rm(outputDir, { recursive: true }))
102
+ .then(() => {
103
+ if (errors) return Promise.reject(new Error("Test Failed"));
104
+ });
105
+
106
+ // Test the Entire App
107
+ test().catch((err) => {
108
+ process.exit(1)
109
+ });
@@ -0,0 +1,14 @@
1
+ const QRCode = require("qrcode");
2
+ const { qrRender } = require("./qrRender");
3
+
4
+ function qrCodeGenerator(data, options) {
5
+ const opts = {
6
+ color: "colored",
7
+ logo: "none",
8
+ ...options,
9
+ };
10
+ const qrSvg = qrRender(QRCode.create(data, { errorCorrectionLevel: "Q" }), opts);
11
+ return qrSvg;
12
+ }
13
+
14
+ module.exports = qrCodeGenerator;
@@ -0,0 +1,229 @@
1
+ const removeModules = ({ matrix, removeFinderPattern = false, removeCenterModules = false }) => {
2
+ let size = matrix.size;
3
+
4
+ const finderPatternModules = removeFinderPattern ? size - 7 : 0;
5
+ const centerModules = removeCenterModules ? (size - 7 * 3) / 2 + 7 : 0;
6
+
7
+ let pos = [
8
+ // top-left
9
+ [0, 0],
10
+ // top-right
11
+ [finderPatternModules, 0],
12
+ // center
13
+ [centerModules, centerModules],
14
+ // bottom-left
15
+ [0, finderPatternModules],
16
+ ];
17
+
18
+ for (let i = 0; i < pos.length; i++) {
19
+ let row = pos[i][0];
20
+ let col = pos[i][1];
21
+
22
+ for (let r = -1; r <= 7; r++) {
23
+ if (row + r <= -1 || size <= row + r) continue;
24
+
25
+ for (let c = -1; c <= 7; c++) {
26
+ if (col + c <= -1 || size <= col + c) continue;
27
+
28
+ matrix.set(row + r, col + c, false, true);
29
+ }
30
+ }
31
+ }
32
+ };
33
+
34
+ const qrModulesDataRender = (data, size, moduleSize) => {
35
+ let svg = "";
36
+
37
+ for (let i = 0; i < data.length; i++) {
38
+ const col = Math.floor(i % size);
39
+ const prevCol = col - 1;
40
+ const nextCol = col + 1;
41
+ const row = Math.floor(i / size);
42
+
43
+ const currentValue = data[i];
44
+ const prevValue = col && Boolean(data[i - 1]);
45
+ const nextValue = nextCol !== size && Boolean(data[i + 1]);
46
+ const prevValueTRow = Boolean(data[i - size]);
47
+ const nextValueBRow = Boolean(data[i + size]);
48
+ const prevValueTRowPrevCol = Boolean(data[i - 1 - size]);
49
+ const nextValueBRowPrevCol = Boolean(data[i - 1 + size]);
50
+ const prevValueTRowNextCol = Boolean(data[i + 1 - size]);
51
+ const nextValueBRowNextCol = Boolean(data[i + 1 + size]);
52
+
53
+ let moduleStyle = "";
54
+
55
+ if (currentValue) {
56
+ if (col && !prevValue && nextValueBRow && nextValueBRowPrevCol) {
57
+ moduleStyle = "n_rb";
58
+
59
+ svg += `<g transform="translate(${prevCol * moduleSize}, ${
60
+ row * moduleSize
61
+ })"><use xlink:href="#${moduleStyle}"/></g>`;
62
+ }
63
+
64
+ if (col && !prevValue && prevValueTRow && prevValueTRowPrevCol) {
65
+ moduleStyle = "n_rt";
66
+
67
+ svg += `<g transform="translate(${prevCol * moduleSize}, ${
68
+ row * moduleSize
69
+ })"><use xlink:href="#${moduleStyle}"/></g>`;
70
+ }
71
+
72
+ if (nextCol !== size && !nextValue && nextValueBRow && nextValueBRowNextCol) {
73
+ moduleStyle = "n_lb";
74
+
75
+ svg += `<g transform="translate(${nextCol * moduleSize}, ${
76
+ row * moduleSize
77
+ })"><use xlink:href="#${moduleStyle}"/></g>`;
78
+ }
79
+
80
+ if (nextCol !== size && !nextValue && prevValueTRow && prevValueTRowNextCol) {
81
+ moduleStyle = "n_lt";
82
+
83
+ svg += `<g transform="translate(${nextCol * moduleSize}, ${
84
+ row * moduleSize
85
+ })"><use xlink:href="#${moduleStyle}"/></g>`;
86
+ }
87
+
88
+ if (!prevValue && nextValue && prevValueTRow && !nextValueBRow) {
89
+ moduleStyle = "rt";
90
+ } else if (!prevValue && nextValue && !prevValueTRow && nextValueBRow) {
91
+ moduleStyle = "rb";
92
+ } else if (prevValue && !nextValue && !prevValueTRow && nextValueBRow) {
93
+ moduleStyle = "lb";
94
+ } else if (prevValue && !nextValue && prevValueTRow && !nextValueBRow) {
95
+ moduleStyle = "lt";
96
+ } else if (!prevValue && !nextValue && prevValueTRow && !nextValueBRow) {
97
+ moduleStyle = "t";
98
+ } else if (prevValue && !nextValue && !prevValueTRow && !nextValueBRow) {
99
+ moduleStyle = "l";
100
+ } else if (!prevValue && nextValue && !prevValueTRow && !nextValueBRow) {
101
+ moduleStyle = "r";
102
+ } else if (!prevValue && !nextValue && !prevValueTRow && nextValueBRow) {
103
+ moduleStyle = "b";
104
+ } else if (!prevValue && !nextValue && !prevValueTRow && !nextValueBRow) {
105
+ moduleStyle = "empty";
106
+ } else {
107
+ moduleStyle = "rect";
108
+ }
109
+
110
+ svg += `<g transform="translate(${col * moduleSize}, ${
111
+ row * moduleSize
112
+ })"><use xlink:href="#${moduleStyle}"/></g>`;
113
+ }
114
+ }
115
+
116
+ return svg;
117
+ };
118
+
119
+ const qrRender = (qrData, customOptions, cb) => {
120
+ const options = {
121
+ color: "colored",
122
+ logo: "fillstuff",
123
+ ...customOptions,
124
+ };
125
+
126
+ removeModules({
127
+ matrix: qrData.modules,
128
+ removeFinderPattern: true,
129
+ removeCenterModules: options.logo !== "none",
130
+ });
131
+
132
+ const data = qrData.modules.data;
133
+ const size = qrData.modules.size;
134
+ const moduleSize = 97;
135
+ const moduleColor = options.color === "colored" ? "#2B3544" : "#000000";
136
+ const logoModule1Color = options.color === "colored" ? "#00BFA5" : "#ffffff";
137
+ const logoModule2Color = options.color === "colored" ? "#FFC74A" : "#ffffff";
138
+ const logoModule3Color = options.color === "colored" ? "#DD5B5B" : "#ffffff";
139
+
140
+ const logoSvg = `
141
+ <g id="fillstuff_logo" stroke="none" stroke-width="1" fill="none">
142
+ <rect fill="currentColor" x="0" y="0" width="${moduleSize * 7}" height="${moduleSize * 7}" rx="150"/>
143
+ <g transform="translate(130, 130) scale(15)">
144
+ <path fill="${logoModule1Color}" d="M5.86241276,8.09571286 C5.86241276,6.86229527 6.86229527,5.86241276 8.09571286,5.86241276 L20.0159522,5.86241276 C20.4784837,5.86241276 20.8534397,5.48745682 20.8534397,5.02492522 L20.8534397,3.62911266 C20.8534397,1.62480909 19.2286306,1.22728198e-16 17.2243271,0 L0.837487537,0 C0.374955942,-2.83218919e-17 5.66437837e-17,0.374955942 0,0.837487537 L0,17.2243271 C2.45456396e-16,19.2286306 1.62480909,20.8534397 3.62911266,20.8534397 L5.02492522,20.8534397 C5.48745682,20.8534397 5.86241276,20.4784837 5.86241276,20.0159522 L5.86241276,8.09571286 Z"/>
145
+ <path fill="${logoModule2Color}" d="M13.5393819,15.7726819 C13.5393819,14.5392643 14.5392643,13.5393819 15.7726819,13.5393819 L23.449651,13.5393819 C23.6717666,13.5393819 23.8847848,13.4511468 24.0418441,13.2940875 C24.1989036,13.137028 24.2871386,12.9240098 24.2871386,12.7018943 L24.2871386,11.3060818 C24.2871386,9.30177815 22.6623295,7.67696909 20.6580259,7.67696909 L8.51445663,7.67696909 C8.05192504,7.67696909 7.67696909,8.05192504 7.67696909,8.51445663 L7.67696909,20.6580259 C7.67696909,22.6623295 9.30177815,24.2871386 11.3060818,24.2871386 L12.7018943,24.2871386 C12.9240098,24.2871386 13.137028,24.1989036 13.2940875,24.0418441 C13.4511468,23.8847848 13.5393819,23.6717666 13.5393819,23.449651 L13.5393819,15.7726819 Z"/>
146
+ <path fill="${logoModule3Color}" d="M16.1914257,15.3539382 L24.3708874,15.3539382 C26.3751909,15.3539382 28,16.9787473 28,18.9830509 L28,24.3708874 C28,26.3751909 26.3751909,28 24.3708874,28 L18.9830509,28 C16.9787473,28 15.3539382,26.3751909 15.3539382,24.3708874 L15.3539382,16.1914257 C15.3539382,15.7288941 15.7288941,15.3539382 16.1914257,15.3539382 Z"/>
147
+ </g>
148
+ </g>
149
+ `;
150
+ const logoSvgMask = `
151
+ <use fill="none" fill-rule="evenodd" transform="translate(${((size - 7 * 3) / 2 + 7) * moduleSize}, ${
152
+ ((size - 7 * 3) / 2 + 7) * moduleSize
153
+ })" xlink:href="#fillstuff_logo"/>
154
+ `;
155
+
156
+ const imageSvg = `
157
+ <g id="image_center">
158
+ <defs>
159
+ <pattern id="image" x="0" y="0" height="100%" width="100%" viewBox="0 0 300 300">
160
+ <image x="0" y="0" width="300" height="300" xlink:href="${options.image}"/>
161
+ </pattern>
162
+ </defs>
163
+ <rect fill="url(#image)" x="0" y="0" width="${moduleSize * 7}" height="${
164
+ moduleSize * 7
165
+ }" rx="50%" stroke="rgba(0, 0, 0, 0.1)" stroke-width="0.2%"/>
166
+ </g>
167
+ `;
168
+ const imageSvgMask = `
169
+ <use fill="none" fill-rule="evenodd" transform="translate(${((size - 7 * 3) / 2 + 7) * moduleSize}, ${
170
+ ((size - 7 * 3) / 2 + 7) * moduleSize
171
+ })" xlink:href="#image_center"/>
172
+ `;
173
+
174
+ const qrSvg = `
175
+ <svg viewBox="0 0 ${moduleSize * size} ${moduleSize * size}" width="${options.width || 250}" height="${
176
+ options.height || 250
177
+ }" version="1.1" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
178
+ <defs>
179
+ <rect id="rect" width="100" height="100" fill="currentColor"/>
180
+ <path id="empty" d="M0,28.6v42.9C0,87.3,12.8,100,28.6,100h42.9c15.9,0,28.6-12.8,28.6-28.6V28.6C100,12.7,87.2,0,71.4,0H28.6 C12.8,0,0,12.8,0,28.6z" fill="currentColor"/>
181
+ <path id="b" d="M0,0 L66,0 C84.7776815,-3.44940413e-15 100,15.2223185 100,34 L100,66 C100,84.7776815 84.7776815,100 66,100 L0,100 L0,0 Z" transform="rotate(-90 50 50)" fill="currentColor"/>
182
+ <path id="r" d="M0,0 L66,0 C84.7776815,-3.44940413e-15 100,15.2223185 100,34 L100,66 C100,84.7776815 84.7776815,100 66,100 L0,100 L0,0 Z" transform="rotate(-180 50 50)" fill="currentColor"/>
183
+ <path id="l" d="M0,0 L66,0 C84.7776815,-3.44940413e-15 100,15.2223185 100,34 L100,66 C100,84.7776815 84.7776815,100 66,100 L0,100 L0,0 Z" fill="currentColor"/>
184
+ <path id="t" d="M0,0 L66,0 C84.7776815,-3.44940413e-15 100,15.2223185 100,34 L100,66 C100,84.7776815 84.7776815,100 66,100 L0,100 L0,0 Z" transform="rotate(90 50 50)" fill="currentColor"/>
185
+ <path id="lt" d="M0,0 L100,0 L100,66 C100,84.7776815 84.7776815,100 66,100 L0,100 L0,0 Z" fill="currentColor"/>
186
+ <path id="lb" d="M0,0 L100,0 L100,66 C100,84.7776815 84.7776815,100 66,100 L0,100 L0,0 Z" transform="rotate(-90 50 50)" fill="currentColor"/>
187
+ <path id="rb" d="M0,0 L100,0 L100,66 C100,84.7776815 84.7776815,100 66,100 L0,100 L0,0 Z" transform="rotate(-180 50 50)" fill="currentColor"/>
188
+ <path id="rt" d="M0,0 L100,0 L100,66 C100,84.7776815 84.7776815,100 66,100 L0,100 L0,0 Z" transform="rotate(90 50 50)" fill="currentColor"/>
189
+ <path id="n_lt" d="M30.5,2V0H0v30.5h2C2,14.7,14.8,2,30.5,2z" fill="currentColor"/>
190
+ <path id="n_lb" d="M2,69.5H0V100h30.5v-2C14.7,98,2,85.2,2,69.5z" fill="currentColor"/>
191
+ <path id="n_rt" d="M98,30.5h2V0H69.5v2C85.3,2,98,14.8,98,30.5z" fill="currentColor"/>
192
+ <path id="n_rb" d="M69.5,98v2H100V69.5h-2C98,85.3,85.2,98,69.5,98z" fill="currentColor"/>
193
+ <path id="point" d="M600.001786,457.329333 L600.001786,242.658167 C600.001786,147.372368 587.039517,124.122784 581.464617,118.535383 C575.877216,112.960483 552.627632,99.9982143 457.329333,99.9982143 L242.670667,99.9982143 C147.372368,99.9982143 124.122784,112.960483 118.547883,118.535383 C112.972983,124.122784 99.9982143,147.372368 99.9982143,242.658167 L99.9982143,457.329333 C99.9982143,552.627632 112.972983,575.877216 118.547883,581.464617 C124.122784,587.027017 147.372368,600.001786 242.670667,600.001786 L457.329333,600.001786 C552.627632,600.001786 575.877216,587.027017 581.464617,581.464617 C587.039517,575.877216 600.001786,552.627632 600.001786,457.329333 Z M457.329333,0 C653.338333,0 700,46.6616668 700,242.658167 C700,438.667167 700,261.332833 700,457.329333 C700,653.338333 653.338333,700 457.329333,700 C261.332833,700 438.667167,700 242.670667,700 C46.6616668,700 0,653.338333 0,457.329333 C0,261.332833 0,352.118712 0,242.658167 C0,46.6616668 46.6616668,0 242.670667,0 C438.667167,0 261.332833,0 457.329333,0 Z M395.996667,200 C480.004166,200 500,220.008332 500,303.990835 C500,387.998334 500,312.001666 500,395.996667 C500,479.991668 480.004166,500 395.996667,500 C312.001666,500 387.998334,500 304.003333,500 C220.008332,500 200,479.991668 200,395.996667 C200,312.001666 200,350.906061 200,303.990835 C200,220.008332 220.008332,200 304.003333,200 C387.998334,200 312.001666,200 395.996667,200 Z" fill="currentColor"/>
194
+ ${options.logo === "fillstuff" ? logoSvg : ""}
195
+ ${options.logo === "image" && options.image ? imageSvg : ""}
196
+ </defs>
197
+ <g transform="translate(0,0)">
198
+ ${qrModulesDataRender(data, size, moduleSize)}
199
+ <use fill-rule="evenodd" transform="translate(0,0)" xlink:href="#point"/>
200
+ <use fill-rule="evenodd" transform="translate(${size * moduleSize - 700},0)" xlink:href="#point"/>
201
+ <use fill-rule="evenodd" transform="translate(0,${size * moduleSize - 700})" xlink:href="#point"/>
202
+ ${options.logo === "fillstuff" ? logoSvgMask : ""}
203
+ ${options.logo === "image" && options.image ? imageSvgMask : ""}
204
+ </g>
205
+ </svg>
206
+ `;
207
+
208
+ const svg = `
209
+ <svg width="${options.width || 250}" height="${options.height || 250}" viewBox="0 0 ${options.width || 250} ${
210
+ options.height || 250
211
+ }" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
212
+ <defs>
213
+ <g id="qr" style="color: ${moduleColor}">${qrSvg}</g>
214
+ </defs>
215
+ <g clip-path="url(#main-mask)">
216
+ <rect x="0" y="0" width="${options.width || 250}" height="${options.height || 250}" fill="transparent"/>
217
+ <use x="0" y="0" xlink:href="#qr" transform="scale(1)" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/>
218
+ </g>
219
+ </svg>
220
+ `;
221
+
222
+ if (typeof cb === "function") {
223
+ cb(null, svg);
224
+ }
225
+
226
+ return svg;
227
+ };
228
+
229
+ module.exports = { qrRender };
@@ -0,0 +1,158 @@
1
+ const { Profile, FS } = require("../Profile");
2
+
3
+ class _16PF extends Profile {
4
+ // Number of pages
5
+ static pages = 1;
6
+
7
+ // Labels of the sample
8
+ labels = {
9
+ L1: { eng: "a", fr: "A", right: "مردم‌گریزی", left: "مردم‌آمیزی" },
10
+ L2: { eng: "b", fr: "B", right: "استدلال عینی", left: "استدلال انتزاعی" },
11
+ L3: { eng: "c", fr: "C", right: "ناپایداری هیجانی", left: "پایداری هیجانی" },
12
+ L4: { eng: "e", fr: "E", right: "سلطه‌پذیری", left: "سلطه‌گری" },
13
+ L5: { eng: "f", fr: "F", right: "دل‌مردگی", left: "سرزندگی" },
14
+ L6: { eng: "g", fr: "G", right: "مصلحت‌گرا", left: "باوجدان" },
15
+ L7: { eng: "h", fr: "H", right: "ترسو", left: "جسور" },
16
+ L8: { eng: "i", fr: "I", right: "یکدنده", left: "حساس" },
17
+ L9: { eng: "l", fr: "L", right: "زودباور", left: "شکاک" },
18
+ L10: { eng: "m", fr: "M", right: "عمل‌گرا", left: "کولی‌باز" },
19
+ L11: { eng: "n", fr: "N", right: "بی‌ظرافت", left: "ظرافت" },
20
+ L12: { eng: "o", fr: "O", right: "اطمینان به خود", left: "مستعد احساس گناه" },
21
+ L13: { eng: "q1", fr: "Q1", right: "باز بودن نسبت به تغییر", left: "بنیادگرا" },
22
+ L14: { eng: "q2", fr: "Q2", right: "متکی بر خود", left: "مسلط به دیگران" },
23
+ L15: { eng: "q3", fr: "Q3", right: "اختلال‌مدار", left: "کمال‌گرا" },
24
+ L16: { eng: "q4", fr: "Q4", right: "آرام", left: "اضطراب" },
25
+ L17: { eng: "extraversion", fr: "برون‌گرایی" },
26
+ L18: { eng: "anxiety", fr: "اضطراب" },
27
+ L19: { eng: "flexibility", fr: "یک‌دندگی" },
28
+ L20: { eng: "independence", fr: "استقلال" },
29
+ L21: { eng: "selfcontrol", fr: "کنترل بالا" },
30
+ L22: { eng: "adjustment", fr: "سازگاری" },
31
+ L23: { eng: "leadership", fr: "قدرت رهبری" },
32
+ L24: { eng: "creativity", fr: "خلاقیت" },
33
+ L25: { eng: "status", fr: "وضعیت" },
34
+ };
35
+
36
+ profileSpec = {
37
+ /* "sample" determines some important info about the sample and profile */
38
+ /* Default prerequisites: 1. gender, 2. age, 3. education */
39
+ /* "prerequisites" is synonym to "fields" in our program */
40
+ sample: {
41
+ name: "پرسشنامه شخصیت کتل" /* Name of the sample */,
42
+ multiProfile: false /* Whether the sample has multiple profiles or not */,
43
+ questions: false /* Determines whether to get questions from inital dataset or not */,
44
+ defaultFields: true /* Determines whether to have default prerequisites in the profile or not */,
45
+ fields: ["marital_status"] /* In case you want to get some additional fields and show in the profile */,
46
+ },
47
+ /* "profile" determines the dimensions of the drawn profile (to be used in svg tag viewbox) */
48
+ /* calculating its dimensions carefully is of great importance */
49
+ profile: {
50
+ get dimensions() {
51
+ return {
52
+ width: 610 + 2 * this.padding.x,
53
+ height: 682 + 2 * this.padding.y,
54
+ };
55
+ },
56
+ padding: {
57
+ x: 0,
58
+ y: 16.8,
59
+ },
60
+ },
61
+ items: {
62
+ minValue: 1,
63
+ maxValue: 10,
64
+ offsetY: 33.8,
65
+ widthCoeff: 16.2,
66
+ fillAndOpacity: {
67
+ 1: { fill: "#1D4ED8", opacity: 1 },
68
+ 2: { fill: "#1D4ED8", opacity: 0.9 },
69
+ 3: { fill: "#1D4ED8", opacity: 0.8 },
70
+ 4: { fill: "#1D4ED8", opacity: 0.7 },
71
+ 5: { fill: "#9CA3AF", opacity: 1 },
72
+ 6: { fill: "#9CA3AF", opacity: 1 },
73
+ 7: { fill: "#0E7490", opacity: 0.7 },
74
+ 8: { fill: "#0E7490", opacity: 0.8 },
75
+ 9: { fill: "#0E7490", opacity: 0.9 },
76
+ 10: { fill: "#0E7490", opacity: 1 },
77
+ },
78
+ label: {
79
+ offsetX: 16.2,
80
+ },
81
+ },
82
+ gaugeItems: {
83
+ maxValues: {
84
+ [this.labels.L17.eng]: 12.3,
85
+ [this.labels.L18.eng]: 8.9,
86
+ [this.labels.L19.eng]: { مرد: 7.2, زن: 8.6 },
87
+ [this.labels.L20.eng]: { مرد: 13.2, زن: 12.7 },
88
+ [this.labels.L21.eng]: 10.9,
89
+ [this.labels.L22.eng]: 14.3,
90
+ [this.labels.L23.eng]: 13.2,
91
+ [this.labels.L24.eng]: 16.8,
92
+ },
93
+ offsetX: 83.25,
94
+ circle: {
95
+ R: 29.7,
96
+ r: 20,
97
+ brs: {
98
+ tl: 0,
99
+ bl: 0,
100
+ tr: 0,
101
+ br: 0,
102
+ },
103
+ angles: {
104
+ start: FS.toRadians(-90),
105
+ end: FS.toRadians(269.9),
106
+ },
107
+ direction: false /* Clockwise direction for the items gauge element */,
108
+ get totalAngle() {
109
+ return this.direction
110
+ ? 2 * Math.PI - (this.angles.end - this.angles.start)
111
+ : this.angles.end - this.angles.start;
112
+ },
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 { items: itemsSpec, gaugeItems: gaugeItemsSpec } = spec;
131
+
132
+ const status = dataset.score.pop().mark;
133
+
134
+ const genderValue = dataset.info.fields.find((f) => f["eng"] === "gender").value;
135
+
136
+ const items = dataset.score.slice(0, 16).map((data) => ({
137
+ label: data.label,
138
+ mark: data.mark,
139
+ offset: (data.mark - 1) * itemsSpec.widthCoeff,
140
+ ...itemsSpec.fillAndOpacity[data.mark],
141
+ }));
142
+
143
+ const gaugeItems = dataset.score.slice(16).map((data) => {
144
+ let maxValue = gaugeItemsSpec.maxValues[data.label.eng];
145
+ maxValue = typeof maxValue === "object" ? maxValue[genderValue] : maxValue;
146
+
147
+ return {
148
+ label: data.label,
149
+ mark: data.mark,
150
+ zeta: (data.mark / maxValue) * gaugeItemsSpec.circle.totalAngle + gaugeItemsSpec.circle.angles.start,
151
+ };
152
+ });
153
+
154
+ return [{ items, status, gaugeItems }];
155
+ }
156
+ }
157
+
158
+ module.exports = _16PF;