Commit e47f4bdd authored by wangqinghua's avatar wangqinghua

下载附件

parent 680b51fc
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<widget id="io.ionic.smart19.starter.test" version="4.0.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <widget id="io.ionic.smart19.starter.test" version="4.0.4" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>党建云平台(测试)</name> <name>党建云平台(测试)</name>
<description>An awesome Ionic/Cordova app.</description> <description>An awesome Ionic/Cordova app.</description>
<author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author> <author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
......
...@@ -61,14 +61,14 @@ ...@@ -61,14 +61,14 @@
<ng-container *ngIf="item.questionType == 4"> <ng-container *ngIf="item.questionType == 4">
<p> <p>
<label> <label>
<input [(ngModel)]="item.answer" [name]="item.questionQueId" value="A" type="radio"> <input [(ngModel)]="item.answer" [name]="item.questionId" value="1" type="radio">
<span class=" selectIndex">A</span>&nbsp;&nbsp; <span class=" selectIndex">A</span>&nbsp;&nbsp;
</label> </label>
</p> </p>
<p> <p>
<label> <label>
<input [(ngModel)]="item.answer" [name]="item.questionQueId" value="B" type="radio"> <input [(ngModel)]="item.answer" [name]="item.questionId" value="0" type="radio">
<span class=" selectIndex">B</span>&nbsp;&nbsp; <span class=" selectIndex">B</span>&nbsp;&nbsp;
</label> </label>
......
...@@ -38,8 +38,9 @@ page-learning-do { ...@@ -38,8 +38,9 @@ page-learning-do {
font-size: 1.6rem; font-size: 1.6rem;
div{ div{
p{ p{
margin-bottom: .8rem; margin-bottom: 1rem;
margin-left: .8rem; margin-left: 1rem;
line-height: 1.5rem;
} }
} }
} }
......
...@@ -31,9 +31,9 @@ export class LearningDoPage { ...@@ -31,9 +31,9 @@ export class LearningDoPage {
public toastCtrl: ToastController, public appService: AppService, public datePipe: DatePipe) { public toastCtrl: ToastController, public appService: AppService, public datePipe: DatePipe) {
} }
ionViewDidLoad(){ ionViewDidLoad() {
this.navbar.backButtonClick= ()=>{ this.navbar.backButtonClick = () => {
this.appService.alert("是否退出当前测试,中途退出直接交卷?"),()=>{ this.appService.alert("是否退出当前测试,中途退出直接交卷?"), () => {
this.submit(); this.submit();
} }
}; };
...@@ -101,7 +101,7 @@ export class LearningDoPage { ...@@ -101,7 +101,7 @@ export class LearningDoPage {
//下一题 //下一题
next() { next() {
if (this.index == this.list.length -1) { if (this.index == this.list.length - 1) {
const toast = this.toastCtrl.create(message); const toast = this.toastCtrl.create(message);
toast.setMessage('已经是最后一题了哦'); toast.setMessage('已经是最后一题了哦');
toast.present(); toast.present();
...@@ -112,7 +112,7 @@ export class LearningDoPage { ...@@ -112,7 +112,7 @@ export class LearningDoPage {
} }
//左划右划 //左划右划
slideChanged(){ slideChanged() {
this.index = this.slides.getActiveIndex(); this.index = this.slides.getActiveIndex();
} }
...@@ -154,9 +154,9 @@ export class LearningDoPage { ...@@ -154,9 +154,9 @@ export class LearningDoPage {
submit() { submit() {
const data = { const data = {
listMap: this.list.map(e => { listMap: this.list.map(e => {
if (e.answer.length > 1) { if (e.answer.length > 1 && e.questionType == 2) {
e.answer = e.answer.substr(0, e.answer.length - 1); e.answer = e.answer.substr(0, e.answer.length - 1);
e.answer = e.answer.split(";").sort(); e.answer = e.answer.split(";").sort().join(";");
} }
const d = { const d = {
questionId: e.questionId, questionId: e.questionId,
...@@ -171,12 +171,12 @@ export class LearningDoPage { ...@@ -171,12 +171,12 @@ export class LearningDoPage {
this.learnSer.submitPaper(data).subscribe( this.learnSer.submitPaper(data).subscribe(
(res) => { (res) => {
this.commonSer.toast("提交成功"); this.commonSer.toast("提交成功");
if(this.type == 'reset') { if (this.type == 'reset') {
this.navCtrl.push("ReviewResultPage", { this.navCtrl.push("ReviewResultPage", {
result: res.data, result: res.data,
title: this.title title: this.title
}) })
}else{ } else {
this.navCtrl.push("LearningResultPage", { this.navCtrl.push("LearningResultPage", {
testId: this.testId, testId: this.testId,
title: this.title title: this.title
......
...@@ -67,21 +67,17 @@ ...@@ -67,21 +67,17 @@
</ng-container> </ng-container>
<!--判断题--> <!--判断题-->
<ng-container *ngIf="item.questionType == 4"> <ng-container *ngIf="item.questionType == 4">
<ng-container *ngFor=" let option4 of item.options;let opindex4 = index;">
<p> <p>
<label> <label>
<input disabled [(ngModel)]="item.answer" [name]="item.questionQueId" value="A" type="radio"> <input disabled [(ngModel)]="item.answer" [name]="item.questionId" value="A" type="radio">
<span class=" selectIndex">A</span>&nbsp;&nbsp; <span class="selectIndex" [ngClass]="{'select-right' : option4.answer == 'right',
'select-error':option4.answer == 'error'}">{{option4.option}}</span>&nbsp;&nbsp;
</label> {{option4.comment}}
</p>
<p>
<label>
<input disabled [(ngModel)]="item.answer" [name]="item.questionQueId" value="B" type="radio">
<span class=" selectIndex">B</span>&nbsp;&nbsp;
</label> </label>
</p> </p>
</ng-container> </ng-container>
</ng-container>
<!--问答--> <!--问答-->
<ng-container *ngIf="item.questionType == 5"> <ng-container *ngIf="item.questionType == 5">
<textarea [(ngModel)]="item.answer" disabled class="content-textarea"></textarea> <textarea [(ngModel)]="item.answer" disabled class="content-textarea"></textarea>
......
...@@ -32,7 +32,15 @@ export class ReviewLearnPage { ...@@ -32,7 +32,15 @@ export class ReviewLearnPage {
(res)=>{ (res)=>{
this.list = res.data; this.list = res.data;
this.list.forEach(e=>{ this.list.forEach(e=>{
if(e.questionType == 1 || e.questionType == 2){ if(e.questionType == 4){
e.options = [
{option:'A', comment:'是'},
{option:'B', comment:'否'},
];
e.myAnswer = e.myAnswer == '1'?'A':'B';
e.correctAnswer = e.correctAnswer == '1'?'A':'B';
}
if(e.questionType == 1 || e.questionType == 2 || e.questionType == 4){
e.options.forEach(s=>{ e.options.forEach(s=>{
if(e.correctAnswer.includes(s.option)){ if(e.correctAnswer.includes(s.option)){
s.answer = 'right'; s.answer = 'right';
...@@ -44,6 +52,8 @@ export class ReviewLearnPage { ...@@ -44,6 +52,8 @@ export class ReviewLearnPage {
}) })
} }
}) })
console.log(this.list)
} }
) )
} }
......
...@@ -81,4 +81,19 @@ export class CommonService{ ...@@ -81,4 +81,19 @@ export class CommonService{
alert.present(); alert.present();
} }
} }
/**
* 下载文件
* @param url 文件URL
*/
downloadFile(title,data: Response) {
const blob = new Blob([data], {type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;"});
const url= window.URL.createObjectURL(blob);
let link = document.createElement("a");
link.setAttribute("href", url);
link.setAttribute("download", title);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
} }
\ No newline at end of file
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