From 0b0c193dd9d3cbb8152c3181a9224bb2cd729fbd Mon Sep 17 00:00:00 2001 From: Dslak Date: Tue, 30 Sep 2025 12:58:40 +0200 Subject: [PATCH] fix recap --- vds-app/App/components/Variables.js | 6 +- vds-app/App/index.js | 2 + vds-app/App/screens/Exam.js | 2 +- vds-app/App/screens/Recap.js | 136 ++++++---- vds-app/App/screens/RecapExam.js | 200 +++++++++++++++ vds-app/App/screens/Results.js | 319 +++++++++++++++--------- vds-app/App/screens/ResultsTrueFalse.js | 2 +- vds-app/App/screens/TrueFalse.js | 3 +- vds-app/android/app/build.gradle | 4 +- vds-app/app.json | 4 +- vds-app/package.json | 2 +- 11 files changed, 506 insertions(+), 174 deletions(-) create mode 100644 vds-app/App/screens/RecapExam.js 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) => ( -