Forum Discussion
Hello,
I hope anybody can help. I want to rank (13) scores (variables) that are determined through an assessment. The scores then need to be ranked (descending order) and then match to variables RankOne, RankTwo, etc.
This is how far I got:
Yes, I checked the article. It was not that much helpful so we decided to make a custom code for it.
here's the latest code:
var player = GetPlayer();
var Analytical_Score = player.GetVar("Analytical_Score");
var Collaborative_Score = player.GetVar("Collaborative_Score");
var Adaptable_Score = player.GetVar("Adaptable_Score");
var data = [Analytical_Score, Collaborative_Score, Adaptable_Score];
var count = 0;
var values = [] ;
for (var i = 0; i < data.length; i++) {
count = count+1
}
var data1 = new Array();
// $.each( data, function( key, value ) {
for (var i = 0; i < data.length; i++) {
data1[i] = data[i].value;
}
// these code are important for reading the score. need to call these variables after sorting is done
// var RankOne = data[0];
// var RankTwo = data[1];
// var RankThree = data[2];
document.write(data[i] + "<br >" ) ;
// for descending order
data1.reverse(data1.sort());
// for ascending order
data1.sort();
player.SetVar("OrderScore",data);