diff --git a/app/component/timer.js b/app/component/timer.js index 6c8e7b0..f470c0a 100644 --- a/app/component/timer.js +++ b/app/component/timer.js @@ -123,9 +123,7 @@ class TimerBar extends Component { } this.props.timeStops(this.seconds - this.state.progress); - this.progress.setValue(0); - console.log(this.props); - console.log(this.progress); + this.progress.setValue(0); } } @@ -156,10 +154,8 @@ class TimerBar extends Component { if(this.props.timerRestart){ if(!this.props.isTopicTest){ - this.progress.setValue(0); - console.log(11111); - } - console.log(22222); + this.progress.setValue(0); + } this.timerStart(); } diff --git a/app/config/quiz/topic6.js b/app/config/quiz/topic6.js index 1c2d311..58ebb2a 100644 --- a/app/config/quiz/topic6.js +++ b/app/config/quiz/topic6.js @@ -186,7 +186,7 @@ export const vocabulary = [ { "id":"tp6_v_24", "type":"vocabulary", - "moji":"おば", + "moji":"おばさん", "romaji":"oba", "english":"Aunt", "audio":"t6_oba.mp3" diff --git a/app/lib/constants.js b/app/lib/constants.js index c8fe321..00a46aa 100644 --- a/app/lib/constants.js +++ b/app/lib/constants.js @@ -11,6 +11,7 @@ export const LEARN_FAILED = 'LEARN_FAILED'; //import the action for start time export const START_TIME_QUIZ = 'START_TIME_QUIZ'; //import the action for start time export const END_TIME_QUIZ = 'END_TIME_QUIZ'; //import the action for start time export const TAKE_QUIZ = 'TAKE_QUIZ'; //import the action for start time +export const MISTAKES = 'MISTAKES'; //import the action for start time //action for user export const USER_LOGIN_SUCCESS = "USER_LOGIN_SUCCESS"; diff --git a/app/reducers/study.js b/app/reducers/study.js index e4c96ba..26e8373 100644 --- a/app/reducers/study.js +++ b/app/reducers/study.js @@ -1,4 +1,4 @@ -import {START_TIME_LEARN ,END_TIME_LEARN , LEARN_FAILED , TAKE_QUIZ} from '../lib/constants'; +import {START_TIME_LEARN ,END_TIME_LEARN , LEARN_FAILED , TAKE_QUIZ, MISTAKES} from '../lib/constants'; const initialState = { startTime:'', @@ -9,7 +9,8 @@ const initialState = { err: '', isErr: false, fukushu: true, - quizSize: 0 + quizSize: 0, + fukushuMistakes:[] }; export default function userReducer (state = initialState, action) { @@ -43,6 +44,11 @@ export default function userReducer (state = initialState, action) { case TAKE_QUIZ: state = Object.assign({}, state, { studyRecord: [].concat(state.studyRecord, [action.studyRecord]) + }); + case MISTAKES: + console.log(action); + state = Object.assign({}, state, { + fukushuMistakes: [].concat(state.fukushuMistakes, [action.mistakes]) }); return state; default: diff --git a/app/screens/Quiz/quizFlash.js b/app/screens/Quiz/quizFlash.js index 2505018..1d8d608 100644 --- a/app/screens/Quiz/quizFlash.js +++ b/app/screens/Quiz/quizFlash.js @@ -35,7 +35,7 @@ import { class QuizFlashScreen extends Component { static navigationOptions = ({ navigation }) => { - subtitle = navigation.getParam('type', null); + subtitle = navigation.getParam('formatType', null); title = navigation.getParam('title', null); confirm = true; @@ -75,8 +75,7 @@ import { this.quizOptions = []; this.byCategory = []; this.reduxParam = []; - this.title = ''; - this.oneType = ''; + this.title = ''; this.study = []; this.initialParams = []; this.isMounted = true; @@ -109,14 +108,21 @@ import { showCorrect:false } + // this.testItemCount = { + // vocabulary: 10, + // kanji: 10, + // grammar: 15, + // reading: 3, + // listening: 3 + // } + this.testItemCount = { - vocabulary: 10, - kanji: 10, - grammar: 15, - reading: 3, - listening: 3 + vocabulary: 1, + kanji: 1, + grammar: 1, + reading: 1, + listening: 1 } - this.state = this.initialState; } @@ -208,29 +214,30 @@ import { const { navigation } = this.props; BackHandler.addEventListener('hardwareBackPress', this.handleBackButton); - - this.oneType = navigation.getParam('oneType',null); + this.mounted = true; - idList = navigation.getParam('idList', null); + let shuffledQuiz = []; this.initialParams = { title: navigation.getParam('title', null), img: navigation.getParam('img', null), - type: navigation.getParam('type', null), + formatType: navigation.getParam('formatType', null), studyType: navigation.getParam('studyType',null), headerTitle: navigation.getParam('headerTitle',null), index: navigation.getParam('index', null), - isTopicTest: navigation.getParam('isTopicTest', null) + isTopicTest: navigation.getParam('isTopicTest', null), + idList: navigation.getParam('idList', null), + oneType: navigation.getParam('oneType',null) } - //console.log(this.initialParams); + console.log(this.initialParams,'weee'); this.setState(this.initialParams); this.setInitial(); this.setListQuestion(); //console.log(this.quizItems); - this.setDefinedQuestion(idList); + this.setDefinedQuestion(this.initialParams.idList); //console.log(this.quizItems,this.testItemCount); if(!this.quizItems){ const resetAction = NavigationActions.reset({ @@ -248,7 +255,7 @@ import { this.allQuestion = shuffledQuiz.map((question) => this.shuffleAnswers(question, shuffledQuiz) ); - console.log(this.allQuestion); + //console.log(this.allQuestion); this.currentQuestion = this.allQuestion[0]; this.setState({ @@ -292,14 +299,14 @@ import { this.study = StudyList.find(function (obj) { return obj.title == this.title; }) - console.log(this.study); + //console.log(this.study); if(this.study.type == 'INITIAL'){ this.quizOptions = this.study.quizOptions; } else{ - console.log(this.study,this.initialParams.headerTitle); + //console.log(this.study,this.initialParams.headerTitle); this.quizOptions = this.study[this.initialParams.headerTitle]; - console.log(this.quizOptions); + //console.log(this.quizOptions); } } @@ -400,7 +407,7 @@ import { // randomized question shuffleItems(array) { var currentIndex = array.length, temporaryValue, randomIndex, output = []; - var limit = this.initialParams.type == 'Test' ? 50 : 25; + var limit = this.initialParams.formatType == 'Test' ? 50 : 25; while (0 !== currentIndex) { randomIndex = Math.floor(Math.random() * currentIndex); @@ -424,7 +431,7 @@ import { this.quizOptions = this.study[questionType]; } - quizFormat = this.oneType ? [this.oneType] : this.quizOptions.types; + quizFormat = this.initialParams.oneType ? [this.initialParams.oneType] : this.quizOptions.types; quizFormatLength = quizFormat.length; randomIndex = Math.floor(Math.random() * quizFormatLength); time = this.time; @@ -689,7 +696,7 @@ import { categoryId : StudyList[index].topic_id + categoryId, studyId : StudyList[index].topic_id + categoryId } - + console.log(value); return value; } diff --git a/app/screens/Study/hiraganaList.js b/app/screens/Study/hiraganaList.js index e129ff9..5e95e2e 100644 --- a/app/screens/Study/hiraganaList.js +++ b/app/screens/Study/hiraganaList.js @@ -80,7 +80,7 @@ class HiraganaListScreen extends Component { param = { index : this.state.index, - type : type, + formatType : type, title : this.state.title, studyType: this.state.studyType, categoryId : this.state.categoryId, diff --git a/app/screens/Study/score.js b/app/screens/Study/score.js index 19a01fc..ffbc1b9 100644 --- a/app/screens/Study/score.js +++ b/app/screens/Study/score.js @@ -47,13 +47,20 @@ import { index: navigation.getParam('index', null), headerTitle: navigation.getParam('headerTitle', null), studyType: navigation.getParam('studyType', null), + isTopicTest: navigation.getParam('isTopicTest', null), + formatType: navigation.getParam('formatType', null), + idList: navigation.getParam('idList', null), + oneType: navigation.getParam('oneType',null) } this.item = StudyList[initialParams.index]; this.item['index'] = initialParams.index; this.item['studyType'] = initialParams.studyType; - //this.item['headerTitle'] = this.item.title; + this.item['isTopicTest'] = initialParams.isTopicTest; this.item['headerTitle'] = initialParams.headerTitle; + this.item['formatType'] = initialParams.formatType; + this.item['idList'] = initialParams.idList; + this.item['oneType'] = initialParams.oneType; console.log(this.item); } goToTopicSelection = () => { @@ -68,7 +75,13 @@ import { this.props.navigation.dispatch(resetAction); }else{ - this.retry(); + var nav = this.setNavStudyList(this.state.type, 1); + + const resetAction = NavigationActions.reset(nav); + + this.props.navigation.dispatch(resetAction); + + } } componentWillUnmount(){ @@ -89,6 +102,32 @@ import { setNav(type, index) { let nav; + if(this.item.headerTitle == 'topic_test'){ + nav = { + index: index, + actions: [ + NavigationActions.navigate({ routeName: 'StudyList' }), + NavigationActions.navigate({ routeName: 'QuizFlash' , params: this.item }) + ] + }; + } + else{ + console.log(this.item); + nav = { + index: index, + actions: [ + NavigationActions.navigate({ routeName: 'StudyList' }), + NavigationActions.navigate({ routeName: 'QuizFlash' , params: this.item }) + ] + }; + } + + return nav; + } + + setNavStudyList(type, index) { + let nav; + if(this.item.headerTitle == 'topic_test'){ nav = { index: index, @@ -255,8 +294,8 @@ const study = require('../../styles/study'); // This function makes Redux know that this component needs to be passed a piece of the state function mapStateToProps(state, props) { - const score = Helper.countScore(state.study.studyRecord,state.study.quizSize); - + //const score = Helper.countScore(state.study.studyRecord,state.study.quizSize); + const score = 100; return { StudentID: state.user.user.id, studyRecord: state.study.studyRecord, diff --git a/app/screens/Study/studyList.js b/app/screens/Study/studyList.js index 13d6f5c..bbb23f2 100644 --- a/app/screens/Study/studyList.js +++ b/app/screens/Study/studyList.js @@ -35,7 +35,7 @@ class StudyListScreen extends Component { setModalVisible(visible) { this.setState({modalVisible: visible}); } - lockedMessage=(item, index)=>{ + lockedMessage=(item, index)=>{ alert(strings[item.topic_id + '_MSG'] ); } @@ -44,7 +44,8 @@ class StudyListScreen extends Component { item['studyType'] = item.title; item['headerTitle'] = item.title; item['categoryId'] = 'C001'; - + //console.log(item); + this.getMistakes(item.topic_id); if(item.type == 'INITIAL'){ item['studyType'] = item.title; this.props.navigation.navigate('HiraganaList',( @@ -75,6 +76,8 @@ class StudyListScreen extends Component { } checkLock = (topic_id) =>{ + + if(this.props.lock){ if(this.props.lock[topic_id]){ if(this.props.lock[topic_id].lock){ @@ -89,6 +92,21 @@ class StudyListScreen extends Component { return true; } } + + getMistakesData(topic_id){ + //return Promise.all([this.props.getMistakes('T008')]) + } + + getMistakes = async() => { + //json = await this.props.getMistakes('T008'); + //console.log(json); + // this.getMistakegetMistakessData() + // .then(([data]) => { + // // both have loaded! + // console.log(data); + // }) + } + render() { var image = ''; this._onSetLanguageTo(this.props.lang); @@ -141,10 +159,22 @@ const study = require('../../styles/study'); // and insert/links it into the props of our component. // This function makes Redux know that this component needs to be passed a piece of the state function mapStateToProps(state, props) { + console.log(state); + + state.summary.lock['T004'] = { + lock:false, + matomeLeft:1 + }; + + state.summary.lock['T005'] = { + lock:false, + matomeLeft:1 +}; + return { fukushu: state.study.fukushu, lang : state.user.lang, - lock : state.summary.lock + lock : state.summary.lock } }