Commit 00c83ad5f605d3d807dccad17614413b8a12cc78

Authored by r-ujihara
1 parent ddd0f8c8

評価取り込み2回目

@@ -20,9 +20,11 @@ @@ -20,9 +20,11 @@
20 "@angular/platform-browser-dynamic": "2.2.1", 20 "@angular/platform-browser-dynamic": "2.2.1",
21 "@angular/platform-server": "2.2.1", 21 "@angular/platform-server": "2.2.1",
22 "@ionic/storage": "^1.1.7", 22 "@ionic/storage": "^1.1.7",
  23 + "chart.js": "^2.5.0",
23 "ionic-angular": "2.1.0", 24 "ionic-angular": "2.1.0",
24 "ionic-native": "2.4.1", 25 "ionic-native": "2.4.1",
25 "ionicons": "3.0.0", 26 "ionicons": "3.0.0",
  27 + "ng2-charts": "^1.5.0",
26 "rxjs": "5.0.0-beta.12", 28 "rxjs": "5.0.0-beta.12",
27 "sw-toolbox": "3.4.0", 29 "sw-toolbox": "3.4.0",
28 "zone.js": "0.6.26" 30 "zone.js": "0.6.26"
@@ -7,8 +7,11 @@ import { QaPage } from '../pages/qa/qa'; @@ -7,8 +7,11 @@ import { QaPage } from '../pages/qa/qa';
7 import { ExtunitPage } from '../pages/extunit/extunit'; 7 import { ExtunitPage } from '../pages/extunit/extunit';
8 import { ExtqaPage } from '../pages/extqa/extqa'; 8 import { ExtqaPage } from '../pages/extqa/extqa';
9 import { HelpPage } from '../pages/help/help'; 9 import { HelpPage } from '../pages/help/help';
  10 +import { StatusPage } from '../pages/status/status'
10 import { DataService } from '../providers/data-service'; 11 import { DataService } from '../providers/data-service';
11 import { Storage } from '@ionic/storage'; 12 import { Storage } from '@ionic/storage';
  13 +import { ChartsModule } from 'ng2-charts/charts/charts';
  14 +import '../../node_modules/chart.js/dist/Chart.bundle.min.js';
12 15
13 @NgModule({ 16 @NgModule({
14 declarations: [ 17 declarations: [
@@ -18,10 +21,12 @@ import { Storage } from '@ionic/storage'; @@ -18,10 +21,12 @@ import { Storage } from '@ionic/storage';
18 QaPage, 21 QaPage,
19 ExtunitPage, 22 ExtunitPage,
20 ExtqaPage, 23 ExtqaPage,
21 - HelpPage 24 + HelpPage,
  25 + StatusPage
22 ], 26 ],
23 imports: [ 27 imports: [
24 - IonicModule.forRoot(MyApp) 28 + IonicModule.forRoot(MyApp),
  29 + ChartsModule
25 ], 30 ],
26 bootstrap: [IonicApp], 31 bootstrap: [IonicApp],
27 entryComponents: [ 32 entryComponents: [
@@ -31,7 +36,8 @@ import { Storage } from '@ionic/storage'; @@ -31,7 +36,8 @@ import { Storage } from '@ionic/storage';
31 QaPage, 36 QaPage,
32 ExtunitPage, 37 ExtunitPage,
33 ExtqaPage, 38 ExtqaPage,
34 - HelpPage 39 + HelpPage,
  40 + StatusPage
35 ], 41 ],
36 providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }, Storage, DataService] 42 providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }, Storage, DataService]
37 }) 43 })
@@ -34,6 +34,7 @@ export class ExtqaPage { @@ -34,6 +34,7 @@ export class ExtqaPage {
34 selectstate: Array<boolean> = new Array(); 34 selectstate: Array<boolean> = new Array();
35 subscription; 35 subscription;
36 screenHeight:number; 36 screenHeight:number;
  37 + positiveCnt: number;
37 38
38 constructor(public navCtrl: NavController, public navParams: NavParams, private dataSevice: DataService) { 39 constructor(public navCtrl: NavController, public navParams: NavParams, private dataSevice: DataService) {
39 this.menuId = navParams.get("menuId"); 40 this.menuId = navParams.get("menuId");
@@ -47,6 +48,7 @@ export class ExtqaPage { @@ -47,6 +48,7 @@ export class ExtqaPage {
47 this.ds = dataSevice; 48 this.ds = dataSevice;
48 this.nv = navCtrl; 49 this.nv = navCtrl;
49 this.selected = -1; 50 this.selected = -1;
  51 + this.positiveCnt = 0;
50 for (var i = 0; i < this.qa1.choicesId.length; i++) { 52 for (var i = 0; i < this.qa1.choicesId.length; i++) {
51 this.selectstate.push(false); 53 this.selectstate.push(false);
52 } 54 }
@@ -74,6 +76,7 @@ export class ExtqaPage { @@ -74,6 +76,7 @@ export class ExtqaPage {
74 if (this.selected === this.qa1.answerId) { //正解 76 if (this.selected === this.qa1.answerId) { //正解
75 this.result = "正解"; 77 this.result = "正解";
76 this.resultcolor = "danger"; 78 this.resultcolor = "danger";
  79 + this.positiveCnt++;
77 } 80 }
78 else { 81 else {
79 this.result = "不正解"; 82 this.result = "不正解";
@@ -84,8 +87,10 @@ export class ExtqaPage { @@ -84,8 +87,10 @@ export class ExtqaPage {
84 if (this.index >= (this.qaList.length - 1)) 87 if (this.index >= (this.qaList.length - 1))
85 { 88 {
86 var key: string; 89 var key: string;
  90 + var value: string;
87 key = this.qa1.menuId + ":" + this.qa1.unitId; 91 key = this.qa1.menuId + ":" + this.qa1.unitId;
88 - this.dataSevice.saveInfo(key); 92 + value = this.positiveCnt + ":" + this.qaList.length;
  93 + this.dataSevice.saveInfo(key, value);
89 } 94 }
90 95
91 var element = document.getElementsByClassName('question-card'); 96 var element = document.getElementsByClassName('question-card');
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 <ion-item (click)="itemSelected(ptn1)"> 23 <ion-item (click)="itemSelected(ptn1)">
24 <ion-icon name='ribbon' item-left [color]="list1state[i] != done ? 'secondary' : 'light'"></ion-icon> 24 <ion-icon name='ribbon' item-left [color]="list1state[i] != done ? 'secondary' : 'light'"></ion-icon>
25 {{ptn1.unitName}} 25 {{ptn1.unitName}}
26 - <ion-note item-right *ngIf="list1state[i] != done">クリア!</ion-note> 26 + <ion-note item-right *ngIf="list1state[i] != done">{{list1state[i]}}</ion-note>
27 <ion-note item-right *ngIf="list1state[i] == done">未実施</ion-note> 27 <ion-note item-right *ngIf="list1state[i] == done">未実施</ion-note>
28 </ion-item> 28 </ion-item>
29 </ion-list> 29 </ion-list>
@@ -73,8 +73,12 @@ export class ExtunitPage { @@ -73,8 +73,12 @@ export class ExtunitPage {
73 for(var i = 0; i< this.list1num; i++) 73 for(var i = 0; i< this.list1num; i++)
74 { 74 {
75 this.list1state[i] = val[i]; 75 this.list1state[i] = val[i];
  76 + if(val[i] != null)
  77 + {
  78 + var svdata = val[i].toString().split(":");
  79 + this.list1state[i] = svdata[1] + "問中" + svdata[0] + "問正解!";
  80 + }
76 } 81 }
77 -  
78 }); 82 });
79 } 83 }
80 } 84 }
@@ -22,6 +22,12 @@ @@ -22,6 +22,12 @@
22 22
23 <button ion-button full large>1・2年生の復習</button> 23 <button ion-button full large>1・2年生の復習</button>
24 24
  25 + <ion-buttons end>
  26 + <button ion-button center color="danger" round (click)="gotoStatus()" icon-left>
  27 + <ion-icon name="stats"></ion-icon>達成状況を確認
  28 + </button>
  29 + </ion-buttons>
  30 +
25 <p *ngFor="let item_f of list_f"> 31 <p *ngFor="let item_f of list_f">
26 <button ion-button color="light" block round (click)="itemSelected(item_f)">{{item_f.title}}</button> 32 <button ion-button color="light" block round (click)="itemSelected(item_f)">{{item_f.title}}</button>
27 </p> 33 </p>
@@ -3,6 +3,7 @@ import { NavController, NavParams } from 'ionic-angular'; @@ -3,6 +3,7 @@ import { NavController, NavParams } from 'ionic-angular';
3 import { DataService } from '../../providers/data-service'; 3 import { DataService } from '../../providers/data-service';
4 import { Menu } from '../../providers/define-menu'; 4 import { Menu } from '../../providers/define-menu';
5 import { UnitPage } from '../unit/unit'; 5 import { UnitPage } from '../unit/unit';
  6 +import { StatusPage } from '../status/status';
6 7
7 /* 8 /*
8 Generated class for the Menu page. 9 Generated class for the Menu page.
@@ -34,4 +35,8 @@ export class MenuPage { @@ -34,4 +35,8 @@ export class MenuPage {
34 itemSelected(item: Menu) { 35 itemSelected(item: Menu) {
35 this.navCtrl.push(UnitPage, {menuId: item.menuId, title:item.title}); 36 this.navCtrl.push(UnitPage, {menuId: item.menuId, title:item.title});
36 } 37 }
  38 +
  39 + gotoStatus() {
  40 + this.navCtrl.push(StatusPage);
  41 + }
37 } 42 }
@@ -34,6 +34,7 @@ export class QaPage { @@ -34,6 +34,7 @@ export class QaPage {
34 selectstate: Array<boolean> = new Array(); 34 selectstate: Array<boolean> = new Array();
35 subscription; 35 subscription;
36 screenHeight:number; 36 screenHeight:number;
  37 + positiveCnt: number;
37 38
38 constructor(public navCtrl: NavController, public navParams: NavParams, private dataSevice: DataService) { 39 constructor(public navCtrl: NavController, public navParams: NavParams, private dataSevice: DataService) {
39 this.menuId = navParams.get("menuId"); 40 this.menuId = navParams.get("menuId");
@@ -47,6 +48,7 @@ export class QaPage { @@ -47,6 +48,7 @@ export class QaPage {
47 this.ds = dataSevice; 48 this.ds = dataSevice;
48 this.nv = navCtrl; 49 this.nv = navCtrl;
49 this.selected = -1; 50 this.selected = -1;
  51 + this.positiveCnt = 0;
50 for (var i = 0; i < this.qa1.choicesId.length; i++) { 52 for (var i = 0; i < this.qa1.choicesId.length; i++) {
51 this.selectstate.push(false); 53 this.selectstate.push(false);
52 } 54 }
@@ -77,6 +79,7 @@ export class QaPage { @@ -77,6 +79,7 @@ export class QaPage {
77 if (this.selected === this.qa1.answerId) { //正解 79 if (this.selected === this.qa1.answerId) { //正解
78 this.result = "正解"; 80 this.result = "正解";
79 this.resultcolor = "danger"; 81 this.resultcolor = "danger";
  82 + this.positiveCnt++;
80 } 83 }
81 else { 84 else {
82 this.result = "不正解"; 85 this.result = "不正解";
@@ -87,8 +90,10 @@ export class QaPage { @@ -87,8 +90,10 @@ export class QaPage {
87 if (this.index >= (this.qaList.length - 1)) 90 if (this.index >= (this.qaList.length - 1))
88 { 91 {
89 var key: string; 92 var key: string;
  93 + var value: string;
90 key = this.qa1.menuId + ":" + this.qa1.unitId; 94 key = this.qa1.menuId + ":" + this.qa1.unitId;
91 - this.dataSevice.saveInfo(key); 95 + value = this.positiveCnt + ":" + this.qaList.length;
  96 + this.dataSevice.saveInfo(key, value);
92 } 97 }
93 98
94 var element = document.getElementsByClassName('question-card'); 99 var element = document.getElementsByClassName('question-card');
  1 +<!--
  2 + Generated template for the Status page.
  3 +
  4 + See http://ionicframework.com/docs/v2/components/#navigation for more info on
  5 + Ionic pages and navigation.
  6 +-->
  7 +<ion-header>
  8 + <ion-navbar color="primary">
  9 + <ion-title>達成状況</ion-title>
  10 + </ion-navbar>
  11 +</ion-header>
  12 +
  13 +<ion-content padding class="status-page">
  14 + <ion-item-group>
  15 + <ion-item-divider color="light">>
  16 + {{list_f[0].title}}
  17 + </ion-item-divider>
  18 + <canvas #baseChart0 height="70" class="status-canvas"></canvas>
  19 + </ion-item-group>
  20 +
  21 + <ion-item-group>
  22 + <ion-item-divider color="light">>
  23 + {{list_f[1].title}}
  24 + </ion-item-divider>
  25 + <canvas #baseChart1 height="70" class="status-canvas"></canvas>
  26 + </ion-item-group>
  27 +
  28 + <ion-item-group>
  29 + <ion-item-divider color="light">>
  30 + {{list_f[2].title}}
  31 + </ion-item-divider>
  32 + <canvas #baseChart2 height="70" class="status-canvas"></canvas>
  33 + </ion-item-group>
  34 +
  35 + <ion-item-group>
  36 + <ion-item-divider color="light">>
  37 + {{list_f[3].title}}
  38 + </ion-item-divider>
  39 + <canvas #baseChart3 height="70" class="status-canvas"></canvas>
  40 + </ion-item-group>
  41 +
  42 + <ion-item-group>
  43 + <ion-item-divider color="light">>
  44 + {{list_f[4].title}}
  45 + </ion-item-divider>
  46 + <canvas #baseChart4 height="70" class="status-canvas"></canvas>
  47 + </ion-item-group>
  48 +
  49 + <ion-item-group>
  50 + <ion-item-divider color="light">>
  51 + {{list_f[5].title}}
  52 + </ion-item-divider>
  53 + <canvas #baseChart5 height="70" class="status-canvas"></canvas>
  54 + </ion-item-group>
  55 +
  56 + <ion-item-group>
  57 + <ion-item-divider color="light">>
  58 + {{list_f[6].title}}
  59 + </ion-item-divider>
  60 + <canvas #baseChart6 height="70" class="status-canvas"></canvas>
  61 + </ion-item-group>
  62 +
  63 + <ion-item-group>
  64 + <ion-item-divider color="light">>
  65 + {{list_f[7].title}}
  66 + </ion-item-divider>
  67 + <canvas #baseChart7 height="70" class="status-canvas"></canvas>
  68 + </ion-item-group>
  69 +</ion-content>
  1 +page-status {
  2 + .status-page {
  3 +
  4 + .status-canvas{
  5 + background-color:white
  6 + }
  7 + }
  8 +}
  1 +import { Component,ViewChild } from '@angular/core';
  2 +import { NavController, NavParams } from 'ionic-angular';
  3 +import { Menu } from '../../providers/define-menu';
  4 +import { ChartData } from '../../providers/define-chartdata';
  5 +import { DataService } from '../../providers/data-service';
  6 +import { Chart } from 'chart.js';
  7 +
  8 +/*
  9 + Generated class for the Status page.
  10 +
  11 + See http://ionicframework.com/docs/v2/components/#navigation for more info on
  12 + Ionic pages and navigation.
  13 +*/
  14 +@Component({
  15 + selector: 'page-status',
  16 + templateUrl: 'status.html'
  17 +})
  18 +export class StatusPage {
  19 + @ViewChild('baseChart0') barCanvas0;
  20 + @ViewChild('baseChart1') barCanvas1;
  21 + @ViewChild('baseChart2') barCanvas2;
  22 + @ViewChild('baseChart3') barCanvas3;
  23 + @ViewChild('baseChart4') barCanvas4;
  24 + @ViewChild('baseChart5') barCanvas5;
  25 + @ViewChild('baseChart6') barCanvas6;
  26 + @ViewChild('baseChart7') barCanvas7;
  27 +
  28 + list_f: Menu[];
  29 +
  30 + chartOptions: any = {
  31 +    scaleShowVerticalLines: false,
  32 +    responsive: true,
  33 + legend: {
  34 + display: false
  35 + },
  36 + tooltips: {
  37 + enabled: true,
  38 + callbacks: {
  39 + label: function(tooltipItem, data) {
  40 + var allData = data.datasets[tooltipItem.datasetIndex].data;
  41 + var tooltipLabel = data.datasets[tooltipItem.datasetIndex].label;
  42 + var tooltipData = allData[tooltipItem.index];
  43 + return tooltipLabel + " : " + tooltipData + "%";
  44 + }
  45 + }
  46 +
  47 + },
  48 + scales: {
  49 + xAxes: [{
  50 + ticks: {
  51 + beginAtZero:true,
  52 + min: 0,
  53 + max: 100,
  54 + callback: function(value){
  55 + return value+'%';
  56 + }
  57 + }
  58 + }],
  59 + yAxes: [{
  60 + barThickness: 20
  61 + }]
  62 + }
  63 +
  64 +  };
  65 + 
  66 +  chartLabels: string[] = new Array();
  67 +  chartType: string = 'horizontalBar';
  68 +  chartLegend: boolean = true;
  69 + chartData: ChartData[] = new Array();
  70 + 
  71 + constructor(public navCtrl: NavController, public navParams: NavParams, private dataSevice: DataService) {
  72 +
  73 + this.list_f = dataSevice.getMenuFirst();
  74 + for(var i = 0; i < this.list_f.length; i++){
  75 +//    this.chartLabels.push(this.list_f[i].title);
  76 + }
  77 +
  78 +   this.chartLabels.push("");
  79 + this.getChartData();
  80 + }
  81 +
  82 + ionViewDidLoad() {
  83 + console.log('ionViewDidLoad StatusPage');
  84 + }
  85 +
  86 + getChart(context) {
  87 + let data = {
  88 + labels: this.chartLabels,
  89 + datasets: this.chartData
  90 + }
  91 +
  92 + return new Chart(context, {
  93 + type:   this.chartType,
  94 + data:   data,
  95 + options: this.chartOptions
  96 + });
  97 + }
  98 +
  99 + getChartData() {
  100 +
  101 + var promiseArray1 = new Array();
  102 + for (var i = 0; i < this.list_f.length; i++) {
  103 + var key: string;
  104 + key = this.list_f[i].menuId.toString();
  105 + promiseArray1.push(this.dataSevice.getInfo(key));
  106 + }
  107 +
  108 + Promise.all(promiseArray1)
  109 + .then(val =>
  110 + {
  111 + for(var i = 0; i< this.list_f.length; i++)
  112 + {
  113 + var cdata: ChartData = { label:'正答率',
  114 + data: new Array(),
  115 + backgroundColor:['rgba(255, 99, 132, 0.2)'],
  116 + borderColor:['rgba(255,99,132,1)'],
  117 + borderWidth:2 };
  118 + var num: number;
  119 + var score: number;
  120 + if(val[i] == null)
  121 + {
  122 + num = 0;
  123 + }
  124 + else
  125 + {
  126 + num = +val[i];
  127 + }
  128 + score = Math.floor((num / this.dataSevice.getQaCnt(this.list_f[i].menuId)) * 100);
  129 +// score = 10*i + 10;
  130 + cdata.data.push(score);
  131 + this.chartData = new Array();
  132 + this.chartData.push(cdata);
  133 + this.getChart(this.getCanvas(i).nativeElement);
  134 + }
  135 +
  136 + });
  137 + }
  138 +
  139 + getCanvas(num:number) : any{
  140 +
  141 + switch(num){
  142 + case 0:
  143 + return this.barCanvas0;
  144 + case 1:
  145 + return this.barCanvas1;
  146 + case 2:
  147 + return this.barCanvas2;
  148 + case 3:
  149 + return this.barCanvas3;
  150 + case 4:
  151 + return this.barCanvas4;
  152 + case 5:
  153 + return this.barCanvas5;
  154 + case 6:
  155 + return this.barCanvas6;
  156 + case 7:
  157 + return this.barCanvas7;
  158 + }
  159 + }
  160 +}
@@ -57,10 +57,10 @@ @@ -57,10 +57,10 @@
57 57
58 <ion-list class="unit-list" padding> 58 <ion-list class="unit-list" padding>
59 <ion-item *ngFor="let ptn1 of list1; let i = index;" (click)="itemSelected(ptn1)"> 59 <ion-item *ngFor="let ptn1 of list1; let i = index;" (click)="itemSelected(ptn1)">
60 - <ion-icon name='ribbon' item-left [color]="list1state[i] != done ? 'secondary' : 'light'"></ion-icon> 60 + <ion-icon name='ribbon' item-left [color]="list1state[i] != null ? 'secondary' : 'light'"></ion-icon>
61 {{ptn1.unitName}} 61 {{ptn1.unitName}}
62 - <ion-note item-right *ngIf="list1state[i] != done">クリア!</ion-note>  
63 - <ion-note item-right *ngIf="list1state[i] == done">未実施</ion-note> 62 + <ion-note item-right *ngIf="list1state[i] != null">{{list1state[i]}}</ion-note>
  63 + <ion-note item-right *ngIf="list1state[i] == null">未実施</ion-note>
64 </ion-item> 64 </ion-item>
65 </ion-list> 65 </ion-list>
66 </ion-card> 66 </ion-card>
@@ -85,10 +85,10 @@ @@ -85,10 +85,10 @@
85 85
86 <ion-list class="unit-list" *ngIf="list2dsp" padding> 86 <ion-list class="unit-list" *ngIf="list2dsp" padding>
87 <ion-item *ngFor="let ptn2 of list2; let i = index;" (click)="itemSelected(ptn2)"> 87 <ion-item *ngFor="let ptn2 of list2; let i = index;" (click)="itemSelected(ptn2)">
88 - <ion-icon name='ribbon' item-left [color]="list2state[i] != done ? 'secondary' : 'light'"></ion-icon> 88 + <ion-icon name='ribbon' item-left [color]="list2state[i] != null ? 'secondary' : 'light'"></ion-icon>
89 {{ptn2.unitName}} 89 {{ptn2.unitName}}
90 - <ion-note item-right *ngIf="list2state[i] != done">クリア!</ion-note>  
91 - <ion-note item-right *ngIf="list2state[i] == done">未実施</ion-note> 90 + <ion-note item-right *ngIf="list2state[i] != null">{{list2state[i]}}</ion-note>
  91 + <ion-note item-right *ngIf="list2state[i] == null">未実施</ion-note>
92 </ion-item> 92 </ion-item>
93 </ion-list> 93 </ion-list>
94 </ion-card> 94 </ion-card>
@@ -113,10 +113,10 @@ @@ -113,10 +113,10 @@
113 113
114 <ion-list class="unit-list" *ngIf="list3dsp" padding> 114 <ion-list class="unit-list" *ngIf="list3dsp" padding>
115 <ion-item *ngFor="let ptn3 of list3; let i = index;" (click)="itemSelected(ptn3)"> 115 <ion-item *ngFor="let ptn3 of list3; let i = index;" (click)="itemSelected(ptn3)">
116 - <ion-icon name='ribbon' item-left [color]="list3state[i] != done ? 'secondary' : 'light'"></ion-icon> 116 + <ion-icon name='ribbon' item-left [color]="list3state[i] != null ? 'secondary' : 'light'"></ion-icon>
117 {{ptn3.unitName}} 117 {{ptn3.unitName}}
118 - <ion-note item-right *ngIf="list3state[i] != done">クリア!</ion-note>  
119 - <ion-note item-right *ngIf="list3state[i] == done">未実施</ion-note> 118 + <ion-note item-right *ngIf="list3state[i] != null">{{list3state[i]}}</ion-note>
  119 + <ion-note item-right *ngIf="list3state[i] == null">未実施</ion-note>
120 </ion-item> 120 </ion-item>
121 </ion-list> 121 </ion-list>
122 </ion-card> 122 </ion-card>
@@ -141,10 +141,10 @@ @@ -141,10 +141,10 @@
141 141
142 <ion-list class="unit-list" *ngIf="list4dsp" padding> 142 <ion-list class="unit-list" *ngIf="list4dsp" padding>
143 <ion-item *ngFor="let ptn4 of list4; let i = index;" (click)="itemSelected(ptn4)"> 143 <ion-item *ngFor="let ptn4 of list4; let i = index;" (click)="itemSelected(ptn4)">
144 - <ion-icon name='ribbon' item-left [color]="list4state[i] != done ? 'secondary' : 'light'"></ion-icon> 144 + <ion-icon name='ribbon' item-left [color]="list4state[i] != null ? 'secondary' : 'light'"></ion-icon>
145 {{ptn4.unitName}} 145 {{ptn4.unitName}}
146 - <ion-note item-right *ngIf="list4state[i] != done">クリア!</ion-note>  
147 - <ion-note item-right *ngIf="list4state[i] == done">未実施</ion-note> 146 + <ion-note item-right *ngIf="list4state[i] != null">{{list4state[i]}}</ion-note>
  147 + <ion-note item-right *ngIf="list4state[i] == null">未実施</ion-note>
148 </ion-item> 148 </ion-item>
149 </ion-list> 149 </ion-list>
150 </ion-card> 150 </ion-card>
@@ -169,10 +169,10 @@ @@ -169,10 +169,10 @@
169 169
170 <ion-list class="unit-list" *ngIf="list5dsp" padding> 170 <ion-list class="unit-list" *ngIf="list5dsp" padding>
171 <ion-item *ngFor="let ptn5 of list5; let i = index;" (click)="itemSelected(ptn5)"> 171 <ion-item *ngFor="let ptn5 of list5; let i = index;" (click)="itemSelected(ptn5)">
172 - <ion-icon name='ribbon' item-left [color]="list5state[i] != done ? 'secondary' : 'light'"></ion-icon> 172 + <ion-icon name='ribbon' item-left [color]="list5state[i] != null ? 'secondary' : 'light'"></ion-icon>
173 {{ptn5.unitName}} 173 {{ptn5.unitName}}
174 - <ion-note item-right *ngIf="list5state[i] != done">クリア!</ion-note>  
175 - <ion-note item-right *ngIf="list5state[i] == done">未実施</ion-note> 174 + <ion-note item-right *ngIf="list5state[i] != null">{{list5state[i]}}</ion-note>
  175 + <ion-note item-right *ngIf="list5state[i] == null">未実施</ion-note>
176 </ion-item> 176 </ion-item>
177 </ion-list> 177 </ion-list>
178 </ion-card> 178 </ion-card>
@@ -197,10 +197,10 @@ @@ -197,10 +197,10 @@
197 197
198 <ion-list class="unit-list" *ngIf="list6dsp" padding> 198 <ion-list class="unit-list" *ngIf="list6dsp" padding>
199 <ion-item *ngFor="let ptn6 of list6; let i = index;" (click)="itemSelected(ptn6)"> 199 <ion-item *ngFor="let ptn6 of list6; let i = index;" (click)="itemSelected(ptn6)">
200 - <ion-icon name='ribbon' item-left [color]="list6state[i] != done ? 'secondary' : 'light'"></ion-icon> 200 + <ion-icon name='ribbon' item-left [color]="list6state[i] != null ? 'secondary' : 'light'"></ion-icon>
201 {{ptn6.unitName}} 201 {{ptn6.unitName}}
202 - <ion-note item-right *ngIf="list6state[i] != done">クリア!</ion-note>  
203 - <ion-note item-right *ngIf="list6state[i] == done">未実施</ion-note> 202 + <ion-note item-right *ngIf="list6state[i] != null">{{list6state[i]}}</ion-note>
  203 + <ion-note item-right *ngIf="list6state[i] == null">未実施</ion-note>
204 </ion-item> 204 </ion-item>
205 </ion-list> 205 </ion-list>
206 </ion-card> 206 </ion-card>
@@ -225,10 +225,10 @@ @@ -225,10 +225,10 @@
225 225
226 <ion-list class="unit-list" *ngIf="list7dsp" padding> 226 <ion-list class="unit-list" *ngIf="list7dsp" padding>
227 <ion-item *ngFor="let ptn7 of list7; let i = index;" (click)="itemSelected(ptn7)"> 227 <ion-item *ngFor="let ptn7 of list7; let i = index;" (click)="itemSelected(ptn7)">
228 - <ion-icon name='ribbon' item-left [color]="list7state[i] != done ? 'secondary' : 'light'"></ion-icon> 228 + <ion-icon name='ribbon' item-left [color]="list7state[i] != null ? 'secondary' : 'light'"></ion-icon>
229 {{ptn7.unitName}} 229 {{ptn7.unitName}}
230 - <ion-note item-right *ngIf="list7state[i] != done">クリア!</ion-note>  
231 - <ion-note item-right *ngIf="list7state[i] == done">未実施</ion-note> 230 + <ion-note item-right *ngIf="list7state[i] != null">{{list7state[i]}}</ion-note>
  231 + <ion-note item-right *ngIf="list7state[i] == null">未実施</ion-note>
232 </ion-item> 232 </ion-item>
233 </ion-list> 233 </ion-list>
234 </ion-card> 234 </ion-card>
@@ -72,6 +72,14 @@ export class UnitPage { @@ -72,6 +72,14 @@ export class UnitPage {
72 72
73 stageStateKey: string; 73 stageStateKey: string;
74 74
  75 + positiveCnt1: number;
  76 + positiveCnt2: number;
  77 + positiveCnt3: number;
  78 + positiveCnt4: number;
  79 + positiveCnt5: number;
  80 + positiveCnt6: number;
  81 + positiveCnt7: number;
  82 +
75 constructor(public navCtrl: NavController, private navParams: NavParams, 83 constructor(public navCtrl: NavController, private navParams: NavParams,
76 public alertCtrl: AlertController, public toastCtrl: ToastController, private dataSevice: DataService) { 84 public alertCtrl: AlertController, public toastCtrl: ToastController, private dataSevice: DataService) {
77 85
@@ -80,6 +88,13 @@ export class UnitPage { @@ -80,6 +88,13 @@ export class UnitPage {
80 this.stageStateKey = "stageState" + this.menuId; 88 this.stageStateKey = "stageState" + this.menuId;
81 89
82 this.currentItem = null; 90 this.currentItem = null;
  91 + this.positiveCnt1 = 0;
  92 + this.positiveCnt2 = 0;
  93 + this.positiveCnt3 = 0;
  94 + this.positiveCnt4 = 0;
  95 + this.positiveCnt5 = 0;
  96 + this.positiveCnt6 = 0;
  97 + this.positiveCnt7 = 0;
83 98
84 this.list2dsp = false; 99 this.list2dsp = false;
85 this.list3dsp = false; 100 this.list3dsp = false;
@@ -179,6 +194,17 @@ export class UnitPage { @@ -179,6 +194,17 @@ export class UnitPage {
179 console.log('ionViewDidLoad UnitPage'); 194 console.log('ionViewDidLoad UnitPage');
180 } 195 }
181 196
  197 + ionViewWillLeave(){
  198 + var key: string;
  199 + var value: string;
  200 + key = this.menuId.toString();
  201 + value = (this.positiveCnt1 + this.positiveCnt2
  202 + + this.positiveCnt3 + this.positiveCnt4
  203 + + this.positiveCnt5 + this.positiveCnt6
  204 + + this.positiveCnt7).toString();
  205 + this.dataSevice.savePositiveInfo(key, value);
  206 + }
  207 +
182 itemSelected(item: Unit) { 208 itemSelected(item: Unit) {
183 this.currentItem = item; 209 this.currentItem = item;
184 this.navCtrl.push(QaPage,{menuId: this.menuId, unitId: item.unitId, title: item.unitName}); 210 this.navCtrl.push(QaPage,{menuId: this.menuId, unitId: item.unitId, title: item.unitName});
@@ -242,7 +268,7 @@ export class UnitPage { @@ -242,7 +268,7 @@ export class UnitPage {
242 { 268 {
243 msg = "次のステージを獲得しました!" 269 msg = "次のステージを獲得しました!"
244 this.isOpenNext = true; 270 this.isOpenNext = true;
245 - this.dataSevice.saveInfo(this.stageStateKey); 271 + this.dataSevice.saveDone(this.stageStateKey);
246 } 272 }
247 273
248 const toast = this.toastCtrl.create({ 274 const toast = this.toastCtrl.create({
@@ -283,6 +309,12 @@ export class UnitPage { @@ -283,6 +309,12 @@ export class UnitPage {
283 { 309 {
284 alldone = false; 310 alldone = false;
285 } 311 }
  312 + else
  313 + {
  314 + var svdata = val[i].toString().split(":");
  315 + this.list1state[i] = svdata[1] + "問中" + svdata[0] + "問正解!";
  316 + this.positiveCnt1 = +svdata[0];
  317 + }
286 } 318 }
287 319
288 if(alldone) 320 if(alldone)
@@ -293,120 +325,144 @@ export class UnitPage { @@ -293,120 +325,144 @@ export class UnitPage {
293 }); 325 });
294 break; 326 break;
295 case 2: 327 case 2:
296 - var promiseArray2 = new Array();  
297 - for (var i = 0; i < this.list2num; i++) {  
298 - var key: string;  
299 - key = this.menuId + ":" + this.list2[i].unitId;  
300 - promiseArray2.push(this.dataSevice.getInfo(key));  
301 - } 328 + var promiseArray2 = new Array();
  329 + for (var i = 0; i < this.list2num; i++) {
  330 + var key: string;
  331 + key = this.menuId + ":" + this.list2[i].unitId;
  332 + promiseArray2.push(this.dataSevice.getInfo(key));
  333 + }
302 334
303 - Promise.all(promiseArray2)  
304 - .then(val =>  
305 - {  
306 - var alldone = true;  
307 - for(var i = 0; i< this.list2num; i++) 335 + Promise.all(promiseArray2)
  336 + .then(val =>
308 { 337 {
309 - this.list2state[i] = val[i];  
310 - if(val[i] == null) 338 + var alldone = true;
  339 + for(var i = 0; i< this.list2num; i++)
311 { 340 {
312 - alldone = false; 341 + this.list2state[i] = val[i];
  342 + if(val[i] == null)
  343 + {
  344 + alldone = false;
  345 + }
  346 + else
  347 + {
  348 + var svdata = val[i].toString().split(":");
  349 + this.list2state[i] = svdata[1] + "問中" + svdata[0] + "問正解!";
  350 + this.positiveCnt2 = +svdata[0];
  351 + }
313 } 352 }
314 - }  
315 353
316 - if(alldone)  
317 - {  
318 - this.openkeyword2 = true;  
319 - this.list3dsp = true;  
320 - }  
321 - }); 354 + if(alldone)
  355 + {
  356 + this.openkeyword2 = true;
  357 + this.list3dsp = true;
  358 + }
  359 + });
322 360
323 break; 361 break;
324 case 3: 362 case 3:
325 - var promiseArray3 = new Array();  
326 - for (var i = 0; i < this.list3num; i++) {  
327 - var key: string;  
328 - key = this.menuId + ":" + this.list3[i].unitId;  
329 - promiseArray3.push(this.dataSevice.getInfo(key));  
330 - } 363 + var promiseArray3 = new Array();
  364 + for (var i = 0; i < this.list3num; i++) {
  365 + var key: string;
  366 + key = this.menuId + ":" + this.list3[i].unitId;
  367 + promiseArray3.push(this.dataSevice.getInfo(key));
  368 + }
331 369
332 - Promise.all(promiseArray3)  
333 - .then(val =>  
334 - {  
335 - var alldone = true;  
336 - for(var i = 0; i< this.list3num; i++) 370 + Promise.all(promiseArray3)
  371 + .then(val =>
337 { 372 {
338 - this.list3state[i] = val[i];  
339 - if(val[i] == null) 373 + var alldone = true;
  374 + for(var i = 0; i< this.list3num; i++)
340 { 375 {
341 - alldone = false; 376 + this.list3state[i] = val[i];
  377 + if(val[i] == null)
  378 + {
  379 + alldone = false;
  380 + }
  381 + else
  382 + {
  383 + var svdata = val[i].toString().split(":");
  384 + this.list3state[i] = svdata[1] + "問中" + svdata[0] + "問正解!";
  385 + this.positiveCnt3 = +svdata[0];
  386 + }
342 } 387 }
343 - }  
344 388
345 - if(alldone)  
346 - {  
347 - this.openkeyword3 = true;  
348 - this.list4dsp = true;  
349 - }  
350 - }); 389 + if(alldone)
  390 + {
  391 + this.openkeyword3 = true;
  392 + this.list4dsp = true;
  393 + }
  394 + });
351 395
352 - break; 396 + break;
353 case 4: 397 case 4:
354 - var promiseArray4 = new Array();  
355 - for (var i = 0; i < this.list4num; i++) {  
356 - var key: string;  
357 - key = this.menuId + ":" + this.list4[i].unitId;  
358 - promiseArray4.push(this.dataSevice.getInfo(key));  
359 - } 398 + var promiseArray4 = new Array();
  399 + for (var i = 0; i < this.list4num; i++) {
  400 + var key: string;
  401 + key = this.menuId + ":" + this.list4[i].unitId;
  402 + promiseArray4.push(this.dataSevice.getInfo(key));
  403 + }
360 404
361 - Promise.all(promiseArray4)  
362 - .then(val =>  
363 - {  
364 - var alldone = true;  
365 - for(var i = 0; i< this.list4num; i++) 405 + Promise.all(promiseArray4)
  406 + .then(val =>
366 { 407 {
367 - this.list4state[i] = val[i];  
368 - if(val[i] == null) 408 + var alldone = true;
  409 + for(var i = 0; i< this.list4num; i++)
369 { 410 {
370 - alldone = false; 411 + this.list4state[i] = val[i];
  412 + if(val[i] == null)
  413 + {
  414 + alldone = false;
  415 + }
  416 + else
  417 + {
  418 + var svdata = val[i].toString().split(":");
  419 + this.list4state[i] = svdata[1] + "問中" + svdata[0] + "問正解!";
  420 + this.positiveCnt4 = +svdata[0];
  421 + }
371 } 422 }
372 - }  
373 423
374 - if(alldone)  
375 - {  
376 - this.openkeyword4 = true;  
377 - this.list5dsp = true;  
378 - }  
379 - });  
380 - break; 424 + if(alldone)
  425 + {
  426 + this.openkeyword4 = true;
  427 + this.list5dsp = true;
  428 + }
  429 + });
  430 + break;
381 case 5: 431 case 5:
382 432
383 - var promiseArray5 = new Array();  
384 - for (var i = 0; i < this.list5num; i++) {  
385 - var key: string;  
386 - key = this.menuId + ":" + this.list5[i].unitId;  
387 - promiseArray5.push(this.dataSevice.getInfo(key));  
388 - } 433 + var promiseArray5 = new Array();
  434 + for (var i = 0; i < this.list5num; i++) {
  435 + var key: string;
  436 + key = this.menuId + ":" + this.list5[i].unitId;
  437 + promiseArray5.push(this.dataSevice.getInfo(key));
  438 + }
389 439
390 - Promise.all(promiseArray5)  
391 - .then(val =>  
392 - {  
393 - var alldone = true;  
394 - for(var i = 0; i< this.list5num; i++) 440 + Promise.all(promiseArray5)
  441 + .then(val =>
395 { 442 {
396 - this.list5state[i] = val[i];  
397 - if(val[i] == null) 443 + var alldone = true;
  444 + for(var i = 0; i< this.list5num; i++)
398 { 445 {
399 - alldone = false; 446 + this.list5state[i] = val[i];
  447 + if(val[i] == null)
  448 + {
  449 + alldone = false;
  450 + }
  451 + else
  452 + {
  453 + var svdata = val[i].toString().split(":");
  454 + this.list5state[i] = svdata[1] + "問中" + svdata[0] + "問正解!";
  455 + this.positiveCnt5 = +svdata[0];
  456 + }
400 } 457 }
401 - }  
402 458
403 - if(alldone)  
404 - {  
405 - this.openkeyword5 = true;  
406 - this.list6dsp = true;  
407 - }  
408 - });  
409 - break; 459 + if(alldone)
  460 + {
  461 + this.openkeyword5 = true;
  462 + this.list6dsp = true;
  463 + }
  464 + });
  465 + break;
410 case 6: 466 case 6:
411 var promiseArray6 = new Array(); 467 var promiseArray6 = new Array();
412 for (var i = 0; i < this.list6num; i++) { 468 for (var i = 0; i < this.list6num; i++) {
@@ -426,6 +482,12 @@ export class UnitPage { @@ -426,6 +482,12 @@ export class UnitPage {
426 { 482 {
427 alldone = false; 483 alldone = false;
428 } 484 }
  485 + else
  486 + {
  487 + var svdata = val[i].toString().split(":");
  488 + this.list6state[i] = svdata[1] + "問中" + svdata[0] + "問正解!";
  489 + this.positiveCnt6 = +svdata[0];
  490 + }
429 } 491 }
430 492
431 if(alldone) 493 if(alldone)
@@ -454,6 +516,12 @@ export class UnitPage { @@ -454,6 +516,12 @@ export class UnitPage {
454 { 516 {
455 alldone = false; 517 alldone = false;
456 } 518 }
  519 + else
  520 + {
  521 + var svdata = val[i].toString().split(":");
  522 + this.list7state[i] = svdata[1] + "問中" + svdata[0] + "問正解!";
  523 + this.positiveCnt7 = +svdata[0];
  524 + }
457 } 525 }
458 526
459 if(alldone) 527 if(alldone)
@@ -100,6 +100,15 @@ export class DataService { @@ -100,6 +100,15 @@ export class DataService {
100 return subjectList; 100 return subjectList;
101 } 101 }
102 102
  103 + public getQaCnt(menuId:number): number {
  104 + var num = 0;
  105 + for (var i = 0; i < this.subject.length; i++) {
  106 + if (this.subject[i].menuId === menuId) {
  107 + num++;
  108 + }
  109 + }
  110 + return num;
  111 + }
103 112
104 public getQa(menuId: number, unitId: number): Qa[] { 113 public getQa(menuId: number, unitId: number): Qa[] {
105 var qaItem: Qa[] = new Array(); 114 var qaItem: Qa[] = new Array();
@@ -131,7 +140,7 @@ export class DataService { @@ -131,7 +140,7 @@ export class DataService {
131 return key; 140 return key;
132 } 141 }
133 142
134 - public saveInfo(key: string) { 143 + public saveDone(key: string) {
135 this.st.get(key).then(val => { 144 this.st.get(key).then(val => {
136 if (val == "done") { 145 if (val == "done") {
137 } else { 146 } else {
@@ -140,6 +149,27 @@ export class DataService { @@ -140,6 +149,27 @@ export class DataService {
140 }); 149 });
141 } 150 }
142 151
  152 + public saveInfo(key: string, value: string) {
  153 + this.st.get(key).then(val => {
  154 + if (val == null) {
  155 + this.st.set(key, value);
  156 + } else {
  157 + var svdata = val.toString().split(":");
  158 + var nwdata = value.split(":");
  159 + if(+svdata[0] < +nwdata[0])
  160 + {
  161 + this.st.set(key, value);
  162 + }
  163 + }
  164 + });
  165 + }
  166 +
  167 + public savePositiveInfo(key: string, value: string) {
  168 + this.st.get(key).then(val => {
  169 + this.st.set(key, value);
  170 + });
  171 + }
  172 +
143 public getInfo(key: string): any { 173 public getInfo(key: string): any {
144 return this.st.get(key); 174 return this.st.get(key);
145 } 175 }
  1 +export interface  ChartData {
  2 + data: number[];
  3 + label: string;
  4 + backgroundColor: string[];
  5 + borderColor: string[];
  6 + borderWidth: number;
  7 +}
Please register or login to post a comment