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 #118 from ZendyLim/feature/#50_goi_quiz
Browse files Browse the repository at this point in the history
Feature/#50 goi quiz
  • Loading branch information
viinkelvin authored Jun 23, 2018
2 parents 6c00ad3 + 540a382 commit 1338fbf
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 49 deletions.
Binary file modified android/app/src/main/res/raw/t4_doushite.mp3
Binary file not shown.
Binary file modified android/app/src/main/res/raw/t4_douyatte.mp3
Binary file not shown.
10 changes: 6 additions & 4 deletions app/actions/helper.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { pointsList } from '../config/quizFormat';

export function countScore(studyRecord,quizItems = 0) {
export function countScore(studyRecord,quizItems = 0, byPoint = false) {
let score = 0;
let countQuest = 0;
var correct = 0;
for(var i = 0; i < studyRecord.length; ++i) {
if(studyRecord[i].correct == '1'){
if(studyRecord[i].type){
correct += pointsList[studyRecord[i].type.toLowerCase()];
}else{
console.log('run this');
}else{
correct += pointsList['initial'];
}
}
Expand All @@ -20,9 +19,12 @@ export function countScore(studyRecord,quizItems = 0) {
}
}

if(quizItems){
if(quizItems && !byPoint){
countQuest = 100;
}
else{
countQuest = quizItems * 2;
}

if(countQuest !== 0 && correct !== 0){
score = Math.floor(( correct / countQuest) * 100 );
Expand Down
4 changes: 3 additions & 1 deletion app/actions/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async function getJWT(){
//================================ API FETCH ===================================

export function getAllRecord(){

return (dispatch) => {
getJWT().then( JWT => {
fetch('https://e-learning-backend.herokuapp.com/api/v1/activities',{
Expand All @@ -27,7 +28,8 @@ export function getAllRecord(){
'Content-Type': 'application/json',
},
}).then(data => data.json())
.then(json => {
.then(json => {

SummaryHelper.setSummaryCount(json.activities.quiz, dataVal =>{
dispatch(summaryCountAllDispatch(dataVal))
});
Expand Down
4 changes: 2 additions & 2 deletions app/component/correct.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class CorrectPanel extends Component {
<View>
<Text style={ styles.correctText }>{ this.stripSpace(displayToText) }</Text>
<Text style={ styles.correctText }>{ this.props.question.romaji }</Text>
<Text style={ styles.correctHighlight }>English</Text>
<Text style={ styles.correctText }>{ this.props.question.english }</Text>
{/* <Text style={ styles.correctHighlight }>English</Text> */}
{/* <Text style={ styles.correctText }>{ this.props.question.english }</Text> */}
</View>

{this.props.question.audio != '' &&
Expand Down
10 changes: 10 additions & 0 deletions app/config/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ export let strings = new LocalizedStrings({
PROCEED : "Proceed >",
QUIZLIST : "Quizlist",
HIRAGANA_KATAKANA_LIST_VALIDATION : "You need to choose at least 5 data",
POINTS: "Points",
QUESTIONS: "Questions",
PASSOVER: "In order to pass you need points above 80",
NEED_PASS:"You need to pass the test 1 time to proceed to next topic. In order to pass you need points above 80",
NEED_PASS_INITIALS:"You need to pass the test 3 times to proceed to next topic. In order to pass you need points above 80",

//login part
SIGN_IN : "Sign In",
Expand Down Expand Up @@ -261,6 +266,11 @@ export let strings = new LocalizedStrings({
PROCEED : "持続する >",
QUIZLIST : "クイズリスト",
HIRAGANA_KATAKANA_LIST_VALIDATION : "少なくとも5つのデータを選択する必要があります",
POINTS: "点",
QUESTIONS: "問",
PASSOVER: "80点以上で合格",
NEED_PASS:"次のトピックを続けるように、テストを1回合格が必要です。80点以上で合。",
NEED_PASS_INITIALS:"次のトピックを続けるように、テストを3回合格が必要です。80点以上で合。",

//login part
SIGN_IN : "サインイン",
Expand Down
14 changes: 7 additions & 7 deletions app/config/quiz/topic2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1268,24 +1268,24 @@ export const listening = [
"english":"vietnam",
"answerOption":[
{
"id":"tp2_l_4",
"id":"tp2_l_3",
"type":"listening",
"moji":"日本"
"moji":"1月 26日"
},
{
"id":"tp2_l_2",
"type":"listening",
"moji":"フィリピン"
"moji":"2月 1日"
},
{
"id":"tp2_l_3",
"id":"tp2_l_1",
"type":"listening",
"moji":"ベトナム"
"moji":"2月 18日"
},
{
"id":"tp2_l_1",
"id":"tp2_l_4",
"type":"listening",
"moji":"タイ"
"moji":"8月 18日"
}
],
"audio":"t2_listening_3.mp3"
Expand Down
28 changes: 17 additions & 11 deletions app/screens/Quiz/quizFlash.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ import {
listening: 3
}

// this.testItemCount = {
// vocabulary: 1,
// kanji: 1,
// grammar: 1,
// reading: 1,
// listening: 1
// }
this.shortType = {
'v' : 'vocabulary',
'g' : 'grammar',
Expand Down Expand Up @@ -192,7 +199,7 @@ import {
<View style={ !timerRun && styles.blocker }></View>
<View style={[ styles.quizInfo ]}>
<Text style={ styles.quizInfoText }>
Points: { this.setScore() }/100 Questions: { this.state.counter+1 }/{ this.allQuestion.length }
{strings.POINTS}: { this.setScore() }/100 {strings.QUESTIONS}: { this.state.counter+1 }/{ this.allQuestion.length }
</Text>
</View>

Expand Down Expand Up @@ -769,12 +776,6 @@ import {

this.setState(this.initialState);
this.props.navigation.dispatch(resetAction);

// this.props.navigation.navigate('ScoreScreen',{
// index : this.state.index,
// typeQuiz : this.initialParams.formatType,
// studyTitle : this.title
// });

}
}
Expand Down Expand Up @@ -848,12 +849,17 @@ import {
};

setScore(){
var quizSizes = 0;

var quizSizes = this.allQuestion.length;
if(this.initialParams.isTopicTest){
quizSizes = this.allQuestion.length;

return Helper.countScore(this.studyRecord,quizSizes);
}
return Helper.countScore(this.studyRecord,quizSizes);
else{
return Helper.countScore(this.studyRecord,quizSizes,true);
}


}

goNextQuestion() {
Expand Down
5 changes: 3 additions & 2 deletions app/screens/Study/score.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ import {
<View style={ scoreStyle.absoluteText }>
<View style={ scoreStyle.containerScore }>
<Text style={ scoreStyle.scoreTotal }>{ this.props.scoreTotal}/100 </Text>
</View>
</View>
</View>
<ProgressCircle
style={ { height: 140 } }
Expand All @@ -219,6 +219,7 @@ import {
/>
</View>
<View style={ scoreStyle.containerMistake }>
<Text style={scoreStyle.ruleScore}>{ strings.PASSOVER }</Text>
<ScrollView style={ scoreStyle.containerMainMistake }>
<Text style={ scoreStyle.sumaryTitle }>SUMMARY</Text>
<Icon name='lock' color='#fff' size={10}/>
Expand All @@ -235,7 +236,7 @@ import {
) :<Text>No study data</Text> }
</ScrollView >
</View>
{ this.props.scoreTotal >= 80 ? (
{ this.props.scoreTotal >= 0 ? (
<View style={ scoreStyle.containerMistake }>
<View style={ scoreStyle.RecordRowButton }>
<View style={ scoreStyle.RecordRowButtonContainer }>
Expand Down
4 changes: 1 addition & 3 deletions app/screens/Study/studyList.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ class StudyListScreen extends Component {
this.props.navigation.navigate('QuizFlash',(
item
));
// this.props.navigation.navigate('TopicList',(
// item
// ));

}
else{
this.props.navigation.navigate('TopicList',(
Expand Down
91 changes: 76 additions & 15 deletions app/screens/Study/topiclist.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import { strings } from '../../config/localization';
import { ImageData } from '../../config/image_list';
import { StudyList } from '../../config/studyList';

import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as Actions from '../../actions/summary';
class TopicListScreen extends Component {

static navigationOptions = ({ navigation }) =>{
Expand All @@ -33,18 +36,24 @@ class TopicListScreen extends Component {
title:"TOPIC10_TITLE",
img: "",
index: "",
nextTopic: "",
};
}

componentDidMount() {
const { navigation } = this.props;
this.setState({

params = {
title: navigation.getParam('title', null),
img: navigation.getParam('img', null),
type: navigation.getParam('type', null),
index: navigation.getParam('index', null),
});
console.log(navigation.getParam('index', null));
index: navigation.getParam('index', null),
}

params.nextTopic = StudyList[params.index + 1];

this.setState(params);
console.log(params);
//Console.log(navigation.getParam('userName', null),"NIAMAK");
}

Expand Down Expand Up @@ -80,18 +89,50 @@ navigateToLearn=(type, categoryId)=>{
navigateToNextTopic=()=>{
var item = StudyList[this.state.index + 1];
item['index'] = this.state.index + 1;

const resetAction = NavigationActions.reset({
index: 1,
actions: [
NavigationActions.navigate({ routeName: 'StudyList' }),
NavigationActions.navigate({ routeName: 'TopicList' , params: item })
]
});
locks = this.props.lock;
console.log(item);
if(locks[item.topic_id].lock){
if(this.state.type == 'INITIAL'){
alert(strings.NEED_PASS_INITIAL);
}
else{
alert(strings.NEED_PASS);
}

}
else{

this.props.navigation.dispatch(resetAction);
let resetAction;


if(item.type == 'FUKUSHU'){

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

resetAction = NavigationActions.reset({
index: 1,
actions: [
NavigationActions.navigate({ routeName: 'StudyList' }),
NavigationActions.navigate({ routeName: 'QuizFlash' , params: item })
]
});

}
else{

resetAction = NavigationActions.reset({
index: 1,
actions: [
NavigationActions.navigate({ routeName: 'StudyList' }),
NavigationActions.navigate({ routeName: 'TopicList' , params: item })
]
});

}

this.props.navigation.dispatch(resetAction);
}

}
render() {
return (
Expand Down Expand Up @@ -119,6 +160,7 @@ navigateToLearn=(type, categoryId)=>{
<Text style={[study.buttonTopicText]}>{ strings['topic_test'] }</Text>
</TouchableOpacity>
</View>

<View style={[study.buttonContainerTopicNext]}>
<TouchableOpacity style={[study.nextTopic, styles.shadow]} onPress={this.navigateToNextTopic.bind(this)}>
<Text style={[study.buttonTopicNextText]}>{ strings['next_topic'] }</Text>
Expand All @@ -139,4 +181,23 @@ navigateToLearn=(type, categoryId)=>{
const styles = require('../../styles/style');
const study = require('../../styles/study');

export default TopicListScreen;
// The function takes data from the app current state,
// 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) {

return {
lock : state.summary.lock
}
}


// Doing this merges our actions into the component’s props,
// while wrapping them in dispatch() so that they immediately dispatch an Action.
// Just by doing this, we will have access to the actions defined in out actions file (action/home.js)
function mapDispatchToProps(dispatch) {
return bindActionCreators(Actions, dispatch);
}

//Connect everything
export default connect(mapStateToProps, mapDispatchToProps)(TopicListScreen);
7 changes: 6 additions & 1 deletion app/styles/score.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ module.exports = StyleSheet.create({
},
imageHome : {
width: '100%',
height: '100%',
height: '100%',
},
ruleScore:{
fontSize:16,
marginBottom:10,
textAlign:"center",
elevation: 4
}

Expand Down
4 changes: 1 addition & 3 deletions app/styles/study.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,9 @@ module.exports = StyleSheet.create({
nextTopic: {
height: 60,
width : '98%',
backgroundColor: '#cccccc',
backgroundColor: primaryColor,
justifyContent: 'center',
alignItems: 'center',
borderColor: '#cccccc',
borderWidth: 1,
borderRadius: 5,
},
buttonTopicNextText:{
Expand Down

0 comments on commit 1338fbf

Please sign in to comment.