Skip to main content
September 7, 2010
Question

Quiz results not rounding on certificate

  • September 7, 2010
  • 1 reply
  • 1003 views

I have an AS3 certicate that I am using from Captivate 4 in Captivate 5.  Though the certificate imports correctly since it is AS3, the score is not rounded to 2 decimal places like it was in Captivate 4.  For example:  C4 result = 94.46%  C5 result = 94.455555555555%.  This looks unattractive on a certificate especially on such a short line.  Does anyone know AS3 enough to show me how to edit the file to achieve the rounding?  The C4 file gave no clues.

This topic has been closed for replies.

1 reply

September 7, 2010

Try and see if the following code will do it

var varToRound:Number = 83.333555;

var tempStr:String = String (varToRound);
var digitToRound:int = 0;
var NumOfDigitsAfterDot:int = 5;

var dotIndex:int = tempStr.indexOf (".");
if (int(tempStr.substr(dotIndex + NumOfDigitsAfterDot+1, 1)) >=5) {
digitToRound = int(tempStr.substr(dotIndex + NumOfDigitsAfterDot, 1)) + 1;


} else {

digitToRound = int(tempStr.substr(dotIndex + NumOfDigitsAfterDot, 1));
}
var tempStr2:String = tempStr.substring(0, dotIndex+NumOfDigitsAfterDot)+String(digitToRound);
var resultVar:Number = Number (tempStr2);

trace ("resultVar= " + resultVar);

September 7, 2010

Thanks for the response, but it not helping.  According to flash CS5, it is returning a result of 83.33356.  When I import it to Captivate, it is not rounding.  Should I be substituting the "var" or any names with my variable name (v_Score)?

September 7, 2010

Yes, yuou should substitue varToRound with whatever variable you want to round. Also, set NumOfDigitsAfterDot to how many digits you want to round after the dot.