Browse Source

examQuestions component

master
Dslak 6 years ago
parent
commit
22e094ed76
  1. 43
      vds-app/App/components/ExamQuestions.js
  2. 30
      vds-app/App/screens/QuizIndex.js

43
vds-app/App/components/ExamQuestions.js

@ -0,0 +1,43 @@
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 { examScheme } from "../components/Variables"
let tmpQuestions = []
const allQuestions = {
aerodynamics: aerodynamicsQuestions,
firstAid: firstAidQuestions,
flightSafety: flightSafetyQuestions,
instruments: instrumentsQuestions,
legislation: legislationQuestions,
materials: materialsQuestions,
meteorology: meteorologyQuestions,
physiopathology: physiopathologyQuestions,
pilotingTechniques: pilotingTechniquesQuestions
}
const generateQuestions = () => {
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
tmpQuestions.push(currentSection[currentIndex])
currentSection = currentSection.filter( (item, index) => index != currentIndex)
}
})
}
generateQuestions()
export const examQuestions = tmpQuestions

30
vds-app/App/screens/QuizIndex.js

@ -13,34 +13,8 @@ import physiopathologyQuestions from "../data/physiopathology"
import pilotingTechniquesQuestions from "../data/pilotingTechniques" import pilotingTechniquesQuestions from "../data/pilotingTechniques"
import { RowItem } from "../components/RowItem" 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()
import { colors, texts} from "../components/Variables"
import { examQuestions } from "../components/ExamQuestions"
export default ({ navigation }) => ( export default ({ navigation }) => (
<ScrollView style={[{ backgroundColor: colors.dark_blue }]}> <ScrollView style={[{ backgroundColor: colors.dark_blue }]}>

Loading…
Cancel
Save