diff --git a/src/activities/algebra_by/AlgebraBy.qml b/src/activities/algebra_by/AlgebraBy.qml --- a/src/activities/algebra_by/AlgebraBy.qml +++ b/src/activities/algebra_by/AlgebraBy.qml @@ -23,9 +23,10 @@ import "../../core" import "../algebra_by" +import "algebra.js" as Activity Algebra { onStart: { - operand.text = "x" + operand.text = Activity.OperandsEnum.TIMES_SIGN } } diff --git a/src/activities/algebra_by/algebra.js b/src/activities/algebra_by/algebra.js --- a/src/activities/algebra_by/algebra.js +++ b/src/activities/algebra_by/algebra.js @@ -27,6 +27,12 @@ var secondOperandVal var firstOperandVal var operations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +var OperandsEnum = { + TIMES_SIGN : "\u00D7", + PLUS_SIGN : "\u002B", + MINUS_SIGN : "\u2212", + DIVIDE_SIGN : "\u2215" +} var nbLevel = operations.length @@ -40,7 +46,7 @@ // currentLevel * N (N behind random) // where the last levels will do: // N * currentLevel - if(operand.text === "x" || operand.text === "+") + if(operand.text === OperandsEnum.TIMES_SIGN || operand.text === OperandsEnum.PLUS_SIGN) nbLevel = 2 * operations.length else nbLevel = operations.length @@ -82,19 +88,19 @@ { switch(operand.text) { - case "x": + case OperandsEnum.TIMES_SIGN: firstOperandVal = coreItems.bar.level secondOperandVal = operations[coreItems.score.currentSubLevel - 1] break; - case "+": + case OperandsEnum.PLUS_SIGN: firstOperandVal = coreItems.bar.level secondOperandVal = operations[coreItems.score.currentSubLevel - 1] break; - case "-": + case OperandsEnum.MINUS_SIGN: firstOperandVal = coreItems.bar.level + 9 secondOperandVal = operations[coreItems.score.currentSubLevel - 1] break; - case "/": + case OperandsEnum.DIVIDE_SIGN: firstOperandVal = coreItems.bar.level * operations[coreItems.score.currentSubLevel - 1] secondOperandVal = coreItems.bar.level break; @@ -115,16 +121,16 @@ function getAnswer() { switch(operand.text) { - case "x": + case OperandsEnum.TIMES_SIGN: return (firstOperandVal * secondOperandVal) - case "+": + case OperandsEnum.PLUS_SIGN: return (firstOperandVal + secondOperandVal) - case "-": + case OperandsEnum.MINUS_SIGN: return (firstOperandVal - secondOperandVal) - case "/": + case OperandsEnum.DIVIDE_SIGN: return (firstOperandVal / secondOperandVal) } } diff --git a/src/activities/algebra_div/AlgebraDiv.qml b/src/activities/algebra_div/AlgebraDiv.qml --- a/src/activities/algebra_div/AlgebraDiv.qml +++ b/src/activities/algebra_div/AlgebraDiv.qml @@ -22,9 +22,10 @@ import "../../core" import "../algebra_by/" +import "../algebra_by/algebra.js" as Activity Algebra { onStart: { - operand.text = "/" + operand.text = Activity.OperandsEnum.DIVIDE_SIGN } } diff --git a/src/activities/algebra_minus/AlgebraMinus.qml b/src/activities/algebra_minus/AlgebraMinus.qml --- a/src/activities/algebra_minus/AlgebraMinus.qml +++ b/src/activities/algebra_minus/AlgebraMinus.qml @@ -23,10 +23,10 @@ import "../../core" import "../algebra_by/" - +import "../algebra_by/algebra.js" as Activity Algebra { onStart: { - operand.text = "-" + operand.text = Activity.OperandsEnum.MINUS_SIGN } } diff --git a/src/activities/algebra_plus/AlgebraPlus.qml b/src/activities/algebra_plus/AlgebraPlus.qml --- a/src/activities/algebra_plus/AlgebraPlus.qml +++ b/src/activities/algebra_plus/AlgebraPlus.qml @@ -22,9 +22,10 @@ import "../../core" import "../algebra_by/" +import "../algebra_by/algebra.js" as Activity Algebra { onStart: { - operand.text = "+" + operand.text = Activity.OperandsEnum.PLUS_SIGN } }