From fe1bfd9c237e78046272aaf6d92babea8c1ddeb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christophe=20No=C3=ABl?= Date: Wed, 23 Nov 2016 11:14:49 +0100 Subject: [PATCH 1/5] first try to integrate the new line hack... --- .../runtime/css/mathEntryInteraction.css | 2 +- .../runtime/css/mathEntryInteraction.css.map | 2 +- .../runtime/mathEntryInteraction.js | 10 +++++++--- .../runtime/scss/mathEntryInteraction.scss | 4 ++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css b/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css index b38ea948..0e688192 100644 --- a/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css +++ b/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css @@ -1,2 +1,2 @@ -.qti-customInteraction .mathEntryInteraction .math-entry{padding:10px}.qti-customInteraction .mathEntryInteraction .math-entry-input{width:100%}.qti-customInteraction .mathEntryInteraction .math-entry-toolgroup{margin:10px 12px 10px 0;display:inline-block}.qti-customInteraction .mathEntryInteraction .math-entry-tool{font-family:"Times New Roman",Times,serif;font-size:14px !important;font-weight:bold;font-style:normal;cursor:pointer;text-decoration:none !important;vertical-align:middle;outline:0;overflow:visible;display:inline-block;line-height:2.5;padding:0 15px;text-align:center;height:35px;background-color:#ccc;color:#4d4d4d;border:1px solid #a3a3a3}.qti-customInteraction .mathEntryInteraction .math-entry-tool:hover{background-color:#e6e6e6} +.qti-customInteraction .mathEntryInteraction .math-entry{padding:10px}.qti-customInteraction .mathEntryInteraction .math-entry-input{width:100%}.qti-customInteraction .mathEntryInteraction .math-entry-toolgroup{margin:10px 12px 10px 0;display:inline-block}.qti-customInteraction .mathEntryInteraction .math-entry-tool{font-family:"Times New Roman",Times,serif;font-size:14px !important;font-weight:bold;font-style:normal;cursor:pointer;text-decoration:none !important;vertical-align:middle;outline:0;overflow:visible;display:inline-block;line-height:2.5;padding:0 15px;text-align:center;height:35px;background-color:#ccc;color:#4d4d4d;border:1px solid #a3a3a3}.qti-customInteraction .mathEntryInteraction .math-entry-tool:hover{background-color:#e6e6e6}.mq-textcolor .mq-text-mode{display:block} /*# sourceMappingURL=mathEntryInteraction.css.map */ diff --git a/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css.map b/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css.map index fe901406..4c2a5202 100644 --- a/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css.map +++ b/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAsCI,wDAAY,CACV,OAAO,CAAE,IAAI,CAGf,8DAAkB,CAChB,KAAK,CAAE,IAAI,CAKb,kEAAsB,CACpB,MAAM,CAAE,gBAAgB,CACxB,OAAO,CAAE,YAAY,CAGvB,6DAAiB,CACf,WAAW,CArBJ,6BAA+B,CAsBtC,SAAS,CAAE,eAAe,CAC1B,WAAW,CAAE,IAAI,CACjB,UAAU,CAAE,MAAM,CAClB,MAAM,CAAE,OAAO,CACf,eAAe,CAAE,eAAe,CAChC,cAAc,CAAE,MAAM,CACtB,OAAO,CAAE,CAAC,CACV,QAAQ,CAAE,OAAO,CACjB,OAAO,CAAE,YAAY,CACrB,WAAW,CAAE,GAAG,CAChB,OAAO,CAAE,MAAM,CACf,UAAU,CAAE,MAAM,CAClB,MAAM,CAAE,IAAI,CACZ,gBAAgB,CArCX,IAAkB,CAsCvB,KAAK,CArCC,OAAiB,CAsCvB,MAAM,CAAE,iBAAiC,CAEzC,mEAAQ,CACN,gBAAgB,CAAE,OAAqB", +"mappings": "AAsCI,wDAAY,CACV,OAAO,CAAE,IAAI,CAGf,8DAAkB,CAChB,KAAK,CAAE,IAAI,CAKb,kEAAsB,CACpB,MAAM,CAAE,gBAAgB,CACxB,OAAO,CAAE,YAAY,CAGvB,6DAAiB,CACf,WAAW,CArBJ,6BAA+B,CAsBtC,SAAS,CAAE,eAAe,CAC1B,WAAW,CAAE,IAAI,CACjB,UAAU,CAAE,MAAM,CAClB,MAAM,CAAE,OAAO,CACf,eAAe,CAAE,eAAe,CAChC,cAAc,CAAE,MAAM,CACtB,OAAO,CAAE,CAAC,CACV,QAAQ,CAAE,OAAO,CACjB,OAAO,CAAE,YAAY,CACrB,WAAW,CAAE,GAAG,CAChB,OAAO,CAAE,MAAM,CACf,UAAU,CAAE,MAAM,CAClB,MAAM,CAAE,IAAI,CACZ,gBAAgB,CArCX,IAAkB,CAsCvB,KAAK,CArCC,OAAiB,CAsCvB,MAAM,CAAE,iBAAiC,CAEzC,mEAAQ,CACN,gBAAgB,CAAE,OAAqB,CAS/C,2BAA4B,CAC1B,OAAO,CAAE,KAAK", "sources": ["../scss/mathEntryInteraction.scss"], "names": [], "file": "mathEntryInteraction.css" diff --git a/views/js/pciCreator/dev/mathEntryInteraction/runtime/mathEntryInteraction.js b/views/js/pciCreator/dev/mathEntryInteraction/runtime/mathEntryInteraction.js index 95ca9642..ab52d8e3 100644 --- a/views/js/pciCreator/dev/mathEntryInteraction/runtime/mathEntryInteraction.js +++ b/views/js/pciCreator/dev/mathEntryInteraction/runtime/mathEntryInteraction.js @@ -76,7 +76,8 @@ define([ lte: toBoolean(config.tool_lte, true), gte: toBoolean(config.tool_gte, true), times: toBoolean(config.tool_times, true), - divide: toBoolean(config.tool_divide, true) + divide: toBoolean(config.tool_divide, true), + newline:toBoolean(config.tool_newline, true) }, authorizeWhiteSpace : toBoolean(config.authorizeWhiteSpace, false) }; @@ -124,13 +125,15 @@ define([ lte: { label: '≤', latex: '\\le', fn: 'write', desc: 'Lower than or equal' }, gte: { label: '≥', latex: '\\ge', fn: 'write', desc: 'Greater than or equal' }, times: { label: '×', latex: '\\times', fn: 'cmd', desc: 'Multiply' }, - divide: { label: '÷', latex: '\\div', fn: 'cmd', desc: 'Divide' } + divide: { label: '÷', latex: '\\div', fn: 'cmd', desc: 'Divide' }, + newline: { label: 'BR', latex: '\\textcolor{black}{\\text{}}', fn: 'write', desc: 'Line break' } }, availableToolGroups = { functions: ['sqrt', 'frac', 'exp', 'log', 'ln', 'e'], trigo: ['pi', 'sin', 'cos'], comparison: ['lte', 'gte'], - operands: ['times', 'divide'] + operands: ['times', 'divide'], + misc: ['newline'] }; @@ -141,6 +144,7 @@ define([ this.$toolbar.append(createToolGroup('trigo')); this.$toolbar.append(createToolGroup('comparison')); this.$toolbar.append(createToolGroup('operands')); + this.$toolbar.append(createToolGroup('misc')); /** * Create a group of buttons diff --git a/views/js/pciCreator/dev/mathEntryInteraction/runtime/scss/mathEntryInteraction.scss b/views/js/pciCreator/dev/mathEntryInteraction/runtime/scss/mathEntryInteraction.scss index b9d8d9aa..fa8e1760 100644 --- a/views/js/pciCreator/dev/mathEntryInteraction/runtime/scss/mathEntryInteraction.scss +++ b/views/js/pciCreator/dev/mathEntryInteraction/runtime/scss/mathEntryInteraction.scss @@ -79,3 +79,7 @@ $buttonFont: "Times New Roman", Times, serif; } } + +.mq-textcolor .mq-text-mode { + display: block; +} \ No newline at end of file From f6654f6b5521faaf084916a7ab5a6a53cb271c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christophe=20No=C3=ABl?= Date: Fri, 2 Dec 2016 14:52:23 +0100 Subject: [PATCH 2/5] updated css --- .../runtime/css/mathEntryInteraction.css | 2 +- .../runtime/css/mathEntryInteraction.css.map | 2 +- .../runtime/scss/mathEntryInteraction.scss | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css b/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css index 0e688192..3049e8ce 100644 --- a/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css +++ b/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css @@ -1,2 +1,2 @@ -.qti-customInteraction .mathEntryInteraction .math-entry{padding:10px}.qti-customInteraction .mathEntryInteraction .math-entry-input{width:100%}.qti-customInteraction .mathEntryInteraction .math-entry-toolgroup{margin:10px 12px 10px 0;display:inline-block}.qti-customInteraction .mathEntryInteraction .math-entry-tool{font-family:"Times New Roman",Times,serif;font-size:14px !important;font-weight:bold;font-style:normal;cursor:pointer;text-decoration:none !important;vertical-align:middle;outline:0;overflow:visible;display:inline-block;line-height:2.5;padding:0 15px;text-align:center;height:35px;background-color:#ccc;color:#4d4d4d;border:1px solid #a3a3a3}.qti-customInteraction .mathEntryInteraction .math-entry-tool:hover{background-color:#e6e6e6}.mq-textcolor .mq-text-mode{display:block} +.qti-customInteraction .mathEntryInteraction .math-entry{padding:10px}.qti-customInteraction .mathEntryInteraction .math-entry-input{width:100%}.qti-customInteraction .mathEntryInteraction .math-entry-toolgroup{margin:10px 12px 10px 0;display:inline-block}.qti-customInteraction .mathEntryInteraction .math-entry-tool{font-family:"Times New Roman",Times,serif;font-size:14px !important;font-weight:bold;font-style:normal;cursor:pointer;text-decoration:none !important;vertical-align:middle;outline:0;overflow:visible;display:inline-block;line-height:2.5;padding:0 15px;text-align:center;height:35px;background-color:#ccc;color:#4d4d4d;border:1px solid #a3a3a3}.qti-customInteraction .mathEntryInteraction .math-entry-tool:hover{background-color:#e6e6e6}.qti-customInteraction .mathEntryInteraction .mq-textcolor .mq-text-mode{display:block} /*# sourceMappingURL=mathEntryInteraction.css.map */ diff --git a/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css.map b/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css.map index 4c2a5202..f287f367 100644 --- a/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css.map +++ b/views/js/pciCreator/dev/mathEntryInteraction/runtime/css/mathEntryInteraction.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAsCI,wD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AE,iBAAiC,CAEzC,mEAAQ,CACN,gBAAgB,CAAE,OAAqB,CAM3C,wEAA4B,CAC1B,OAAO,CAAE,KAAK", "sources": ["../scss/mathEntryInteraction.scss"], "names": [], "file": "mathEntryInteraction.css" diff --git a/views/js/pciCreator/dev/mathEntryInteraction/runtime/scss/mathEntryInteraction.scss b/views/js/pciCreator/dev/mathEntryInteraction/runtime/scss/mathEntryInteraction.scss index fa8e1760..c9c7ebb7 100644 --- a/views/js/pciCreator/dev/mathEntryInteraction/runtime/scss/mathEntryInteraction.scss +++ b/views/js/pciCreator/dev/mathEntryInteraction/runtime/scss/mathEntryInteraction.scss @@ -76,10 +76,11 @@ $buttonFont: "Times New Roman", Times, serif; } + // hack for newline + .mq-textcolor .mq-text-mode { + display: block; + } + } } - -.mq-textcolor .mq-text-mode { - display: block; -} \ No newline at end of file From 00991177ae6e7439484e05469d5ac5e9ae9cf5ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christophe=20No=C3=ABl?= Date: Fri, 2 Dec 2016 14:52:36 +0100 Subject: [PATCH 3/5] allow setting newline as an option --- .../creator/tpl/propertiesForm.tpl | 7 +++++++ .../creator/widget/states/Question.js | 2 ++ .../runtime/mathEntryInteraction.js | 18 +++++++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/views/js/pciCreator/dev/mathEntryInteraction/creator/tpl/propertiesForm.tpl b/views/js/pciCreator/dev/mathEntryInteraction/creator/tpl/propertiesForm.tpl index f2bc9bbb..1abf7940 100644 --- a/views/js/pciCreator/dev/mathEntryInteraction/creator/tpl/propertiesForm.tpl +++ b/views/js/pciCreator/dev/mathEntryInteraction/creator/tpl/propertiesForm.tpl @@ -19,6 +19,13 @@ {{__ "authorize white space"}} +
diff --git a/views/js/pciCreator/dev/mathEntryInteraction/creator/widget/states/Question.js b/views/js/pciCreator/dev/mathEntryInteraction/creator/widget/states/Question.js index ca453ba6..f9530e5d 100644 --- a/views/js/pciCreator/dev/mathEntryInteraction/creator/widget/states/Question.js +++ b/views/js/pciCreator/dev/mathEntryInteraction/creator/widget/states/Question.js @@ -93,6 +93,7 @@ define([ tool_gte: toBoolean(interaction.prop('tool_gte'), true), tool_times: toBoolean(interaction.prop('tool_times'), true), tool_divide: toBoolean(interaction.prop('tool_divide'), true), + allowNewLine: toBoolean(interaction.prop('allowNewLine'), false), authorizeWhiteSpace: toBoolean(interaction.prop('authorizeWhiteSpace'), false) })); @@ -118,6 +119,7 @@ define([ tool_gte: configChangeCallBack, tool_times: configChangeCallBack, tool_divide: configChangeCallBack, + allowNewLine: configChangeCallBack, authorizeWhiteSpace: configChangeCallBack }); }; diff --git a/views/js/pciCreator/dev/mathEntryInteraction/runtime/mathEntryInteraction.js b/views/js/pciCreator/dev/mathEntryInteraction/runtime/mathEntryInteraction.js index ab52d8e3..eee5b11b 100644 --- a/views/js/pciCreator/dev/mathEntryInteraction/runtime/mathEntryInteraction.js +++ b/views/js/pciCreator/dev/mathEntryInteraction/runtime/mathEntryInteraction.js @@ -77,9 +77,9 @@ define([ gte: toBoolean(config.tool_gte, true), times: toBoolean(config.tool_times, true), divide: toBoolean(config.tool_divide, true), - newline:toBoolean(config.tool_newline, true) }, - authorizeWhiteSpace : toBoolean(config.authorizeWhiteSpace, false) + allowNewLine: toBoolean(config.allowNewLine, false), + authorizeWhiteSpace: toBoolean(config.authorizeWhiteSpace, false) }; }, @@ -125,15 +125,13 @@ define([ lte: { label: '≤', latex: '\\le', fn: 'write', desc: 'Lower than or equal' }, gte: { label: '≥', latex: '\\ge', fn: 'write', desc: 'Greater than or equal' }, times: { label: '×', latex: '\\times', fn: 'cmd', desc: 'Multiply' }, - divide: { label: '÷', latex: '\\div', fn: 'cmd', desc: 'Divide' }, - newline: { label: 'BR', latex: '\\textcolor{black}{\\text{}}', fn: 'write', desc: 'Line break' } + divide: { label: '÷', latex: '\\div', fn: 'cmd', desc: 'Divide' } }, availableToolGroups = { functions: ['sqrt', 'frac', 'exp', 'log', 'ln', 'e'], trigo: ['pi', 'sin', 'cos'], comparison: ['lte', 'gte'], - operands: ['times', 'divide'], - misc: ['newline'] + operands: ['times', 'divide'] }; @@ -144,7 +142,6 @@ define([ this.$toolbar.append(createToolGroup('trigo')); this.$toolbar.append(createToolGroup('comparison')); this.$toolbar.append(createToolGroup('operands')); - this.$toolbar.append(createToolGroup('misc')); /** * Create a group of buttons @@ -212,6 +209,13 @@ define([ self.mathField.focus(); }); + + this.$input.on('keypress.qtiCommonRenderer', function (e) { + var latex = '\\textcolor{black}{\\text{}}'; + if (self.config.allowNewLine && e.keyCode === 13) { + self.mathField.write(latex); + } + }); }, From f4b6c3483fcf4f9774698b22f4505abad907428b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christophe=20No=C3=ABl?= Date: Fri, 2 Dec 2016 14:54:07 +0100 Subject: [PATCH 4/5] bump version --- manifest.php | 2 +- scripts/update/Updater.php | 5 +++++ views/js/pciCreator/dev/mathEntryInteraction/pciCreator.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/manifest.php b/manifest.php index f6ce7c2c..3c132267 100644 --- a/manifest.php +++ b/manifest.php @@ -31,7 +31,7 @@ 'label' => 'QTI Portable Custom Interaction', 'description' => '', 'license' => 'GPL-2.0', - 'version' => '1.3.0', + 'version' => '1.4.0', 'author' => 'Open Assessment Technologies SA', 'requires' => array( 'taoQtiItem' => '>=5.13.0' diff --git a/scripts/update/Updater.php b/scripts/update/Updater.php index 3dc0153d..032f3498 100644 --- a/scripts/update/Updater.php +++ b/scripts/update/Updater.php @@ -87,5 +87,10 @@ public function update($currentVersion) call_user_func(new RegisterPciMathEntry(), ['0.2.0']); $this->setVersion('1.3.0'); } + + if($this->isVersion('1.3.0')){ + call_user_func(new RegisterPciMathEntry(), ['0.3.0']); + $this->setVersion('1.4.0'); + } } } \ No newline at end of file diff --git a/views/js/pciCreator/dev/mathEntryInteraction/pciCreator.json b/views/js/pciCreator/dev/mathEntryInteraction/pciCreator.json index e28e76ab..211fd32e 100644 --- a/views/js/pciCreator/dev/mathEntryInteraction/pciCreator.json +++ b/views/js/pciCreator/dev/mathEntryInteraction/pciCreator.json @@ -3,7 +3,7 @@ "label": "Math entry", "short": "Math entry", "description": "Allow test taker to type math formulas", - "version": "0.2.0", + "version": "0.3.0", "author": "Christophe Noël", "email": "christophe@taotesting.com", "tags": [ From 8673e90851bf916d5fa15954defca9d0e09ac905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christophe=20No=C3=ABl?= Date: Fri, 2 Dec 2016 14:56:38 +0100 Subject: [PATCH 5/5] destroy new event handler --- .../dev/mathEntryInteraction/runtime/mathEntryInteraction.js | 1 + 1 file changed, 1 insertion(+) diff --git a/views/js/pciCreator/dev/mathEntryInteraction/runtime/mathEntryInteraction.js b/views/js/pciCreator/dev/mathEntryInteraction/runtime/mathEntryInteraction.js index eee5b11b..d026f4d0 100644 --- a/views/js/pciCreator/dev/mathEntryInteraction/runtime/mathEntryInteraction.js +++ b/views/js/pciCreator/dev/mathEntryInteraction/runtime/mathEntryInteraction.js @@ -302,6 +302,7 @@ define([ */ destroy: function destroy() { this.$toolbar.off('mousedown.qtiCommonRenderer'); + this.$input.off('keypress.qtiCommonRenderer'); this.resetResponse(); this.mathField.revert(); },