Skip to content

Commit

Permalink
Merge pull request #389 from oat-sa/feature/BSA-391/allow-to-disable-…
Browse files Browse the repository at this point in the history
…figure-widgets

Feature/BSA-391/Allow to disable figure widgets
  • Loading branch information
jsconan authored Dec 11, 2023
2 parents bae1c52 + 92ae44a commit 60e8035
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@oat-sa/tao-core-libs": "^1.0.0",
"@oat-sa/tao-core-sdk": "^3.0.0",
"@oat-sa/tao-core-shared-libs": "^1.4.1",
"@oat-sa/tao-core-ui": "^3.0.1",
"@oat-sa/tao-core-ui": "^3.1.0",
"@oat-sa/tao-item-runner": "^1.0.0",
"@oat-sa/tao-qunit-testrunner": "^2.0.0",
"async": "^0.2.10",
Expand Down
20 changes: 14 additions & 6 deletions src/qtiCommonRenderer/renderers/Figure.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,25 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2022 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
* Copyright (c) 2022-2023 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*/
import context from 'context';
import _ from 'lodash';
import tpl from 'taoQtiItem/qtiCommonRenderer/tpl/figure';
import containerHelper from 'taoQtiItem/qtiCommonRenderer/helpers/container';
import imageTpl from 'taoQtiItem/qtiCommonRenderer/tpl/figure-image';
import widgetTpl from 'taoQtiItem/qtiCommonRenderer/tpl/figure-widget';

const DISABLE_FIGURE_WIDGET = context.featureFlags['FEATURE_FLAG_DISABLE_FIGURE_WIDGET'];

export default {
qtiClass: 'figure',
getContainer: containerHelper.get,
template: tpl,
getData: function (elem, data) {
template: DISABLE_FIGURE_WIDGET ? imageTpl : widgetTpl,
getData(elem, data) {
if (DISABLE_FIGURE_WIDGET) {
return data;
}

let showFigure = false;
if (data.attributes.class && ['wrap-left', 'wrap-right'].includes(data.attributes.class)) {
showFigure = true;
Expand All @@ -40,10 +48,10 @@ export default {
elem.attributes.showFigure = showFigure;
return data;
},
render: function(figure) {
render(figure) {
const $figure = containerHelper.get(figure);
const $img = $figure.find('img');
if ($img.length && $figure.prop('tagName') === 'FIGURE') {
if ($img.length && (DISABLE_FIGURE_WIDGET || $figure.prop('tagName') === 'FIGURE')) {
// move width from image to figure
$figure.css({ width: $img.attr('width') });
$img.attr('width', '100%');
Expand Down
1 change: 1 addition & 0 deletions src/qtiCommonRenderer/tpl/figure-image.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<figure data-serial="{{serial}}"{{#if attributes.class}} class="{{attributes.class}}"{{/if}}{{#if attributes.xml:lang}} lang="{{attributes.xml:lang}}"{{/if}}>{{{body}}}</figure>
File renamed without changes.
5 changes: 4 additions & 1 deletion test/qtiCommonRenderer/static/figure/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@
define([
'jquery',
'lodash',
'context',
'taoQtiItem/runner/qtiItemRunner',
'taoQtiItem/qtiItem/core/Figure',
'json!taoQtiItem/test/samples/json/static/figure.json'
], function($, _, qtiItemRunner, Figure, itemData) {
], function($, _, context, qtiItemRunner, Figure, itemData) {
'use strict';

let runner;
const fixtureContainerId = '#item-container';
const outsideContainerId = '#outside-container';
const imageSampleUrl = '/test/samples/json/static/tao-logo.png';

context.featureFlags = {};

QUnit.module('Order Interaction', {
afterEach: function() {
if (runner) {
Expand Down

0 comments on commit 60e8035

Please sign in to comment.