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

Commit

Permalink
#50 fix retry button
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidborredom committed Jun 20, 2018
1 parent 305b384 commit abbc331
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 41 deletions.
10 changes: 3 additions & 7 deletions app/component/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ class TimerBar extends Component {
}

this.props.timeStops(this.seconds - this.state.progress);
this.progress.setValue(0);
console.log(this.props);
console.log(this.progress);
this.progress.setValue(0);
}

}
Expand Down Expand Up @@ -156,10 +154,8 @@ class TimerBar extends Component {

if(this.props.timerRestart){
if(!this.props.isTopicTest){
this.progress.setValue(0);
console.log(11111);
}
console.log(22222);
this.progress.setValue(0);
}
this.timerStart();

}
Expand Down
2 changes: 1 addition & 1 deletion app/config/quiz/topic6.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export const vocabulary = [
{
"id":"tp6_v_24",
"type":"vocabulary",
"moji":"おば",
"moji":"おばさん",
"romaji":"oba",
"english":"Aunt",
"audio":"t6_oba.mp3"
Expand Down
1 change: 1 addition & 0 deletions app/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const LEARN_FAILED = 'LEARN_FAILED'; //import the action for start time
export const START_TIME_QUIZ = 'START_TIME_QUIZ'; //import the action for start time
export const END_TIME_QUIZ = 'END_TIME_QUIZ'; //import the action for start time
export const TAKE_QUIZ = 'TAKE_QUIZ'; //import the action for start time
export const MISTAKES = 'MISTAKES'; //import the action for start time

//action for user
export const USER_LOGIN_SUCCESS = "USER_LOGIN_SUCCESS";
Expand Down
10 changes: 8 additions & 2 deletions app/reducers/study.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {START_TIME_LEARN ,END_TIME_LEARN , LEARN_FAILED , TAKE_QUIZ} from '../lib/constants';
import {START_TIME_LEARN ,END_TIME_LEARN , LEARN_FAILED , TAKE_QUIZ, MISTAKES} from '../lib/constants';

const initialState = {
startTime:'',
Expand All @@ -9,7 +9,8 @@ const initialState = {
err: '',
isErr: false,
fukushu: true,
quizSize: 0
quizSize: 0,
fukushuMistakes:[]
};

export default function userReducer (state = initialState, action) {
Expand Down Expand Up @@ -43,6 +44,11 @@ export default function userReducer (state = initialState, action) {
case TAKE_QUIZ:
state = Object.assign({}, state, {
studyRecord: [].concat(state.studyRecord, [action.studyRecord])
});
case MISTAKES:
console.log(action);
state = Object.assign({}, state, {
fukushuMistakes: [].concat(state.fukushuMistakes, [action.mistakes])
});
return state;
default:
Expand Down
53 changes: 30 additions & 23 deletions app/screens/Quiz/quizFlash.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
class QuizFlashScreen extends Component {

static navigationOptions = ({ navigation }) => {
subtitle = navigation.getParam('type', null);
subtitle = navigation.getParam('formatType', null);
title = navigation.getParam('title', null);
confirm = true;

Expand Down Expand Up @@ -75,8 +75,7 @@ import {
this.quizOptions = [];
this.byCategory = [];
this.reduxParam = [];
this.title = '';
this.oneType = '';
this.title = '';
this.study = [];
this.initialParams = [];
this.isMounted = true;
Expand Down Expand Up @@ -109,14 +108,21 @@ import {
showCorrect:false
}

// this.testItemCount = {
// vocabulary: 10,
// kanji: 10,
// grammar: 15,
// reading: 3,
// listening: 3
// }

this.testItemCount = {
vocabulary: 10,
kanji: 10,
grammar: 15,
reading: 3,
listening: 3
vocabulary: 1,
kanji: 1,
grammar: 1,
reading: 1,
listening: 1
}

this.state = this.initialState;

}
Expand Down Expand Up @@ -208,29 +214,30 @@ import {
const { navigation } = this.props;

BackHandler.addEventListener('hardwareBackPress', this.handleBackButton);

this.oneType = navigation.getParam('oneType',null);

this.mounted = true;
idList = navigation.getParam('idList', null);

let shuffledQuiz = [];

this.initialParams = {
title: navigation.getParam('title', null),
img: navigation.getParam('img', null),
type: navigation.getParam('type', null),
formatType: navigation.getParam('formatType', null),
studyType: navigation.getParam('studyType',null),
headerTitle: navigation.getParam('headerTitle',null),
index: navigation.getParam('index', null),
isTopicTest: navigation.getParam('isTopicTest', null)
isTopicTest: navigation.getParam('isTopicTest', null),
idList: navigation.getParam('idList', null),
oneType: navigation.getParam('oneType',null)
}
//console.log(this.initialParams);
console.log(this.initialParams,'weee');
this.setState(this.initialParams);

this.setInitial();

this.setListQuestion();
//console.log(this.quizItems);
this.setDefinedQuestion(idList);
this.setDefinedQuestion(this.initialParams.idList);
//console.log(this.quizItems,this.testItemCount);
if(!this.quizItems){
const resetAction = NavigationActions.reset({
Expand All @@ -248,7 +255,7 @@ import {
this.allQuestion = shuffledQuiz.map((question) =>
this.shuffleAnswers(question, shuffledQuiz)
);
console.log(this.allQuestion);
//console.log(this.allQuestion);
this.currentQuestion = this.allQuestion[0];

this.setState({
Expand Down Expand Up @@ -292,14 +299,14 @@ import {
this.study = StudyList.find(function (obj) {
return obj.title == this.title;
})
console.log(this.study);
//console.log(this.study);
if(this.study.type == 'INITIAL'){
this.quizOptions = this.study.quizOptions;
}
else{
console.log(this.study,this.initialParams.headerTitle);
//console.log(this.study,this.initialParams.headerTitle);
this.quizOptions = this.study[this.initialParams.headerTitle];
console.log(this.quizOptions);
//console.log(this.quizOptions);
}

}
Expand Down Expand Up @@ -400,7 +407,7 @@ import {
// randomized question
shuffleItems(array) {
var currentIndex = array.length, temporaryValue, randomIndex, output = [];
var limit = this.initialParams.type == 'Test' ? 50 : 25;
var limit = this.initialParams.formatType == 'Test' ? 50 : 25;

while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex);
Expand All @@ -424,7 +431,7 @@ import {
this.quizOptions = this.study[questionType];
}

quizFormat = this.oneType ? [this.oneType] : this.quizOptions.types;
quizFormat = this.initialParams.oneType ? [this.initialParams.oneType] : this.quizOptions.types;
quizFormatLength = quizFormat.length;
randomIndex = Math.floor(Math.random() * quizFormatLength);
time = this.time;
Expand Down Expand Up @@ -689,7 +696,7 @@ import {
categoryId : StudyList[index].topic_id + categoryId,
studyId : StudyList[index].topic_id + categoryId
}

console.log(value);
return value;
}

Expand Down
2 changes: 1 addition & 1 deletion app/screens/Study/hiraganaList.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class HiraganaListScreen extends Component {

param = {
index : this.state.index,
type : type,
formatType : type,
title : this.state.title,
studyType: this.state.studyType,
categoryId : this.state.categoryId,
Expand Down
47 changes: 43 additions & 4 deletions app/screens/Study/score.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,20 @@ import {
index: navigation.getParam('index', null),
headerTitle: navigation.getParam('headerTitle', null),
studyType: navigation.getParam('studyType', null),
isTopicTest: navigation.getParam('isTopicTest', null),
formatType: navigation.getParam('formatType', null),
idList: navigation.getParam('idList', null),
oneType: navigation.getParam('oneType',null)
}

this.item = StudyList[initialParams.index];
this.item['index'] = initialParams.index;
this.item['studyType'] = initialParams.studyType;
//this.item['headerTitle'] = this.item.title;
this.item['isTopicTest'] = initialParams.isTopicTest;
this.item['headerTitle'] = initialParams.headerTitle;
this.item['formatType'] = initialParams.formatType;
this.item['idList'] = initialParams.idList;
this.item['oneType'] = initialParams.oneType;
console.log(this.item);
}
goToTopicSelection = () => {
Expand All @@ -68,7 +75,13 @@ import {
this.props.navigation.dispatch(resetAction);

}else{
this.retry();
var nav = this.setNavStudyList(this.state.type, 1);

const resetAction = NavigationActions.reset(nav);

this.props.navigation.dispatch(resetAction);


}
}
componentWillUnmount(){
Expand All @@ -89,6 +102,32 @@ import {
setNav(type, index) {
let nav;

if(this.item.headerTitle == 'topic_test'){
nav = {
index: index,
actions: [
NavigationActions.navigate({ routeName: 'StudyList' }),
NavigationActions.navigate({ routeName: 'QuizFlash' , params: this.item })
]
};
}
else{
console.log(this.item);
nav = {
index: index,
actions: [
NavigationActions.navigate({ routeName: 'StudyList' }),
NavigationActions.navigate({ routeName: 'QuizFlash' , params: this.item })
]
};
}

return nav;
}

setNavStudyList(type, index) {
let nav;

if(this.item.headerTitle == 'topic_test'){
nav = {
index: index,
Expand Down Expand Up @@ -255,8 +294,8 @@ const study = require('../../styles/study');
// This function makes Redux know that this component needs to be passed a piece of the state
function mapStateToProps(state, props) {

const score = Helper.countScore(state.study.studyRecord,state.study.quizSize);

//const score = Helper.countScore(state.study.studyRecord,state.study.quizSize);
const score = 100;
return {
StudentID: state.user.user.id,
studyRecord: state.study.studyRecord,
Expand Down
36 changes: 33 additions & 3 deletions app/screens/Study/studyList.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class StudyListScreen extends Component {
setModalVisible(visible) {
this.setState({modalVisible: visible});
}
lockedMessage=(item, index)=>{
lockedMessage=(item, index)=>{
alert(strings[item.topic_id + '_MSG'] );
}

Expand All @@ -44,7 +44,8 @@ class StudyListScreen extends Component {
item['studyType'] = item.title;
item['headerTitle'] = item.title;
item['categoryId'] = 'C001';

//console.log(item);
this.getMistakes(item.topic_id);
if(item.type == 'INITIAL'){
item['studyType'] = item.title;
this.props.navigation.navigate('HiraganaList',(
Expand Down Expand Up @@ -75,6 +76,8 @@ class StudyListScreen extends Component {
}

checkLock = (topic_id) =>{


if(this.props.lock){
if(this.props.lock[topic_id]){
if(this.props.lock[topic_id].lock){
Expand All @@ -89,6 +92,21 @@ class StudyListScreen extends Component {
return true;
}
}

getMistakesData(topic_id){
//return Promise.all([this.props.getMistakes('T008')])
}

getMistakes = async() => {
//json = await this.props.getMistakes('T008');
//console.log(json);
// this.getMistakegetMistakessData()
// .then(([data]) => {
// // both have loaded!
// console.log(data);
// })
}

render() {
var image = '';
this._onSetLanguageTo(this.props.lang);
Expand Down Expand Up @@ -141,10 +159,22 @@ const study = require('../../styles/study');
// and insert/links it into the props of our component.
// This function makes Redux know that this component needs to be passed a piece of the state
function mapStateToProps(state, props) {
console.log(state);

state.summary.lock['T004'] = {
lock:false,
matomeLeft:1
};

state.summary.lock['T005'] = {
lock:false,
matomeLeft:1
};

return {
fukushu: state.study.fukushu,
lang : state.user.lang,
lock : state.summary.lock
lock : state.summary.lock
}
}

Expand Down

0 comments on commit abbc331

Please sign in to comment.