diff --git a/vds-app/App/components/Variables.js b/vds-app/App/components/Variables.js
index 8ef4cc6..a32cd00 100644
--- a/vds-app/App/components/Variables.js
+++ b/vds-app/App/components/Variables.js
@@ -87,7 +87,7 @@ export const texts = {
changeQuestion: "Cambia domanda...",
lens: "\uD83D\uDD0D"
}
-
+/*
export const examScheme = [
{section: "aerodynamics", questions: 8, points: 3},
{section: "firstAid", questions: 1, points: 2},
@@ -99,14 +99,14 @@ export const examScheme = [
{section: "physiopathology", questions: 1, points: 2},
{section: "pilotingTechniques", questions: 5, points: 4}
]
-/*
+*/
export const examScheme = [
{section: "aerodynamics", questions: 1, points: 3},
{section: "firstAid", questions: 1, points: 2},
{section: "flightSafety", questions: 1, points: 4},
{section: "instruments", questions: 1, points: 2}
]
-*/
+
export const resultsScheme = [
{points: "da 86 a 100 punti", result: "idoneo"},
diff --git a/vds-app/App/index.js b/vds-app/App/index.js
index 9774627..3593db8 100644
--- a/vds-app/App/index.js
+++ b/vds-app/App/index.js
@@ -11,6 +11,7 @@ import Exam from "./screens/Exam";
import Results from "./screens/Results";
import ResultsTrueFalse from "./screens/ResultsTrueFalse";
import Recap from "./screens/Recap";
+import RecapExam from "./screens/RecapExam";
import RecapTrueFalse from "./screens/RecapTrueFalse";
import Info from "./screens/Info";
import Setup from "./screens/Setup";
@@ -28,6 +29,7 @@ export default function App() {
+
diff --git a/vds-app/App/screens/Exam.js b/vds-app/App/screens/Exam.js
index 8a35f43..c24e78b 100644
--- a/vds-app/App/screens/Exam.js
+++ b/vds-app/App/screens/Exam.js
@@ -172,7 +172,7 @@ class Exam extends React.Component {
render() {
const { availableIds, activeQuestionId, results, correctCount, wrongCount, totalCount, clickedId } = this.state;
- const questions = this.props.route.params?.questions || [];
+ const questions = this.props.route?.params?.questions || [];
const question = questions.find(q => q.id === activeQuestionId) || questions[0];
return (
diff --git a/vds-app/App/screens/Recap.js b/vds-app/App/screens/Recap.js
index 9e8ac02..83a3950 100644
--- a/vds-app/App/screens/Recap.js
+++ b/vds-app/App/screens/Recap.js
@@ -134,65 +134,101 @@ const Recap = () => {
return true;
}, [navigation, storeWrongAnswers]);
- // Attach hardware back handler
+
+ const showResults = useCallback(() => {
+ navigation.navigate("Results", {
+ wrongAnswers: wrongAnswers
+ })
+ return true;
+ }, [navigation, storeWrongAnswers]);
+
useFocusEffect(
useCallback(() => {
- this.backHandler = BackHandler.addEventListener( 'hardwareBackPress', this.handleBackButton)
- return () => this.backHandler?.remove();
+ const backHandler = BackHandler.addEventListener(
+ 'hardwareBackPress',
+ handleBackButton
+ );
+ return () => backHandler.remove();
}, [handleBackButton])
);
+
const questions = route.params?.wrongAnswers || [];
- return (
-
-
-
-
+ const currentResults = route.params
+ const wrongAnswers = currentResults.wrongAnswers || null
+ const percentage = currentResults.total ? (100/currentResults.total) * currentResults.correct : 0
+ let resultStyle = ''//currentResults.points >= 80 ? currentResults.points >= 85 ? styles.correct : styles.unsafe : styles.wrong
+ let boxStyle = currentResults.points >= 80 ? currentResults.points >= 85 ? styles.boxCorrect : styles.boxUnsafe : styles.boxWrong
- aaa{texts.recapTitle}
-
-
-
- {questions.map((question) => (
-
- {question.id}
- {question.question}
-
-
- {question.answers.map((answer) => (
-
- ))}
-
-
- ))}
-
-
-
-
-
-
-
-
+ if(!currentResults.isExam) {
+ resultStyle = ''//percentage >= 80 ? percentage >= 85 ? styles.correct : styles.unsafe : styles.wrong
+ boxStyle = percentage >= 80 ? percentage >= 85 ? styles.boxCorrect : styles.boxUnsafe : styles.boxWrong
+ }
+
+
+ return (
+
+
+
-
-
- );
+
+
+
+
+ {`${texts.corrects}: ${currentResults.correct}`}
+
+
+ {`${texts.wrongs}: ${currentResults.wrong}`}
+
+
+ {`${texts.percentage}: ${Math.round(percentage)}%`}
+
+ {
+ currentResults.points ? (
+
+ {`${texts.points}: ${currentResults.points}/${currentResults.totalPoints}`}
+
+ ) : null
+ }
+
+ {currentResults.isExam ?
+
+ {currentResults.points >= 80 ? currentResults.points >= 85 ? texts.exam_passed : texts.exam_needs_oral : texts.exam_not_passed}
+ :
+ }
+
+
+ {wrongAnswers.length ?
+
+ :
+
+
+
+ }
+
+
+
+ )
};
export default Recap;
diff --git a/vds-app/App/screens/RecapExam.js b/vds-app/App/screens/RecapExam.js
new file mode 100644
index 0000000..1c13dc8
--- /dev/null
+++ b/vds-app/App/screens/RecapExam.js
@@ -0,0 +1,200 @@
+import React from "react"
+import { View, ScrollView, StyleSheet, StatusBar, Text, Dimensions, Image, ImageBackground, BackHandler } from "react-native"
+import SafeAreaView from 'react-native-safe-area-view'
+import AsyncStorage from '@react-native-async-storage/async-storage'
+
+import { Button, ButtonContainer } from "../components/Button"
+import { Banner } from "../components/Banner"
+import { colors, texts, examScheme, credentials } from "../components/Variables"
+
+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"
+
+const screen = Dimensions.get("window")
+const header = require("../assets/header.png")
+const bgImage = require("../assets/bg.jpg")
+
+const allQuestions = {
+ aerodynamics: aerodynamicsQuestions,
+ firstAid: firstAidQuestions,
+ flightSafety: flightSafetyQuestions,
+ instruments: instrumentsQuestions,
+ legislation: legislationQuestions,
+ materials: materialsQuestions,
+ meteorology: meteorologyQuestions,
+ physiopathology: physiopathologyQuestions,
+ pilotingTechniques: pilotingTechniquesQuestions
+}
+
+const styles = StyleSheet.create({
+ container: {
+ backgroundColor: colors.blue,
+ flex: 1
+ },
+ safearea: {
+ flex: 1,
+ marginTop: 0,
+ justifyContent: "space-between",
+ paddingHorizontal: 20,
+ paddingBottom: 40
+ },
+ headerContainer: {
+ marginTop: -40,
+ alignItems: "center",
+ justifyContent: "center",
+ width: "100%",
+ height: screen.width/1.5
+ },
+ header: {
+ width: "100%"
+ },
+ box: {
+ marginTop: 30,
+ borderColor: colors.black_alpha,
+ borderWidth: 1,
+ padding: 15,
+ borderRadius: 5,
+ backgroundColor: colors.white_alpha
+ },
+ text: {
+ color: colors.white,
+ fontSize: 20,
+ textAlign: "center",
+ fontWeight: "600",
+ paddingTop: 0
+ },
+ textCode: {
+ color: colors.white,
+ fontSize: 12,
+ textAlign: "center",
+ fontWeight: "500",
+ paddingTop: 10,
+ paddingBottom: 0
+ },
+ textBig: {
+ color: colors.white,
+ fontSize: 22,
+ textAlign: "center",
+ fontWeight: "400",
+ paddingBottom: 15,
+ textTransform: "uppercase",
+ textShadowColor: 'rgba(0, 0, 0, 0.75)',
+ textShadowOffset: {width: -1, height: 1},
+ textShadowRadius: 10
+ },
+ bg: {
+ width: "100%",
+ height: "100%"
+ },
+ bannerContainer: {
+ flex: 1,
+ alignItems: "center",
+ justifyContent: "center"
+ }
+})
+
+class RecapTrueFalse extends React.Component {
+
+ componentDidMount() {
+ this.backHandler = BackHandler.addEventListener( 'hardwareBackPress', this.handleBackButton)
+ AsyncStorage.getItem('storeWrongAnswers').then((value) => {
+ //console.log(value)
+ })
+ }
+
+ componentWillUnmount() {
+ this.backHandler?.remove()
+ }
+
+ handleBackButton = () => {
+
+ let tmpQuestions = []
+ let fullQuestions = []
+
+ examScheme.forEach( (elem) => {
+ let currentSection = allQuestions[elem.section]
+ for(let i=0; i index != currentIndex)
+ }
+
+ this.props.navigation.navigate("Splash", {
+ trueFalseQuestions: tmpQuestions
+ })
+ return true
+ }
+
+ render() {
+
+ const questions = this.props.route?.params?.wrongAnswers || []
+
+
+ return (
+
+
+
+
+
+ {texts.recapTitle}
+
+
+
+ {questions.map( (question, index) => (
+
+ {question.id}
+ {question.question}
+
+
+ {question.answers.map( (answer, index) => {
+ if(question.clicked == answer.id) {
+ return (
+
+ )}
+ }
+ )}
+
+
+ ))}
+
+
+ {this.handleBackButton()}
+ }
+ />
+
+
+
+
+
+
+
+
+
+
+ )
+ }
+}
+
+export default RecapTrueFalse
diff --git a/vds-app/App/screens/Results.js b/vds-app/App/screens/Results.js
index b1527ac..6f599f2 100644
--- a/vds-app/App/screens/Results.js
+++ b/vds-app/App/screens/Results.js
@@ -1,4 +1,4 @@
-import React, { useCallback } from "react";
+import React from "react";
import {
View,
ScrollView,
@@ -6,9 +6,12 @@ import {
Text,
Image,
BackHandler,
-} from "react-native";
+ Dimensions,
+} from "react-native"; // 👈 Add Dimensions here
import { SafeAreaView } from "react-native-safe-area-context";
import { useNavigation, useRoute, useFocusEffect } from "@react-navigation/native";
+import AsyncStorage from "@react-native-async-storage/async-storage";
+
import { Button, ButtonContainer } from "../components/Button";
import { Banner } from "../components/Banner";
@@ -37,148 +40,240 @@ const allQuestions = {
};
const header = require("../assets/header.png");
+// Get screen dimensions
+const screen = Dimensions.get("window");
+const maxTime = 0
const styles = StyleSheet.create({
- container: { backgroundColor: colors.blue, flex: 1 },
+ container: {
+ backgroundColor: colors.dark_blue,
+ flex: 1
+ },
safearea: {
flex: 1,
marginTop: 0,
justifyContent: "space-between",
paddingHorizontal: 20,
- paddingBottom: 40,
+ paddingBottom: 40
},
headerContainer: {
marginTop: -40,
alignItems: "center",
justifyContent: "center",
width: "100%",
- height: 200,
+ height: screen.width/1.5
+ },
+ header: {
+ width: "100%"
},
- header: { width: "100%" },
box: {
- marginTop: 30,
- borderColor: colors.black_alpha,
- borderWidth: 1,
- padding: 15,
- borderRadius: 5,
+ marginTop: 20,
+ marginBottom: 20,
+ marginHorizontal: 20,
+ width: screen.width-80,
+ borderRadius: 10,
+ borderBottomEndRadius: 80,
+ borderTopStartRadius: 100,
backgroundColor: colors.white_alpha,
+ borderColor: colors.white,
+ borderWidth: 2,
+ paddingVertical: 30
+ },
+ boxCorrect: {
+ backgroundColor: colors.green_light,
+ },
+ boxWrong: {
+ backgroundColor: colors.red,
+ },
+ boxUnsafe: {
+ backgroundColor: colors.orange,
+ },
+ button: {
+ width: screen.width-80,
+ marginHorizontal: 20
},
text: {
color: colors.white,
- fontSize: 20,
+ fontSize: 22,
textAlign: "center",
- fontWeight: "600",
+ fontWeight: "400",
+ lineHeight: 40,
+ textShadowColor: 'rgba(0, 0, 0, 0.75)',
+ textShadowOffset: {width: -1, height: 1},
+ textShadowRadius: 10
},
- textCode: {
+ textSmall: {
color: colors.white,
- fontSize: 12,
+ marginTop: 20,
+ fontSize: 26,
textAlign: "center",
fontWeight: "500",
- paddingTop: 10,
+ lineHeight: 30,
+ textShadowColor: 'rgba(0, 0, 0, 0.75)',
+ textShadowOffset: {width: -1, height: 1},
+ textShadowRadius: 10
},
- textBig: {
- color: colors.white,
- fontSize: 22,
- textAlign: "center",
- fontWeight: "400",
- paddingBottom: 15,
- textTransform: "uppercase",
- textShadowColor: "rgba(0,0,0,0.75)",
- textShadowOffset: { width: -1, height: 1 },
- textShadowRadius: 10,
+ textLabel: {
+ paddingHorizontal: 20,
+ paddingVertical: 20
},
- bannerContainer: { flex: 1, alignItems: "center", justifyContent: "center" },
-});
+ correct: {
+ color: colors.green
+ },
+ wrong: {
+ color: colors.red
+ },
+ unsafe: {
+ color: colors.yellow
+ }
+})
+
+class Results extends React.Component {
-const Results = () => {
- const navigation = useNavigation();
- const route = useRoute();
+ state = {
+ bannerExpanded: true,
+ timer: maxTime,
+ storeWrongAnswers: []
+ }
- const handleBackButton = useCallback(() => {
- const tmpQuestions = [];
- let fullQuestions = [];
+ componentDidMount() {
+ this.backHandler = BackHandler.addEventListener(
+ "hardwareBackPress",
+ this.handleBackButton
+ );
- examScheme.forEach((elem) => {
- fullQuestions.push(...allQuestions[elem.section]);
+ AsyncStorage.getItem("storeWrongAnswers").then((value) => {
+ const currentResults = this.props.route.params.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({ storeWrongAnswers: result });
});
+ }
+
+
+ componentWillUnmount() {
+ if (this.backHandler) { this.backHandler.remove(); }
+ }
+
- for (let i = 0; i < 10; i++) {
- const index = Math.floor(Math.random() * fullQuestions.length);
- tmpQuestions.push(fullQuestions[index]);
- fullQuestions.splice(index, 1);
+ handleBackButton = () => {
+
+ let tmpQuestions = []
+ AsyncStorage.getItem('setupData').then((value) => {
+ let setupData = JSON.parse(value)
+
+ examScheme.forEach( (elem) => {
+ let currentSection = setupData.excludeDelta ? allQuestions[elem.section].filter(item => !item.delta) : allQuestions[elem.section]
+ for(let i=0; i index != currentIndex)
+ }
+ })
+
+ this.props.navigation.navigate("Splash", {
+ examQuestions: tmpQuestions,
+ storeWrongAnswers: this.state.storeWrongAnswers
+ })
+
+ return true
+
+ })
+ }
+
+
+ render() {
+
+ const currentResults = this.props.route?.params?.results || [];
+
+ const wrongAnswers = currentResults.wrongAnswers || null
+ const percentage = currentResults.total ? (100/currentResults.total) * currentResults.correct : 0
+ let resultStyle = ''//currentResults.points >= 80 ? currentResults.points >= 85 ? styles.correct : styles.unsafe : styles.wrong
+ let boxStyle = currentResults.points >= 80 ? currentResults.points >= 85 ? styles.boxCorrect : styles.boxUnsafe : styles.boxWrong
+
+ if(!currentResults.isExam) {
+ resultStyle = ''//percentage >= 80 ? percentage >= 85 ? styles.correct : styles.unsafe : styles.wrong
+ boxStyle = percentage >= 80 ? percentage >= 85 ? styles.boxCorrect : styles.boxUnsafe : styles.boxWrong
}
- navigation.navigate("Splash", { trueFalseQuestions: tmpQuestions });
- return true;
- }, [navigation]);
-
- // Attach hardware back button handler
- useFocusEffect(
- useCallback(() => {
- // this.backHandler = BackHandler.addEventListener( 'hardwareBackPress', this.handleBackButton)
- // return () => this.backHandler?.remove()
- const backHandler = BackHandler.addEventListener(
- "hardwareBackPress",
- handleBackButton
- );
- return () => backHandler.remove();
- }, [handleBackButton])
- );
-
- const questions = route.params.results?.wrongAnswers || [];
-
- return (
-
-
-
-
- {texts.recapTitle}
-
-
-
- {questions.map((q) => (
-
- {q.id}
- {q.question}
-
-
- {q.answers.map(
- (ans) =>
- q.clicked === ans.id && (
-
- )
- )}
-
-
- ))}
-
-
-
-
-
-
-
-
+
+ return (
+
+
+
-
-
- );
-};
+
+
+
+
+ {`${texts.corrects}: ${currentResults.correct}`}
+
+
+ {`${texts.wrongs}: ${currentResults.wrong}`}
+
+
+ {`${texts.percentage}: ${Math.round(percentage)}%`}
+
+ {
+ currentResults.points ? (
+
+ {`${texts.points}: ${currentResults.points}/${currentResults.totalPoints}`}
+
+ ) : null
+ }
+
+ {currentResults.isExam ?
+
+ {currentResults.points >= 80 ? currentResults.points >= 85 ? texts.exam_passed : texts.exam_needs_oral : texts.exam_not_passed}
+ :
+ }
+
+
+ {wrongAnswers.length ?
+
+ {
+ this.props.navigation.navigate("RecapExam", {
+ wrongAnswers: wrongAnswers
+ })
+ }}/>
+ {this.handleBackButton()}
+ }
+ />
+
+ :
+
+ {this.handleBackButton()}
+ }
+ />
+
+ }
+
+
+
+
+
+ )
+ }
+}
-export default Results;
+export default Results
diff --git a/vds-app/App/screens/ResultsTrueFalse.js b/vds-app/App/screens/ResultsTrueFalse.js
index 2b78957..5837b2a 100644
--- a/vds-app/App/screens/ResultsTrueFalse.js
+++ b/vds-app/App/screens/ResultsTrueFalse.js
@@ -71,7 +71,7 @@ class Results extends React.Component {
render() {
- const questions = this.props.route.params.results?.wrongAnswers || [];
+ const questions = this.props.route?.params?.results?.wrongAnswers || [];
return (
diff --git a/vds-app/App/screens/TrueFalse.js b/vds-app/App/screens/TrueFalse.js
index 949c8c0..90c1f28 100644
--- a/vds-app/App/screens/TrueFalse.js
+++ b/vds-app/App/screens/TrueFalse.js
@@ -107,8 +107,7 @@ class Quiz extends React.Component {
componentDidMount() {
this.backHandler = BackHandler.addEventListener( 'hardwareBackPress', this.handleBackButton)
-
- const questions = this.props.route.params?.questions || [];
+ const questions = this.props.route?.params?.questions || [];
this.setState({
availableIds: questions.map(q => q.id),
activeQuestionId: questions.length ? questions[Math.floor(Math.random() * questions.length)].id : null
diff --git a/vds-app/android/app/build.gradle b/vds-app/android/app/build.gradle
index bfc95f4..0f093b5 100644
--- a/vds-app/android/app/build.gradle
+++ b/vds-app/android/app/build.gradle
@@ -92,8 +92,8 @@ android {
applicationId 'com.dslak.vdsquiz'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode 33
- versionName "3.8.5"
+ versionCode 34
+ versionName "3.8.6"
buildConfigField "String", "REACT_NATIVE_RELEASE_LEVEL", "\"${findProperty('reactNativeReleaseLevel') ?: 'stable'}\""
}
diff --git a/vds-app/app.json b/vds-app/app.json
index 9f4b2c5..e649670 100644
--- a/vds-app/app.json
+++ b/vds-app/app.json
@@ -7,7 +7,7 @@
"android",
"web"
],
- "version": "3.8.5",
+ "version": "3.8.6",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
@@ -25,7 +25,7 @@
"android": {
"icon": "./assets/icon.png",
"permissions": [],
- "versionCode": 33
+ "versionCode": 34
},
"ios": {
"icon": "./assets/iconIOS.png",
diff --git a/vds-app/package.json b/vds-app/package.json
index feae892..a3a01ca 100644
--- a/vds-app/package.json
+++ b/vds-app/package.json
@@ -1,6 +1,6 @@
{
"name": "vds-quiz",
- "version": "3.8.5",
+ "version": "3.8.6",
"license": "MIT",
"main": "node_modules/expo/AppEntry.js",
"scripts": {