[gbrainy] More flexibility given answers: trim spaces and case in answer by default, ignore spaces when approp
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] More flexibility given answers: trim spaces and case in answer by default, ignore spaces when approp
- Date: Sat, 19 Mar 2011 11:22:45 +0000 (UTC)
commit 4c3813d5835c0fb64afc44e6daed37da6561f2d8
Author: Jordi Mas <jmas softcatala org>
Date: Sat Mar 19 12:24:03 2011 +0100
More flexibility given answers: trim spaces and case in answer by default, ignore spaces when appropiated plus additional versions of the same answer
data/games.xml | 6 +++---
src/Core/Main/Xml/GameXml.cs | 2 +-
src/Games/Calculation/CalculationCloserFraction.cs | 2 +-
src/Games/Calculation/CalculationOperator.cs | 2 +-
src/Games/Calculation/CalculationProportions.cs | 2 +-
src/Games/Calculation/CalculationRatio.cs | 2 +-
src/Games/Calculation/CalculationTwoNumbers.cs | 5 +++--
src/Games/Logic/PuzzleBuildTriangle.cs | 3 +--
src/Games/Logic/PuzzleExtraCircle.cs | 2 +-
src/Games/Logic/PuzzleFigureLetter.cs | 3 ++-
src/Games/Logic/PuzzleFigurePattern.cs | 2 +-
src/Games/Logic/PuzzleFigures.cs | 2 +-
src/Games/Logic/PuzzleLargerShape.cs | 2 +-
src/Games/Logic/PuzzleMissingPiece.cs | 2 +-
src/Games/Logic/PuzzleMissingSlice.cs | 2 +-
src/Games/Logic/PuzzleMostInCommon.cs | 2 +-
src/Games/Logic/PuzzleNextFigure.cs | 2 +-
src/Games/Logic/PuzzlePencil.cs | 2 +-
src/Games/Logic/PuzzleQuadrilaterals.cs | 2 +-
src/Games/Logic/PuzzleSquareDots.cs | 2 +-
src/Games/Logic/PuzzleTetris.cs | 2 +-
src/Games/Logic/PuzzleTimeNow.cs | 3 +--
src/Games/Memory/MemoryColouredFigures.cs | 2 +-
src/Games/Memory/MemoryFiguresNumbers.cs | 2 +-
src/Games/Memory/MemoryIndications.cs | 2 +-
tests/Core/GameAnswerTest.cs | 2 +-
26 files changed, 31 insertions(+), 31 deletions(-)
---
diff --git a/data/games.xml b/data/games.xml
index 37cfbf9..25cf666 100644
--- a/data/games.xml
+++ b/data/games.xml
@@ -251,7 +251,7 @@
<answer>[rslt_a] | [rslt_b]</answer>
<_answer_show>[rslt_a] and [rslt_b]</_answer_show>
<answer_expression>[0-9]+</answer_expression>
- <answer_checkattributes>Trim | MatchAll</answer_checkattributes>
+ <answer_checkattributes>MatchAll</answer_checkattributes>
<_rationale>From year 1000 to year 10000, palindrome years occur at 110 year intervals except for the end of each millennium that occur at a 11 years interval.</_rationale>
</variant>
</game>
@@ -310,7 +310,7 @@
<answer_show>[answer_a], [answer_b], [answer_c], [answer_d], [answer_e]</answer_show>
<answer>[answer_a] | [answer_b] | [answer_c] | [answer_d] | [answer_e]</answer>
<answer_expression>[0-9]+</answer_expression>
- <answer_checkattributes>Trim | MatchAll</answer_checkattributes>
+ <answer_checkattributes>MatchAll</answer_checkattributes>
</variant>
</game>
@@ -408,7 +408,7 @@
<option x = "0.3" y = "0.6" width ="0.45" height ="0.1" order ="randomized">
<string _text = "[option_prefix] [option_c] and [option_d]" x = "0.05" y = "0.02" size = "large"/>
</option>
-
+ <!-- Since this a multioption the answer string is set to option | this string, what makes answer_show is not useful here -->
<_answer>[option_a] and [option_b]</_answer>
<_rationale>[option_a] and [option_b] are both multiples of [product].</_rationale>
</variant>
diff --git a/src/Core/Main/Xml/GameXml.cs b/src/Core/Main/Xml/GameXml.cs
index 1c0ae29..dca2ca9 100644
--- a/src/Core/Main/Xml/GameXml.cs
+++ b/src/Core/Main/Xml/GameXml.cs
@@ -127,7 +127,7 @@ namespace gbrainy.Core.Main.Xml
if (attrib == GameAnswerCheckAttributes.None)
return;
- Answer.CheckAttributes = attrib;
+ Answer.CheckAttributes |= attrib;
}
protected override void Initialize ()
diff --git a/src/Games/Calculation/CalculationCloserFraction.cs b/src/Games/Calculation/CalculationCloserFraction.cs
index 31ee550..bd103c8 100644
--- a/src/Games/Calculation/CalculationCloserFraction.cs
+++ b/src/Games/Calculation/CalculationCloserFraction.cs
@@ -59,7 +59,7 @@ namespace gbrainy.Games.Calculation
protected override void Initialize ()
{
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
options = new double [options_cnt * 2];
bool duplicated;
bool done = false;
diff --git a/src/Games/Calculation/CalculationOperator.cs b/src/Games/Calculation/CalculationOperator.cs
index 2db6fc5..28dde3f 100644
--- a/src/Games/Calculation/CalculationOperator.cs
+++ b/src/Games/Calculation/CalculationOperator.cs
@@ -106,7 +106,7 @@ namespace gbrainy.Games.Calculation
Answer.Correct = String.Format ("{0} | {1}", oper1, oper2);
Answer.CheckExpression = "[+*-/]";
- Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MatchAll;
Answer.CorrectShow = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} and {1}"), oper1, oper2);
}
diff --git a/src/Games/Calculation/CalculationProportions.cs b/src/Games/Calculation/CalculationProportions.cs
index 4a72fa9..d057b31 100644
--- a/src/Games/Calculation/CalculationProportions.cs
+++ b/src/Games/Calculation/CalculationProportions.cs
@@ -93,7 +93,7 @@ namespace gbrainy.Games.Calculation
}
}
- Answer.SetMultiOptionAnswer (which, options[correct_pos].ToString ());
+ Answer.SetMultiOptionAnswer (which, String.Format ("{0:##0.##}", options[which]));
// Options
double x = DrawAreaX + 0.25, y = DrawAreaY + 0.16;
diff --git a/src/Games/Calculation/CalculationRatio.cs b/src/Games/Calculation/CalculationRatio.cs
index 3795c1d..348ac87 100644
--- a/src/Games/Calculation/CalculationRatio.cs
+++ b/src/Games/Calculation/CalculationRatio.cs
@@ -83,7 +83,7 @@ namespace gbrainy.Games.Calculation
Answer.Correct = String.Format ("{0} | {1}", number_a, number_b);
Answer.CheckExpression = "[0-9]+";
- Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MatchAll;
Answer.CorrectShow = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} and {1}"), number_a, number_b);
}
diff --git a/src/Games/Calculation/CalculationTwoNumbers.cs b/src/Games/Calculation/CalculationTwoNumbers.cs
index 8825149..99db9e4 100644
--- a/src/Games/Calculation/CalculationTwoNumbers.cs
+++ b/src/Games/Calculation/CalculationTwoNumbers.cs
@@ -60,7 +60,7 @@ namespace gbrainy.Games.Calculation
protected override void Initialize ()
{
- Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MatchAll;
type = (SubGameTypes) random.Next ((int) SubGameTypes.Length);
switch (CurrentDifficulty) {
@@ -140,7 +140,8 @@ namespace gbrainy.Games.Calculation
number_b = -num_a;
Answer.Correct = String.Format ("{0} | {1}", number_a, number_b);
- Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAllInOrder;
+ Answer.CheckAttributes &= ~GameAnswerCheckAttributes.MatchAll;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MatchAllInOrder;
if (base.CheckAnswer (answer) == true)
return true;
diff --git a/src/Games/Logic/PuzzleBuildTriangle.cs b/src/Games/Logic/PuzzleBuildTriangle.cs
index f2cadba..5b007dc 100644
--- a/src/Games/Logic/PuzzleBuildTriangle.cs
+++ b/src/Games/Logic/PuzzleBuildTriangle.cs
@@ -63,8 +63,7 @@ namespace gbrainy.Games.Logic
protected override void Initialize ()
{
- Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase
- | GameAnswerCheckAttributes.MatchAll | GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MatchAll | GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
switch (CurrentDifficulty) {
case GameDifficulty.Easy:
diff --git a/src/Games/Logic/PuzzleExtraCircle.cs b/src/Games/Logic/PuzzleExtraCircle.cs
index 69502ec..da6955b 100644
--- a/src/Games/Logic/PuzzleExtraCircle.cs
+++ b/src/Games/Logic/PuzzleExtraCircle.cs
@@ -80,7 +80,7 @@ namespace gbrainy.Games.Logic
cp = new ColorPalette ();
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
cercle_colors = new Color [total_slices];
badcercle_colors = new Color [total_slices];
diff --git a/src/Games/Logic/PuzzleFigureLetter.cs b/src/Games/Logic/PuzzleFigureLetter.cs
index d20e8d9..ecd5c6d 100644
--- a/src/Games/Logic/PuzzleFigureLetter.cs
+++ b/src/Games/Logic/PuzzleFigureLetter.cs
@@ -76,7 +76,8 @@ namespace gbrainy.Games.Logic
}
Answer.CheckExpression = Answer.GetMultiOptionsExpression ();
- Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MatchAll;
+ Console.WriteLine (Answer.Correct);
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleFigurePattern.cs b/src/Games/Logic/PuzzleFigurePattern.cs
index a48376e..2ad60f4 100644
--- a/src/Games/Logic/PuzzleFigurePattern.cs
+++ b/src/Games/Logic/PuzzleFigurePattern.cs
@@ -58,7 +58,7 @@ namespace gbrainy.Games.Logic
protected override void Initialize ()
{
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
random_indices = new ArrayListIndicesRandom ((int) Figures.Last);
random_indices.Initialize ();
diff --git a/src/Games/Logic/PuzzleFigures.cs b/src/Games/Logic/PuzzleFigures.cs
index 2bee3d0..3a64509 100644
--- a/src/Games/Logic/PuzzleFigures.cs
+++ b/src/Games/Logic/PuzzleFigures.cs
@@ -57,7 +57,7 @@ namespace gbrainy.Games.Logic
random_indices = new ArrayListIndicesRandom (6);
random_indices.Initialize ();
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
StringBuilder sb = new StringBuilder (3);
diff --git a/src/Games/Logic/PuzzleLargerShape.cs b/src/Games/Logic/PuzzleLargerShape.cs
index ede0afa..7c83320 100644
--- a/src/Games/Logic/PuzzleLargerShape.cs
+++ b/src/Games/Logic/PuzzleLargerShape.cs
@@ -125,7 +125,7 @@ namespace gbrainy.Games.Logic
protected override void Initialize ()
{
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
palette = new ColorPalette ();
switch (random.Next (2)) {
diff --git a/src/Games/Logic/PuzzleMissingPiece.cs b/src/Games/Logic/PuzzleMissingPiece.cs
index 20fbe63..f0d5ac0 100644
--- a/src/Games/Logic/PuzzleMissingPiece.cs
+++ b/src/Games/Logic/PuzzleMissingPiece.cs
@@ -53,7 +53,7 @@ namespace gbrainy.Games.Logic
protected override void Initialize ()
{
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption| GameAnswerCheckAttributes.IgnoreSpaces;
random_indices = new ArrayListIndicesRandom (3);
random_indices.Initialize ();
diff --git a/src/Games/Logic/PuzzleMissingSlice.cs b/src/Games/Logic/PuzzleMissingSlice.cs
index 21ac44b..998046f 100644
--- a/src/Games/Logic/PuzzleMissingSlice.cs
+++ b/src/Games/Logic/PuzzleMissingSlice.cs
@@ -85,7 +85,7 @@ namespace gbrainy.Games.Logic
random_indices.Initialize ();
ans_pos = random.Next (possible_answers);
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
Answer.SetMultiOptionAnswer (ans_pos, Answer.GetFigureName (ans_pos));
bad_answers = new int [possible_answers * items_per_slice];
diff --git a/src/Games/Logic/PuzzleMostInCommon.cs b/src/Games/Logic/PuzzleMostInCommon.cs
index b73d6ec..2cdaa92 100644
--- a/src/Games/Logic/PuzzleMostInCommon.cs
+++ b/src/Games/Logic/PuzzleMostInCommon.cs
@@ -102,7 +102,7 @@ namespace gbrainy.Games.Logic
array_good.AddRange (new Element [] {Element.SmallCircle, Element.SmallCircle, Element.SmallCircle,
Element.MediumCircle,Element.MediumCircle, Element.MediumCircleWithChild, Element.MediumCircleWithChild});
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
// Four random samples with equal elements
questions = new ArrayList ();
diff --git a/src/Games/Logic/PuzzleNextFigure.cs b/src/Games/Logic/PuzzleNextFigure.cs
index 50dcdaf..2834fcc 100644
--- a/src/Games/Logic/PuzzleNextFigure.cs
+++ b/src/Games/Logic/PuzzleNextFigure.cs
@@ -70,7 +70,7 @@ namespace gbrainy.Games.Logic
{
random_indices = new ArrayListIndicesRandom ((int) Figures.Last);
random_indices.Initialize ();
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
for (int i = 0; i < (int) Figures.Last; i++)
{
diff --git a/src/Games/Logic/PuzzlePencil.cs b/src/Games/Logic/PuzzlePencil.cs
index 2abe422..72054b3 100644
--- a/src/Games/Logic/PuzzlePencil.cs
+++ b/src/Games/Logic/PuzzlePencil.cs
@@ -49,7 +49,7 @@ namespace gbrainy.Games.Logic
random_indices = new ArrayListIndicesRandom (figures);
random_indices.Initialize ();
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
for (int i = 0; i < random_indices.Count; i++) {
if (random_indices[i] != answer_index)
diff --git a/src/Games/Logic/PuzzleQuadrilaterals.cs b/src/Games/Logic/PuzzleQuadrilaterals.cs
index c39c950..20ccbf3 100644
--- a/src/Games/Logic/PuzzleQuadrilaterals.cs
+++ b/src/Games/Logic/PuzzleQuadrilaterals.cs
@@ -59,7 +59,7 @@ namespace gbrainy.Games.Logic
protected override void Initialize ()
{
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
random_indices = new ArrayListIndicesRandom ((int) Figures.Last);
random_indices.Initialize ();
diff --git a/src/Games/Logic/PuzzleSquareDots.cs b/src/Games/Logic/PuzzleSquareDots.cs
index 05cf361..4905e35 100644
--- a/src/Games/Logic/PuzzleSquareDots.cs
+++ b/src/Games/Logic/PuzzleSquareDots.cs
@@ -212,7 +212,7 @@ namespace gbrainy.Games.Logic
protected override void Initialize ()
{
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
possible_answers = new ArrayListIndicesRandom (3);
possible_answers.Initialize ();
diff --git a/src/Games/Logic/PuzzleTetris.cs b/src/Games/Logic/PuzzleTetris.cs
index b7c123c..1813455 100644
--- a/src/Games/Logic/PuzzleTetris.cs
+++ b/src/Games/Logic/PuzzleTetris.cs
@@ -49,7 +49,7 @@ namespace gbrainy.Games.Logic
protected override void Initialize ()
{
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
random_indices_questions = new ArrayListIndicesRandom (4);
random_indices_questions.Initialize ();
diff --git a/src/Games/Logic/PuzzleTimeNow.cs b/src/Games/Logic/PuzzleTimeNow.cs
index 6f9f1f0..370d52c 100644
--- a/src/Games/Logic/PuzzleTimeNow.cs
+++ b/src/Games/Logic/PuzzleTimeNow.cs
@@ -70,8 +70,7 @@ namespace gbrainy.Games.Logic
// http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.aspx
// For 12-hour clock format use {0:%h} and for 24-hour clock format use {0:%H}. The date formats {0:h} and {0:H} are invalid.
Answer.Correct = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0:h tt}"), ans);
-
- Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.IgnoreSpaces;
+ Answer.CheckAttributes = GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.IgnoreSpaces;
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Memory/MemoryColouredFigures.cs b/src/Games/Memory/MemoryColouredFigures.cs
index 311db29..dcfe6c5 100644
--- a/src/Games/Memory/MemoryColouredFigures.cs
+++ b/src/Games/Memory/MemoryColouredFigures.cs
@@ -63,7 +63,7 @@ namespace gbrainy.Games.Memory
protected override void Initialize ()
{
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
switch (CurrentDifficulty) {
case GameDifficulty.Easy:
diff --git a/src/Games/Memory/MemoryFiguresNumbers.cs b/src/Games/Memory/MemoryFiguresNumbers.cs
index 35c76c9..8b2b264 100644
--- a/src/Games/Memory/MemoryFiguresNumbers.cs
+++ b/src/Games/Memory/MemoryFiguresNumbers.cs
@@ -47,7 +47,7 @@ namespace gbrainy.Games.Memory
protected override void Initialize ()
{
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
switch (CurrentDifficulty) {
case GameDifficulty.Easy:
diff --git a/src/Games/Memory/MemoryIndications.cs b/src/Games/Memory/MemoryIndications.cs
index bf7e970..6c79ae9 100644
--- a/src/Games/Memory/MemoryIndications.cs
+++ b/src/Games/Memory/MemoryIndications.cs
@@ -176,7 +176,7 @@ namespace gbrainy.Games.Memory
indications[2] = new Indication (Indication.Type.Turn, second_turn); // up or down
indications[3] = new Indication (Indication.Type.Turn, random.Next (2)); // right or left
- Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
+ Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
if (CurrentDifficulty==GameDifficulty.Easy) {
indications[4] = new Indication (Indication.Type.End, 1);
diff --git a/tests/Core/GameAnswerTest.cs b/tests/Core/GameAnswerTest.cs
index 7f97a17..61f9aa9 100644
--- a/tests/Core/GameAnswerTest.cs
+++ b/tests/Core/GameAnswerTest.cs
@@ -25,7 +25,7 @@ using gbrainy.Core.Main;
namespace gbrainyTest
{
[TestFixture]
- public class GameTest : UnitTestSupport
+ public class GameAnswerTest : UnitTestSupport
{
[TestFixtureSetUp]
public void Construct ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]