Skip to main content
Nadya-volg-1983
Participant
July 20, 2016
Question

how to get an corresponding variable?

  • July 20, 2016
  • 1 reply
  • 430 views

What can be done to output integer value variable, or no more than 3 characters. Values after the decimal point is not necessary to show.

This topic has been closed for replies.

1 reply

Lilybiri
Legend
July 20, 2016

Why not use the quizzing system variables, at least to 'show' the results? They have the proper formatting.

For user variables, you'll need to use JavaScript to format the result.

Nadya-volg-1983
Participant
July 20, 2016

I wrote the script

(function () {

    var PZ_result = '$$PZ_result$$'.split('.');

  })();

gives an error message

     

Lilybiri
Legend
July 20, 2016

You need to use the API for JS, something like this:

var num = window.cpAPIInterface.getVariableValue('myVar');

window.cpAPIInterface.setVariableValue('myVar', num.toFixed(2));