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

Commit

Permalink
#50 fix topic test
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidborredom committed Jun 2, 2018
1 parent 8ff16d8 commit eb95cf4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 23 deletions.
57 changes: 42 additions & 15 deletions app/screens/Quiz/quizFlash.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {

this.optionsNumber = 4;
this.allQuestion = [];
this.currentQuestion = [];
this.quizItems = [];
this.timeStops = 0;
this.studyRecord = [];
Expand Down Expand Up @@ -205,14 +206,15 @@ import {
type: navigation.getParam('type', null),
studyType: navigation.getParam('studyType',null),
headerTitle: navigation.getParam('headerTitle',null),
index: navigation.getParam('index', null)
index: navigation.getParam('index', null),
isTopicTest: navigation.getParam('isTopicTest', null)
}

this.setState(this.initialParams);

this.setInitial();

this.quizItems = quizItems[this.initialParams.studyType];
this.setListQuestion()

this.setDefinedQuestion(idList);

Expand All @@ -227,18 +229,21 @@ import {
this.props.navigation.dispatch(resetAction);
}
else{
console.log(this.quizItems);
shuffledQuiz = this.shuffleItems(this.quizItems);

this.randomQuizFormat();


this.allQuestion = shuffledQuiz.map((question) =>
this.shuffleAnswers(question, shuffledQuiz)
);

this.currentQuestion = this.allQuestion[0];

this.setState({
question: this.allQuestion[0]
question: this.currentQuestion
});

this.randomQuizFormat();

this.setStartQuiz();
}
}
Expand Down Expand Up @@ -279,6 +284,23 @@ import {

}

setListQuestion(){
if(this.initialParams.isTopicTest){
topics = ['vocabulary', 'grammar', 'kanji'];
for(i = 0; i < topics.length; i++){

tempQuiz = quizItems[this.initialParams.studyType + '_and_' + topics[i]];

for(a = 0; a < tempQuiz.length; a++){
this.quizItems.push(tempQuiz[a]);
}
}
}
else{
this.quizItems = quizItems[this.initialParams.studyType];
}
}

// will change all question based on what you put in 'idList'
setDefinedQuestion(idList){
if(idList && idList.length){
Expand Down Expand Up @@ -340,12 +362,16 @@ import {
return array;
};

randomQuizFormat(){
randomQuizFormat(){
let quizFormat, quizFormatLength, paramFormat, time;

var quizFormat = this.oneType ? [this.oneType] : this.quizOptions.types;
var quizFormatLength = quizFormat.length, randomIndex;
var paramFormat,time;
if(this.initialParams.isTopicTest){
questionType = this.currentQuestion.type;
this.quizOptions = this.study[questionType];
}

quizFormat = this.oneType ? [this.oneType] : this.quizOptions.types;
quizFormatLength = quizFormat.length;
randomIndex = Math.floor(Math.random() * quizFormatLength);


Expand Down Expand Up @@ -489,14 +515,15 @@ import {
if(counter < this.allQuestion.length){
this.showCorrect = false;
this.timeStops = 0;

this.currentQuestion = this.allQuestion[counter];

this.randomQuizFormat();

this.setState({
counter: counter,
//questionId: questionId,
question: this.allQuestion[counter],
answerOptions: this.allQuestion[counter].answerOption,
question: this.currentQuestion,
answerOptions: this.currentQuestion.answerOption,
answer: '',
timerRun:true,
timerRestart:true,
Expand Down
25 changes: 17 additions & 8 deletions app/screens/Study/topiclist.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,28 @@ class TopicListScreen extends Component {
}

navigateToLearn=(type)=>{

param = {
img : this.state.img,
title : this.state.title,
index : this.state.index,
type : this.state.type,
headerTitle : type,
studyType : this.state.title + '_and_' +type,
};

if(type == 'topic_test'){

param.isTopicTest = true;
param.studyType = this.state.title;

this.props.navigation.navigate('QuizFlash',(
param
));
}
else{
this.props.navigation.navigate('HiraganaList',(
{
img : this.state.img,
title : this.state.title,
index : this.state.index,
type : this.state.type,
headerTitle : type,
studyType : this.state.title + '_and_' +type,
}
param
));
}
}
Expand Down

0 comments on commit eb95cf4

Please sign in to comment.