Browse Source

[新增]初始化时计算试卷各项分数

master
邵佳豪 4 years ago
parent
commit
cb632ef788
  1. 3
      src/app/examiner/create-test-score/create-test-score.component.ts
  2. 7
      src/app/student/examination-details/examination-details.component.html
  3. 46
      src/app/student/examination-details/examination-details.component.ts

3
src/app/examiner/create-test-score/create-test-score.component.ts

@ -617,8 +617,6 @@ export class CreateTestScoreComponent implements OnInit {
examScore:any = 0//整个试卷的总分
//计算分数
calculateScore(key){
//key代表第几个建筑
@ -638,6 +636,7 @@ export class CreateTestScoreComponent implements OnInit {
x += i.score
})
}
element.planScore = x
examScore2 += Number(x)
})
this.examScore = examScore + examScore2

7
src/app/student/examination-details/examination-details.component.html

@ -3,10 +3,13 @@
<div class="cneter">
<div class="left">
<div class="headerLeft"><div>单位列表</div><div style="text-align: right;">总分: <label style="color: #07CDCF;"></label></div></div>
<div class="headerLeft"><div>单位列表</div><div style="text-align: right;">总分:
<label style="color: #07CDCF;">{{examScore}}</label>
</div></div>
<div class="centerLeft" style="background: #F5FDFE;"><div class="overflowText">单位名称</div><div class="overflowText">总分</div></div>
<div class="centerLeft" *ngFor="let item of paperCompanyData" [ngClass]="{'selectPaper': selectPaper.id == item.id}" (click)='togglePaper(item)'>
<div class="overflowText">{{item.companyInfo.name}}</div><div class="overflowText"></div>
<div class="overflowText">{{item.companyInfo.name}}</div>
<div class="overflowText">{{item.score}}+{{item.planScore || 0}}</div>
</div>
</div>
<div class="right">

46
src/app/student/examination-details/examination-details.component.ts

@ -15,6 +15,7 @@ export class ExaminationDetailsComponent implements OnInit {
async ngOnInit(): Promise<void> {
await this.getTestInfo()
this.getUnitPlans()//将试卷的预案考题放进数据中
}
paperData:any //试卷信息
@ -37,7 +38,7 @@ export class ExaminationDetailsComponent implements OnInit {
this.paperCompanyData = JSON.parse( JSON.stringify(data.paperDataInfo) ) //具体考卷
this.selectPaper = this.paperCompanyData[0] || {id:null} //当前选择考卷
this.handlePaperData()
resolve(1)
resolve()
})
})
@ -57,8 +58,47 @@ export class ExaminationDetailsComponent implements OnInit {
}
//获得单位预案设定
getUnitPlans(){
async getUnitPlans(){
for (let index = 0; index < this.paperCompanyData.length; index++) {
const item = this.paperCompanyData[index];
let params = {
paperId : item.paperId,
companyId : item.companyInfo.id
}
await new Promise((resolve,reject)=>{
this.http.get(`/api/PaperPlans`,{params:params}).subscribe(data => {
item.planList = []
item.planList = data
resolve()
})
})
}
this.calculateScore()
}
examScore:any = 0//整个试卷的总分
//计算分数
calculateScore(){
let examScore = 0
let examScore2 = 0
this.paperCompanyData.forEach(item => {
//计算每个单位基本信息部分总分
item.score = item.basicInfoScore + item.adjoinScore + item.importLocationScore + item.functionalDivisionScore + item.facilityScore
//计算整个试卷基本信息总分
examScore += item.score
//计算整个试卷预案试题总分
let x = 0
if(item.planList){
item.planList.forEach(i => {
x += i.score
})
}
item.planScore = x
examScore2 += x
})
//计算总分
this.examScore = examScore + examScore2
console.log(678,this.paperCompanyData)
}
}

Loading…
Cancel
Save