Putting numbers up front for scale questions

Updated at March 13th, 2020

When projects are imported from the SPSS file the questions can have a format that looks like this: 

Placing the numbers in the front instead of the back can make the information more readable and visually appealing. 


7 point scale

There are a few ways to do this, you can either edit the format for any question, or use the console.

The following code will move the number to the front, e.g., 'Most Valuable 7' to '7 Most Valuable.'

protobi.getDimensions().forEach(function(dim) { var fmt = dim.get('format'); if (fmt) { for (var key in fmt) { var d =fmt[key].slice(-1); if (d==+d) { console.log(fmt[key]); fmt[key] = d + ' ' + fmt[key].slice(0,-1)}} }})


It can be seen in the console of the below project: 

10 point scale

The following code works for 10 point scales because it will move two digit numbers to the front, e.g., 'Excellent 10' to '10 Excellent.' Similar to the code above for 7 point scales, put this code in your console. 

protobi.getDimensions().forEach(function(dim) { var fmt = dim.get('format'); if (fmt) { for (var key in fmt) { var d =fmt[key].slice(-2); if (d==+d) { console.log(fmt[key]); fmt[key] = d + ' ' + fmt[key].slice(0,-2)}} }})


The two sets of code above are examples of how JavaScript can be utilized to efficiently modify your Protobi project.


Was this article helpful?