diff --git a/app/src/main/assets/tutors/bigmath/animator_graph.json b/app/src/main/assets/tutors/bigmath/animator_graph.json index 766e31b8f..a26c25c4f 100644 --- a/app/src/main/assets/tutors/bigmath/animator_graph.json +++ b/app/src/main/assets/tutors/bigmath/animator_graph.json @@ -37,14 +37,25 @@ "preenter": [], "preexit": [], "edges": [ - { - "constraint": "", - "edge": "NEXT_DIGIT" - } + {"constraint": "", "edge": "BEGIN_PROBLEM_REGULAR"}, + {"constraint": "FTR_IS_CARRY", "edge": "BEGIN_PROBLEM_CARRY"}, + {"constraint": "FTR_IS_BORROW", "edge": "BEGIN_PROBLEM_BORROW"} + ] + }, + + "BEGIN_PROBLEM_REGULAR": { + "type": "NODE", + "COMMENT": "Regular problem with no carry or borrow.", + "maptype":"moduleMap", + "mapname": "EMPTY", + "preenter": [], + "preexit": [], + "edges": [ + {"constraint": "", "edge": "NEXT_DIGIT_R"} ] }, - "NEXT_DIGIT":{ + "NEXT_DIGIT_R":{ "COMMENT":"This node moves to the next digit in the problem.", "type":"node", "maptype":"moduleMap", @@ -53,11 +64,11 @@ "preexit" :[], "edges": [ - {"constraint":"","edge":"USER_INPUT"} + {"constraint":"","edge":"USER_INPUT_R"} ] }, - "USER_INPUT": { + "USER_INPUT_R": { "COMMENT":"Preps the tutor for user input, then waits for user input.", "type": "node", "maptype":"moduleMap", @@ -65,12 +76,12 @@ "preenter": [], "preexit": [], "edges": [ - {"constraint": "FTR_CORRECT", "edge": "CORRECT_FEEDBACK"}, - {"constraint": "", "edge": "WRONG_FEEDBACK"} + {"constraint": "FTR_CORRECT", "edge": "CORRECT_FEEDBACK_R"}, + {"constraint": "", "edge": "WRONG_FEEDBACK_R"} ] }, - "CORRECT_FEEDBACK": { + "CORRECT_FEEDBACK_R": { "COMMENT": "Provides feedback for correct response.", "type": "node", "maptype": "moduleMap", @@ -78,12 +89,12 @@ "preenter": [], "preexit": [], "edges": [ - {"constraint": "FTR_PROBLEM_DONE", "edge": "PROBLEM_CORRECT"}, // if done with problem, continue to next problem - {"constraint": "FTR_PROBLEM_HAS_MORE", "edge": "NEXT_DIGIT"} // if not done, progress to next digit + {"constraint": "FTR_PROBLEM_DONE", "edge": "PROBLEM_CORRECT_R"}, // if done with problem, continue to next problem + {"constraint": "FTR_PROBLEM_HAS_MORE", "edge": "NEXT_DIGIT_R"} // if not done, progress to next digit ] }, - "WRONG_FEEDBACK": { + "WRONG_FEEDBACK_R": { "COMMENT": "Provides feedback for wrong response.", "type": "node", "maptype": "moduleMap", @@ -91,11 +102,173 @@ "preenter": [], "preexit": [], "edges": [ - {"constraint": "", "edge": "USER_INPUT"} // go back to wait for user input + {"constraint": "", "edge": "USER_INPUT_R"} // go back to wait for user input ] }, - "PROBLEM_CORRECT": { + "PROBLEM_CORRECT_R": { + "COMMENT": "When user has completed a problem.", + "type": "node", + "maptype": "moduleMap", + "mapname": "PROBLEMCORRECT", + "preenter": [], + "preexit": [], + "edges": [ + {"constraint": "FTR_MORE_PROBLEMS", "edge": "NEXT_PROBLEM"}, // if more problems, go to next problem + {"constraint": "FTR_PROBLEMS_DONE", "edge": "NEXT_SCENE"} // if problems done, go to next scene (aka finish) + ] + }, + + // ========================== + // ====== BEGIN CARRY ====== + // ========================== + + "BEGIN_PROBLEM_CARRY": { + "type": "NODE", + "COMMENT": "Regular problem with no carry or borrow.", + "maptype":"moduleMap", + "mapname": "EMPTY", + "preenter": [], + "preexit": [], + "edges": [ + {"constraint": "", "edge": "NEXT_DIGIT_C"} + ] + }, + + // MATH_AG (c) + // MATH_AG ONE_DIGIT_C + // MATH_AG (c) TAP_THINGIES... + // MATH_AG (c) "Write a one HERE... " + // MATH_AG (s) sound files are here + // MATH_AG (s) https://drive.google.com/drive/u/0/folders/1_ZaJmkW7rioIz7gIovIfdH6OQhgXyvQw + "NEXT_DIGIT_C":{ + "COMMENT":"This node moves to the next digit in the problem.", + "type":"node", + "maptype":"moduleMap", + "mapname": "NEXTDIGIT", + "preenter":[], + "preexit" :[], + "edges": + [ + {"constraint":"","edge":"USER_INPUT_C"} + ] + }, + + "USER_INPUT_C": { + "COMMENT":"Preps the tutor for user input, then waits for user input.", + "type": "node", + "maptype":"moduleMap", + "mapname": "USERINPUT", + "preenter": [], + "preexit": [], + "edges": [ + {"constraint": "FTR_CORRECT", "edge": "CORRECT_FEEDBACK_C"}, + {"constraint": "", "edge": "WRONG_FEEDBACK_C"} + ] + }, + + "CORRECT_FEEDBACK_C": { + "COMMENT": "Provides feedback for correct response.", + "type": "node", + "maptype": "moduleMap", + "mapname": "CORRECTFEEDBACK", + "preenter": [], + "preexit": [], + "edges": [ + {"constraint": "FTR_PROBLEM_DONE", "edge": "PROBLEM_CORRECT_C"}, // if done with problem, continue to next problem + {"constraint": "FTR_PROBLEM_HAS_MORE", "edge": "NEXT_DIGIT_C"} // if not done, progress to next digit + ] + }, + + "WRONG_FEEDBACK_C": { + "COMMENT": "Provides feedback for wrong response.", + "type": "node", + "maptype": "moduleMap", + "mapname": "WRONGFEEDBACK", + "preenter": [], + "preexit": [], + "edges": [ + {"constraint": "", "edge": "USER_INPUT_C"} // go back to wait for user input + ] + }, + + "PROBLEM_CORRECT_C": { + "COMMENT": "When user has completed a problem.", + "type": "node", + "maptype": "moduleMap", + "mapname": "PROBLEMCORRECT", + "preenter": [], + "preexit": [], + "edges": [ + {"constraint": "FTR_MORE_PROBLEMS", "edge": "NEXT_PROBLEM"}, // if more problems, go to next problem + {"constraint": "FTR_PROBLEMS_DONE", "edge": "NEXT_SCENE"} // if problems done, go to next scene (aka finish) + ] + }, + + "BEGIN_PROBLEM_BORROW": { + "type": "NODE", + "COMMENT": "Regular problem with no carry or borrow.", + "maptype":"moduleMap", + "mapname": "EMPTY", + "preenter": [], + "preexit": [], + "edges": [ + {"constraint": "", "edge": "NEXT_DIGIT_B"} + ] + }, + + "NEXT_DIGIT_B":{ + "COMMENT":"This node moves to the next digit in the problem.", + "type":"node", + "maptype":"moduleMap", + "mapname": "NEXTDIGIT", + "preenter":[], + "preexit" :[], + "edges": + [ + {"constraint":"","edge":"USER_INPUT_B"} + ] + }, + + "USER_INPUT_B": { + "COMMENT":"Preps the tutor for user input, then waits for user input.", + "type": "node", + "maptype":"moduleMap", + "mapname": "USERINPUT", + "preenter": [], + "preexit": [], + "edges": [ + {"constraint": "FTR_CORRECT", "edge": "CORRECT_FEEDBACK_B"}, + {"constraint": "", "edge": "WRONG_FEEDBACK_B"} + ] + }, + + "CORRECT_FEEDBACK_B": { + "COMMENT": "Provides feedback for correct response.", + "type": "node", + "maptype": "moduleMap", + "mapname": "CORRECTFEEDBACK", + "preenter": [], + "preexit": [], + "edges": [ + {"constraint": "FTR_PROBLEM_DONE", "edge": "PROBLEM_CORRECT_B"}, // if done with problem, continue to next problem + {"constraint": "FTR_PROBLEM_HAS_MORE", "edge": "NEXT_DIGIT_B"} // if not done, progress to next digit + ] + }, + + "WRONG_FEEDBACK_B": { + "COMMENT": "Provides feedback for wrong response.", + "type": "node", + "maptype": "moduleMap", + "mapname": "WRONGFEEDBACK", + "preenter": [], + "preexit": [], + "edges": [ + {"constraint": "", "edge": "USER_INPUT_B"} // go back to wait for user input + ] + }, + + "PROBLEM_CORRECT_B": { "COMMENT": "When user has completed a problem.", "type": "node", "maptype": "moduleMap", @@ -149,6 +322,15 @@ ] }, + "EMPTY": { + "type": "MODULE", + "reuse": true, + "COMMENT": "???", + "tracks": [ + {"name": "LOG_EVENT", "type": "QUEUEDCOMMAND", "id": "SBigMath", "method": "logState", "parms": "type#node,value#EMPTY:String", "features":""} + ] + }, + "NEXTDIGIT": { "type": "MODULE", "reuse": true, diff --git a/comp_bigmath/src/main/java/cmu/xprize/comp_bigmath/BM_CONST.java b/comp_bigmath/src/main/java/cmu/xprize/comp_bigmath/BM_CONST.java index d0777026f..5ceab6181 100644 --- a/comp_bigmath/src/main/java/cmu/xprize/comp_bigmath/BM_CONST.java +++ b/comp_bigmath/src/main/java/cmu/xprize/comp_bigmath/BM_CONST.java @@ -26,13 +26,22 @@ public class BM_CONST { public static final String OPB_LOCATION = "opB"; public static final String RESULT_LOCATION = "result"; + // class for just features public static final class FEATURES { + + // for choosing which type of problem + public static final String FTR_IS_CARRY = "FTR_IS_CARRY"; + public static final String FTR_IS_BORROW = "FTR_IS_BORROW"; + + // for correct vs wrong answers public static final String FTR_CORRECT = "FTR_CORRECT"; public static final String FTR_WRONG = "FTR_WRONG"; + // for when the problem is finished, or has more to do public static final String FTR_PROBLEM_DONE = "FTR_PROBLEM_DONE"; public static final String FTR_PROBLEM_HAS_MORE = "FTR_PROBLEM_HAS_MORE"; + // for when the data source has more problems or not public static final String FTR_MORE_PROBLEMS = "FTR_MORE_PROBLEMS"; public static final String FTR_PROBLEMS_DONE = "FTR_PROBLEMS_DONE"; } diff --git a/comp_bigmath/src/main/java/cmu/xprize/comp_bigmath/CBigMath_Component.java b/comp_bigmath/src/main/java/cmu/xprize/comp_bigmath/CBigMath_Component.java index 8d7b04673..158da6a78 100644 --- a/comp_bigmath/src/main/java/cmu/xprize/comp_bigmath/CBigMath_Component.java +++ b/comp_bigmath/src/main/java/cmu/xprize/comp_bigmath/CBigMath_Component.java @@ -126,9 +126,9 @@ protected void updateDataSet(CBigMath_Data data) { // first load dataset into fields loadDataSet(data); + // features are published inside setData() {... _sal.setData() } _mechanic.setData(data); _mechanic.doAllTheThings(); - } /** @@ -141,7 +141,6 @@ protected void loadDataSet(CBigMath_Data data) { task = data.task; layout = data.layout; dataset = data.dataset; - } /** diff --git a/comp_bigmath/src/main/java/cmu/xprize/comp_bigmath/StudentActionListenerImpl.java b/comp_bigmath/src/main/java/cmu/xprize/comp_bigmath/StudentActionListenerImpl.java index ddbdcd931..3901e2828 100644 --- a/comp_bigmath/src/main/java/cmu/xprize/comp_bigmath/StudentActionListenerImpl.java +++ b/comp_bigmath/src/main/java/cmu/xprize/comp_bigmath/StudentActionListenerImpl.java @@ -12,6 +12,8 @@ import static cmu.xprize.comp_bigmath.BM_CONST.ALL_DIGITS; import static cmu.xprize.comp_bigmath.BM_CONST.FEATURES.FTR_CORRECT; +import static cmu.xprize.comp_bigmath.BM_CONST.FEATURES.FTR_IS_BORROW; +import static cmu.xprize.comp_bigmath.BM_CONST.FEATURES.FTR_IS_CARRY; import static cmu.xprize.comp_bigmath.BM_CONST.FEATURES.FTR_PROBLEM_DONE; import static cmu.xprize.comp_bigmath.BM_CONST.FEATURES.FTR_PROBLEM_HAS_MORE; import static cmu.xprize.comp_bigmath.BM_CONST.FEATURES.FTR_WRONG; @@ -73,6 +75,9 @@ public void setData(CBigMath_Data data, int numDigits) { operator = data.operation; _numDigits = numDigits; + // retract carry and borrow features... + _publisher.retractFeature(FTR_IS_CARRY); + _publisher.retractFeature(FTR_IS_BORROW); if (operator.equals("+")) setCarryLogic(operandA, operandB); else setBorrowLogic(operandA, operandB); @@ -90,7 +95,11 @@ private void setCarryLogic(int a, int b) { // if a_one + b_one > 9, we must carry to tens column _isCarryOne = getOnesDigit(a) + getOnesDigit(b) > 9; + if (_isCarryOne) { + _publisher.publishFeature(FTR_IS_CARRY); + } + if (_numDigits < 3) return; // only works for hundreds... // if (carried_ten) + a_one + b_one > 9, we must carry to the huns column _isCarryTen = (_isCarryOne ? 1 : 0) + getTensDigit(a) + getTensDigit(b) > 9; @@ -107,7 +116,11 @@ private void setBorrowLogic(int a, int b) { // if a_one < b_one, we need to borrow a ten from a_ten _isBorrowTen = getOnesDigit(a) < getOnesDigit(b); + if (_isBorrowTen) { + _publisher.publishFeature(FTR_IS_BORROW); + } + if (_numDigits < 3) return; // save this for later, when we do 3 digits // if a_ten - (borrowed_ten) < b_ten, we need to borrow a hundred from a_hun _isBorrowHun = getTensDigit(a) - (_isBorrowTen? 1 : 0) < getTensDigit(b); @@ -214,16 +227,21 @@ public void fireAction(String selection, String action, String input) { _publisher.retractFeature(FTR_PROBLEM_HAS_MORE); _publisher.publishFeature(FTR_PROBLEM_DONE); } else { + + + // ROBO_MATH MATH_AG move this logic to animator graph carry check should be moved here... + _bigMath._currentDigit = TEN_DIGIT; _publisher.retractFeature(FTR_PROBLEM_DONE); _publisher.publishFeature(FTR_PROBLEM_HAS_MORE); } - // ROBO_MATH NEXT NEXT NEXT figure out messy carry stuff + // ROBO_MATH MATH_AG move to go with logic if(_isCarryOne) { _hasWrittenOnesResult = true; // can't go to next digit unless we've written carry + // MATH_AG this should go inside "NEXT_DIGIT" _bigMath.showCarryTen(); if(!_hasCarriedToTens) { break; @@ -261,13 +279,19 @@ public void fireAction(String selection, String action, String input) { case "symbol_carry_ten": + // ROBO_MATH NEXT NEXT NEXT, there should be some behavior here + // ROBO_MATH NEXT NEXT NEXT, they should be written in any order (also, this is optional) expectedInput = _isCarryOne ? 1 : 0; // the zero won't get used... if(input.equals(String.valueOf(expectedInput))) { + // give some sort of correct feedback??? _bigMath.markDigitCorrect(TEN_CARRY_DIGIT); + // _publisher.retractFeature(FTR_WRONG); + // _publisher.publishFeature(FTR_CORRECT); _hasCarriedToTens = true; + // ROBO_MATH (xx) both of these must be done if (_hasWrittenOnesResult) { // ----------