diff --git a/application/config/version.php b/application/config/version.php
index 594f44e2520..d4ff4794dc2 100644
--- a/application/config/version.php
+++ b/application/config/version.php
@@ -12,7 +12,7 @@
*/
$config['versionnumber'] = '5.3.2';
-$config['dbversionnumber'] = 482;
+$config['dbversionnumber'] = 483;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['templateapiversion'] = 3;
diff --git a/application/helpers/update/updates/Update_483.php b/application/helpers/update/updates/Update_483.php
new file mode 100644
index 00000000000..c6761021fe6
--- /dev/null
+++ b/application/helpers/update/updates/Update_483.php
@@ -0,0 +1,15 @@
+
'/>
- ' name='code_' maxlength='5' size='6' value=''/>
+ ' name='code_' maxlength='20' size='20' value=''/>
diff --git a/application/views/questionAdministration/modals.twig b/application/views/questionAdministration/modals.twig
index a0a3ffe998f..96646e1961c 100644
--- a/application/views/questionAdministration/modals.twig
+++ b/application/views/questionAdministration/modals.twig
@@ -49,6 +49,9 @@
+
+ {{ gT('Warning: Some answer codes will be truncated.') }}
+
diff --git a/assets/scripts/admin/questionEditor.js b/assets/scripts/admin/questionEditor.js
index 2d4e1698a81..acb82d53fe0 100644
--- a/assets/scripts/admin/questionEditor.js
+++ b/assets/scripts/admin/questionEditor.js
@@ -622,6 +622,7 @@ $(document).on('ready pjax:scriptcomplete', function () {
function labelSetDestruct() {
$('#labelsets').select2('destroy');
$('#labelsetpreview').empty();
+ $('#longcodesalert').hide();
}
/**
@@ -649,6 +650,8 @@ $(document).on('ready pjax:scriptcomplete', function () {
const $tabindex = $('');
const $tabbody = $('');
+ var hasInvalidCodes = false;
+ const source = $('#labelsetbrowserModal').data('source');
const i = 0;
$.each(json.languages, (language, languageName) => {
const $linkItem = $aTemplate.clone();
@@ -670,18 +673,27 @@ $(document).on('ready pjax:scriptcomplete', function () {
labelSet.labels.forEach((label) => {
// Label title is not concatenated directly because it may have non-encoded HTML
- const $labelTitleDiv = $('');
+ const $labelTitleDiv = $('');
$labelTitleDiv.text(label.title);
const $listItem = $listItemTemplate.clone();
- $listItem.append(`${label.code} `);
+ $listItem.append(`${label.code} `);
$listItem.append($labelTitleDiv);
- $listItem.append('');
$listItem.attr('data-label', JSON.stringify(label));
$itemList.append($listItem);
+
+ if (source === 'answeroptions' && label.code.length > 5) {
+ hasInvalidCodes = true;
+ }
});
$bodyItem.append(`${labelSet.label_name}`); // jshint ignore: line
$itemList.appendTo($bodyItem);
+
+ if (hasInvalidCodes) {
+ $('#longcodesalert').show();
+ } else {
+ $('#longcodesalert').hide();
+ }
});
$('#labelsetpreview').empty();
$('').append($tabindex).append($tabbody).appendTo($('#labelsetpreview'));
@@ -811,6 +823,9 @@ $(document).on('ready pjax:scriptcomplete', function () {
$tr = $row.eq(4);
} else if (source === 'answeroptions') {
$tr = $row.eq(2);
+
+ // Make sure codes are limited to 5 characters
+ label.code = label.code.substr(0, 5);
} else {
throw 'source is not subquestions or answeroptions: ' + source;
}
@@ -1672,6 +1687,8 @@ $(document).on('ready pjax:scriptcomplete', function () {
$('#labelsetbrowserModal').modal('show');
initLabelSetModal(event);
+
+ $('#labelsetbrowserModal').data('source', source);
},
/**
diff --git a/installer/create-database.php b/installer/create-database.php
index c019f43bfb9..3ea964241f7 100755
--- a/installer/create-database.php
+++ b/installer/create-database.php
@@ -173,7 +173,7 @@ function populateDatabase($oDB)
$oDB->createCommand()->createTable('{{labels}}', array(
'id' => "pk",
'lid' => "integer NOT NULL DEFAULT 0",
- 'code' => "string(5) NOT NULL default ''",
+ 'code' => "string(20) NOT NULL default ''",
'sortorder' => "integer NOT NULL",
'assessment_value' => "integer NOT NULL default '0'",
), $options);
|