@baravak/risloo-profile-cli 4.40.0 → 4.40.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baravak/risloo-profile-cli",
3
- "version": "4.40.0",
3
+ "version": "4.40.2",
4
4
  "description": "**Risloo Profile CLI** is a library for creating profiles, reports and sheets for *psychological* samples.",
5
5
  "main": "bin/risloo.js",
6
6
  "publishConfig": {
@@ -91,21 +91,27 @@ class BDI93 extends Profile {
91
91
  const sorted = [...questions].sort((a, b) => b.option - a.option)
92
92
  for(let i = 0; i < 6; i+=2){
93
93
  factors.push({
94
- ...dataset.score[i],
95
- percentage: dataset.score[i+1].mark,
96
- percentageText: Math.round(dataset.score[i+1].mark * 100),
94
+ ...{
95
+ ...dataset.score[i],
96
+ mark: dataset.score[i].mark ?? 0
97
+ },
98
+ percentage: dataset.score[i+1].mark ?? 0,
99
+ percentageText: Math.round((dataset.score[i+1].mark ?? 0) * 100),
97
100
  bg:`url(#bg${dataset.score[i].label.eng})`
98
101
  })
99
102
  }
100
103
 
101
104
  const report = dataset.score[8].mark
102
105
  const total = {
103
- ...dataset.score[6],
104
- percentage: dataset.score[7].mark,
105
- percentageText: Math.round(dataset.score[7].mark * 100),
106
- w: calculateWidth(dataset.score[6].mark),
106
+ ...{
107
+ ...dataset.score[6],
108
+ mark: dataset.score[6].mark ?? 0
109
+ },
110
+ percentage: dataset.score[7].mark ?? 0,
111
+ percentageText: Math.round((dataset.score[7].mark ?? 0) * 100),
112
+ w: calculateWidth(dataset.score[6].mark ?? 0),
107
113
  colors: totalColors[report],
108
- alert: dataset.score[9].mark
114
+ alert: dataset.score[9].mark ?? 0
109
115
  }
110
116
  const alerts = []
111
117
  if(questions[1].option > 0){
@@ -75,7 +75,8 @@ class BDI9A extends Profile {
75
75
 
76
76
  const report = dataset.score[3].mark
77
77
  const gReport = dataset.score[2].mark
78
-
78
+ dataset.score[0].mark = dataset.score[0].mark ?? 0
79
+ dataset.score[1].mark = dataset.score[1].mark ?? 0
79
80
  dataset.score[1].mark = isNaN(dataset.score[1].mark) ? 0 : dataset.score[1].mark
80
81
  const total = {
81
82
  ...dataset.score[0],
@@ -93,6 +94,7 @@ class BDI9A extends Profile {
93
94
  if(questions[6].option > 0){
94
95
  alerts.push(questions[6])
95
96
  }
97
+ console.log(total)
96
98
  return [{total, report, gReport, alerts,sorted}];
97
99
  }
98
100
  }
@@ -23,6 +23,12 @@
23
23
  <stop offset="1" stop-color="{{colors.[1]}}"/>
24
24
  </linearGradient>
25
25
  {{/with}}
26
+ <clipPath id="raw-rect">
27
+ {{bar 28 300 (object tr=4 tl=4 br=0 bl=0) (toRad 0)}}
28
+ </clipPath>
29
+ <clipPath id="total-rect">
30
+ {{bar 449 28 (object tr=4 br=4 tl=0 bl=0) (toRad 0)}}
31
+ </clipPath>
26
32
  </defs>
27
33
 
28
34
  <g transform="translate({{spec.profile.padding.[0].x}}, {{spec.profile.padding.[0].y}})">
@@ -55,7 +61,7 @@
55
61
  <g transform="translate(141,0)">
56
62
  {{#each factors as | factor index |}}
57
63
  <g transform="translate({{math 128 '*' index}},{{math 300 '-' (math 300 '*' percentage)}})">
58
- {{bar 28 (math 300 '*' percentage) (object tr=4 tl=4 br=0 bl=0) (toRad 0) fill=bg transform="translate(0,24)"}}
64
+ {{bar 28 (math 300 '*' percentage) (object tr=4 tl=4 br=0 bl=0) (toRad 0) fill=bg transform="translate(0,24)" clip-path="url(#raw-rect)"}}
59
65
  <text font-size="16" font-weight="600" fill="{{ternary (boolean percentage '>' 0.24) '#FFFFFF' '#4F46E5'}}" transform="{{ternary (boolean percentage '>' 0.24) 'translate(19,34) rotate(-90 0 0)' 'translate(19,16) rotate(-90 0 0)'}}" text-anchor="{{ternary (boolean percentage '>' 0.24) 'start' 'end'}}">{{percentageText}} ٪</text>
60
66
  </g>
61
67
  {{/each}}
@@ -68,7 +74,7 @@
68
74
  <text y="0" x="-8" dy=".85em" text-anchor="start" font-size="13" font-weight="500" fill="#64748B">نمره کل</text>
69
75
  <text y="0" x="-8" dy="2.1em" text-anchor="start" font-size="13" font-weight="600" fill="#475569">{{total.percentageText}} ٪</text>
70
76
  {{bar 449 28 (object tr=4 br=4 tl=0 bl=0) (toRad 0) fill="#F8FAFC"}}
71
- {{bar total.w 28 (object tr=4 br=4 tl=0 bl=0) (toRad 0) fill="url(#bgtotal)"}}
77
+ {{bar total.w 28 (object tr=4 br=4 tl=0 bl=0) (toRad 0) fill="url(#bgtotal)" clip-path="url(#total-rect)"}}
72
78
  <text y="14" x="{{ternary (boolean total.mark '>' 5) (math total.w '-' 8) (math total.w '+' 8)}}" dy=".3em" text-anchor="{{ternary (boolean total.mark '>' 5) 'start' 'end'}}" font-size="16" font-weight="600" fill="{{ternary (boolean total.mark '>' 5) '#FFFFFF' total.colors.[1]}}">{{total.mark}}</text>
73
79
  </g>
74
80
  <g transform="translate(48,0)">