@oat-sa/tao-core-ui 1.67.0 → 1.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ckeditor/ckConfigurator.js +10 -1
- package/dist/maths/calculator/basicCalculator.js +4 -4
- package/dist/maths/calculator/calculatorComponent.js +22 -25
- package/dist/maths/calculator/core/board.js +12329 -720
- package/dist/maths/calculator/core/labels.js +7924 -138
- package/dist/maths/calculator/core/plugin.js +4 -5
- package/dist/maths/calculator/css/calculator.css +18 -5
- package/dist/maths/calculator/css/calculator.css.map +1 -1
- package/dist/maths/calculator/defaultCalculator.js +10 -6
- package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +23 -25
- package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +7979 -194
- package/dist/maths/calculator/scientificCalculator.js +7 -12
- package/package.json +5 -7
- package/src/ckeditor/ckConfigurator.js +11 -4
- package/src/maths/calculator/basicCalculator.js +1 -4
- package/src/maths/calculator/calculatorComponent.js +49 -60
- package/src/maths/calculator/core/board.js +372 -493
- package/src/maths/calculator/core/labels.js +46 -48
- package/src/maths/calculator/core/plugin.js +3 -5
- package/src/maths/calculator/core/tpl/terms.tpl +7 -1
- package/src/maths/calculator/css/calculator.css +18 -5
- package/src/maths/calculator/css/calculator.css.map +1 -1
- package/src/maths/calculator/defaultCalculator.js +7 -9
- package/src/maths/calculator/plugins/keyboard/templateKeyboard/defaultTemplate.tpl +3 -3
- package/src/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +17 -20
- package/src/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +102 -108
- package/src/maths/calculator/scientificCalculator.js +2 -10
- package/src/maths/calculator/scss/calculator.scss +14 -1
- package/src/maths/calculator/tpl/basicKeyboard.tpl +3 -3
- package/src/maths/calculator/tpl/scientificKeyboard.tpl +4 -4
- package/dist/maths/calculator/core/areaBroker.js +0 -43
- package/dist/maths/calculator/core/expression.js +0 -463
- package/dist/maths/calculator/core/terms.js +0 -456
- package/dist/maths/calculator/core/tokenizer.js +0 -229
- package/dist/maths/calculator/core/tokens.js +0 -167
- package/dist/maths/calculator/plugins/core/degrad.js +0 -71
- package/dist/maths/calculator/plugins/core/history.js +0 -149
- package/dist/maths/calculator/plugins/core/remind.js +0 -76
- package/dist/maths/calculator/plugins/core/stepNavigation.js +0 -148
- package/dist/maths/calculator/plugins/modifiers/pow10.js +0 -136
- package/dist/maths/calculator/plugins/modifiers/sign.js +0 -314
- package/dist/maths/calculator/pluginsLoader.js +0 -47
- package/src/maths/calculator/core/areaBroker.js +0 -38
- package/src/maths/calculator/core/expression.js +0 -430
- package/src/maths/calculator/core/terms.js +0 -459
- package/src/maths/calculator/core/tokenizer.js +0 -245
- package/src/maths/calculator/core/tokens.js +0 -178
- package/src/maths/calculator/plugins/core/degrad.js +0 -90
- package/src/maths/calculator/plugins/core/history.js +0 -166
- package/src/maths/calculator/plugins/core/remind.js +0 -96
- package/src/maths/calculator/plugins/core/stepNavigation.js +0 -175
- package/src/maths/calculator/plugins/modifiers/pow10.js +0 -143
- package/src/maths/calculator/plugins/modifiers/sign.js +0 -339
- package/src/maths/calculator/pluginsLoader.js +0 -46
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
define(['ui/maths/calculator/core/terms'], function (registeredTerms) { 'use strict';
|
|
2
|
-
|
|
3
|
-
registeredTerms = registeredTerms && Object.prototype.hasOwnProperty.call(registeredTerms, 'default') ? registeredTerms['default'] : registeredTerms;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* This program is free software; you can redistribute it and/or
|
|
7
|
-
* modify it under the terms of the GNU General Public License
|
|
8
|
-
* as published by the Free Software Foundation; under version 2
|
|
9
|
-
* of the License (non-upgradable).
|
|
10
|
-
*
|
|
11
|
-
* This program is distributed in the hope that it will be useful,
|
|
12
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
-
* GNU General Public License for more details.
|
|
15
|
-
*
|
|
16
|
-
* You should have received a copy of the GNU General Public License
|
|
17
|
-
* along with this program; if not, write to the Free Software
|
|
18
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
19
|
-
*
|
|
20
|
-
* Copyright (c) 2019 Open Assessment Technologies SA ;
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* List of helpers that apply on tokens
|
|
25
|
-
* @type {Object}
|
|
26
|
-
*/
|
|
27
|
-
var tokensHelper = {
|
|
28
|
-
/**
|
|
29
|
-
* Identifies the type of a given token
|
|
30
|
-
* @param {String|Object} token
|
|
31
|
-
* @returns {String|null}
|
|
32
|
-
*/
|
|
33
|
-
getType: function getType(token) {
|
|
34
|
-
var type, term;
|
|
35
|
-
if ('string' !== typeof token) {
|
|
36
|
-
type = token && token.type || null;
|
|
37
|
-
term = registeredTerms[type];
|
|
38
|
-
return term && term.type || type;
|
|
39
|
-
}
|
|
40
|
-
return token;
|
|
41
|
-
},
|
|
42
|
-
/**
|
|
43
|
-
* Checks if the type is related to a digit value
|
|
44
|
-
* @param {String|Object} type
|
|
45
|
-
* @returns {Boolean}
|
|
46
|
-
*/
|
|
47
|
-
isDigit: function isDigit(type) {
|
|
48
|
-
return tokensHelper.getType(type) === 'digit';
|
|
49
|
-
},
|
|
50
|
-
/**
|
|
51
|
-
* Checks if the type is related to an operator
|
|
52
|
-
* @param {String|Object} type
|
|
53
|
-
* @returns {Boolean}
|
|
54
|
-
*/
|
|
55
|
-
isOperator: function isOperator(type) {
|
|
56
|
-
return tokensHelper.getType(type) === 'operator';
|
|
57
|
-
},
|
|
58
|
-
/**
|
|
59
|
-
* Checks if the type is related to an operand
|
|
60
|
-
* @param {String|Object} type
|
|
61
|
-
* @returns {Boolean}
|
|
62
|
-
*/
|
|
63
|
-
isOperand: function isOperand(type) {
|
|
64
|
-
type = tokensHelper.getType(type);
|
|
65
|
-
return type !== 'operator' && type !== 'aggregator' && type !== 'separator';
|
|
66
|
-
},
|
|
67
|
-
/**
|
|
68
|
-
* Checks if the type is related to an operand
|
|
69
|
-
* @param {String|Object} type
|
|
70
|
-
* @returns {Boolean}
|
|
71
|
-
*/
|
|
72
|
-
isValue: function isValue(type) {
|
|
73
|
-
type = tokensHelper.getType(type);
|
|
74
|
-
return type === 'digit' || type === 'constant' || type === 'variable' || type === 'term' || type === 'error';
|
|
75
|
-
},
|
|
76
|
-
/**
|
|
77
|
-
* Checks if the type is related to an aggregator
|
|
78
|
-
* @param {String|Object} type
|
|
79
|
-
* @returns {Boolean}
|
|
80
|
-
*/
|
|
81
|
-
isAggregator: function isAggregator(type) {
|
|
82
|
-
return tokensHelper.getType(type) === 'aggregator';
|
|
83
|
-
},
|
|
84
|
-
/**
|
|
85
|
-
* Checks if the type is related to an error
|
|
86
|
-
* @param {String|Object} type
|
|
87
|
-
* @returns {Boolean}
|
|
88
|
-
*/
|
|
89
|
-
isError: function isError(type) {
|
|
90
|
-
return tokensHelper.getType(type) === 'error';
|
|
91
|
-
},
|
|
92
|
-
/**
|
|
93
|
-
* Checks if the type is related to a constant
|
|
94
|
-
* @param {String|Object} type
|
|
95
|
-
* @returns {Boolean}
|
|
96
|
-
*/
|
|
97
|
-
isConstant: function isConstant(type) {
|
|
98
|
-
return tokensHelper.getType(type) === 'constant';
|
|
99
|
-
},
|
|
100
|
-
/**
|
|
101
|
-
* Checks if the type is related to a variable
|
|
102
|
-
* @param {String|Object} type
|
|
103
|
-
* @returns {Boolean}
|
|
104
|
-
*/
|
|
105
|
-
isVariable: function isVariable(type) {
|
|
106
|
-
type = tokensHelper.getType(type);
|
|
107
|
-
return type === 'variable' || type === 'term';
|
|
108
|
-
},
|
|
109
|
-
/**
|
|
110
|
-
* Checks if the type is related to a function
|
|
111
|
-
* @param {String|Object} type
|
|
112
|
-
* @returns {Boolean}
|
|
113
|
-
*/
|
|
114
|
-
isFunction: function isFunction(type) {
|
|
115
|
-
return tokensHelper.getType(type) === 'function';
|
|
116
|
-
},
|
|
117
|
-
/**
|
|
118
|
-
* Checks if the type is related to an identifier
|
|
119
|
-
* @param {String|Object} type
|
|
120
|
-
* @returns {Boolean}
|
|
121
|
-
*/
|
|
122
|
-
isIdentifier: function isIdentifier(type) {
|
|
123
|
-
type = tokensHelper.getType(type);
|
|
124
|
-
return type === 'constant' || type === 'variable' || type === 'term' || type === 'function' || type === 'error';
|
|
125
|
-
},
|
|
126
|
-
/**
|
|
127
|
-
* Checks if the type is related to a separator
|
|
128
|
-
* @param {String|Object} type
|
|
129
|
-
* @returns {Boolean}
|
|
130
|
-
*/
|
|
131
|
-
isSeparator: function isSeparator(type) {
|
|
132
|
-
type = tokensHelper.getType(type);
|
|
133
|
-
return type === 'operator' || type === 'aggregator' || type === 'separator';
|
|
134
|
-
},
|
|
135
|
-
/**
|
|
136
|
-
* Checks if the type is related to a modifier
|
|
137
|
-
* @param {String|Object} type
|
|
138
|
-
* @returns {Boolean}
|
|
139
|
-
*/
|
|
140
|
-
isModifier: function isModifier(type) {
|
|
141
|
-
type = tokensHelper.getType(type);
|
|
142
|
-
return type === 'operator' || type === 'function';
|
|
143
|
-
},
|
|
144
|
-
/**
|
|
145
|
-
* Ensures an expression is a string. If a token or a descriptor is provided, extract the value.
|
|
146
|
-
* @param {String|Number|Object} expression
|
|
147
|
-
* @returns {String}
|
|
148
|
-
*/
|
|
149
|
-
stringValue: function stringValue(expression) {
|
|
150
|
-
var type = typeof expression;
|
|
151
|
-
if (type !== 'string') {
|
|
152
|
-
if (expression && 'undefined' !== typeof expression.value) {
|
|
153
|
-
expression = expression.value;
|
|
154
|
-
} else if (expression && 'undefined' !== typeof expression.result) {
|
|
155
|
-
expression = expression.result;
|
|
156
|
-
} else if (type === 'object' || type === 'undefined' || expression === null) {
|
|
157
|
-
expression = '';
|
|
158
|
-
}
|
|
159
|
-
expression = String(expression);
|
|
160
|
-
}
|
|
161
|
-
return expression;
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
return tokensHelper;
|
|
166
|
-
|
|
167
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
define(['i18n', 'util/namespace', 'ui/maths/calculator/core/plugin'], function (__, nsHelper, pluginFactory) { 'use strict';
|
|
2
|
-
|
|
3
|
-
__ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
|
|
4
|
-
nsHelper = nsHelper && Object.prototype.hasOwnProperty.call(nsHelper, 'default') ? nsHelper['default'] : nsHelper;
|
|
5
|
-
pluginFactory = pluginFactory && Object.prototype.hasOwnProperty.call(pluginFactory, 'default') ? pluginFactory['default'] : pluginFactory;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This program is free software; you can redistribute it and/or
|
|
9
|
-
* modify it under the terms of the GNU General Public License
|
|
10
|
-
* as published by the Free Software Foundation; under version 2
|
|
11
|
-
* of the License (non-upgradable).
|
|
12
|
-
*
|
|
13
|
-
* This program is distributed in the hope that it will be useful,
|
|
14
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
* GNU General Public License for more details.
|
|
17
|
-
*
|
|
18
|
-
* You should have received a copy of the GNU General Public License
|
|
19
|
-
* along with this program; if not, write to the Free Software
|
|
20
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
21
|
-
*
|
|
22
|
-
* Copyright (c) 2018 Open Assessment Technologies SA ;
|
|
23
|
-
*/
|
|
24
|
-
var pluginName = 'degrad';
|
|
25
|
-
var degrad = pluginFactory({
|
|
26
|
-
name: pluginName,
|
|
27
|
-
/**
|
|
28
|
-
* Called when the plugin is installing in its host.
|
|
29
|
-
*/
|
|
30
|
-
install: function install() {
|
|
31
|
-
var calculator = this.getCalculator();
|
|
32
|
-
calculator.setCommand('degree', __('Degree'), __('Set the trigonometric function to work in degrees')).setCommand('radian', __('Radian'), __('Set the trigonometric function to work in radians'));
|
|
33
|
-
},
|
|
34
|
-
/**
|
|
35
|
-
* Called when the plugin should be initialized.
|
|
36
|
-
*/
|
|
37
|
-
init: function init() {
|
|
38
|
-
var calculator = this.getCalculator();
|
|
39
|
-
function getMathsConfig() {
|
|
40
|
-
var config = calculator.getConfig();
|
|
41
|
-
if (!config.maths) {
|
|
42
|
-
config.maths = {};
|
|
43
|
-
}
|
|
44
|
-
return config.maths;
|
|
45
|
-
}
|
|
46
|
-
function setupMathsEvaluator() {
|
|
47
|
-
var config = calculator.getConfig();
|
|
48
|
-
var degree = config.maths && config.maths.degree;
|
|
49
|
-
calculator.setState('degree', degree).setState('radian', !degree).setupMathsEvaluator();
|
|
50
|
-
}
|
|
51
|
-
setupMathsEvaluator();
|
|
52
|
-
calculator.on(nsHelper.namespaceAll('command-degree', pluginName), function () {
|
|
53
|
-
getMathsConfig().degree = true;
|
|
54
|
-
setupMathsEvaluator();
|
|
55
|
-
}).on(nsHelper.namespaceAll('command-radian', pluginName), function () {
|
|
56
|
-
getMathsConfig().degree = false;
|
|
57
|
-
setupMathsEvaluator();
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
/**
|
|
61
|
-
* Called when the plugin is destroyed. Mostly when the host is destroyed itself.
|
|
62
|
-
*/
|
|
63
|
-
destroy: function destroy() {
|
|
64
|
-
var calculator = this.getCalculator();
|
|
65
|
-
calculator.deleteCommand('degree').deleteCommand('radian').setState('degree', false).setState('radian', false).off('.' + pluginName);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
return degrad;
|
|
70
|
-
|
|
71
|
-
});
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
define(['lodash', 'i18n', 'util/namespace', 'ui/maths/calculator/core/plugin'], function (_, __, nsHelper, pluginFactory) { 'use strict';
|
|
2
|
-
|
|
3
|
-
_ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
|
|
4
|
-
__ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
|
|
5
|
-
nsHelper = nsHelper && Object.prototype.hasOwnProperty.call(nsHelper, 'default') ? nsHelper['default'] : nsHelper;
|
|
6
|
-
pluginFactory = pluginFactory && Object.prototype.hasOwnProperty.call(pluginFactory, 'default') ? pluginFactory['default'] : pluginFactory;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* This program is free software; you can redistribute it and/or
|
|
10
|
-
* modify it under the terms of the GNU General Public License
|
|
11
|
-
* as published by the Free Software Foundation; under version 2
|
|
12
|
-
* of the License (non-upgradable).
|
|
13
|
-
*
|
|
14
|
-
* This program is distributed in the hope that it will be useful,
|
|
15
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
-
* GNU General Public License for more details.
|
|
18
|
-
*
|
|
19
|
-
* You should have received a copy of the GNU General Public License
|
|
20
|
-
* along with this program; if not, write to the Free Software
|
|
21
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
22
|
-
*
|
|
23
|
-
* Copyright (c) 2018 Open Assessment Technologies SA ;
|
|
24
|
-
*/
|
|
25
|
-
var pluginName = 'history';
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Defines an entry in the history
|
|
29
|
-
* @typedef {Object} historyEntry
|
|
30
|
-
* @property {String} expression - The expression that has been extracted when the entry was created
|
|
31
|
-
* @property {Object} variables - The list of variables that has been extracted when the entry was created
|
|
32
|
-
* @property {String} [current] - The current edited expression if the entry is modified
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
var history = pluginFactory({
|
|
36
|
-
name: pluginName,
|
|
37
|
-
/**
|
|
38
|
-
* Called when the plugin is installing in its host.
|
|
39
|
-
*/
|
|
40
|
-
install: function install() {
|
|
41
|
-
var calculator = this.getCalculator();
|
|
42
|
-
calculator.setCommand('historyClear', __('Clear History'), __('Clear history')).setCommand('historyGet', __('Get History'), __('Get the history list')).setCommand('historyUp', __('Previous'), __('Remind the previous expression in the history')).setCommand('historyDown', __('Next'), __('Remind the next expression in the history'));
|
|
43
|
-
},
|
|
44
|
-
/**
|
|
45
|
-
* Called when the plugin should be initialized.
|
|
46
|
-
*/
|
|
47
|
-
init: function init() {
|
|
48
|
-
var calculator = this.getCalculator();
|
|
49
|
-
var history, cursor, current;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Creates an entry from the current state
|
|
53
|
-
* @returns {historyEntry}
|
|
54
|
-
*/
|
|
55
|
-
function getCurrentState() {
|
|
56
|
-
return {
|
|
57
|
-
expression: calculator.getExpression(),
|
|
58
|
-
variables: calculator.getVariables(),
|
|
59
|
-
current: null
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Clears the entire history
|
|
65
|
-
*/
|
|
66
|
-
function reset() {
|
|
67
|
-
current = getCurrentState();
|
|
68
|
-
history = [];
|
|
69
|
-
cursor = 0;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Retrieves a memory entry in the history
|
|
74
|
-
* @param {Number} position
|
|
75
|
-
* @returns {Object|null}
|
|
76
|
-
*/
|
|
77
|
-
function getMemoryAt(position) {
|
|
78
|
-
if (position >= 0 && position < history.length) {
|
|
79
|
-
return history[position];
|
|
80
|
-
} else if (position === history.length) {
|
|
81
|
-
return current;
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Reminds an expression from the history
|
|
88
|
-
* @param {Number} position
|
|
89
|
-
*/
|
|
90
|
-
function remind(position) {
|
|
91
|
-
var memory = getMemoryAt(position);
|
|
92
|
-
|
|
93
|
-
// keep the current expression in the memory, in case the user goes back to it
|
|
94
|
-
if (cursor === history.length && position !== cursor) {
|
|
95
|
-
current = getCurrentState();
|
|
96
|
-
} else {
|
|
97
|
-
history[cursor].current = calculator.getExpression();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// restore an expression from the history at the wanted position
|
|
101
|
-
if (memory) {
|
|
102
|
-
cursor = position;
|
|
103
|
-
if (memory.variables) {
|
|
104
|
-
calculator.setVariables(memory.variables);
|
|
105
|
-
}
|
|
106
|
-
calculator.replace(memory.current || memory.expression);
|
|
107
|
-
memory.current = null;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Adds a memory entry in the history from the current expression
|
|
113
|
-
*/
|
|
114
|
-
function push() {
|
|
115
|
-
var last = getMemoryAt(history.length - 1);
|
|
116
|
-
var memory = getMemoryAt(cursor);
|
|
117
|
-
if (!last || calculator.getExpression() !== last.expression) {
|
|
118
|
-
history.push(getCurrentState());
|
|
119
|
-
}
|
|
120
|
-
if (memory) {
|
|
121
|
-
memory.current = null;
|
|
122
|
-
}
|
|
123
|
-
cursor = history.length;
|
|
124
|
-
}
|
|
125
|
-
reset();
|
|
126
|
-
calculator.on(nsHelper.namespaceAll('evaluate', pluginName), push).on(nsHelper.namespaceAll('command-historyClear command-clearAll destroy', pluginName), reset).on(nsHelper.namespaceAll('command-historyUp', pluginName), function () {
|
|
127
|
-
remind(cursor - 1);
|
|
128
|
-
}).on(nsHelper.namespaceAll('command-historyDown', pluginName), function () {
|
|
129
|
-
remind(cursor + 1);
|
|
130
|
-
}).on(nsHelper.namespaceAll('command-historyGet', pluginName), function () {
|
|
131
|
-
/**
|
|
132
|
-
* @event history
|
|
133
|
-
* @param {Array} history - The current history list
|
|
134
|
-
*/
|
|
135
|
-
calculator.trigger('history', _.map(history, 'expression'));
|
|
136
|
-
});
|
|
137
|
-
},
|
|
138
|
-
/**
|
|
139
|
-
* Called when the plugin is destroyed. Mostly when the host is destroyed itself.
|
|
140
|
-
*/
|
|
141
|
-
destroy: function destroy() {
|
|
142
|
-
var calculator = this.getCalculator();
|
|
143
|
-
calculator.deleteCommand('historyClear').deleteCommand('historyUp').deleteCommand('historyDown').deleteCommand('historyGet').off('.' + pluginName);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
return history;
|
|
148
|
-
|
|
149
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
define(['i18n', 'util/namespace', 'ui/maths/calculator/core/plugin'], function (__, nsHelper, pluginFactory) { 'use strict';
|
|
2
|
-
|
|
3
|
-
__ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
|
|
4
|
-
nsHelper = nsHelper && Object.prototype.hasOwnProperty.call(nsHelper, 'default') ? nsHelper['default'] : nsHelper;
|
|
5
|
-
pluginFactory = pluginFactory && Object.prototype.hasOwnProperty.call(pluginFactory, 'default') ? pluginFactory['default'] : pluginFactory;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This program is free software; you can redistribute it and/or
|
|
9
|
-
* modify it under the terms of the GNU General Public License
|
|
10
|
-
* as published by the Free Software Foundation; under version 2
|
|
11
|
-
* of the License (non-upgradable).
|
|
12
|
-
*
|
|
13
|
-
* This program is distributed in the hope that it will be useful,
|
|
14
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
* GNU General Public License for more details.
|
|
17
|
-
*
|
|
18
|
-
* You should have received a copy of the GNU General Public License
|
|
19
|
-
* along with this program; if not, write to the Free Software
|
|
20
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
21
|
-
*
|
|
22
|
-
* Copyright (c) 2018 Open Assessment Technologies SA ;
|
|
23
|
-
*/
|
|
24
|
-
var pluginName = 'remind';
|
|
25
|
-
var varRemindName = 'mem';
|
|
26
|
-
var varLastName = 'last';
|
|
27
|
-
var remind = pluginFactory({
|
|
28
|
-
name: pluginName,
|
|
29
|
-
/**
|
|
30
|
-
* Called when the plugin is installing in its host.
|
|
31
|
-
*/
|
|
32
|
-
install: function install() {
|
|
33
|
-
var calculator = this.getCalculator();
|
|
34
|
-
calculator.setCommand('remind', __('Remind'), __('Remind the recorded value')).setCommand('remindLast', __('Remind Last'), __('Remind the last value')).setCommand('remindStore', __('Store'), __('Store the value a variable')).setCommand('remindClear', __('Clear'), __('Clear the stored variables'));
|
|
35
|
-
},
|
|
36
|
-
/**
|
|
37
|
-
* Called when the plugin should be initialized.
|
|
38
|
-
*/
|
|
39
|
-
init: function init() {
|
|
40
|
-
var calculator = this.getCalculator();
|
|
41
|
-
calculator.on(nsHelper.namespaceAll('evaluate', pluginName), function (result) {
|
|
42
|
-
calculator.setVariable(varLastName, result);
|
|
43
|
-
}).on(nsHelper.namespaceAll('command-remind', pluginName), function () {
|
|
44
|
-
if (calculator.hasVariable(varRemindName)) {
|
|
45
|
-
calculator.useVariable(varRemindName);
|
|
46
|
-
}
|
|
47
|
-
}).on(nsHelper.namespaceAll('command-remindLast', pluginName), function () {
|
|
48
|
-
if (calculator.hasVariable(varLastName)) {
|
|
49
|
-
calculator.useVariable(varLastName);
|
|
50
|
-
}
|
|
51
|
-
}).on(nsHelper.namespaceAll('command-remindStore', pluginName), function () {
|
|
52
|
-
if (calculator.hasVariable(varLastName)) {
|
|
53
|
-
calculator.setVariable(varRemindName, calculator.getVariable(varLastName));
|
|
54
|
-
}
|
|
55
|
-
}).on(nsHelper.namespaceAll('command-remindClear command-clearAll destroy', pluginName), function () {
|
|
56
|
-
if (calculator.hasVariable(varRemindName)) {
|
|
57
|
-
calculator.deleteVariable(varRemindName);
|
|
58
|
-
}
|
|
59
|
-
}).on(nsHelper.namespaceAll('destroy', pluginName), function () {
|
|
60
|
-
if (calculator.hasVariable(varLastName)) {
|
|
61
|
-
calculator.deleteVariable(varLastName);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
/**
|
|
66
|
-
* Called when the plugin is destroyed. Mostly when the host is destroyed itself.
|
|
67
|
-
*/
|
|
68
|
-
destroy: function destroy() {
|
|
69
|
-
var calculator = this.getCalculator();
|
|
70
|
-
calculator.deleteCommand('remind').deleteCommand('remindLast').deleteCommand('remindStore').deleteCommand('remindClear').off('.' + pluginName);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
return remind;
|
|
75
|
-
|
|
76
|
-
});
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
define(['i18n', 'util/namespace', 'ui/maths/calculator/core/plugin'], function (__, nsHelper, pluginFactory) { 'use strict';
|
|
2
|
-
|
|
3
|
-
__ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
|
|
4
|
-
nsHelper = nsHelper && Object.prototype.hasOwnProperty.call(nsHelper, 'default') ? nsHelper['default'] : nsHelper;
|
|
5
|
-
pluginFactory = pluginFactory && Object.prototype.hasOwnProperty.call(pluginFactory, 'default') ? pluginFactory['default'] : pluginFactory;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This program is free software; you can redistribute it and/or
|
|
9
|
-
* modify it under the terms of the GNU General Public License
|
|
10
|
-
* as published by the Free Software Foundation; under version 2
|
|
11
|
-
* of the License (non-upgradable).
|
|
12
|
-
*
|
|
13
|
-
* This program is distributed in the hope that it will be useful,
|
|
14
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
* GNU General Public License for more details.
|
|
17
|
-
*
|
|
18
|
-
* You should have received a copy of the GNU General Public License
|
|
19
|
-
* along with this program; if not, write to the Free Software
|
|
20
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
21
|
-
*
|
|
22
|
-
* Copyright (c) 2018 Open Assessment Technologies SA ;
|
|
23
|
-
*/
|
|
24
|
-
var pluginName = 'stepNavigation';
|
|
25
|
-
var stepNavigation = pluginFactory({
|
|
26
|
-
name: pluginName,
|
|
27
|
-
/**
|
|
28
|
-
* Called when the plugin is installing in its host.
|
|
29
|
-
*/
|
|
30
|
-
install: function install() {
|
|
31
|
-
var calculator = this.getCalculator();
|
|
32
|
-
calculator.setCommand('stepMoveLeft', __('Move Left'), __('Move the cursor one step on the left')).setCommand('stepMoveRight', __('Move Right'), __('Move the cursor one step on the right')).setCommand('stepDeleteLeft', __('Delete Left'), __('Delete the term on the left side of the cursor')).setCommand('stepDeleteRight', __('Delete Right'), __('Delete the term on the right side of the cursor'));
|
|
33
|
-
},
|
|
34
|
-
/**
|
|
35
|
-
* Called when the plugin should be initialized.
|
|
36
|
-
*/
|
|
37
|
-
init: function init() {
|
|
38
|
-
var calculator = this.getCalculator();
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Remove a sub-expresion from the expression
|
|
42
|
-
* @param expression
|
|
43
|
-
* @param position
|
|
44
|
-
* @param length
|
|
45
|
-
*/
|
|
46
|
-
function remove(expression, position, length) {
|
|
47
|
-
if (length) {
|
|
48
|
-
expression = calculator.getExpression();
|
|
49
|
-
calculator.setExpression(expression.substr(0, position) + expression.substr(position + length)).setPosition(position);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Remove a token from the expression
|
|
55
|
-
* @param expression
|
|
56
|
-
* @param token
|
|
57
|
-
*/
|
|
58
|
-
function removeToken(expression, token) {
|
|
59
|
-
var from, length;
|
|
60
|
-
if (token) {
|
|
61
|
-
expression = calculator.getExpression();
|
|
62
|
-
from = token.offset;
|
|
63
|
-
length = token.value.length;
|
|
64
|
-
while (from + length < expression.length && expression.charAt(from + length) === ' ') {
|
|
65
|
-
length++;
|
|
66
|
-
}
|
|
67
|
-
remove(expression, from, length);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
calculator.on(nsHelper.namespaceAll('command-stepMoveLeft', pluginName), function () {
|
|
71
|
-
var position = calculator.getPosition();
|
|
72
|
-
var tokens = calculator.getTokens();
|
|
73
|
-
var index = calculator.getTokenIndex();
|
|
74
|
-
var token = calculator.getToken();
|
|
75
|
-
var offset = position;
|
|
76
|
-
if (token && position > 0) {
|
|
77
|
-
if (position === token.offset) {
|
|
78
|
-
if (index > 0) {
|
|
79
|
-
token = tokens[index - 1];
|
|
80
|
-
} else {
|
|
81
|
-
token = null;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
token = null;
|
|
86
|
-
}
|
|
87
|
-
if (token) {
|
|
88
|
-
offset = token.offset;
|
|
89
|
-
} else {
|
|
90
|
-
offset = 0;
|
|
91
|
-
}
|
|
92
|
-
if (offset !== position) {
|
|
93
|
-
calculator.setPosition(offset);
|
|
94
|
-
}
|
|
95
|
-
}).on(nsHelper.namespaceAll('command-stepMoveRight', pluginName), function () {
|
|
96
|
-
var expression = calculator.getExpression();
|
|
97
|
-
var position = calculator.getPosition();
|
|
98
|
-
var tokens = calculator.getTokens();
|
|
99
|
-
var index = calculator.getTokenIndex();
|
|
100
|
-
var token = calculator.getToken();
|
|
101
|
-
var offset = expression.length;
|
|
102
|
-
if (token && index < tokens.length - 1) {
|
|
103
|
-
token = tokens[index + 1];
|
|
104
|
-
if (token) {
|
|
105
|
-
offset = token.offset;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (offset !== position) {
|
|
109
|
-
calculator.setPosition(offset);
|
|
110
|
-
}
|
|
111
|
-
}).on(nsHelper.namespaceAll('command-stepDeleteLeft', pluginName), function () {
|
|
112
|
-
var expression = calculator.getExpression();
|
|
113
|
-
var position = calculator.getPosition();
|
|
114
|
-
var tokens = calculator.getTokens();
|
|
115
|
-
var index = calculator.getTokenIndex();
|
|
116
|
-
var token = calculator.getToken();
|
|
117
|
-
if (token) {
|
|
118
|
-
if (position > token.offset) {
|
|
119
|
-
removeToken(expression, token);
|
|
120
|
-
} else {
|
|
121
|
-
if (index > 0) {
|
|
122
|
-
removeToken(expression, tokens[index - 1]);
|
|
123
|
-
} else if (position > 0) {
|
|
124
|
-
remove(expression, 0, token.offset);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}).on(nsHelper.namespaceAll('command-stepDeleteRight', pluginName), function () {
|
|
129
|
-
var expression = calculator.getExpression();
|
|
130
|
-
var position = calculator.getPosition();
|
|
131
|
-
var token = calculator.getToken();
|
|
132
|
-
if (token && position >= token.offset && position < token.offset + token.value.length) {
|
|
133
|
-
removeToken(expression, token);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
},
|
|
137
|
-
/**
|
|
138
|
-
* Called when the plugin is destroyed. Mostly when the host is destroyed itself.
|
|
139
|
-
*/
|
|
140
|
-
destroy: function destroy() {
|
|
141
|
-
var calculator = this.getCalculator();
|
|
142
|
-
calculator.deleteCommand('stepMoveLeft').deleteCommand('stepMoveRight').deleteCommand('stepDeleteLeft').deleteCommand('stepDeleteRight').off('.' + pluginName);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
return stepNavigation;
|
|
147
|
-
|
|
148
|
-
});
|