Skip to content

Commit

Permalink
Fixed issue #17593: Generated answer code is too long (#2059)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieljenik committed Oct 22, 2021
1 parent d2f29d4 commit 112e8d9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions assets/scripts/admin/questionEditor.js
Expand Up @@ -929,7 +929,7 @@ $(document).on('ready pjax:scriptcomplete', function () {
// TODO: Doc answers
const answers = {};
const lsrows = $('#quickaddarea').val().split('\n');
const allrows = $closestTable.find('tr').length;
const allrows = $closestTable.find('tbody tr').length;
const separatorchar = getSeparatorChar(lsrows);

let numericSuffix = '';
Expand Down Expand Up @@ -958,14 +958,16 @@ $(document).on('ready pjax:scriptcomplete', function () {
const thisrow = value.splitCSV(separatorchar);

if (thisrow.length <= languages.length) {
let qCode = (parseInt(k) + 1).toString();
let numericCode = (parseInt(k) + 1);
if (lsreplace === false) {
qCode += (parseInt(allrows));
numericCode += (parseInt(allrows));
}
while (qCode.toString().length < numericSuffix.length) {
let qCode = numericCode.toString();
while (qCode.length < numericSuffix.length) {
qCode = `0${qCode}`;
}
thisrow.unshift(codeSigil.join('') + qCode);
let prefix = codeSigil.slice(0, Math.max(0, 5 - qCode.length)).join('');
thisrow.unshift(prefix + qCode);
} else {
thisrow[0] = thisrow[0].replace(/[^A-Za-z0-9]/g, '').substr(0, 20);
}
Expand Down

0 comments on commit 112e8d9

Please sign in to comment.