I would write your own "group score" values to hidden
equation type questions
. Then they are in the data and also can be accessed by Expression manager.
See
Qcode.value here -
www.limesurvey.org/manual/Expression_Man...#Access_to_Variables
.
So, the first equation question could be something like:
Code:
{sum(G1Q1.value, G1Q2.value, G1Q3.value,...)}
The second equation question something like:
Code:
{sum(G2Q1.value, G2Q2.value, G2Q3.value,...)}
...
Then, your JS would look something like this (where
equation1,
equation2, etc. are the equation question codes):
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify this question
var thisQuestion = $('#question{QID}');
// Define the group scores
var scores = {
G1: {equation1},
G2: {equation2},
G3: {equation3},
G4: {equation4},
G5: {equation5}
};
// Sort the array
var tuples = [];
for (var key in scores) tuples.push([key, scores[key]]);
tuples.sort(function(a, b) {
a = a[1];
b = b[1];
return a < b ? -1 : (a > b ? 1 : 0);
});
// Loop through the sorted array
for (var i = 0; i < tuples.length; i++) {
var key = tuples[i][0];
var value = tuples[i][1];
// Display in question text
$('.question-text', thisQuestion).append('<br />'+key+': '+value+'');
// Insert into textarea
$('textarea', thisQuestion).val($('textarea', thisQuestion).val()+key+': '+value+'\n');
}
});
</script>