Skip to content

Commit

Permalink
Merge branch 'release-12.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jul 9, 2024
2 parents 62e87b5 + 2327771 commit bc141ad
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 78 deletions.
115 changes: 64 additions & 51 deletions views/js/controller/items/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* 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) 2014 - 2019 (original work) Open Assessment Techniologies SA
* Copyright (c) 2014 - 2024 (original work) Open Assessment Technologies SA
*
*/
define([
Expand All @@ -34,7 +34,7 @@ define([
'tpl!taoItems/controller/items/tpl/relatedTestsPopup',
'tpl!taoItems/controller/items/tpl/relatedClassTestsPopup',
'tpl!taoItems/controller/items/tpl/forbiddenClassAction',
'css!taoItems/controller/items/css/relatedTestsPopup.css',
'css!taoItems/controller/items/css/relatedTestsPopup.css'
], function (
_,
$,
Expand Down Expand Up @@ -63,22 +63,33 @@ define([
uri: actionContext.id
};
const config = _.merge(defaultConfig, module.config());
const previewerConfig = _.omit({
readOnly: false,
fullPage: true,
pluginsOptions: config.pluginsOptions
}, _.isUndefined);

previewerFactory(config.provider, config.uri, config.state, previewerConfig);
const previewerConfig = _.omit(
{
readOnly: false,
fullPage: true,
pluginsOptions: config.pluginsOptions
},
_.isUndefined
);
const getProvider = id => {
if (!id || !config.providers) {
return config.provider;
}
const previewerId = parseInt(`${id}`.split('-').pop(), 10) || 0;
if (!config.providers[previewerId]) {
return config.provider;
}
return config.providers[previewerId].id;
};
previewerFactory(getProvider(this.id) || 'qtiItem', config.uri, config.state, previewerConfig);
});

binder.register('deleteItem', function (actionContext) {
return new Promise((resolve, reject) => {
checkRelations({
sourceId: actionContext.id,
type: 'item'
})
.then((responseRelated) => {
}).then(responseRelated => {
const relatedTests = responseRelated.data.relations;
const name = prepareName($('a.clicked', actionContext.tree).text().trim());
if (relatedTests.length === 0) {
Expand All @@ -94,8 +105,8 @@ define([
number: relatedTests.length,
numberOther: relatedTests.length - 3 > 0 ? relatedTests.length - 3 : 0,
tests: relatedTests.length <= 3 ? relatedTests : relatedTests.slice(0, 3),
multiple: relatedTests.length > 1,
multipleOthers: relatedTests.length - 3 > 1,
multiple: relatedTests.length > 1,
multipleOthers: relatedTests.length - 3 > 1
}),
() => accept(actionContext, this.url, resolve, reject),
() => cancel(reject)
Expand All @@ -111,38 +122,38 @@ define([
classId: actionContext.id,
type: 'item'
})
.then((responseRelated) => {
const relatedTests = responseRelated.data.relations;
const name = prepareName($('a.clicked', actionContext.tree).text().trim());
if (relatedTests.length === 0) {
confirmDeleteDialog(
__('Are you sure you want to delete the class %s and all of its content?', `<b>${name}</b>`),
() => accept(actionContext, this.url, resolve, reject),
() => cancel(reject)
);
} else {
confirmDeleteDialog(
relatedClassTestsPopupTpl({
name,
number: relatedTests.length,
numberOther: relatedTests.length - 3 > 0 ? relatedTests.length - 3 : 0,
tests: relatedTests.length <= 3 ? relatedTests : relatedTests.slice(0, 3),
multiple: relatedTests.length > 1,
multipleOthers: relatedTests.length - 3 > 1,
}),
() => accept(actionContext, this.url, resolve, reject),
() => cancel(reject)
);
}
})
.catch(errorObject => {
if (errorObject.response.code === 999) {
alertDialog(
forbiddenClassActionTpl(),
() => cancel(reject)
);
}
});
.then(responseRelated => {
const relatedTests = responseRelated.data.relations;
const name = prepareName($('a.clicked', actionContext.tree).text().trim());
if (relatedTests.length === 0) {
confirmDeleteDialog(
__(
'Are you sure you want to delete the class %s and all of its content?',
`<b>${name}</b>`
),
() => accept(actionContext, this.url, resolve, reject),
() => cancel(reject)
);
} else {
confirmDeleteDialog(
relatedClassTestsPopupTpl({
name,
number: relatedTests.length,
numberOther: relatedTests.length - 3 > 0 ? relatedTests.length - 3 : 0,
tests: relatedTests.length <= 3 ? relatedTests : relatedTests.slice(0, 3),
multiple: relatedTests.length > 1,
multipleOthers: relatedTests.length - 3 > 1
}),
() => accept(actionContext, this.url, resolve, reject),
() => cancel(reject)
);
}
})
.catch(errorObject => {
if (errorObject.response.code === 999) {
alertDialog(forbiddenClassActionTpl(), () => cancel(reject));
}
});
});
});

Expand Down Expand Up @@ -183,14 +194,16 @@ define([
} else {
if (response.success && !response.deleted) {
$(actionContext.tree).trigger('refresh.taotree');
reject(response.msg
|| response.message
|| __('Unable to delete the selected resource because you do not have the required rights to delete part of its content.'));
reject(
response.msg ||
response.message ||
__(
'Unable to delete the selected resource because you do not have the required rights to delete part of its content.'
)
);
}

reject(response.msg
|| response.message
|| __('Unable to delete the selected resource'));
reject(response.msg || response.message || __('Unable to delete the selected resource'));
}
});
}
Expand Down
55 changes: 30 additions & 25 deletions views/js/controller/items/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,59 @@
* 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) 2014-2019 (original work) Open Assessment Technologies SA;
* Copyright (c) 2014-2024 (original work) Open Assessment Technologies SA;
*/
define([
'jquery',
'i18n',
'module',
'layout/actions',
'ui/lock',
'layout/section'
],
function($, __, module, actions, lock, section){
define(['jquery', 'i18n', 'module', 'layout/actions', 'ui/lock', 'layout/section'], function (
$,
__,
module,
actions,
lock,
section
) {
'use strict';

/**
* The item properties controller
*/
var editItemController = {

/**
* Controller entry point
*/
start() {
const config = module.config();
const maxButtons = 10; // arbitrary value for the max number of buttons

const previewAction = actions.getBy('item-preview');
const authoringAction = actions.getBy('item-authoring');

if(previewAction){
previewAction.state.disabled = !config.isPreviewEnabled;
const getPreviewId = idx => `item-preview${idx ? `-${idx}` : ''}`;
const previewActions = [];
for (let i = 0; i < maxButtons; i++) {
const action = actions.getBy(getPreviewId(i));
if (!action) {
break;
}
previewActions.push(action);
}
if(authoringAction){
previewActions.forEach(previewAction => {
previewAction.state.disabled = !config.isPreviewEnabled;
});

const authoringAction = actions.getBy('item-authoring');
if (authoringAction) {
authoringAction.state.disabled = !config.isAuthoringEnabled;
}
actions.updateState();

$('#lock-box').each(function() {
$('#lock-box').each(function () {
lock($(this)).register();
});

//some of the others sections (like the authoring) might have an impact
//on the state of the other actions, so we reload when we come back
section
.off('show')
.on('show', sectionContext => {
if(sectionContext.id === 'manage_items'){
actions.exec('item-properties');
}
});
section.off('show').on('show', sectionContext => {
if (sectionContext.id === 'manage_items') {
actions.exec('item-properties');
}
});
}
};

Expand Down
2 changes: 1 addition & 1 deletion views/js/loader/taoItems.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/js/loader/taoItems.min.js.map

Large diffs are not rendered by default.

0 comments on commit bc141ad

Please sign in to comment.