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

TOPIC: Saving totals to DB

Saving totals to DB 2 years 11 months ago #65479

  • sitiomatic
  • sitiomatic's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
Hello everyone.
I have a poll with 5 sections of 20 questions.
It is a contest, and each question has a 1 point value. Wins the contest the participant who gets more points.
When the survey is complete it shows the result to the participant.
My problem is that it is not recorded anywhere and when I export the results I have not the total of each participant.
Since the only information that interests me is the total of each participant, how can get this saved to export it?
Thanks for the help!
The administrator has disabled public write access.

Re: Saving totals to DB 2 years 11 months ago #65481

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
LimeSurvey 1.92 solves this. There is an Equation question type that can compute and store totals. See details here.

I'm afraid you'll have to ask someone else for suggestions about how to do this with LimeSurvey 1.91+
The administrator has disabled public write access.

Re: Saving totals to DB 2 years 11 months ago #65483

  • Ben_V
  • Ben_V's Avatar
  • OFFLINE
  • Platinum Lime
  • Posts: 1067
  • Thank you received: 235
  • Karma: 74
Hi,
1) Set your survey "group by group" or "question by question"
2) Create a (hidden) numerical input question type
3) in the source of the question put this js code snippet adapting the SGQA Identifier
123*= Survey ID
456*= Question Group ID
789*= Question ID
<script> 
jQuery(document).ready(function() {
	document.getElementById('answer123X456X789').value = "{assessment_CURRENT_TOTAL}";
document.getElementById('display789').style.display= "none";
document.getElementById('answer123X456X789').style.display= "none";
});
</script>
Check it
* just for the example...could be more digits

SGQA.gif
Benoît

goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche)
goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar)
goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de...
Last Edit: 2 years 11 months ago by Ben_V.
The administrator has disabled public write access.

Re: Saving totals to DB 2 years 11 months ago #65518

  • sitiomatic
  • sitiomatic's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
The script is working great. Thanks!
I have a problem adding the text <script> to the question. When I save the question, <script> is replaced with <sc<x>ript> and it doesn't work.
I added the text to the database using phpmyadmin.
Html editor is off.
The administrator has disabled public write access.

Re: Saving totals to DB 2 years 11 months ago #65520

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2605
  • Thank you received: 302
  • Karma: 110
Did you follow the instructions on how to use JS in Limesurey? You need to switch off the XSS filter...
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Re: Saving totals to DB 2 years 11 months ago #65521

  • sitiomatic
  • sitiomatic's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
Thanks holch! Now everything it's working fine :)
The administrator has disabled public write access.

Re: Saving totals to DB 2 years 11 months ago #65803

  • jg2011
  • jg2011's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
I am on 1.90 build 9343.
I have tried the exact steps described by Ben above. I have javascript seton via the XSS switch.
The assessment total is displayed correctly at the end of the survey.

<script>
jQuery(document).ready(function() {
document.getElementById('answer73863X92X946').value = "{assessment_CURRENT_TOTAL}";
document.getElementById('display73863').style.display= "none";
document.getElementById('answer73863X92X946').style.display= "none";
});
</script>

But the assessment_CURRENT_TOTAL is not stored in the database by the javascript above.

What else is missing in the steps above? Note: I have only one question group, and the hidden question is the last question (946) in that group (92).

Do I need to thave a line for GROUP in the ASSESSMENTS Area of the survey? I only have one line now - for the TOTAL. And THAT is working.

Your help is appreciated.
The administrator has disabled public write access.

Re: Saving totals to DB 2 years 11 months ago #65807

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6252
  • Thank you received: 799
  • Karma: 239
Can you try:
<script>
jQuery(document).ready(function() {
('#question946 input.text').val({assessment_CURRENT_TOTAL});
// ('#question946').hide(); // remove the // after testing to hide the question
});
</script>
The administrator has disabled public write access.

Re: Saving totals to DB 2 years 11 months ago #65817

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 293
  • Karma: 248
jg2011 wrote:
What else is missing in the steps above? Note: I have only one question group, and the hidden question is the last question (946) in that group (92).
If I remember correctly the function to calculate the current total assessment value reads out the data from the database. Data is saved to the database each time you click next so you should try to switch your survey to question-by-question mode or add a second group holding the numrical question.

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: Saving totals to DB 2 years 10 months ago #65890

  • jg2011
  • jg2011's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Thank you both for the prompt assistance.
Shnoulee: Is there something missing here?
('#question946 input.text').val({assessment_CURRENT_TOTAL});
There is no $ at the beginning and that space between the 6 and the i...how does that work? Please note, I am NOT a javascript expert.

Mazi: The Next button does cause assessment_CURRENT_TOTAL to be calculated. I was able to see this when I added a numeric question at the end of the question group, added the exact code as shown, and made it visible rather than hidden. However, IF the question is then hidden, it doesn't calculate!!! I don't want the user to see the interim assessment score. Since all answers are mandatory, if they would not complete a response, and then lick Next, an error message would be displayed - along with the raw assessment score.

One option is to make the survey question by question.

But I do not see why hiding a question should cause the code not to execute.

Ideas and thoughts welcome.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.270 seconds
Donation Image