You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

126 lines
4.2 KiB

import React from "react"
import { ScrollView, StatusBar } from "react-native"
import testQuestions from "../data/test"
import aerodynamicsQuestions from "../data/aerodynamics"
import firstAidQuestions from "../data/firstAid"
import flightSafetyQuestions from "../data/flightSafety"
import instrumentsQuestions from "../data/instruments"
import legislationQuestions from "../data/legislation"
import materialsQuestions from "../data/materials"
import meteorologyQuestions from "../data/meteorology"
import physiopathologyQuestions from "../data/physiopathology"
import pilotingTechniquesQuestions from "../data/pilotingTechniques"
import { RowItem } from "../components/RowItem"
import { colors, texts, examScheme } from "../components/Variables"
let examQuestions = []
const allQuestions = {
aerodynamics: aerodynamicsQuestions,
firstAid: firstAidQuestions,
flightSafety: flightSafetyQuestions,
instruments: instrumentsQuestions,
legislation: legislationQuestions,
materials: materialsQuestions,
meteorology: meteorologyQuestions,
physiopathology: physiopathologyQuestions,
pilotingTechniques: pilotingTechniquesQuestions
}
const composeExamQuestions = () => {
examScheme.forEach( (elem) => {
let currentSection = allQuestions[elem.section]
for(let i=0; i<elem.questions; i++) {
const currentIndex = Math.floor(Math.random() * elem.questions)
//currentSection[currentIndex].question = elem.section + currentSection[currentIndex].question
examQuestions.push(currentSection[currentIndex])
currentSection = currentSection.filter( (item, index) => index != currentIndex)
}
})
}
composeExamQuestions()
export default ({ navigation }) => (
<ScrollView style={[{ backgroundColor: colors.dark_blue }]}>
<StatusBar barStyle="dark-content" />
<RowItem name={texts.aerodynamics} color={colors.blue} onPress={() =>
navigation.navigate("Quiz", {
title: texts.aerodynamics,
questions: aerodynamicsQuestions,
color: colors.blue
})}/>
<RowItem name={texts.first_aid} color={colors.blue} onPress={() =>
navigation.navigate("Quiz", {
title: texts.first_aid,
questions: firstAidQuestions,
color: colors.blue
})}/>
<RowItem name={texts.flight_safety} color={colors.blue} onPress={() =>
navigation.navigate("Quiz", {
title: texts.flight_safety,
questions: flightSafetyQuestions,
color: colors.blue
})}/>
<RowItem name={texts.instruments} color={colors.blue} onPress={() =>
navigation.navigate("Quiz", {
title: texts.instruments,
questions: instrumentsQuestions,
color: colors.blue
})}/>
<RowItem name={texts.legislation} color={colors.blue} onPress={() =>
navigation.navigate("Quiz", {
title: texts.legislation,
questions: legislationQuestions,
color: colors.blue
})}/>
<RowItem name={texts.materials} color={colors.blue} onPress={() =>
navigation.navigate("Quiz", {
title: texts.materials,
questions: materialsQuestions,
color: colors.blue
})}/>
<RowItem name={texts.meteorology} color={colors.blue} onPress={() =>
navigation.navigate("Quiz", {
title: texts.meteorology,
questions: meteorologyQuestions,
color: colors.blue
})}/>
<RowItem name={texts.physiopathology} color={colors.blue} onPress={() =>
navigation.navigate("Quiz", {
title: texts.physiopathology,
questions: physiopathologyQuestions,
color: colors.blue
})}/>
<RowItem name={texts.piloting_techniques} color={colors.blue} onPress={() =>
navigation.navigate("Quiz", {
title: texts.piloting_techniques,
questions: pilotingTechniquesQuestions,
color: colors.blue
})}/>
<RowItem name={texts.exam} color={colors.blue} onPress={() =>
navigation.navigate("Exam", {
title: texts.exam,
questions: examQuestions,
color: colors.blue
})}/>
<RowItem name="TEST" color={colors.orange} onPress={() =>
navigation.navigate("Quiz", {
title: "TEST",
questions: testQuestions,
color: colors.blue
})}/>
</ScrollView>
)