@baravak/risloo-profile-cli 4.6.2 → 4.7.1

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.
@@ -0,0 +1,230 @@
1
+ const { Profile, FS } = require("../Profile");
2
+
3
+ const firstItemCats = [ 'negative', 'positive', 'negative', 'positive', 'negative', 'positive', 'negative', 'positive', 'negative', 'negative', 'negative', 'negative', 'positive', 'positive', 'positive', 'positive', 'positive', 'positive', 'negative', 'negative', 'negative', 'positive', 'positive', 'positive', 'negative', 'positive', 'positive', 'negative', 'negative', 'negative']
4
+
5
+ class JSIQ9Q extends Profile {
6
+ // Number of pages
7
+ static pages = 2;
8
+
9
+ // Labels of the sample
10
+ labels = {
11
+ L0: { eng: "section_1_positive_total", },
12
+ L1: { eng: "section_1_positive_average", },
13
+
14
+ L2: { eng: "section_1_negative_total", },
15
+ L3: { eng: "section_1_negative_average", },
16
+
17
+ L4 : {eng: "section_2_total", fr: "", max:400},
18
+ L5 : {eng: "section_2_percentage", fr: "", max:0},
19
+ L6 : {eng: "section_2_family_system_consciousness_total", fr: "", max:25},
20
+ L7 : {eng: "section_2_family_system_consciousness_percentage", fr: "", max:0},
21
+ L8 : {eng: "section_2_love_giving_total", fr: "", max:120},
22
+ L9 : {eng: "section_2_love_giving_percentage", fr: "", max:0},
23
+ L10 : {eng: "section_2_power_perception_total", fr: "", max:175},
24
+ L12 : {eng: "section_2_power_perception_percentage", fr: "", max:0},
25
+ L13 : {eng: "section_2_sexual_safety_awareness_total", fr: "", max:80},
26
+ L14 : {eng: "section_2_sexual_safety_awareness_percentage", fr: "", max:0},
27
+
28
+ L15 : {eng: "section_2_male_safety_awareness_total", fr: "", max:40},
29
+ L16 : {eng: "section_2_male_safety_awareness_percentage", fr: "", max:0},
30
+ L17 : {eng: "section_2_perceived_safety_from_spouse_total", fr: "", max:40},
31
+ L18 : {eng: "section_2_perceived_safety_from_spouse_percentage", fr: "", max:0},
32
+
33
+ };
34
+
35
+ profileSpec = {
36
+ /* "sample" determines some important info about the sample and profile */
37
+ /* Default prerequisites: 1. gender, 2. age, 3. education */
38
+ /* "prerequisites" is synonym to "fields" in our program */
39
+ sample: {
40
+ name: "پرسشنامه تعامل همسران - فرم آقایان" /* Name of the sample */,
41
+ multiProfile: false /* Whether the sample has multiple profiles or not */,
42
+ questions: true /* Determines whether to get questions from inital dataset or not */,
43
+ defaultFields: true /* Determines whether to have default prerequisites in the profile or not */,
44
+ fields: [] /* In case you want to get some additional fields and show in the profile */,
45
+ },
46
+ /* "profile" determines the dimensions of the drawn profile (to be used in svg tag viewbox) */
47
+ /* calculating its dimensions carefully is of great importance */
48
+ profile: {
49
+ get dimensions() {
50
+ return {
51
+ width: 851 + 2 * this.padding.x,
52
+ height: 676 + 2 * this.padding.y,
53
+ };
54
+ },
55
+ padding: {
56
+ x: 26,
57
+ y: 20,
58
+ },
59
+ },
60
+ /* "labels" part which has to be provided for each profile */
61
+ labels: Object.values(this.labels),
62
+ };
63
+
64
+ constructor(dataset, options, config = {}) {
65
+ super();
66
+ this._init(dataset, options, config);
67
+ }
68
+ f4 (data){
69
+ const {
70
+ spec: { parameters: spec },
71
+ dataset,
72
+ } = this;
73
+ const rawSpec = {
74
+ maxValue: 40,
75
+ circle: {
76
+ R: 55,
77
+ r: 55 * .65,
78
+ angles: {
79
+ start: FS.toRadians(-90),
80
+ end: FS.toRadians(180),
81
+ },
82
+ direction: false,
83
+ get totalAngle() {
84
+ return this.direction
85
+ ? 2 * Math.PI - (this.angles.end - this.angles.start)
86
+ : this.angles.end - this.angles.start;
87
+ },
88
+ }
89
+ }
90
+ return {
91
+ rawSpec,
92
+ mark: data.mark,
93
+ percentage: Math.round(data.percentage * 100),
94
+ zeta: (data.mark / rawSpec.maxValue) * rawSpec.circle.totalAngle + rawSpec.circle.angles.start,
95
+ };
96
+ }
97
+ firstPage(){
98
+ const {
99
+ spec: { parameters: spec },
100
+ dataset,
101
+ } = this;
102
+
103
+ const raw = {'negative': [[], [], [], [], []], 'positive': [[], [], [], [], []]};
104
+ const itemOptions = {
105
+ negative: [
106
+ {
107
+ color : "#737373",
108
+ bg : "#FAFAFA",
109
+ opacity : 1
110
+ },
111
+ {
112
+ color : "#991B1B",
113
+ bg : "#DC2626",
114
+ opacity : 0.03
115
+ },
116
+ {
117
+ color : "#991B1B",
118
+ bg : "#DC2626",
119
+ opacity : 0.06
120
+ },
121
+ {
122
+ color : "#991B1B",
123
+ bg : "#DC2626",
124
+ opacity : 0.1
125
+ },
126
+ {
127
+ color : "#991B1B",
128
+ bg : "#DC2626",
129
+ opacity : 0.15
130
+ }
131
+ ],
132
+ positive: [
133
+ {
134
+ color : "#78716C",
135
+ bg : "#FAFAF9",
136
+ opacity : 1
137
+ },
138
+ {
139
+ color : "#166534",
140
+ bg : "#16A34A",
141
+ opacity : 0.03
142
+ },
143
+ {
144
+ color : "#166534",
145
+ bg : "#16A34A",
146
+ opacity : 0.06
147
+ },
148
+ {
149
+ color : "#166534",
150
+ bg : "#16A34A",
151
+ opacity : 0.1
152
+ },
153
+ {
154
+ color : "#166534",
155
+ bg : "#16A34A",
156
+ opacity : 0.15
157
+ }
158
+ ]
159
+ }
160
+
161
+ dataset.questions.slice(0, 30).forEach((row, i) => {
162
+ const answered = parseInt(row.user_answered)
163
+ const cat = firstItemCats[i]
164
+ const newRow = {
165
+ option: itemOptions[cat][answered],
166
+ value: answered,
167
+ label: i === 10 ? 'بی‌تفاوتی به مسئولیت‌های خانواده' :row.text
168
+ }
169
+ raw[cat][answered].push(newRow)
170
+ });
171
+ const positive = {
172
+ average: dataset.score[1].mark,
173
+ items: [...raw.positive[4],...raw.positive[3],...raw.positive[2],...raw.positive[1],...raw.positive[0]],
174
+ breakpoint: null
175
+ }
176
+ positive.items.forEach((item, i) => {
177
+ if (item.value < positive.average && !positive.breakpoint) {
178
+ positive.breakpoint = i
179
+ }
180
+ })
181
+ const negative = {
182
+ average: dataset.score[3].mark,
183
+ items: [...raw.negative[4],...raw.negative[3],...raw.negative[2],...raw.negative[1],...raw.negative[0]],
184
+ breakpoint: null
185
+ }
186
+ negative.items.forEach((item, i) => {
187
+ if (item.value < negative.average && !negative.breakpoint) {
188
+ negative.breakpoint = i
189
+ }
190
+ })
191
+ const items = dataset.score.slice(5, 14).filter((r, i) => i %2 !== 0).map((r, i) => {
192
+ r.percentage = Math.round(dataset.score[7 + (i*2)].mark * 100)
193
+ r.percentagex = dataset.score[7 + (i*2)].mark
194
+ return r
195
+ })
196
+ const total = dataset.score[4]
197
+ total.percentage = Math.round(dataset.score[5].mark * 100)
198
+ const f4_1 = dataset.score[14]
199
+ f4_1.percentage = dataset.score[15].mark
200
+
201
+ const f4_2 = dataset.score[16]
202
+ f4_2.percentage = dataset.score[17].mark
203
+ return { positive, negative, items : {
204
+ family: items[0],
205
+ love: items[1],
206
+ power: items[2],
207
+ sexual: items[3],
208
+ }, total, f4_1: this.f4(f4_1), f4_2: this.f4(f4_2),
209
+ titleAppend: ' - آقایان'
210
+ }
211
+ }
212
+ _calcContext() {
213
+ const firstPageData = this.firstPage()
214
+ return [firstPageData, {
215
+ love: {
216
+ percentage: 1 - firstPageData.items.love.percentagex,
217
+ mark: firstPageData.items.love.mark
218
+ },
219
+ power: {
220
+ percentage: 1 - firstPageData.items.power.percentagex,
221
+ mark: firstPageData.items.power.mark
222
+ },
223
+ titleAppend: firstPageData.titleAppend
224
+ }];
225
+ }
226
+ }
227
+
228
+
229
+
230
+ module.exports = JSIQ9Q;
@@ -0,0 +1,231 @@
1
+ const { Profile, FS } = require("../Profile");
2
+
3
+ const firstItemCats = ["negative", "positive", "positive", "positive", "negative", "positive", "negative", "negative", "positive", "negative", "negative", "negative", "negative", "negative", "negative", "positive", "negative", "negative", "negative", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "negative", "positive", "negative", "negative"]
4
+
5
+ class JSIQ9V extends Profile {
6
+ // Number of pages
7
+ static pages = 2;
8
+
9
+ // Labels of the sample
10
+ labels = {
11
+ L0: { eng: "section_1_positive_total", },
12
+ L1: { eng: "section_1_positive_average", },
13
+
14
+ L2: { eng: "section_1_negative_total", },
15
+ L3: { eng: "section_1_negative_average", },
16
+
17
+ L4 : {eng: "section_2_total", fr: "", max:400},
18
+ L5 : {eng: "section_2_percentage", fr: "", max:0},
19
+ L6 : {eng: "section_2_family_system_consciousness_total", fr: "", max:25},
20
+ L7 : {eng: "section_2_family_system_consciousness_percentage", fr: "", max:0},
21
+ L8 : {eng: "section_2_power_giving_total", fr: "", max:140},
22
+ L9 : {eng: "section_2_power_giving_percentage", fr: "", max:0},
23
+ L10 : {eng: "section_2_perception_of_love_total", fr: "", max:150},
24
+ L12 : {eng: "section_2_perception_of_love_percentage", fr: "", max:0},
25
+ L13 : {eng: "section_2_sexual_safety_awareness_total", fr: "", max:85},
26
+ L14 : {eng: "section_2_sexual_safety_awareness_percentage", fr: "", max:0},
27
+
28
+ L15 : {eng: "section_2_female_safety_awareness_total", fr: "", max:30},
29
+ L16 : {eng: "section_2_female_safety_awareness_percentage", fr: "", max:0},
30
+ L17 : {eng: "section_2_perceived_spousal_safety_total", fr: "", max:70},
31
+ L18 : {eng: "section_2_perceived_spousal_safety_percentage", fr: "", max:0},
32
+
33
+ };
34
+
35
+ profileSpec = {
36
+ /* "sample" determines some important info about the sample and profile */
37
+ /* Default prerequisites: 1. gender, 2. age, 3. education */
38
+ /* "prerequisites" is synonym to "fields" in our program */
39
+ sample: {
40
+ name: "پرسشنامه تعامل همسران - فرم خانم‌ها" /* Name of the sample */,
41
+ multiProfile: false /* Whether the sample has multiple profiles or not */,
42
+ questions: true /* Determines whether to get questions from inital dataset or not */,
43
+ defaultFields: true /* Determines whether to have default prerequisites in the profile or not */,
44
+ fields: [] /* In case you want to get some additional fields and show in the profile */,
45
+ },
46
+ /* "profile" determines the dimensions of the drawn profile (to be used in svg tag viewbox) */
47
+ /* calculating its dimensions carefully is of great importance */
48
+ profile: {
49
+ get dimensions() {
50
+ return {
51
+ width: 851 + 2 * this.padding.x,
52
+ height: 676 + 2 * this.padding.y,
53
+ };
54
+ },
55
+ padding: {
56
+ x: 26,
57
+ y: 20,
58
+ },
59
+ },
60
+ /* "labels" part which has to be provided for each profile */
61
+ labels: Object.values(this.labels),
62
+ };
63
+
64
+ constructor(dataset, options, config = {}) {
65
+ super();
66
+ this._init(dataset, options, config);
67
+ }
68
+ f4 (data){
69
+ const {
70
+ spec: { parameters: spec },
71
+ dataset,
72
+ } = this;
73
+ const rawSpec = {
74
+ maxValue: data.label.max,
75
+ circle: {
76
+ R: 55,
77
+ r: 55 * .65,
78
+ angles: {
79
+ start: FS.toRadians(-90),
80
+ end: FS.toRadians(180),
81
+ },
82
+ direction: false,
83
+ get totalAngle() {
84
+ return this.direction
85
+ ? 2 * Math.PI - (this.angles.end - this.angles.start)
86
+ : this.angles.end - this.angles.start;
87
+ },
88
+ }
89
+ }
90
+ return {
91
+ rawSpec,
92
+ mark: data.mark,
93
+ percentage: Math.round(data.percentage * 100),
94
+ zeta: (data.mark / rawSpec.maxValue) * rawSpec.circle.totalAngle + rawSpec.circle.angles.start,
95
+ };
96
+ }
97
+ firstPage(){
98
+ const {
99
+ spec: { parameters: spec },
100
+ dataset,
101
+ } = this;
102
+
103
+ const raw = {'negative': [[], [], [], [], []], 'positive': [[], [], [], [], []]};
104
+ const itemOptions = {
105
+ negative: [
106
+ {
107
+ color : "#737373",
108
+ bg : "#FAFAFA",
109
+ opacity : 1
110
+ },
111
+ {
112
+ color : "#991B1B",
113
+ bg : "#DC2626",
114
+ opacity : 0.03
115
+ },
116
+ {
117
+ color : "#991B1B",
118
+ bg : "#DC2626",
119
+ opacity : 0.06
120
+ },
121
+ {
122
+ color : "#991B1B",
123
+ bg : "#DC2626",
124
+ opacity : 0.1
125
+ },
126
+ {
127
+ color : "#991B1B",
128
+ bg : "#DC2626",
129
+ opacity : 0.15
130
+ }
131
+ ],
132
+ positive: [
133
+ {
134
+ color : "#78716C",
135
+ bg : "#FAFAF9",
136
+ opacity : 1
137
+ },
138
+ {
139
+ color : "#166534",
140
+ bg : "#16A34A",
141
+ opacity : 0.03
142
+ },
143
+ {
144
+ color : "#166534",
145
+ bg : "#16A34A",
146
+ opacity : 0.06
147
+ },
148
+ {
149
+ color : "#166534",
150
+ bg : "#16A34A",
151
+ opacity : 0.1
152
+ },
153
+ {
154
+ color : "#166534",
155
+ bg : "#16A34A",
156
+ opacity : 0.15
157
+ }
158
+ ]
159
+ }
160
+
161
+ dataset.questions.slice(0, 30).forEach((row, i) => {
162
+ const answered = parseInt(row.user_answered)
163
+ const cat = firstItemCats[i]
164
+
165
+ const newRow = {
166
+ option: itemOptions[cat][answered],
167
+ value: answered,
168
+ label: i === 7 ? 'بی‌تفاوتی به مسئولیت‌های خانواده' :row.text
169
+ }
170
+ raw[cat][answered].push(newRow)
171
+ });
172
+ const positive = {
173
+ average: dataset.score[1].mark,
174
+ items: [...raw.positive[4],...raw.positive[3],...raw.positive[2],...raw.positive[1],...raw.positive[0]],
175
+ breakpoint: null
176
+ }
177
+ positive.items.forEach((item, i) => {
178
+ if (item.value < positive.average && !positive.breakpoint) {
179
+ positive.breakpoint = i
180
+ }
181
+ })
182
+ const negative = {
183
+ average: dataset.score[3].mark,
184
+ items: [...raw.negative[4],...raw.negative[3],...raw.negative[2],...raw.negative[1],...raw.negative[0]],
185
+ breakpoint: null
186
+ }
187
+ negative.items.forEach((item, i) => {
188
+ if (item.value < negative.average && !negative.breakpoint) {
189
+ negative.breakpoint = i
190
+ }
191
+ })
192
+ const items = dataset.score.slice(5, 14).filter((r, i) => i %2 !== 0).map((r, i) => {
193
+ r.percentage = Math.round(dataset.score[7 + (i*2)].mark * 100)
194
+ r.percentagex = dataset.score[7 + (i*2)].mark
195
+ return r
196
+ })
197
+ const total = dataset.score[4]
198
+ total.percentage = Math.round(dataset.score[5].mark * 100)
199
+ const f4_1 = dataset.score[14]
200
+ f4_1.percentage = dataset.score[15].mark
201
+
202
+ const f4_2 = dataset.score[16]
203
+ f4_2.percentage = dataset.score[17].mark
204
+ return { positive, negative, items : {
205
+ family: items[0],
206
+ love: items[1],
207
+ power: items[2],
208
+ sexual: items[3],
209
+ }, total, f4_1: this.f4(f4_1), f4_2: this.f4(f4_2),
210
+ titleAppend: ' - بانوان'
211
+ }
212
+ }
213
+ _calcContext() {
214
+ const firstPageData = this.firstPage()
215
+ return [firstPageData, {
216
+ love: {
217
+ percentage: 1 - firstPageData.items.love.percentagex,
218
+ mark: firstPageData.items.love.mark
219
+ },
220
+ power: {
221
+ percentage: 1 - firstPageData.items.power.percentagex,
222
+ mark: firstPageData.items.power.mark
223
+ },
224
+ titleAppend: firstPageData.titleAppend
225
+ }];
226
+ }
227
+ }
228
+
229
+
230
+
231
+ module.exports = JSIQ9V;