|  | @ -20,6 +20,14 @@ const styles = StyleSheet.create({ | 
		
	
		
			
				|  |  |     paddingVertical: 20, |  |  |     paddingVertical: 20, | 
		
	
		
			
				|  |  |     marginTop: 20, |  |  |     marginTop: 20, | 
		
	
		
			
				|  |  |   }, |  |  |   }, | 
		
	
		
			
				|  |  |  |  |  |   timer: { | 
		
	
		
			
				|  |  |  |  |  |     color: colors.white, | 
		
	
		
			
				|  |  |  |  |  |     fontSize: 30, | 
		
	
		
			
				|  |  |  |  |  |     textAlign: "center", | 
		
	
		
			
				|  |  |  |  |  |     fontWeight: "600", | 
		
	
		
			
				|  |  |  |  |  |     paddingVertical: 10, | 
		
	
		
			
				|  |  |  |  |  |     marginTop: 10, | 
		
	
		
			
				|  |  |  |  |  |   }, | 
		
	
		
			
				|  |  |   safearea: { |  |  |   safearea: { | 
		
	
		
			
				|  |  |     flex: 1, |  |  |     flex: 1, | 
		
	
		
			
				|  |  |     marginTop: 20, |  |  |     marginTop: 20, | 
		
	
	
		
			
				|  | @ -27,6 +35,9 @@ const styles = StyleSheet.create({ | 
		
	
		
			
				|  |  |   } |  |  |   } | 
		
	
		
			
				|  |  | }) |  |  | }) | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  | let interval = null | 
		
	
		
			
				|  |  |  |  |  | const maxTime = 10 | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  | class Exam extends React.Component { |  |  | class Exam extends React.Component { | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |   state = { |  |  |   state = { | 
		
	
	
		
			
				|  | @ -39,7 +50,8 @@ class Exam extends React.Component { | 
		
	
		
			
				|  |  |                       ].id, |  |  |                       ].id, | 
		
	
		
			
				|  |  |     answered: false, |  |  |     answered: false, | 
		
	
		
			
				|  |  |     answerCorrect: false, |  |  |     answerCorrect: false, | 
		
	
		
			
				|  |  |     results: false |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     results: false, | 
		
	
		
			
				|  |  |  |  |  |     timer: 0 | 
		
	
		
			
				|  |  |   } |  |  |   } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |   answer = correct => { |  |  |   answer = correct => { | 
		
	
	
		
			
				|  | @ -67,7 +79,7 @@ class Exam extends React.Component { | 
		
	
		
			
				|  |  |     this.setState( (state) => { |  |  |     this.setState( (state) => { | 
		
	
		
			
				|  |  |       const updatedIndexes = state.availableIds.filter( item => item != state.activeQuestionId) |  |  |       const updatedIndexes = state.availableIds.filter( item => item != state.activeQuestionId) | 
		
	
		
			
				|  |  |       const nextId = updatedIndexes[Math.floor(Math.random() * updatedIndexes.length)] |  |  |       const nextId = updatedIndexes[Math.floor(Math.random() * updatedIndexes.length)] | 
		
	
		
			
				|  |  |       let resultsShow = false |  |  |  | 
		
	
		
			
				|  |  |  |  |  |       let resultsShow = this.state.timer >= maxTime-1 || false | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |       if (!updatedIndexes.length) { |  |  |       if (!updatedIndexes.length) { | 
		
	
		
			
				|  |  |         resultsShow = true |  |  |         resultsShow = true | 
		
	
	
		
			
				|  | @ -77,7 +89,6 @@ class Exam extends React.Component { | 
		
	
		
			
				|  |  |       } |  |  |       } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |       return { |  |  |       return { | 
		
	
		
			
				|  |  |         //totalCount: updatedIndexes.length,
 |  |  |  | 
		
	
		
			
				|  |  |         availableIds: updatedIndexes, |  |  |         availableIds: updatedIndexes, | 
		
	
		
			
				|  |  |         activeQuestionId: nextId, |  |  |         activeQuestionId: nextId, | 
		
	
		
			
				|  |  |         answered: false, |  |  |         answered: false, | 
		
	
	
		
			
				|  | @ -90,6 +101,24 @@ class Exam extends React.Component { | 
		
	
		
			
				|  |  |     const questions = this.props.navigation.getParam("questions", []) |  |  |     const questions = this.props.navigation.getParam("questions", []) | 
		
	
		
			
				|  |  |     const question = questions.filter(item => item.id == this.state.activeQuestionId)[0] || questions[0] |  |  |     const question = questions.filter(item => item.id == this.state.activeQuestionId)[0] || questions[0] | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |     if(this.state.timer==0) { | 
		
	
		
			
				|  |  |  |  |  |       interval = setInterval( () => { | 
		
	
		
			
				|  |  |  |  |  |         this.setState( (state) => { | 
		
	
		
			
				|  |  |  |  |  |           return { | 
		
	
		
			
				|  |  |  |  |  |             timer: this.state.timer+1, | 
		
	
		
			
				|  |  |  |  |  |             results: this.state.timer >= maxTime-1 || false | 
		
	
		
			
				|  |  |  |  |  |           } | 
		
	
		
			
				|  |  |  |  |  |         }) | 
		
	
		
			
				|  |  |  |  |  |       }, 1000) | 
		
	
		
			
				|  |  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |     if(this.state.timer >= maxTime) { | 
		
	
		
			
				|  |  |  |  |  |       clearInterval(interval) | 
		
	
		
			
				|  |  |  |  |  |       setTimeout( () => { | 
		
	
		
			
				|  |  |  |  |  |         this.props.navigation.popToTop() | 
		
	
		
			
				|  |  |  |  |  |       }, 5000) | 
		
	
		
			
				|  |  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |     return ( |  |  |     return ( | 
		
	
		
			
				|  |  |       <ScrollView style={[ |  |  |       <ScrollView style={[ | 
		
	
		
			
				|  |  |           styles.container, |  |  |           styles.container, | 
		
	
	
		
			
				|  | @ -98,6 +127,7 @@ class Exam extends React.Component { | 
		
	
		
			
				|  |  |       > |  |  |       > | 
		
	
		
			
				|  |  |         <StatusBar barStyle="light-content" /> |  |  |         <StatusBar barStyle="light-content" /> | 
		
	
		
			
				|  |  |         <SafeAreaView style={styles.safearea}> |  |  |         <SafeAreaView style={styles.safearea}> | 
		
	
		
			
				|  |  |  |  |  |           <Text style={styles.timer}>{new Date(this.state.timer * 1000).toISOString().substr(11, 8)}</Text> | 
		
	
		
			
				|  |  |           <View> |  |  |           <View> | 
		
	
		
			
				|  |  |             <Text style={styles.text}>{question.question}</Text> |  |  |             <Text style={styles.text}>{question.question}</Text> | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
	
		
			
				|  | 
 |