|
|
@ -1,5 +1,5 @@ |
|
|
|
import React from "react" |
|
|
|
import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, BackHandler} from "react-native" |
|
|
|
import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, BackHandler, AsyncStorage} from "react-native" |
|
|
|
|
|
|
|
import { Button, ButtonContainer } from "../components/Button" |
|
|
|
import { colors, texts, examScheme } from "../components/Variables" |
|
|
@ -119,11 +119,27 @@ class Results extends React.Component { |
|
|
|
|
|
|
|
state = { |
|
|
|
bannerExpanded: true, |
|
|
|
timer: maxTime |
|
|
|
timer: maxTime, |
|
|
|
storeWrongAnswers: [] |
|
|
|
} |
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
BackHandler.addEventListener('hardwareBackPress', this.handleBackButton) |
|
|
|
|
|
|
|
AsyncStorage.getItem('storeWrongAnswers').then( (value) => { |
|
|
|
const currentResults = this.props.navigation.getParam("results") |
|
|
|
const wrongAnswers = currentResults.wrongAnswers || [] |
|
|
|
const stored = JSON.parse(value) || [] |
|
|
|
const result = currentResults.isWrong ? wrongAnswers : Object.assign([], wrongAnswers, stored); |
|
|
|
AsyncStorage.setItem('storeWrongAnswers', JSON.stringify(result)) |
|
|
|
|
|
|
|
this.setState( (state) => { |
|
|
|
return { |
|
|
|
storeWrongAnswers: result |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
}).done() |
|
|
|
} |
|
|
|
|
|
|
|
componentWillUnmount() { |
|
|
@ -142,14 +158,14 @@ class Results extends React.Component { |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
//tmpQuestions.forEach( (e) => { console.log(e.id) })
|
|
|
|
|
|
|
|
this.props.navigation.navigate("Splash", { |
|
|
|
examQuestions: tmpQuestions |
|
|
|
examQuestions: tmpQuestions, |
|
|
|
storeWrongAnswers: this.state.storeWrongAnswers |
|
|
|
}) |
|
|
|
return true |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
|
|
|
const currentResults = this.props.navigation.getParam("results") |
|
|
@ -163,7 +179,6 @@ class Results extends React.Component { |
|
|
|
boxStyle = percentage >= 80 ? percentage >= 85 ? styles.boxCorrect : styles.boxUnsafe : styles.boxWrong |
|
|
|
} |
|
|
|
|
|
|
|
//console.log(currentResults)
|
|
|
|
|
|
|
|
return ( |
|
|
|
<View style={styles.container} > |
|
|
@ -182,9 +197,13 @@ class Results extends React.Component { |
|
|
|
<Text style={styles.text}> |
|
|
|
<Text style={styles.textLabel}>{`${texts.percentage}: ${Math.round(percentage)}%`}</Text> |
|
|
|
</Text> |
|
|
|
<Text style={styles.text}> |
|
|
|
<Text style={styles.textLabel}>{`${texts.points}: ${currentResults.points}/${currentResults.totalPoints}`}</Text> |
|
|
|
</Text> |
|
|
|
{ |
|
|
|
currentResults.points ? ( |
|
|
|
<Text style={styles.text}> |
|
|
|
<Text style={styles.textLabel}>{`${texts.points}: ${currentResults.points}/${currentResults.totalPoints}`}</Text> |
|
|
|
</Text> |
|
|
|
) : null |
|
|
|
} |
|
|
|
|
|
|
|
{currentResults.isExam ? |
|
|
|
<Text style={[styles.textSmall, resultStyle]}> |
|
|
|