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

Commit

Permalink
#50 added fukushu and studytype
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidborredom committed Jun 20, 2018
1 parent d6d6c7c commit 4f32f6c
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 20 deletions.
Binary file modified app/assets/img/topic/image_loading.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions app/config/quizFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,46 @@ export const pointsList = {
'grammar': 2,
'reading': 5,
'listening': 5
};
//types:['romaji_moji', 'moji_romaji','audio_moji','audio_romaji'],
//types:['english_moji','audio_english','audio_moji'],
// types:['english_moji','english_fill','audio_english','audio_fill'],
//types:['english_moji','audio_english','fill','arrange'],
//types:['kanji_moji','kanji_fill','kanji_english','audio_kanji','moji_kanji'],
export const studyType = {
hiragana:{
romaji_moji:'HQ1',
moji_romaji:'HQ2',
audio_moji:'HQ3',
},
initial:{
english_moji:'IQ1',
audio_english:'IQ2',
audio_moji:'IQ3'
},
vocabulary:{
english_moji:'GQ1',
english_fill:'GQ2',
audio_english:'GQ3',
audio_fill:'GQ4'
},
grammar:{
english_moji:'BQ1',
audio_english:'BQ2',
fill:'BQ3',
arrange:'BQ4',
},
kanji:{
kanji_moji:'KQ1',
kanji_fill:'KQ2',
kanji_english:'KQ3',
audio_kanji:'KQ4',
moji_kanji:'KQ5',
},
listening:{
audio_moji:'LQ1',
},
reading:{
moji:'RQ1',
}
};
9 changes: 6 additions & 3 deletions app/config/studyList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export const StudyList = [{
topic_id: 'T001',
quizOptions: {
random: false,
types:['romaji_moji', 'moji_romaji','audio_moji','audio_romaji'],
//types:['romaji_moji', 'moji_romaji','audio_moji','audio_romaji'],
types:['romaji_moji', 'moji_romaji','audio_moji'],
style:'quizSquared'
}
},
Expand All @@ -19,7 +20,8 @@ export const StudyList = [{
quizOptions: {
random: true,
//types:['audio_english', 'audio_moji'],
types:['moji_english', 'english_moji','audio_english','audio_moji'],
//types:['moji_english', 'english_moji','audio_english','audio_moji'],
types:['english_moji','audio_english','audio_moji'],
withCorrection:true,
style:'quizLong'
}
Expand All @@ -33,7 +35,8 @@ export const StudyList = [{
quizOptions: {
random: true,
//types:['audio_english', 'audio_moji'],
types:['moji_english', 'english_moji','audio_english','audio_moji'],
//types:['moji_english', 'english_moji','audio_english','audio_moji'],
types:['english_moji','audio_english','audio_moji'],
withCorrection:true,
style:'quizVocab'
}
Expand Down
134 changes: 120 additions & 14 deletions app/screens/Quiz/quizFlash.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {

import { quizItems } from '../../config/quiz/index';
import { StudyList } from '../../config/studyList';
import { studyType } from '../../config/quizFormat';

/*
TODO:
Expand Down Expand Up @@ -116,6 +117,12 @@ import {
listening: 3
}

this.shortType = {
'v' : 'vocabulary',
'g' : 'grammar',
'k' : 'kanji'
}

// this.testItemCount = {
// vocabulary: 1,
// kanji: 1,
Expand All @@ -124,6 +131,12 @@ import {
// listening: 1
// }

this.fukushuItemCount = {
vocabulary: 2,
kanji: 2,
grammar: 2
}

this.state = this.initialState;

}
Expand Down Expand Up @@ -234,8 +247,22 @@ import {

this.setInitial();

this.setListQuestion();
this.setDefinedQuestion(this.initialParams.idList);

if(this.initialParams.idList && this.initialParams.idList.length){
if(this.initialParams.formatType == 'FUKUSHU'){
this.setDefineFukushu(this.initialParams.idList);
//this.setListQuestion();
}
else{
this.setListQuestion();
this.setDefinedQuestion(this.initialParams.idList);
}
}
else{
this.setListQuestion();
}


if(!this.quizItems){
const resetAction = NavigationActions.reset({
index: 0,
Expand Down Expand Up @@ -335,7 +362,7 @@ import {

// will change all question based on what you put in 'idList'
setDefinedQuestion(idList){
if(idList && idList.length){
//if(idList && idList.length){
var quizItemsTemp = [];

for(i = 0; i < idList.length; i++){
Expand All @@ -344,9 +371,73 @@ import {
return obj.id == currentId;
});
}

this.quizItems = quizItemsTemp;
//}
}

setDefineFukushu(idList){
//will get the first

//(?![a-z]+\d+_)([a-z])(?=_) <-- will get the middle string of an id
console.log();


var quizItemsTemp = [];
var existingId = [];
var existingByCat = [];

for(i = 0; i < idList.length; i++){
currentId = idList[i];
id = currentId.match(/(\d+)(?=_+[a-z])/);
type = currentId.match(/(?=_)*([a-z])(?=_)/);
if(id != null && type != null && this.shortType[type[0]]){
id = id[0];
type = type[0];
typeName = this.shortType[type];
tempQuiz = quizItems[ 'TOPIC' + id + '_TITLE_and_' + typeName];
if(existingByCat[typeName] == undefined) existingByCat[typeName] = [];
if(this.fukushuItemCount[typeName] <= existingByCat[typeName].length) continue;

if(tempQuiz == undefined) continue;

quizItemsTemp[quizItemsTemp.length] = tempQuiz.find(function (obj) {
return obj.id == currentId;
});

existingByCat[typeName][existingByCat[typeName].length] = 1;

if(existingId.indexOf(type + id) > -1) continue;

existingId[existingId.length] = type + id;

if(this.byCategory[typeName] == undefined){
this.byCategory[typeName] = tempQuiz;
}

}

}
console.log(quizItemsTemp);
console.log(this.byCategory);

// this.byCategory[topics[i]] = tempQuiz;

// for(c = 0; c < this.testItemCount[topics[i]]; c++){
// randomItem = '';

// while(!randomItem){
// randomIndex = Math.floor(Math.random() * tempQuiz.length);
// if(currentItems.indexOf(tempQuiz[randomIndex].id) > -1) continue;

// currentItems[currentItems.length] = tempQuiz[randomIndex].id;
// randomItem = tempQuiz[randomIndex];
// this.quizItems.push(randomItem);
// }
// }

this.quizItems = quizItemsTemp;
}

}

// randomized answer options
Expand All @@ -368,7 +459,7 @@ import {
randomItem = '';

while(!randomItem){
if(this.initialParams.isTopicTest){
if(this.initialParams.isTopicTest || this.initialParams.formatType == 'FUKUSHU'){
byCat = this.byCategory[type];
randomIndex = Math.floor(Math.random() * byCat.length);
if(currentItems.indexOf(byCat[randomIndex].id) > -1) continue;
Expand Down Expand Up @@ -414,7 +505,7 @@ import {
randomQuizFormat(){
let quizFormat, quizFormatLength, paramFormat, time, randomIndex;

if(this.initialParams.isTopicTest){
if(this.initialParams.isTopicTest || this.initialParams.formatType == 'FUKUSHU'){
questionType = this.currentQuestion.type;
this.quizOptions = this.study[questionType];
}
Expand Down Expand Up @@ -453,27 +544,27 @@ import {
case 'romaji_moji':
paramFormat = {
answerFormat: 'moji',
questionFormat: 'romaji'
questionFormat: 'romaji',
};
break;
case 'moji_romaji':
paramFormat = {
answerFormat: 'romaji',
questionFormat: 'moji'
questionFormat: 'moji',
};
break;

case 'moji_english':
paramFormat = {
answerFormat: 'english',
questionFormat: 'moji'
questionFormat: 'moji',
};
break;

case 'english_moji':
paramFormat = {
answerFormat: 'moji',
questionFormat: 'english'
questionFormat: 'english',
};
break;

Expand Down Expand Up @@ -598,12 +689,13 @@ import {
};
break;
}


paramFormat.studyType = this.setStudyType(quizFormat);
paramFormat.format = quizFormat;

console.log(paramFormat,'ss');
if(this.initialParams.isTopicTest){
paramFormat.time = 900000; //15mins
//paramFormat.time = 5000; //15mins
//paramFormat.time = 5000; //5seconds
}
else{
paramFormat.time = time;
Expand All @@ -612,6 +704,19 @@ import {
return paramFormat;
}

setStudyType(quizFormat){

if(this.study.topic_id == 'T001'){
return studyType.hiragana[quizFormat];
}
else if(this.study.type == 'INITIAL'){
return studyType.initial[quizFormat];
}
else{
return studyType[this.currentQuestion.type][quizFormat];
}
}

setNextQuestion(forceEnd = 0) {

const counter = this.state.counter + 1;
Expand Down Expand Up @@ -708,9 +813,10 @@ import {
questionTime: (this.timeStops * 1000),
questionTotalTime : this.state.time,
type: this.state.question.type.toUpperCase(),
studyType: this.state.studyType, // TODO
correctTitle: this.stripSpace(correctTitle)
}

console.log('-wweee', parseValue);
this.studyRecord[this.studyRecord.length] = parseValue;

this.props.takeQuiz(parseValue); //call our action
Expand Down
14 changes: 13 additions & 1 deletion app/screens/Study/score.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ import {
this.item['formatType'] = initialParams.formatType;
this.item['idList'] = initialParams.idList;
this.item['oneType'] = initialParams.oneType;

this.props.getLockRecord();

}
goToTopicSelection = () => {
Expand All @@ -74,7 +76,17 @@ import {
});
this.props.navigation.dispatch(resetAction);

}else{
}
else if(this.item.formatType == 'FUKUSHU'){
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'StudyList' }),
]
});
this.props.navigation.dispatch(resetAction);
}
else{
var nav = this.setNavStudyList(this.state.type, 1);

const resetAction = NavigationActions.reset(nav);
Expand Down
12 changes: 10 additions & 2 deletions app/screens/Study/studyList.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,23 @@ class StudyListScreen extends Component {
item['categoryId'] = 'C001';
//console.log(item);
this.getMistakes(item.topic_id);
console.log(item);
if(item.type == 'INITIAL'){
item['studyType'] = item.title;
this.props.navigation.navigate('HiraganaList',(
item
));
}else if(item.type == 'FUKUSHU'){
this.props.navigation.navigate('TopicList',(
item

item['formatType'] = 'FUKUSHU';
item['idList'] = this.props.lock[item.topic_id].mistakes;

this.props.navigation.navigate('QuizFlash',(
item
));
// this.props.navigation.navigate('TopicList',(
// item
// ));
}
else{
this.props.navigation.navigate('TopicList',(
Expand Down

0 comments on commit 4f32f6c

Please sign in to comment.