Skip to content

Commit

Permalink
Fixed issue #10949: numbering of sub questions The first subquestion …
Browse files Browse the repository at this point in the history
…is numbered with leading 0, like SQ001, while the following is numbered SQ2, SQ3 etc.
  • Loading branch information
LouisGac committed Apr 22, 2016
1 parent dec5874 commit 8d05392
Showing 1 changed file with 25 additions and 35 deletions.
60 changes: 25 additions & 35 deletions scripts/admin/subquestions.js
Expand Up @@ -108,7 +108,7 @@ function bindClickIfNotExpanded()
*/
function getRelevanceToolTip()
{
var relevanceTooltip = !relevanceIsExpanded() ?
var relevanceTooltip = !relevanceIsExpanded() ?
'data-toggle="tooltip" data-title="' + clickToExpand + '"' :
'';

Expand Down Expand Up @@ -393,41 +393,31 @@ function updatecodes()

function getNextCode(sSourceCode)
{

i=1;
found=true;
mNumberFound=-1;
while (i<=sSourceCode.length && found)
{
found=is_numeric(sSourceCode.substr(-i));
if (found)
{
mNumberFound=sSourceCode.substr(-i);
i++;
}
}
if (mNumberFound==-1)
{
sBaseCode=sSourceCode;
mNumberFound=0
}
else
{
sBaseCode=sSourceCode.substr(0,sSourceCode.length-mNumberFound.length);
}
var iNumberFound=+mNumberFound;
do
sourcecode = sSourceCode;
i=1;
found=true;
foundnumber=-1;
sclength = sourcecode.length;
while (i<=sclength && found == true)
{
found=is_numeric(sourcecode.substr(sclength-i,i));
if (found)
{
iNumberFound=iNumberFound+1;
sNewNumber=iNumberFound+'';
sResult=sBaseCode+sNewNumber;
if (sResult.length>5)
{
sResult=sResult.substr(sResult.length - 5);
}
foundnumber=sourcecode.substr(sclength-i,i);
i++;
}
while (areCodesUnique(sResult)==false);
return(sResult);
}
if (foundnumber==-1)
{
return(sourcecode);
}
else
{
foundnumber++;
foundnumber=foundnumber+'';
result=sourcecode.substr(0,sclength-foundnumber.length)+foundnumber;
return(result);
}
}

/**
Expand Down Expand Up @@ -508,7 +498,7 @@ function code_duplicates_check()

// Flash the elements that are duplicates
//$theDuplicateElement.fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);

}
});
cansubmit= false;
Expand Down

0 comments on commit 8d05392

Please sign in to comment.