【angular】考试卷子详情
因为数据库中数据问题,截取空白页不如上盘原型图:
主体代码:
<div *ngFor="let q of qt.questionMainList; let i=index" [ngSwitch]="qt.questionTypeId"><div *ngFor="let qtl of questionTypeList; let k=index"><div *ngIf="qt.questionTypeId==qtl.id" [ngSwitch]="qtl.questionCode"><div *ngSwitchCase="0"><app-subjective-input [question]="q" [exampaperScore]="exampaper.paperScore" (votedScore)="acceptScore($event)">app-subjective-input>……div>div>div>
通过[]将question、paperScore传给子组件,通过()将子组件中各题的分数传出来
子组件:
@Input() question:QuestionMainModel; //题干实体@Input() exampaperScore:string;//试卷得分@Output() votedScore = new EventEmitter();……
试卷分数=之前试卷总分-当前题本来的分数+当前题修改后的分数
this.exampaperScore = (parseFloat(this.exampaperScore) - parseFloat(this.currentQuestionScore) + parseFloat(this.question.stuScore)).toString();this.votedScore.emit(this.exampaperScore);这里将修改后的分数送给父组件用于显示,也用于和试卷满分比较
修改一道题便提交一道题的分数
html中回显学生答案:
<div class="question_input_div">
<p><strong>{{question.questionMainOrder + ". " + question.questionContent}}strong><span *ngIf="question.score">({{question.score}}分)span>p>
<div *ngIf="question.imageName"><img class="question_img" src="{{question.imageId}}">div>
<div class="question_input" *ngFor="let option of question.questionSubEntityList;let i=index">div><div><a *ngIf="!question.studentAnswer ; else showAnswer">您未作答此题a><ng-template #showAnswer><strong>您的答案是:strong><label style='font-weight:normal;'>{{question.studentAnswer}}label>ng-template><br/> 正确答案如下:<a style="font-weight:normal;color:red">{{question.answer}}a>div><div>是否答对:<a *ngIf=" (question.stuScore | toNumber) > 0 ; else elseBlock"><strong style="color:red">√strong> a><ng-template #elseBlock><strong style="color:red">Xstrong>ng-template><input type="text" maxlength="2" id="scoreId" style="width:6%" (change)="submitScore($event.target.value)" [(ngModel)]="question.stuScore"onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" /><label class="scoreSytle">分label>div>div>
<p-dialog header="提示" [(visible)]="display" modal="modal" width="400" [responsive]="true"><p style="text-align:center">{{message}}p><p-footer><button type="button" pButton (click)="display=false" label="确定">button>p-footer>
p-dialog>
<br/>
过程中涉及到了字符串的截取:
http://blog.csdn.net/ma15732625261/article/details/79538357
input和output:很重要
http://blog.csdn.net/ma15732625261/article/details/78227191
后记:
想截取那篇文出来的效果是平行的,不太好看,所以把我们组长截取的沾出来写一篇博客吧
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
