Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:
  • Page:
  • 1
  • 2

TOPIC: Can I do quota management on Tokens fields?

Can I do quota management on Tokens fields? 3 years 9 months ago #87703

  • amoswagon
  • amoswagon's Avatar
  • Offline
  • Junior Lime
  • Posts: 20
  • Karma: 0
Can I do quota management on Tokens fields?
I want to pre-load Gender info (Male/ Female) into the tokens list.
Can I activate the quota management based on who showed up? for example I want only 50 female?

I know I can set 'show' conditions based on Tokens fields, but I couldn't find a way to limit quotas using them.

Thanks!
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 9 months ago #87728

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9305
  • Thank you received: 1330
  • Karma: 386
Hello,

To use quota, you have to put the answer in a "Single choice question" . You can use some javascript to do this.

For example, put M/F in your attribute, Question code : GENDER, SUB QUestion code : M/F, question type: List radio

And in question HTML source (with XSS filtering to no)
<script>
$(function() {
 $("question{QID} input.radio[value='{TOKEN:ATTRIBUTE_1']").click();
});
</script>

Denis
Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 9 months ago #87737

  • amoswagon
  • amoswagon's Avatar
  • Offline
  • Junior Lime
  • Posts: 20
  • Karma: 0
This is very helpful but I'm new to it, I need more details with your example.

In Tokens table:
- added attribute called 'male-female' with 'M' and 'F' values (for male and female)

In the Survey:
- added a single choice question (radio list)
- question coded in 'GENDER'
- 2 answer choices: 'M'(code) 'Male' (label), 'F' (code) 'Female' (label)
- added your javascript to the source of the question text
- replaced '{QID}' with 'GENDER'
- replaced 'ATTRIBUTE_1' with 'male-female"

What am I doing wrong?

Thanks!
Amos
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 9 months ago #87744

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9305
  • Thank you received: 1330
  • Karma: 386
amoswagon wrote:
- replaced '{QID}' with 'GENDER'
- replaced 'ATTRIBUTE_1' with 'male-female"

What am I doing wrong?
Replacing :)

Limesurvey replace itself {QID} by question number and {TOKEN:ATTRIBUTE_1} by the value of the token attribute.

See : docs.limesurvey.org/tiki-index.php?page=...stion_default_value_

Default value work for text question type, not for single choic question but .val("{TOKEN:ATTRIBUTE_1}") jquery work (for select qestion type, sure).

Denis
Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 9 months ago #87757

  • amoswagon
  • amoswagon's Avatar
  • Offline
  • Junior Lime
  • Posts: 20
  • Karma: 0
I get it now. Thank you :blush:
I managed to do it with Text type, but still it doesn't work with single.

<script>
$(function() {
$("question{QID} input.radio[value='{TOKEN:ATTRIBUTE_1']").click();
});
</script>

Do you have a syntax error? I think one '}' is missing after 'ATTRIBUTE_1'.
I'll try to figure it out by myself.

Thanks again.
Amos
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 9 months ago #87777

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9305
  • Thank you received: 1330
  • Karma: 386
amoswagon wrote:
Do you have a syntax error? I think one '}' is missing after 'ATTRIBUTE_1'.
I'll try to figure it out by myself.
You're right, and lost some # too.
$(function() {
 $("#question{QID} input.radio[value='{TOKEN:ATTRIBUTE_1}']").click();
});
Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 9 months ago #87807

  • amoswagon
  • amoswagon's Avatar
  • Offline
  • Junior Lime
  • Posts: 20
  • Karma: 0
It's working! Could you believe?! :ohmy:
Thank you!
Amos
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 9 months ago #87838

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9305
  • Thank you received: 1330
  • Karma: 386
amoswagon wrote:
It's working! Could you believe?! :ohmy:
Yes :P but if you don't have token table and token attribute_1, javascript is breaked.
Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 8 months ago #89907

  • amoswagon
  • amoswagon's Avatar
  • Offline
  • Junior Lime
  • Posts: 20
  • Karma: 0
Hi.

Since I upgraded to 2.00+ the javascript you gave me does not work!?
Very frustrating!

Any ideas?

Amos
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 8 months ago #89918

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6214
  • Thank you received: 1376
  • Karma: 539
Have you upgraded to the latest version? There was a problem with {QID} in 2.0 but it has been fixed recently.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 8 months ago #89920

  • amoswagon
  • amoswagon's Avatar
  • Offline
  • Junior Lime
  • Posts: 20
  • Karma: 0
Yes. Upgraded to: Version 2.00+ Build 121208

Still doesn't work.
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 8 months ago #89922

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6214
  • Thank you received: 1376
  • Karma: 539
Are you getting any JavaScript errors? Can you activate a test survey for us to see?

T.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 8 months ago #89928

  • amoswagon
  • amoswagon's Avatar
  • Offline
  • Junior Lime
  • Posts: 20
  • Karma: 0
Yes. I do receive Javascript errors.
Even simple javascript to hide the question don't work anymore:

<script type="text/javascript" charset="utf-8">
$("#question{QID}").hide();
</script>Are you?

{QID} and {TOKEN:ATTRIBUTE_1} by themselves work and retrieve the values correctly.

Here is a survey example we I try to hide the question using Javascript:
datachili.invokesolutions.com/index.php/...x/sid/748622/lang/en
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 8 months ago #89930

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6214
  • Thank you received: 1376
  • Karma: 539
Ah, I see.

In 2.0 you need to replace this in startpage.pstpl:
<script type="text/javascript" src="{TEMPLATEURL}template.js"></script>

With this placeholder tag that now includes all required JavaScript:
{TEMPLATEJS}
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 3 years 8 months ago by tpartner.
The administrator has disabled public write access.

Can I do quota management on Tokens fields? 3 years 8 months ago #89931

  • amoswagon
  • amoswagon's Avatar
  • Offline
  • Junior Lime
  • Posts: 20
  • Karma: 0
How could I ever find that!?

Thank you so much!!!
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.466 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form