- Posts: 1128
- Thank you received: 329
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Multiple assessment values for multiple-choice question.
- Ben_V
- Topic Author
- Offline
- Platinum Member
Less
More
10 years 3 months ago - 10 years 3 months ago #103781
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Multiple assessment values for multiple-choice question. was created by Ben_V
Hello,
Since LS 1.90 it's not possible to set separately assessment values. This value is the same for all answer options and have to be set in the advanced settings of the question.
I suppose that it won't be a hard task to retrieve the correct score using an equation type question (equation may need a long expression depending on the items number ->see attached img), but is there a way to achieve this using javascript?
Many thanks for any help you can provide...
Ben
Since LS 1.90 it's not possible to set separately assessment values. This value is the same for all answer options and have to be set in the advanced settings of the question.
I suppose that it won't be a hard task to retrieve the correct score using an equation type question (equation may need a long expression depending on the items number ->see attached img), but is there a way to achieve this using javascript?
Many thanks for any help you can provide...
Ben
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Attachments:
Last edit: 10 years 3 months ago by Ben_V.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
10 years 3 months ago #103786
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Multiple assessment values for multiple-choice question.
Hi Ben,
The easiest approach with JavaScript would probably be to append the score value to the answer codes. Then on page submit, we could detect which items are checked, add those scores and load them in a hidden text question. (I assume the scored question would be a multiple-choice)
Is this more or less what you're after?
The easiest approach with JavaScript would probably be to append the score value to the answer codes. Then on page submit, we could detect which items are checked, add those scores and load them in a hidden text question. (I assume the scored question would be a multiple-choice)
Is this more or less what you're after?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Ben_V
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
10 years 3 months ago - 10 years 3 months ago #103791
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Multiple assessment values for multiple-choice question.
Thanks Tony,
Yes your approach looks great...
if answer options are (code/points):
opt11 :1 point
opt12: 1 point
opt21: 2 points
opt22: 2 points
opt31: 3 points
opt32: 3 points
the overall assessment value have to be 0 (and the js code will refer to all answer options)
...or it's possible to use for example "1" and set the js only for options scoring 2 or 3 points ?
Yes your approach looks great...
if answer options are (code/points):
opt11 :1 point
opt12: 1 point
opt21: 2 points
opt22: 2 points
opt31: 3 points
opt32: 3 points
the overall assessment value have to be 0 (and the js code will refer to all answer options)
...or it's possible to use for example "1" and set the js only for options scoring 2 or 3 points ?
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Last edit: 10 years 3 months ago by Ben_V.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
10 years 3 months ago #103794
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Multiple assessment values for multiple-choice question.
The overall assessment value wouldn't matter because this workaround wouldn't use the built-in assessments at all. Any assessment message(s) would need to be generated by Expression Manager depending on the value of the hidden question.
I'll get an example to you later today.
Another question...would you need this to be dynamic on this page or would it just affect a message or something later in the survey?
I'll get an example to you later today.
Another question...would you need this to be dynamic on this page or would it just affect a message or something later in the survey?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Ben_V
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
10 years 3 months ago - 10 years 3 months ago #103800
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Multiple assessment values for multiple-choice question.
Thanks again Tony,
I just need to retrieve the total score for this question.. so I don't need nothing dynamic on the page
I was planning a 2 groups question (survey display: group by group):
Group 1:
- Q1 the multiple-choice question.
Group 2:
- Qscore (numerical)
When all this will be working, I will add a radio type question (if possible in group 2) to retrieve an assessment based on the Qscore question.
In fact I don't use EM to grab this assessment into the db, but a prefilled radio question.
something like:
PS: it's not an urgent matter at all...
I just need to retrieve the total score for this question.. so I don't need nothing dynamic on the page
I was planning a 2 groups question (survey display: group by group):
Group 1:
- Q1 the multiple-choice question.
Group 2:
- Qscore (numerical)
When all this will be working, I will add a radio type question (if possible in group 2) to retrieve an assessment based on the Qscore question.
In fact I don't use EM to grab this assessment into the db, but a prefilled radio question.
something like:
Code:
$(document).ready(function() { var ACT = '{ASSESSMENT_CURRENT_TOTAL}'; var SGQ = '10002X65X1215'; // LS < 1.91 // var SGQ = '{SGQ}'; // LS > 1.92 if(ACT == 0) document.getElementById('answer'+SGQ+'A0').checked=true; if(ACT == 2) document.getElementById('answer'+SGQ+'A1').checked=true; if(ACT >= 3) document.getElementById('answer'+SGQ+'A2').checked=true; // document.limesurvey.submit(); });
PS: it's not an urgent matter at all...
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Last edit: 10 years 3 months ago by Ben_V.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
10 years 3 months ago #103823
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Multiple assessment values for multiple-choice question.
Okay, so here is a test survey.
In group 1, there is a multiple-choice followed by a short-text (note that the short-text must be place directly after the multiple-choice).
"Scores" are appended to the sub-question codes of the multiple-choice.
The short-text contains the script below that:
- Hides the short-text
- Puts a listener on the multiple-choice checkboxes
- When a checkbox is changed, the scores for all checked options are totaled and loaded into the short-text.
Group 2 simply contains a text-display question that presents the score.
.
In group 1, there is a multiple-choice followed by a short-text (note that the short-text must be place directly after the multiple-choice).
"Scores" are appended to the sub-question codes of the multiple-choice.
The short-text contains the script below that:
- Hides the short-text
- Puts a listener on the multiple-choice checkboxes
- When a checkbox is changed, the scores for all checked options are totaled and loaded into the short-text.
Group 2 simply contains a text-display question that presents the score.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the questions var qID = {QID}; var thisQuestion = $('#question'+qID); var prevMultiChoice = $(thisQuestion).prevAll('.multiple-opt:eq(0)'); // Hide this question $('#question'+qID).hide(); // Find the initial score var totalScore = 0; $('input.checkbox:checked', prevMultiChoice).each(function(i) { var thisScore = $(this).attr('id').slice(-1); totalScore = totalScore + Number(thisScore); }); // Store the score $('input[type="text"]', thisQuestion).val(totalScore); // Listener on the checkboxes $('input.checkbox', prevMultiChoice).change(function(event) { // Find the score totalScore = 0; $('input.checkbox:checked', prevMultiChoice).each(function(i) { var thisScore = $(this).attr('id').slice(-1); totalScore = totalScore + Number(thisScore); }); // Store the score $('input[type="text"]', thisQuestion).val(totalScore); }); }); </script>
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: Ben_V
The topic has been locked.
- Ben_V
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
10 years 3 months ago #103824
by Ben_V
Tony, I don't know what to say... only it's really genial and that I won't regret LS 1.87 anymore !
Hope that your nice sample will help some other users.
The good extra surprise is that very few lines of code are needed.
Thanks a lot, again.
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Multiple assessment values for multiple-choice question.
Tony, I don't know what to say... only it's really genial and that I won't regret LS 1.87 anymore !
Hope that your nice sample will help some other users.
The good extra surprise is that very few lines of code are needed.
Thanks a lot, again.
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.