diff --git a/app/actions/study.js b/app/actions/study.js index b585d67..0600e62 100644 --- a/app/actions/study.js +++ b/app/actions/study.js @@ -59,8 +59,7 @@ export function startLearnDispatch(studyType, startLearn, studyID, quizSize) { } } -export function endLearnDispatch(studyType, json) { - console.log(studyType,'dadasd'); +export function endLearnDispatch(studyType, json) { return { type: END_TIME_LEARN, endTime: studyType.endTime diff --git a/app/component/question.js b/app/component/question.js index 54a606e..afe694a 100644 --- a/app/component/question.js +++ b/app/component/question.js @@ -25,41 +25,31 @@ class QuestionPanel extends Component { constructor(props) { super(props); - this.currentAudio = this.props.question.id; + this.currentAudio = ''; this.currentQuestion = ''; this.imageSource = this.props.img ? ( ImageData[this.props.img] ) : ImageData.default_bg; } - componentWillMount() { + componentDidMount() { this.currentQuestion = this.props.question.id; - if(this.props.format == 'audio'){ - this.loadAudio(); - setTimeout(() => { - this.playAudio(true) - }, 500); + if(this.props.format == 'audio'){ + this.loadAudio(); } } componentDidUpdate(){ if(this.currentQuestion != this.props.question.id){ - - this.stopAudio(); - + this.stopAudio(); this.currentQuestion = this.props.question.id; if(this.props.format == 'audio'){ this.loadAudio(); - this.props.questionReady(true); - + this.props.questionReady(true); } else{ this.props.questionReady(true); } } - - if(this.quizAudio){ - this.quizAudio.stop(); - } } @@ -78,6 +68,7 @@ class QuestionPanel extends Component { if(this.props.timesUp){ return( + { strings.TIMES_UP } ); @@ -91,7 +82,7 @@ class QuestionPanel extends Component { if(this.props.format == 'audio'){ return( - this.playAudio(true) }> + this.loadAudio(true) }> @@ -170,12 +161,14 @@ class QuestionPanel extends Component { ); } - loadAudio(){ + loadAudio(forcePlay = false){ + this.stopAudio(); + this.quizAudio = new Sound(this.props.question.audio, Sound.MAIN_BUNDLE, (error) => { if (error) { return; } - this.playAudio(); + this.playAudio(forcePlay); }); } @@ -183,15 +176,14 @@ class QuestionPanel extends Component { playAudio(forcePlay = false){ playDifferentAudio = this.currentAudio != this.props.question.id && this.props.format == 'audio'; - + if(playDifferentAudio || forcePlay){ - + this.currentAudio = this.props.question.id; this.quizAudio.stop(() => { this.quizAudio.play((success) => { - if (!success) { - //this.quizAudio.reset(); - } + + // this.quizAudio.release(); }); }); diff --git a/app/component/timer.js b/app/component/timer.js index f470c0a..5ad9abf 100644 --- a/app/component/timer.js +++ b/app/component/timer.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Text, View, Animated, Dimensions} from 'react-native'; +import { Text, View, Animated, Dimensions, Easing} from 'react-native'; import PropTypes from 'prop-types'; var { width } = Dimensions.get('window'); @@ -23,6 +23,7 @@ class TimerBar extends Component { this.state = { progress: 0, + duration: this.props.time, start: true }; @@ -78,11 +79,13 @@ class TimerBar extends Component { componentDidMount() { this.progress.addListener((progress) => { + let progressVal = parseFloat(this.seconds - ((progress.value * this.seconds) / 100 )).toFixed(2); this.setState({ - progress: parseFloat(this.seconds - ((progress.value * this.seconds) / 100 )).toFixed(2) + progress: progressVal, + duration:(progressVal * 1000) }); }); - + this.timerStart(); } @@ -93,22 +96,25 @@ class TimerBar extends Component { this.timerResume(); } - componentWillMount() { + componentWillUnmount() { this.progress.removeListener(); } - timerStart(){ - this.duration = this.props.time; - this.seconds = this.duration / 1000; + timerStart(resume = false){ + if(!resume){ + this.duration = this.props.time; + this.seconds = this.duration / 1000; + } + Animated.timing(this.progress, { duration: this.duration, - toValue: 100 - }).start(() => { + toValue: 100, + easing: Easing.linear + }).start(() => { this.timerEnd(); }); - - + this.props.onRestart(false); } @@ -116,7 +122,7 @@ class TimerBar extends Component { if(this.props.timerRun && this.state.progress == 0){ if(!this.props.isTopicTest){ - this.props.onTimesUp(true); + this.props.onTimesUp(true); } else{ this.props.onTestEnd(true); @@ -141,22 +147,24 @@ class TimerBar extends Component { } timerResume(){ - if(this.props.timerResume){ - this.timerStart(); + if(this.props.timerResume){ + this.duration = this.state.duration; + this.timerStart(true); } } timerRestart(){ - // if(this.props.timerRestart && !this.props.isTopicTest){ - // this.progress.setValue(0); - // this.timerStart(); - // } if(this.props.timerRestart){ + if(!this.props.isTopicTest){ - this.progress.setValue(0); - } - this.timerStart(); + this.progress.setValue(0); + this.timerStart(); + } + else{ + this.duration = this.state.duration; + this.timerStart(true); + } } } diff --git a/app/screens/Quiz/quizFlash.js b/app/screens/Quiz/quizFlash.js index 756212d..9965d7d 100644 --- a/app/screens/Quiz/quizFlash.js +++ b/app/screens/Quiz/quizFlash.js @@ -154,7 +154,7 @@ import { { this.state.question && this.state.question.id ? ( - + - + + + Points: { this.setScore() }/100 Questions: { this.state.counter+1 }/{ this.allQuestion.length } + + + { - var endTime = ( new Date().getTime() / 1000); - var quizSizes = 0; + var endTime = ( new Date().getTime() / 1000); var parseValue = this.reduxParam; - - if(this.initialParams.isTopicTest){ - quizSizes = this.allQuestion.length; - } - score = Helper.countScore(this.studyRecord,quizSizes); - //console.log(this.studyRecord,this.allQuestion.length); + parseValue['finishTime'] = endTime; parseValue['questions'] = this.studyRecord; - parseValue['score'] = score; + parseValue['score'] = this.setScore(); this.props.endLearn(parseValue); //call our action }; + setScore(){ + var quizSizes = 0; + + if(this.initialParams.isTopicTest){ + quizSizes = this.allQuestion.length; + } + return Helper.countScore(this.studyRecord,quizSizes); + } + goNextQuestion() { this.setNextQuestion(); @@ -859,9 +866,11 @@ import { if(this.initialParams.formatType == 'Quiz'){ this.setState({ - showCorrect:true, + showCorrect:true, + expression:'sad', + timesUp:true }); - + } else{ this.setState({ @@ -869,8 +878,8 @@ import { expression:'sad' }); - setTimeout(() => { - + + setTimeout(() => { this.setNextQuestion(); }, this.state.pause); } diff --git a/app/screens/Study/hiraganaList.js b/app/screens/Study/hiraganaList.js index 99ec7ac..3a923ca 100644 --- a/app/screens/Study/hiraganaList.js +++ b/app/screens/Study/hiraganaList.js @@ -208,12 +208,12 @@ class HiraganaListScreen extends Component { { strings['STUDY_QUIZ'] } - + { strings['STUDY_REVIEW'] } - { scoreQuiz } + {/* { scoreQuiz } */} diff --git a/app/styles/study.js b/app/styles/study.js index 36dbac1..593591c 100644 --- a/app/styles/study.js +++ b/app/styles/study.js @@ -125,6 +125,13 @@ module.exports = StyleSheet.create({ marginRight: 10, }, + mB10: { + marginBottom: 10, + }, + mB20: { + marginBottom: 20, + }, + textBlack: { color: 'black', }, diff --git a/app/styles/style.js b/app/styles/style.js index 860dd01..e7e270f 100644 --- a/app/styles/style.js +++ b/app/styles/style.js @@ -403,6 +403,18 @@ module.exports = StyleSheet.create({ position:'absolute' }, // Question Panel + quizInfo:{ + //position:"absolute", + right:0, + top:0, + zIndex:10, + padding:5, + backgroundColor:"rgba(255,255,255,0.8)" + }, + quizInfoText:{ + fontSize:16, + textAlign:"right" + }, questionWrapper: { padding:10, flex: 1, @@ -522,7 +534,9 @@ module.exports = StyleSheet.create({ timesUpText:{ color:'#fff', flexDirection:'column', - fontSize:36 + fontSize:36, + marginLeft:5, + marginRight:5 }, quizBtnContainer:{ position:'relative' @@ -628,13 +642,13 @@ module.exports = StyleSheet.create({ color:textSecondary }, blocker:{ - position:'absolute', + position:'absolute', width:'100%', height:'100%', left:0, top:0, elevation:10, - zIndex:10 + zIndex:99 }, absoluteScreen : { position: 'absolute',