|
@@ -36,11 +36,11 @@
|
|
|
</div>
|
|
|
<div class="panel">
|
|
|
<div class="score">
|
|
|
- <div><span>25</span><span>题</span></div>
|
|
|
+ <div><span>{{getNum(item.chapters)}}</span><span>题</span></div>
|
|
|
<div>题目总数</div>
|
|
|
</div>
|
|
|
<div class="score">
|
|
|
- <div><span>98</span><span>分</span></div>
|
|
|
+ <div><span>{{getScore(item.array)}}</span><span>分</span></div>
|
|
|
<div>综合得分</div>
|
|
|
</div>
|
|
|
<div class="btn">
|
|
@@ -92,6 +92,69 @@ export default {
|
|
|
role: this.$route.query.role,
|
|
|
}
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ getNum() {
|
|
|
+ return function (array) {
|
|
|
+ let _array = JSON.parse(array)
|
|
|
+ let num = 0;
|
|
|
+ _array.forEach(el => {
|
|
|
+ if ((el.ttype == 3 || el.ttype == 2) && el.array.length > 0) {
|
|
|
+ el.array.forEach(item => {
|
|
|
+ if (item.ttype == 2 && item.array.length > 0) {
|
|
|
+ item.array.forEach(item2 => {
|
|
|
+ if (item2.ttype == 1 && item2.json) {
|
|
|
+ num++
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (item.ttype == 1 && item.json) {
|
|
|
+ num++
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (el.ttype == 1 && el.json) {
|
|
|
+ num++
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return num;
|
|
|
+ };
|
|
|
+ },
|
|
|
+ getScore() {
|
|
|
+ return function (array) {
|
|
|
+ // let _array = JSON.parse(array)
|
|
|
+ let _score = 0;
|
|
|
+ let scoreArray = [];
|
|
|
+ for(var i = 0;i<array.length;i++){
|
|
|
+ let _array = JSON.parse(array[i].courseJson)
|
|
|
+ let score = 0;
|
|
|
+ for(var j = 0;j<_array.length;j++){
|
|
|
+ let el = _array[j];
|
|
|
+ if ((el.ttype == 3 || el.ttype == 2) && el.array.length > 0) {
|
|
|
+ for(var k = 0;k<el.array.length;k++){
|
|
|
+ let item = el.array[k];
|
|
|
+ if (item.ttype == 2 && item.array.length > 0) {
|
|
|
+ for(var z = 0;z<item.array.length;z++){
|
|
|
+ let item2 = item.array[k];
|
|
|
+ if (item2.ttype == 1 && item2.json && item2.json.score2) {
|
|
|
+ score+=parseInt(item2.json.score2)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (item.ttype == 1 && item.json && item.json.score2) {
|
|
|
+ score+=parseInt(item.json.score2)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (el.ttype == 1 && el.json && el.json.score2) {
|
|
|
+ score+=parseInt(el.json.score2)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ scoreArray.push(score)
|
|
|
+ }
|
|
|
+ scoreArray.forEach(el => {
|
|
|
+ _score+=el
|
|
|
+ })
|
|
|
+ console.log(scoreArray)
|
|
|
+ return (_score ? _score / scoreArray.length : 0);
|
|
|
+ };
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
checkType(type) {
|
|
|
this.type = type
|
|
@@ -125,6 +188,7 @@ export default {
|
|
|
// 遍历原始数据,根据 parentId 进行分组
|
|
|
array.forEach(item => {
|
|
|
if (!worksArray[item.courseid]) {
|
|
|
+ // console.log(item.chapters);
|
|
|
worksArray[item.courseid] = {
|
|
|
id: item.id,
|
|
|
courseid: item.courseid,
|