Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Access answer in Assessment Result Message

Access answer in Assessment Result Message 3 years 8 months ago #56759

  • thaJack
  • thaJack's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Karma: 0
I would like to have my assessment result message display two different things based on the answer to a specific question.

For example, if the assessment score is 100, it will display the appropriate message. That works perfectly right now.

But, I want the message to have something dynamic in it. For example:

If (answer to question 11111X2X3 = "YES")
Then display "this text"
ElseIf (answer to question 11111X2X3 = "NO")
Then display "that text"

How would I go about doing that?
The administrator has disabled public write access.

Re: Access answer in Assessment Result Message 3 years 8 months ago #56760

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4272
  • Thank you received: 806
  • Karma: 369
You should be able to create 2 assessments for the same question(s) with different ranges to display different messages.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Access answer in Assessment Result Message 3 years 8 months ago #56761

  • thaJack
  • thaJack's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Karma: 0
Yes, but that won't work for me. Let's say I were making a test and a score of 100+ were passing.

In the end, the assessment score is 150. It will display the appropriate assessment message for that score.

However, if the answer to question 11111X2X3 is "YES", I also want it to display something else with it.

Having multiple assessment messages won't help me in this case, as it would show both messages regardless of the answer to 11111X2X3

If 11111X2X3 = YES adds 10 points and NO adds 0 points, you will still end up at 100+ and get the assessment message. You have no way to have a message display based on a single answer.

In a nutshell, if assessment score >X and answer to 11111X2X3 = YES I want to display one message, and if 11111X2X3 = NO I want to display something different.

I imaging some Javascript is necessary in the assessment message, but I need to be able to access the answer to a specific question.
Last Edit: 3 years 8 months ago by thaJack. Reason: Clarification
The administrator has disabled public write access.

Re: Access answer in Assessment Result Message 3 years 8 months ago #56771

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5331
  • Thank you received: 296
  • Karma: 249
thaJack wrote:
If 11111X2X3 = YES adds 10 points and NO adds 0 points, you will still end up at 100+ and get the assessment message. You have no way to have a message display based on a single answer.
That is not true. You can add 1000 point if the answer to question X is yes and you set a second assessment with MAX=1150 this second message should only show up if the question was answered "yes".

You set need to set scores and limits carefully.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Access answer in Assessment Result Message 3 years 8 months ago #56778

  • thaJack
  • thaJack's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Karma: 0
I have multiple answers within the survey that add 150 to the assessment value. The number of those could change from day to day.

Essentially what I'm doing is trying to set a "trigger." If any of the "trigger" answers are selected during the survey I want it to tell the person "XYZ" at the end. If none of the triggers are hit, I want it to say "ABC" at the end.

However, if none of the triggers were hit, and the answer to question 11111X2X3 = "YES" then I want it to tell them "DEF" in addition to "ABC".

I may submit this as a feature, but it would be neat if the assessment values on answers accepted three different things:

"+10": would add 10 to the assessment score.
"-10": would subtract 10 from the assessment score.
"10" or "=10": would set the assessment score to 10.

So maybe if they answered the first question with an answer set to "+10" it would make their assessment score "10". Then, on the next question the value was "-5", it would bring their total back down to "5". Then, on the third question they hit one where the assessment value is "50", it would make their total "50".

I would love to be able to set the assessment value to something rather than adding/subtracting it every time.

This way, I could have all of my triggers set to "=150" and if they hit any of them, no matter how many, I would know that at the end the assessment would result in "150".

Additionally, it would be nice to be able to have the assessment score a condition of a question. For example, only show this question if the running assessment score is ">=100".
The administrator has disabled public write access.

Re: Access answer in Assessment Result Message 3 years 8 months ago #56799

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4272
  • Thank you received: 806
  • Karma: 369
I think the only way to accomplish this is to use JavaScript and a cookie to pass the value of question 11111X2X3 into the end page and then display message "DEF" accordingly.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 3 years 8 months ago by tpartner.
The administrator has disabled public write access.

Re: Access answer in Assessment Result Message 3 years 8 months ago #56802

  • thaJack
  • thaJack's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Karma: 0
Is that something easy to do?
The administrator has disabled public write access.

Re: Access answer in Assessment Result Message 3 years 8 months ago #56839

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5331
  • Thank you received: 296
  • Karma: 249
Tony offers advanced, paid support, he might be able to help you out with this.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Access answer in Assessment Result Message 3 years 8 months ago #56853

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4272
  • Thank you received: 806
  • Karma: 369
Is that something easy to do?
It's not hard. The following example stores the answer to a Yes/No question in a cookie and then only displays the end message if that answer is "Yes".

1) Set up your survey to use JavaScript.

2) Add the following to the source of a question (or question help) in the last page of the survey. Replace "11111X22X33" with the SGQA of a Yes/No question on a previous page. The script will create a cookie with the answer of the Yes/No.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		// Set a cookie with the answer of the Yes/No question
		document.cookie = 'q1Answer={INSERTANS:11111X22X33}';		
 
	})
 
</script>

3) Create your dynamic end message and wrap it in a span element that can be dynamically hidden and shown. In the source of the end messsage, add something like:
<span class="dynamicMessage">Some end message that is only displayed if the yes/No question is "Yes".</span>

4) Also in the source of the end messsage, add the following script. It will initially hide the end message and then retrieve the cookie. If the cookie value is "Yes" the end message will be displayed.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		// A function to get the value of a cookie by name
		function getCookie (cookieName) {
			var results = document.cookie.match ('(^|;) ?' + cookieName + '=([^;]*)(;|$)');
 
			if (results) {
				return (unescape (results[2]));
			}
			else {
				return null;
			}
		}
 
		// Hide the dynamic message
		$('.dynamicMessage').hide();
 
		// Retrieve the cookie value
		var q1Answer = getCookie ('q1Answer');
 
		// Display the message if the answer is "Yes"
		if(q1Answer == 'Yes') {
			$('.dynamicMessage').show();
		}
 
	});
 
</script>

So, this should let you display assessment messages with a dynamic end message under them.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 3 years 8 months ago by tpartner.
The administrator has disabled public write access.

Re: Access answer in Assessment Result Message 3 years 8 months ago #56865

  • thaJack
  • thaJack's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Karma: 0
Could I use two variables in the same cookie on two different questions? For example:

<code>
document.cookie = 'q1Answer={INSERTANS:11111X22X33}';
</code>

in one question and then...

<code>
document.cookie = 'q2Answer={INSERTANS:11111X22X34}';
</code>

In a second question? Would I query them the same way on my assessment result page? I only want to show the dynamic message, for example, if both questions are YES.

I would do (if... and... else), obviously. But they could be stored in the same cookie?
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.137 seconds
Donation Image