Changeset View
Changeset View
Standalone View
Standalone View
src/activities/algebra_by/algebra.js
Context not available. | |||||
27 | var secondOperandVal | 27 | var secondOperandVal | ||
---|---|---|---|---|---|
28 | var firstOperandVal | 28 | var firstOperandVal | ||
29 | var operations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | 29 | var operations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | ||
30 | var OperandsEnum = { | ||||
31 | TIMES_SIGN : "\u00D7", | ||||
32 | PLUS_SIGN : "\u002B", | ||||
33 | MINUS_SIGN : "\u2212", | ||||
34 | DIVIDE_SIGN : "\u2215" | ||||
35 | } | ||||
30 | 36 | | |||
31 | var nbLevel = operations.length | 37 | var nbLevel = operations.length | ||
32 | 38 | | |||
Context not available. | |||||
40 | // currentLevel * N (N behind random) | 46 | // currentLevel * N (N behind random) | ||
41 | // where the last levels will do: | 47 | // where the last levels will do: | ||
42 | // N * currentLevel | 48 | // N * currentLevel | ||
43 | if(operand.text === "x" || operand.text === "+") | 49 | if(operand.text === OperandsEnum.TIMES_SIGN || operand.text === OperandsEnum.PLUS_SIGN) | ||
44 | nbLevel = 2 * operations.length | 50 | nbLevel = 2 * operations.length | ||
45 | else | 51 | else | ||
46 | nbLevel = operations.length | 52 | nbLevel = operations.length | ||
Context not available. | |||||
82 | { | 88 | { | ||
83 | switch(operand.text) | 89 | switch(operand.text) | ||
84 | { | 90 | { | ||
85 | case "x": | 91 | case OperandsEnum.TIMES_SIGN: | ||
86 | firstOperandVal = coreItems.bar.level | 92 | firstOperandVal = coreItems.bar.level | ||
87 | secondOperandVal = operations[coreItems.score.currentSubLevel - 1] | 93 | secondOperandVal = operations[coreItems.score.currentSubLevel - 1] | ||
88 | break; | 94 | break; | ||
89 | case "+": | 95 | case OperandsEnum.PLUS_SIGN: | ||
90 | firstOperandVal = coreItems.bar.level | 96 | firstOperandVal = coreItems.bar.level | ||
91 | secondOperandVal = operations[coreItems.score.currentSubLevel - 1] | 97 | secondOperandVal = operations[coreItems.score.currentSubLevel - 1] | ||
92 | break; | 98 | break; | ||
93 | case "-": | 99 | case OperandsEnum.MINUS_SIGN: | ||
94 | firstOperandVal = coreItems.bar.level + 9 | 100 | firstOperandVal = coreItems.bar.level + 9 | ||
95 | secondOperandVal = operations[coreItems.score.currentSubLevel - 1] | 101 | secondOperandVal = operations[coreItems.score.currentSubLevel - 1] | ||
96 | break; | 102 | break; | ||
97 | case "/": | 103 | case OperandsEnum.DIVIDE_SIGN: | ||
98 | firstOperandVal = coreItems.bar.level * operations[coreItems.score.currentSubLevel - 1] | 104 | firstOperandVal = coreItems.bar.level * operations[coreItems.score.currentSubLevel - 1] | ||
99 | secondOperandVal = coreItems.bar.level | 105 | secondOperandVal = coreItems.bar.level | ||
100 | break; | 106 | break; | ||
Context not available. | |||||
115 | function getAnswer() { | 121 | function getAnswer() { | ||
116 | switch(operand.text) | 122 | switch(operand.text) | ||
117 | { | 123 | { | ||
118 | case "x": | 124 | case OperandsEnum.TIMES_SIGN: | ||
119 | return (firstOperandVal * secondOperandVal) | 125 | return (firstOperandVal * secondOperandVal) | ||
120 | 126 | | |||
121 | case "+": | 127 | case OperandsEnum.PLUS_SIGN: | ||
122 | return (firstOperandVal + secondOperandVal) | 128 | return (firstOperandVal + secondOperandVal) | ||
123 | 129 | | |||
124 | case "-": | 130 | case OperandsEnum.MINUS_SIGN: | ||
125 | return (firstOperandVal - secondOperandVal) | 131 | return (firstOperandVal - secondOperandVal) | ||
126 | 132 | | |||
127 | case "/": | 133 | case OperandsEnum.DIVIDE_SIGN: | ||
128 | return (firstOperandVal / secondOperandVal) | 134 | return (firstOperandVal / secondOperandVal) | ||
129 | } | 135 | } | ||
130 | } | 136 | } | ||
Context not available. |