Welcome, Guest
Username: Password: Remember me

TOPIC: Assessment Rules Message & Logic

Assessment Rules Message & Logic 3 years 8 months ago #55327

  • jazzy
  • jazzy's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Hello LimeSurvey People!

I'm wondering if it's possible to perform any type of logic based on the {TOTAL} or {PERC} numbers in the assessment Rules message section.

For example, I'd like to disply different messages based on the {TOTAL} number

if {TOTAL} > 5 then
"YOU DID GREAT"
else
"KEEP WORKING ON IT"
endif

Or maybe show a percentage like {TOTAL}/100

Is any of this possible? Thank you all!
The administrator has disabled public write access.

Re: Assessment Rules Message & Logic 3 years 8 months ago #55360

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
According to docs.limesurvey.org/Assessments&structur...tions+for+LimeSurvey you can set different max values to display different messages.

As for the percentages: Just assign the scores in a way so that the sum of answers equals 100, e.g. whne having 20 right/wrong questions assign 5 points to each correct answer.

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: Assessment Rules Message & Logic 3 years 8 months ago #55363

  • jazzy
  • jazzy's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Thanks Mazi! So what you are saying is there is no way to use a scripting language (php or java script) in this message area?

Thanks for your help and keep up the good work!
The administrator has disabled public write access.

Re: Assessment Rules Message & Logic 3 years 8 months ago #55364

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4207
  • Thank you received: 791
  • Karma: 360
You can absolutely use JavaScript in the end page.

If {TOTAL} or {PERC} aren't directly accessable to JavaScript (I haven't tested) you can place them in a hidden element and grab them from there.
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: Assessment Rules Message & Logic 3 years 8 months ago #55368

  • jazzy
  • jazzy's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Hi TPartner,

I think I read somewhere in these forums that it is possible to use javascript in the END MESSAGE section (and do some really cool stuff like you're talking about) but I was wondering about the assessment RULES MESSAGE area. I've seen nothing mentioned in these forums or in the help documents about that.

Thank you!
The administrator has disabled public write access.

Re: Assessment Rules Message & Logic 3 years 8 months ago #55396

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
Here comes an assessment test survey for Tony if he want to play around a little:

File Attachment:

File Name: Assessments-Revised.lss
File Size: 25 KB


The element needs some ID or class assigned so javascript know what element to deal with. I didn't test either but theoretically this should be possible.

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: Assessment Rules Message & Logic 3 years 8 months ago #55422

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4207
  • Thank you received: 791
  • Karma: 360
Thanks Mazi,, here's what I did with the sample survey:

1) Created 2 assessment rules to display different messages depending on the total. (0-1 = poor, 2-3 = good)

2) In the source of the assessment text, wrapped {TOTAL} in a span with a class that we can access with Javascript:
<span class="assessTotal">{TOTAL}</span>

3) In the source of the assessment text, inserted an empty span that we can load with Javascript:
<span class="assessPercent">&nbsp;</span>

4) So the complete assessment text looks like:
You did great, you got <span class="assessTotal">{TOTAL}</span> points out of a possible 3. This gives you a score of <span class="assessPercent">&nbsp;</span>%.

5) Added the following script to the source of the survey end message. The script grabs the contents of the .assessTotal span, converts it to a percentage and inserts that into the .assessPercent span. Modify the totalPossible as necessary (line 4).
<script type="text/javascript" charset="utf-8">
 
	//  EDIT HERE - Maximum possible points
	var totalPossible = 3;
 
	// Get the value of {TOTAL}
	var assessTotal = $('.assessTotal').text();
 
	// Convert it to a percentage 
	var assessPercent = (($('.assessTotal').text()/totalPossible)*100).toFixed();
 
	// Load the .assessPercent span 
	$('.assessPercent').text(assessPercent);
 
</script>


Here's the modified survey.

File Attachment:

File Name: limesurvey_survey_65617.lss
File Size: 28 KB
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.
Moderators: ITEd
Time to create page: 0.126 seconds
Donation Image