[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

@@ -31,6 +31,9 @@ app_src += $(addprefix apps/,\
variable_box_empty_controller.cpp \
)
apps_official += apps/exam_mode_configuration_official.cpp
apps_non_official += apps/exam_mode_configuration_non_official.cpp
apps_launch_on_boarding_src += apps/apps_container_launch_on_boarding.cpp
apps_launch_default_src += apps/apps_container_launch_default.cpp
apps_prompt_none_src += apps/apps_container_prompt_none.cpp
@@ -85,7 +88,7 @@ $(BUILD_DIR)/apps/i18n.h: $(BUILD_DIR)/apps/i18n.cpp
$(eval $(call depends_on_image,apps/title_bar_view.cpp,apps/exam_icon.png))
all_app_src = $(app_src) $(epsilon_src) $(apps_launch_on_boarding_src) $(apps_launch_default_src) $(apps_prompt_none_src) $(apps_prompt_update_src) $(apps_prompt_beta_src) $(apps_settings_official) $(apps_settings_non_official) $(tests_src)
all_app_src = $(app_src) $(epsilon_src) $(apps_launch_on_boarding_src) $(apps_launch_default_src) $(apps_prompt_none_src) $(apps_prompt_update_src) $(apps_prompt_beta_src) $(apps_official) $(apps_non_official) $(tests_src)
$(call object_for,$(all_app_src)): $(BUILD_DIR)/apps/i18n.h
$(call object_for,$(all_app_src)): $(BUILD_DIR)/python/port/genhdr/qstrdefs.generated.h
@@ -98,15 +101,15 @@ apps_tests_src += $(addprefix apps/,\
# Configure variants
apps_all_src = $(app_src)
apps_all_src += $(apps_settings_official) $(apps_settings_non_official)
apps_all_src += $(apps_official) $(apps_non_official)
apps_all_src += $(apps_launch_default_src) $(apps_launch_on_boarding_src)
apps_all_src += $(apps_prompt_none_src) $(apps_prompt_update_src) $(apps_prompt_beta_src)
apps_default_src = $(app_src) $(apps_settings_non_official) $(apps_launch_default_src) $(apps_prompt_none_src)
apps_official_default_src = $(app_src) $(apps_settings_official) $(apps_launch_default_src) $(apps_prompt_none_src)
apps_onboarding_src = $(app_src) $(apps_settings_non_official) $(apps_launch_on_boarding_src) $(apps_prompt_none_src)
apps_official_onboarding_src = $(app_src) $(apps_settings_official) $(apps_launch_on_boarding_src) $(apps_prompt_none_src)
apps_onboarding_update_src = $(app_src) $(apps_settings_non_official) $(apps_launch_on_boarding_src) $(apps_prompt_update_src)
apps_official_onboarding_update_src = $(app_src) $(apps_settings_official) $(apps_launch_on_boarding_src) $(apps_prompt_update_src)
apps_onboarding_beta_src = $(app_src) $(apps_settings_non_official) $(apps_launch_on_boarding_src) $(apps_prompt_beta_src)
apps_official_onboarding_beta_src = $(app_src) $(apps_settings_official) $(apps_launch_on_boarding_src) $(apps_prompt_beta_src)
apps_default_src = $(app_src) $(apps_non_official) $(apps_launch_default_src) $(apps_prompt_none_src)
apps_official_default_src = $(app_src) $(apps_official) $(apps_launch_default_src) $(apps_prompt_none_src)
apps_onboarding_src = $(app_src) $(apps_non_official) $(apps_launch_on_boarding_src) $(apps_prompt_none_src)
apps_official_onboarding_src = $(app_src) $(apps_official) $(apps_launch_on_boarding_src) $(apps_prompt_none_src)
apps_onboarding_update_src = $(app_src) $(apps_non_official) $(apps_launch_on_boarding_src) $(apps_prompt_update_src)
apps_official_onboarding_update_src = $(app_src) $(apps_official) $(apps_launch_on_boarding_src) $(apps_prompt_update_src)
apps_onboarding_beta_src = $(app_src) $(apps_non_official) $(apps_launch_on_boarding_src) $(apps_prompt_beta_src)
apps_official_onboarding_beta_src = $(app_src) $(apps_official) $(apps_launch_on_boarding_src) $(apps_prompt_beta_src)

View File

@@ -1,6 +1,7 @@
#include "apps_container.h"
#include "apps_container_storage.h"
#include "global_preferences.h"
#include "exam_mode_configuration.h"
#include <ion.h>
#include <poincare/init.h>
#include <poincare/exception_checkpoint.h>
@@ -325,16 +326,9 @@ void AppsContainer::redrawWindow() {
}
void AppsContainer::activateExamMode(GlobalPreferences::ExamMode examMode) {
assert(examMode == GlobalPreferences::ExamMode::Standard || examMode == GlobalPreferences::ExamMode::Dutch);
assert(examMode != GlobalPreferences::ExamMode::Off && examMode != GlobalPreferences::ExamMode::Unknown);
reset();
/* The Dutch exam mode LED is supposed to be orange but we can only make
* blink "pure" colors: with RGB leds on or off (as the PWM is used for
* blinking). The closest "pure" color is Yellow. Moreover, Orange LED is
* already used when the battery is charging. Using yellow, we can assert
* that the yellow LED only means that Dutch exam mode is on and avoid
* confusing states when the battery is charging and states when the Dutch
* exam mode is on. */
Ion::LED::setColor(examMode == GlobalPreferences::ExamMode::Dutch ? KDColorYellow : KDColorRed);
Ion::LED::setColor(ExamModeConfiguration::examModeColor(examMode));
Ion::LED::setBlinking(1000, 0.1f);
}

View File

@@ -1,6 +1,7 @@
#include "calculation.h"
#include "../shared/poincare_helpers.h"
#include "../global_preferences.h"
#include "../exam_mode_configuration.h"
#include <poincare/exception_checkpoint.h>
#include <poincare/undefined.h>
#include <poincare/unreal.h>
@@ -239,8 +240,8 @@ Calculation::DisplayOutput Calculation::displayOutput(Context * context) {
(strcmp(approximateOutputText(NumberOfSignificantDigits::Maximal), Undefined::Name()) == 0 &&
strcmp(inputText(), exactOutputText()) == 0)
||
// Force all outputs to be ApproximateOnly in Dutch exam mode
GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Dutch
// Force all outputs to be ApproximateOnly if required by the exam mode configuration
ExamModeConfiguration::exactExpressionsAreForbidden(GlobalPreferences::sharedGlobalPreferences()->examMode())
||
/* If the input contains the following types, we only display the
* approximate output. */

View File

@@ -0,0 +1,27 @@
#ifndef APPS_EXAM_MODE_CONFIGURATION_H
#define APPS_EXAM_MODE_CONFIGURATION_H
#include "global_preferences.h"
#include "settings/settings_message_tree.h"
#include <apps/i18n.h>
namespace ExamModeConfiguration {
// Settings menu
extern const Settings::SettingsMessageTree s_modelExamChildren[2];
int numberOfAvailableExamMode();
GlobalPreferences::ExamMode examModeAtIndex(int index);
I18n::Message examModeActivationMessage(int index);
// Settings pop-up
I18n::Message examModeActivationWarningMessage(GlobalPreferences::ExamMode mode, int line);
// Exam mode behaviour
KDColor examModeColor(GlobalPreferences::ExamMode mode);
bool appIsForbiddenInExamMode(I18n::Message appName, GlobalPreferences::ExamMode mode);
bool exactExpressionsAreForbidden(GlobalPreferences::ExamMode mode);
}
#endif

View File

@@ -0,0 +1,38 @@
#include "exam_mode_configuration.h"
constexpr Settings::SettingsMessageTree ExamModeConfiguration::s_modelExamChildren[] = {Settings::SettingsMessageTree(I18n::Message::ActivateExamMode), Settings::SettingsMessageTree(I18n::Message::Default)};
int ExamModeConfiguration::numberOfAvailableExamMode() {
return 1;
}
GlobalPreferences::ExamMode ExamModeConfiguration::examModeAtIndex(int index) {
return GlobalPreferences::ExamMode::Standard;
}
I18n::Message ExamModeConfiguration::examModeActivationMessage(int index) {
return I18n::Message::ActivateExamMode;
}
I18n::Message ExamModeConfiguration::examModeActivationWarningMessage(GlobalPreferences::ExamMode mode, int line) {
if (mode == GlobalPreferences::ExamMode::Off) {
I18n::Message warnings[] = {I18n::Message::ExitExamMode1, I18n::Message::ExitExamMode2, I18n::Message::Default};
return warnings[line];
}
assert(mode == GlobalPreferences::ExamMode::Standard);
I18n::Message warnings[] = {I18n::Message::ActiveExamModeMessage1, I18n::Message::ActiveExamModeMessage2, I18n::Message::ActiveExamModeMessage3};
return warnings[line];
}
KDColor ExamModeConfiguration::examModeColor(GlobalPreferences::ExamMode mode) {
assert(mode == GlobalPreferences::ExamMode::Standard);
return KDColorRed;
}
bool ExamModeConfiguration::appIsForbiddenInExamMode(I18n::Message appName, GlobalPreferences::ExamMode mode) {
return false;
}
bool ExamModeConfiguration::exactExpressionsAreForbidden(GlobalPreferences::ExamMode mode) {
return false;
}

View File

@@ -0,0 +1,47 @@
#include "exam_mode_configuration.h"
constexpr Settings::SettingsMessageTree ExamModeConfiguration::s_modelExamChildren[2] = {Settings::SettingsMessageTree(I18n::Message::ActivateExamMode), Settings::SettingsMessageTree(I18n::Message::ActivateDutchExamMode)};
int ExamModeConfiguration::numberOfAvailableExamMode() {
return 2;
}
GlobalPreferences::ExamMode ExamModeConfiguration::examModeAtIndex(int index) {
return index == 0 ? GlobalPreferences::ExamMode::Standard : GlobalPreferences::ExamMode::Dutch;
}
I18n::Message ExamModeConfiguration::examModeActivationMessage(int index) {
return index == 0 ? I18n::Message::ActivateExamMode : I18n::Message::ActivateDutchExamMode;
}
I18n::Message ExamModeConfiguration::examModeActivationWarningMessage(GlobalPreferences::ExamMode mode, int line) {
if (mode == GlobalPreferences::ExamMode::Off) {
I18n::Message warnings[] = {I18n::Message::ExitExamMode1, I18n::Message::ExitExamMode2, I18n::Message::Default};
return warnings[line];
} else if (mode == GlobalPreferences::ExamMode::Standard) {
I18n::Message warnings[] = {I18n::Message::ActiveExamModeMessage1, I18n::Message::ActiveExamModeMessage2, I18n::Message::ActiveExamModeMessage3};
return warnings[line];
}
assert(mode == GlobalPreferences::ExamMode::Dutch);
I18n::Message warnings[] = {I18n::Message::ActiveDutchExamModeMessage1, I18n::Message::ActiveDutchExamModeMessage2, I18n::Message::ActiveDutchExamModeMessage3};
return warnings[line];
}
KDColor ExamModeConfiguration::examModeColor(GlobalPreferences::ExamMode mode) {
/* The Dutch exam mode LED is supposed to be orange but we can only make
* blink "pure" colors: with RGB leds on or off (as the PWM is used for
* blinking). The closest "pure" color is Yellow. Moreover, Orange LED is
* already used when the battery is charging. Using yellow, we can assert
* that the yellow LED only means that Dutch exam mode is on and avoid
* confusing states when the battery is charging and states when the Dutch
* exam mode is on. */
return mode == GlobalPreferences::ExamMode::Dutch ? KDColorYellow : KDColorRed;
}
bool ExamModeConfiguration::appIsForbiddenInExamMode(I18n::Message appName, GlobalPreferences::ExamMode mode) {
return appName == I18n::Message::CodeApp && mode == GlobalPreferences::ExamMode::Dutch;
}
bool ExamModeConfiguration::exactExpressionsAreForbidden(GlobalPreferences::ExamMode mode) {
return mode == GlobalPreferences::ExamMode::Dutch;
}

View File

@@ -1,5 +1,6 @@
#include "exam_pop_up_controller.h"
#include "apps_container.h"
#include "exam_mode_configuration.h"
#include <apps/i18n.h>
#include "global_preferences.h"
#include <assert.h>
@@ -65,10 +66,14 @@ ExamPopUpController::ContentView::ContentView(Responder * parentResponder) :
return true;
}, parentResponder), KDFont::SmallFont),
m_warningTextView(KDFont::SmallFont, I18n::Message::Warning, 0.5, 0.5, KDColorWhite, KDColorBlack),
m_messageTextView1(KDFont::SmallFont, I18n::Message::Default, 0.5, 0.5, KDColorWhite, KDColorBlack),
m_messageTextView2(KDFont::SmallFont, I18n::Message::Default, 0.5, 0.5, KDColorWhite, KDColorBlack),
m_messageTextView3(KDFont::SmallFont, I18n::Message::Default, 0.5, 0.5, KDColorWhite, KDColorBlack)
m_messageTextViews{}
{
for (int i = 0; i < k_maxNumberOfLines; i++) {
m_messageTextViews[i].setFont(KDFont::SmallFont);
m_messageTextViews[i].setAlignment(0.5f, 0.5f);
m_messageTextViews[i].setBackgroundColor(KDColorBlack);
m_messageTextViews[i].setTextColor(KDColorWhite);
}
}
void ExamPopUpController::ContentView::drawRect(KDContext * ctx, KDRect rect) const {
@@ -89,19 +94,8 @@ int ExamPopUpController::ContentView::selectedButton() {
}
void ExamPopUpController::ContentView::setMessagesForExamMode(GlobalPreferences::ExamMode mode) {
if (mode == GlobalPreferences::ExamMode::Off) {
m_messageTextView1.setMessage(I18n::Message::ExitExamMode1);
m_messageTextView2.setMessage(I18n::Message::ExitExamMode2);
m_messageTextView3.setMessage(I18n::Message::Default);
} else if (mode == GlobalPreferences::ExamMode::Standard) {
m_messageTextView1.setMessage(I18n::Message::ActiveExamModeMessage1);
m_messageTextView2.setMessage(I18n::Message::ActiveExamModeMessage2);
m_messageTextView3.setMessage(I18n::Message::ActiveExamModeMessage3);
} else {
assert(mode == GlobalPreferences::ExamMode::Dutch);
m_messageTextView1.setMessage(I18n::Message::ActiveDutchExamModeMessage1);
m_messageTextView2.setMessage(I18n::Message::ActiveDutchExamModeMessage2);
m_messageTextView3.setMessage(I18n::Message::ActiveDutchExamModeMessage3);
for (int i = 0; i < k_maxNumberOfLines; i++) {
m_messageTextViews[i].setMessage(ExamModeConfiguration::examModeActivationWarningMessage(mode, i));
}
}
@@ -113,19 +107,12 @@ View * ExamPopUpController::ContentView::subviewAtIndex(int index) {
switch (index) {
case 0:
return &m_warningTextView;
case 1:
return &m_messageTextView1;
case 2:
return &m_messageTextView2;
case 3:
return &m_messageTextView3;
case 4:
return &m_cancelButton;
case 5:
return &m_okButton;
default:
assert(false);
return nullptr;
return &m_messageTextViews[index-1];
}
}
@@ -134,9 +121,9 @@ void ExamPopUpController::ContentView::layoutSubviews(bool force) {
KDCoordinate width = bounds().width();
KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height();
m_warningTextView.setFrame(KDRect(0, k_topMargin, width, textHeight), force);
m_messageTextView1.setFrame(KDRect(0, k_topMargin+k_paragraphHeight+textHeight, width, textHeight), force);
m_messageTextView2.setFrame(KDRect(0, k_topMargin+k_paragraphHeight+2*textHeight, width, textHeight), force);
m_messageTextView3.setFrame(KDRect(0, k_topMargin+k_paragraphHeight+3*textHeight, width, textHeight), force);
for (int i = 0; i < k_maxNumberOfLines; i++) {
m_messageTextViews[i].setFrame(KDRect(0, k_topMargin+k_paragraphHeight+(i+1)*textHeight, width, textHeight), force);
}
m_cancelButton.setFrame(KDRect(k_buttonMargin, height-k_buttonMargin-k_buttonHeight, (width-3*k_buttonMargin)/2, k_buttonHeight), force);
m_okButton.setFrame(KDRect(2*k_buttonMargin+(width-3*k_buttonMargin)/2, height-k_buttonMargin-k_buttonHeight, (width-3*k_buttonMargin)/2, k_buttonHeight), force);
}

View File

@@ -41,9 +41,8 @@ private:
HighContrastButton m_cancelButton;
HighContrastButton m_okButton;
MessageTextView m_warningTextView;
MessageTextView m_messageTextView1;
MessageTextView m_messageTextView2;
MessageTextView m_messageTextView3;
constexpr static int k_maxNumberOfLines = 3;
MessageTextView m_messageTextViews[k_maxNumberOfLines];
};
ContentView m_contentView;
GlobalPreferences::ExamMode m_targetExamMode;

View File

@@ -31,6 +31,9 @@ apps_settings_non_official += $(addprefix apps/settings/,\
sub_menu/exam_mode_controller_non_official.cpp \
)
apps_official += $(apps_settings_official)
apps_non_official += $(apps_settings_non_official)
i18n_files += $(addprefix apps/settings/,\
base.de.i18n\
base.en.i18n\

View File

@@ -12,7 +12,6 @@ constexpr SettingsMessageTree s_modelEditionModeChildren[2] = {SettingsMessageTr
constexpr SettingsMessageTree s_modelFloatDisplayModeChildren[4] = {SettingsMessageTree(I18n::Message::Decimal), SettingsMessageTree(I18n::Message::Scientific), SettingsMessageTree(I18n::Message::Engineering), SettingsMessageTree(I18n::Message::SignificantFigures)};
constexpr SettingsMessageTree s_modelComplexFormatChildren[3] = {SettingsMessageTree(I18n::Message::Real), SettingsMessageTree(I18n::Message::Cartesian), SettingsMessageTree(I18n::Message::Polar)};
constexpr SettingsMessageTree s_modelFontChildren[2] = {SettingsMessageTree(I18n::Message::LargeFont), SettingsMessageTree(I18n::Message::SmallFont)};
constexpr SettingsMessageTree s_modelExamChildren[2] = {SettingsMessageTree(I18n::Message::ActivateExamMode), SettingsMessageTree(I18n::Message::ActivateDutchExamMode)};
constexpr SettingsMessageTree s_modelAboutChildren[3] = {SettingsMessageTree(I18n::Message::SoftwareVersion), SettingsMessageTree(I18n::Message::SerialNumber), SettingsMessageTree(I18n::Message::FccId)};
MainController::MainController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate) :

View File

@@ -1,4 +1,5 @@
#include "main_controller.h"
#include "../exam_mode_configuration.h"
#include <apps/i18n.h>
namespace Settings {
@@ -11,7 +12,7 @@ constexpr SettingsMessageTree s_modelMenu[] =
SettingsMessageTree(I18n::Message::Brightness),
SettingsMessageTree(I18n::Message::FontSizes, s_modelFontChildren),
SettingsMessageTree(I18n::Message::Language),
SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren),
SettingsMessageTree(I18n::Message::ExamMode, ExamModeConfiguration::s_modelExamChildren),
SettingsMessageTree(I18n::Message::BetaPopUp),
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};

View File

@@ -1,4 +1,5 @@
#include "main_controller.h"
#include "../exam_mode_configuration.h"
#include <apps/i18n.h>
namespace Settings {
@@ -11,7 +12,7 @@ constexpr SettingsMessageTree s_modelMenu[] =
SettingsMessageTree(I18n::Message::Brightness),
SettingsMessageTree(I18n::Message::FontSizes, s_modelFontChildren),
SettingsMessageTree(I18n::Message::Language),
SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren),
SettingsMessageTree(I18n::Message::ExamMode, ExamModeConfiguration::s_modelExamChildren),
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu);

View File

@@ -1,4 +1,5 @@
#include "main_controller.h"
#include "../exam_mode_configuration.h"
#include <apps/i18n.h>
namespace Settings {
@@ -11,7 +12,7 @@ constexpr SettingsMessageTree s_modelMenu[] =
SettingsMessageTree(I18n::Message::Brightness),
SettingsMessageTree(I18n::Message::FontSizes, s_modelFontChildren),
SettingsMessageTree(I18n::Message::Language),
SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren),
SettingsMessageTree(I18n::Message::ExamMode, ExamModeConfiguration::s_modelExamChildren),
SettingsMessageTree(I18n::Message::UpdatePopUp),
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};

View File

@@ -1,6 +1,7 @@
#include "exam_mode_controller.h"
#include "../../global_preferences.h"
#include "../../apps_container.h"
#include "../../exam_mode_configuration.h"
#include <apps/i18n.h>
#include <assert.h>
#include <cmath>
@@ -13,8 +14,12 @@ namespace Settings {
ExamModeController::ExamModeController(Responder * parentResponder) :
GenericSubController(parentResponder),
m_contentView(&m_selectableTableView),
m_cell{MessageTableCell(I18n::Message::ExamModeActive, KDFont::LargeFont), MessageTableCell(I18n::Message::ActivateDutchExamMode, KDFont::LargeFont)}
m_cell{}
{
for (int i = 0; i < k_maxNumberOfCells; i++) {
m_cell[i].setMessage(ExamModeConfiguration::examModeActivationMessage(i));
m_cell[i].setMessageFont(KDFont::LargeFont);
}
}
bool ExamModeController::handleEvent(Ion::Events::Event event) {
@@ -43,6 +48,10 @@ void ExamModeController::didEnterResponderChain(Responder * previousFirstRespond
// --------------------------------------------------------------------------
}
int ExamModeController::numberOfRows() const {
return ExamModeConfiguration::numberOfAvailableExamMode();
}
HighlightCell * ExamModeController::reusableCell(int index, int type) {
assert(type == 0);
assert(index >= 0 && index < k_maxNumberOfCells);
@@ -71,4 +80,13 @@ int ExamModeController::initialSelectedRow() const {
return row;
}
GlobalPreferences::ExamMode ExamModeController::examMode() {
GlobalPreferences::ExamMode mode = ExamModeConfiguration::examModeAtIndex(selectedRow());
if (GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
// If the exam mode is already on, this re-activate the same exam mode
mode = GlobalPreferences::sharedGlobalPreferences()->examMode();
}
return mode;
}
}

View File

@@ -5,14 +5,6 @@ using namespace Shared;
namespace Settings {
GlobalPreferences::ExamMode ExamModeController::examMode() {
return GlobalPreferences::ExamMode::Standard;
}
int ExamModeController::numberOfRows() const {
return 1;
}
int ExamModeController::numberOfCautionLines() const {
return k_numberOfCautionMessageLines;
}

View File

@@ -5,24 +5,6 @@ using namespace Shared;
namespace Settings {
GlobalPreferences::ExamMode ExamModeController::examMode() {
GlobalPreferences::ExamMode mode = GlobalPreferences::ExamMode::Standard;
if (GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
// If the exam mode is already on, this re-activate the same exam mode
mode = GlobalPreferences::sharedGlobalPreferences()->examMode();
} else if (m_messageTreeModel->children(selectedRow())->label() == I18n::Message::ActivateDutchExamMode) {
mode = GlobalPreferences::ExamMode::Dutch;
}
return mode;
}
int ExamModeController::numberOfRows() const {
if (GlobalPreferences::sharedGlobalPreferences()->language() != I18n::Language::EN || GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
return 1;
}
return GenericSubController::numberOfRows();
}
int ExamModeController::numberOfCautionLines() const {
return 0;
}

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());