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

Commit

Permalink
#50 Make goi quiz works
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidborredom committed May 24, 2018
1 parent 6789d3d commit b80b46d
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 33 deletions.
60 changes: 59 additions & 1 deletion app/config/quiz.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,60 @@

let topic_title_vocab_kanji = [
{
"id":"tp1_1",
"type":"vocabulary",
"romaji":"otoosan",
"moji":"おとおさん",
"kanji":"お父さん",
"english":"Father",
"audio":"ka.mp3"
},
{
"id":"tp1_2",
"type":"vocabulary",
"romaji":"okaasan",
"moji":"おかあさん",
"kanji":"お母さん",
"english":"Mother",
"audio":"ki.mp3"
},
{
"id":"tp1_3",
"type":"vocabulary",
"romaji":"oneesan",
"moji":"おねえさん",
"kanji":"お姉さん",
"english":"Sister",
"audio":"ku.mp3"
},
{
"id":"tp1_4",
"type":"vocabulary",
"romaji":"oniisan",
"moji":"おにいさん",
"kanji":"お兄さん",
"english":"Brother",
"audio":"ke.mp3"
},
{
"id":"tp1_5",
"type":"vocabulary",
"romaji":"imouto",
"moji":"いもうと",
"kanji":"妹",
"english":"Little Sister",
"audio":"ko.mp3"
},
{
"id":"tp1_6",
"type":"vocabulary",
"romaji":"otouto",
"moji":"おとうと",
"kanji":"弟",
"english":"Little Brother",
"audio":"ko.mp3"
}
];

export const quizItems = {
"HIRAGANA_TITLE": [
Expand Down Expand Up @@ -1788,5 +1844,7 @@ export const quizItems = {
"english":"six",
"audio":"ko.mp3"
}
]
],
"TOPIC1_TITLE_and_vocabulary": topic_title_vocab_kanji
};

71 changes: 39 additions & 32 deletions app/screens/Quiz/quizFlash.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ import {
this.title = '';
this.oneType = '';
this.study = [];
this.initialParams = [];
this.initialParams = [];
this.isMounted = true;

this.state = {
timesUp: false,
Expand Down Expand Up @@ -151,6 +152,7 @@ import {
componentWillMount() {
const { navigation } = this.props;
this.oneType = navigation.getParam('oneType',null);
this.mounted = true;
idList = navigation.getParam('idList', null);
let shuffledQuiz = [];

Expand All @@ -162,13 +164,13 @@ import {
headerTitle: navigation.getParam('headerTitle',null),
index: navigation.getParam('index', null)
}

console.log(this.initialParams);
this.setState(this.initialParams);

this.setInitial();

this.quizItems = quizItems[this.initialParams.title];

this.quizItems = quizItems[this.initialParams.studyType];
console.log(this.quizItems);
this.setDefinedQuestion(idList);

if(!this.quizItems){
Expand Down Expand Up @@ -200,6 +202,10 @@ import {

}

componentWillUnmount(){
this.mounted = false;
}

// set items
setInitial(){
this.study = StudyList.find(function (obj) {
Expand Down Expand Up @@ -342,35 +348,36 @@ import {
}

setNextQuestion() {
const counter = this.state.counter + 1;

this.setTakeQuiz();

if(counter < this.allQuestion.length){
this.randomQuizFormat();
const counter = this.state.counter + 1;
if(this.mounted){
this.setTakeQuiz();
if(counter < this.allQuestion.length){
this.randomQuizFormat();

this.timeStops = 0;

this.setState({
counter: counter,
//questionId: questionId,
question: this.allQuestion[counter],
answerOptions: this.allQuestion[counter].answerOption,
answer: '',
timerRun:true,
timerRestart:true,
timesUp: false,
expression:'default',
correct: 0
});
}
else{
this.setEndQuiz();
this.props.navigation.navigate('ScoreScreen',{
index : this.state.index,
typeQuiz : this.state.type,
studyTitle : this.title
});
this.timeStops = 0;

this.setState({
counter: counter,
//questionId: questionId,
question: this.allQuestion[counter],
answerOptions: this.allQuestion[counter].answerOption,
answer: '',
timerRun:true,
timerRestart:true,
timesUp: false,
expression:'default',
correct: 0
});
}
else{
this.setEndQuiz();
this.props.navigation.navigate('ScoreScreen',{
index : this.state.index,
typeQuiz : this.state.type,
studyTitle : this.title
});
}
}

}
Expand Down

0 comments on commit b80b46d

Please sign in to comment.