[apps] Gather all code regarding exam mode in ExamModeCOnfiguration file

This commit is contained in:
Émilie Feral
2020-02-10 10:41:38 +01:00
committed by Léa Saviot
parent 541acb6a7c
commit e17ae9024e
17 changed files with 181 additions and 86 deletions

View File

@@ -1,6 +1,7 @@
#include "equation_store.h"
#include "../constant.h"
#include "../shared/poincare_helpers.h"
#include "../exam_mode_configuration.h"
#include "../global_preferences.h"
#include <limits.h>
@@ -224,8 +225,8 @@ EquationStore::Error EquationStore::privateExactSolve(Poincare::Context * contex
}
}
// Create the results' layouts
// In Dutch exam mode, display only approximate solutions
bool forbidExactSolutions = GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Dutch;
// Some exam mode configuration requires to display only approximate solutions
bool forbidExactSolutions = ExamModeConfiguration::exactExpressionsAreForbidden(GlobalPreferences::sharedGlobalPreferences()->examMode());
int solutionIndex = 0;
int initialNumberOfSolutions = m_numberOfSolutions <= k_maxNumberOfExactSolutions ? m_numberOfSolutions : -1;
// We iterate through the solutions and the potential delta
@@ -244,8 +245,9 @@ EquationStore::Error EquationStore::privateExactSolve(Poincare::Context * contex
char approximateBuffer[::Constant::MaxSerializedExpressionSize];
m_exactSolutionExactLayouts[solutionIndex].serializeForParsing(exactBuffer, ::Constant::MaxSerializedExpressionSize);
m_exactSolutionApproximateLayouts[solutionIndex].serializeForParsing(approximateBuffer, ::Constant::MaxSerializedExpressionSize);
/* Cheat: declare exact and approximate solutions to be identical in
* Dutch exam mode to display only the approximate solutions. */
/* Cheat: declare exact and approximate solutions to be identical in when
* 'forbidExactSolutions' is true to display only the approximate
* solutions. */
m_exactSolutionIdentity[solutionIndex] = forbidExactSolutions || strcmp(exactBuffer, approximateBuffer) == 0;
if (!m_exactSolutionIdentity[solutionIndex]) {
m_exactSolutionEquality[solutionIndex] = Expression::ParsedExpressionsAreEqual(exactBuffer, approximateBuffer, context, updatedComplexFormat(context), preferences->angleUnit());