Verified Commit f120725c authored by jxtxzzw's avatar jxtxzzw

优化:支持考试分数基准分非 0

Signed-off-by: jxtxzzw's avatarjxtxzzw <jxtxzzw@126.com>
parent 750d057f
Pipeline #169 passed with stages
in 7 minutes and 41 seconds
......@@ -18,6 +18,12 @@
150,
150,
150
],
"zeros": [
0,
0,
0,
0
]
},
{
......@@ -46,27 +52,37 @@
90,
60,
30
],
"zeros": [
0,
0,
0,
0,
0,
0
]
},
{
"name": "TOEFL",
"name": "GRE",
"sections": [
"Reading",
"Listening",
"Speaking",
"Verbal",
"Quantitative",
"Writing"
],
"scores": [
28,
27,
23,
28
154,
170,
3
],
"totals": [
30,
30,
30,
30
170,
170,
6
],
"zeros": [
130,
130,
0
]
}
]
......@@ -10,11 +10,7 @@
<i-circle
v-for="(section, index) in item.sections"
:key="section"
:percent="
(parseFloat(item.scores[index]) /
parseFloat(item.totals[index])) *
100
"
:percent="percent(item, index)"
dashboard
stroke-color="#2D8CF0"
>
......@@ -26,19 +22,21 @@
{{ section }}
</p>
</div>
<span>
<span v-if="parseFloat(item.zeros[index]) === 0">
{{ $t('exam.total') }}
<i>
{{ item.totals[index] }}
</i>
</span>
<span v-else>
<i>
{{ item.zeros[index] + '~' + item.totals[index] }}
</i>
</span>
</i-circle>
<i-circle
key="sum"
:percent="
(parseFloat(sum(item.scores)) / parseFloat(sum(item.totals))) *
100
"
:percent="percent(item, null)"
dashboard
stroke-color="#5cb85c"
>
......@@ -50,12 +48,17 @@
{{ $t('exam.sum') }}
</p>
</div>
<span>
<span v-if="parseFloat(sum(item.zeros)) === 0">
{{ $t('exam.total') }}
<i>
{{ sum(item.totals) }}
</i>
</span>
<span v-else>
<i>
{{ sum(item.zeros) + '~' + sum(item.totals) }}
</i>
</span>
</i-circle>
</div>
</Card>
......@@ -74,6 +77,23 @@ export default {
}
},
methods: {
percent(item, index) {
let p = 0
if (index != null) {
p =
((parseFloat(item.scores[index]) - parseFloat(item.zeros[index])) /
(parseFloat(item.totals[index]) - parseFloat(item.zeros[index]))) *
100
} else {
p =
((parseFloat(this.sum(item.scores)) -
parseFloat(this.sum(item.zeros))) /
(parseFloat(this.sum(item.totals)) -
parseFloat(this.sum(item.zeros)))) *
100
}
return p
},
sum(arr) {
let sum = 0
for (const x of arr) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment