Skip to content
This repository has been archived by the owner on Apr 14, 2020. It is now read-only.

Commit

Permalink
Merge pull request #114 from ZendyLim/feature/#50_goi_quiz
Browse files Browse the repository at this point in the history
Feature/#50 goi quiz
  • Loading branch information
andy1dx authored Jun 22, 2018
2 parents 88e5bcd + fbbd2c3 commit 20a3b09
Show file tree
Hide file tree
Showing 19 changed files with 261 additions and 153 deletions.
28 changes: 1 addition & 27 deletions app/actions/study.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function endLearn(postValue){
body: JSON.stringify(postValue)
}).then(data => data.json())
.then(json => {
console.log(json);
dispatch(endLearnDispatch(postValue, json))
})
.catch(err => dispatch(endLearnFailedDispatch(err)))
Expand All @@ -47,33 +48,6 @@ export function takeQuiz(studyData){
};
}

// export function getMistakes(topicId){
// return (dispatch) => {
// getJWT().then( JWT => {
// fetch('https://e-learning-backend.herokuapp.com/api/v1/mistakes?' + topicId
// ,{
// method: 'GET',
// headers: {
// 'Authorization' : JWT,
// 'Accept': 'application/json',
// 'Content-Type': 'application/json',
// },
// }).then(data => data.json())
// .then(json => {
// if(type == 'QUIZ'){
// dispatch(summaryRecordQuizDispatch(json, type))
// }else{
// dispatch(summaryRecordTestDispatch(json, type))
// }
// })
// .catch(err => dispatch(failedSummary(err)))
// })
// };


// }


// ===================================== ACTION SENDING DATA TO REDUCER =================================================
export function startLearnDispatch(studyType, startLearn, studyID, quizSize) {
return {
Expand Down
33 changes: 18 additions & 15 deletions app/component/correct.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class CorrectPanel extends Component {
}
componentWillMount() {

this.loadAudio();
//this.loadAudio();
}

componentDidUpdate(){

this.loadAudio();
//this.loadAudio();
}


Expand All @@ -51,9 +51,11 @@ class CorrectPanel extends Component {
<Text style={ styles.correctText }>{ this.props.question.english }</Text>
</View>

<TouchableHighlight onPress={() => this.playAudio(true) } style={ styles.correctAudio }>
<Icon name="volume-up" style={ styles.correctVolume }></Icon>
</TouchableHighlight>
{this.props.question.audio != '' &&
(<TouchableHighlight onPress={() => this.loadAudio() } style={ styles.correctAudio }>
<Icon name="volume-up" style={ styles.correctVolume }></Icon>
</TouchableHighlight>)
}
</View>
);

Expand All @@ -74,13 +76,13 @@ class CorrectPanel extends Component {
);
}

loadAudio(){
loadAudio(){
this.quizAudio = new Sound(this.props.question.audio, Sound.MAIN_BUNDLE, (error) => {
if (error) {
console.log('failed to load the sound', error);
return;
}

this.playAudio(true);
});
}

Expand All @@ -89,16 +91,17 @@ class CorrectPanel extends Component {
playDifferentAudio = this.currentAudio != this.props.question.id && this.props.format == 'audio';

if(playDifferentAudio || forcePlay){

this.currentAudio = this.props.question.id;

this.quizAudio.play((success) => {
if (!success) {
this.quizAudio.reset();
}

this.currentAudio = this.props.question.id;
this.quizAudio.stop(() => {
this.quizAudio.play((success) => {
if (!success) {
//this.quizAudio.reset();
}
});
});

}

}

stripSpace(val){
Expand Down
8 changes: 2 additions & 6 deletions app/component/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,8 @@ class QuestionPanel extends Component {
if (error) {
return;
}
this.playAudio()
this.playAudio();


});
}

Expand All @@ -195,11 +194,8 @@ class QuestionPanel extends Component {
}
});
});



}


}

}
Expand Down
Loading

0 comments on commit 20a3b09

Please sign in to comment.