From 9e61163028b5cd11b6bfc8061ca7e8dee50db4e0 Mon Sep 17 00:00:00 2001 From: jbphet Date: Fri, 13 Jul 2018 15:05:10 -0600 Subject: [PATCH] changed how the auto-answer feature is blocked in production versions, see https://github.com/phetsims/arithmetic/issues/182 --- js/common/ArithmeticQueryParameters.js | 7 ++++++- js/common/model/ArithmeticModel.js | 18 ++++-------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/js/common/ArithmeticQueryParameters.js b/js/common/ArithmeticQueryParameters.js index 872cbcf6..1118613b 100644 --- a/js/common/ArithmeticQueryParameters.js +++ b/js/common/ArithmeticQueryParameters.js @@ -13,10 +13,15 @@ define( function( require ) { var ArithmeticQueryParameters = QueryStringMachine.getAll( { - // Automatically answer most problems to enable faster testing of level completion. + // automatically answer most problems to enable faster testing of level completion autoAnswer: { type: 'flag' } } ); + // prevent auto answer in versions that are intended for publication + if ( phet.chipper.isProduction && !phet.chipper.isDebugBuild ) { + ArithmeticQueryParameters.autoAnswer = false; + } + arithmetic.register( 'ArithmeticQueryParameters', ArithmeticQueryParameters ); return ArithmeticQueryParameters; diff --git a/js/common/model/ArithmeticModel.js b/js/common/model/ArithmeticModel.js index c7b8c43c..bf07a789 100644 --- a/js/common/model/ArithmeticModel.js +++ b/js/common/model/ArithmeticModel.js @@ -225,8 +225,8 @@ define( function( require ) { this.activeLevelModel.gameTimer.start(); // may already be running, if so this is a no-op this.refreshEmitter.emit(); - // automatically answer most of the problems if enabled - this is for testing only - this.autoAnswerIfEnabled(); + // automatically answer most of the problems if enabled - this is for testing + ArithmeticQueryParameters.autoAnswer && this.autoAnswer(); }, // @private @@ -236,16 +236,6 @@ define( function( require ) { } ); }, - // @private, check if auto answer should be performed and, if so, do it - autoAnswerIfEnabled: function() { - - // Automatically answer most of the problems if the autoAnswer query parameter was specified, but only if this is - // not a production release. - if ( ArithmeticQueryParameters.autoAnswer && window.phet.joist.sim.version.indexOf( '-' ) > 0 ) { - this.autoAnswer(); - } - }, - // @public - set the level to be played, initializing or restoring the level as appropriate setLevel: function( level ) { this.levelNumberProperty.set( level ); @@ -263,8 +253,8 @@ define( function( require ) { else { this.nextProblem(); - // automatically answer most of the problems if enabled - this is for testing only - this.autoAnswerIfEnabled(); + // automatically answer most of the problems if enabled - this is for testing + ArithmeticQueryParameters.autoAnswer && this.autoAnswer(); } },