- Posts: 8
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Hide the equation question value $('.question-text span[id^="LEMtailor_Q_"]:eq(0)', thisQuestion).hide(); // Listener on the slider $('.numeric-multi:eq(0) input[type=text]:eq(0)').on('slideStop', function(event) { var ansSQ001 = $.trim($('.question-text span[id^="LEMtailor_Q_"]:eq(0)', thisQuestion).text()); // get subquestion answer var ans = ansSQ001; var A1 = 1; // matrix cell A1 var B1 = 2; // matrix cell B1 if (ans<0) { B1 = 1/Math.abs(ans); } else { B1 = ans; } // 'inverts' negative scores var A2 = 1/B1; // matrix cell A2 var B2 = 1; // matrix cell B2 var ColA = A1 + A2; // matrix column A var ColB = B1 + B2; // matrix column B var Row1norm = (A1/ColA + B1/ColB)/2; // average of normalized cells A1 and B1 var Row2norm = (A2/ColA + B2/ColB)/2; // average of normalized cells A2 and B2 var Row1avg = Row1norm.toFixed(2); // Row 1 average rounded to 2 decimal places var Row2avg = Row2norm.toFixed(2); // Row 2 average rounded to 2 decimal places // Clear old text $('.question-text .inserted-text', thisQuestion).remove(); // Insert new text $('.question-text', thisQuestion).append('<div class="inserted-text">\ 2x2 matrix, comparing Alpa to Beta\ <br><br>'+ans+'\ <br>priority Alpha: '+Row1avg+'\ <br>priority Beta: '+Row2avg+'\ </div>'); }); }); </script>
... var thisQuestion = $('#question{QID}'); var equation2= $(thisQuestion).nextAll('.equation:eq(1)'); var equation3= $(thisQuestion).nextAll('.equation:eq(2)'); var equation4= $(thisQuestion).nextAll('.equation:eq(3)'); ... ... var ansSQ001 = $.trim($('.question-text span[id^="LEMtailor_Q_"]:eq(0)', thisQuestion).text()); var ansSQ002 = $.trim($('.question-text span[id^="LEMtailor_Q_"]:eq(0)', equation2).text()); var ansSQ003 = $.trim($('.question-text span[id^="LEMtailor_Q_"]:eq(0)', equation3).text()); var ansSQ004 = $.trim($('.question-text span[id^="LEMtailor_Q_"]:eq(0)', equation4).text()); ...