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

TOPIC: {INSERTANS:{SGQ}} in 1.92rc1

Re: {INSERTANS:{SGQ}} in 1.92rc1 2 years 10 months ago #71868

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
flocs wrote:
What I could have done until now (1.91+) is
$("#answer{SGQ}").val(computedValue);
//without the need of changing anything

$("#answer{SGQ}").val(computedValue); is supported in 1.92
The administrator has disabled public write access.

Re: {INSERTANS:{SGQ}} in 1.92rc1 2 years 10 months ago #71873

  • fransmarcelissen
  • fransmarcelissen's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 169
  • Thank you received: 31
  • Karma: 10
Thanks for your answer, Tom.
1. If I am really the only person who uses {INSERTANS:{SGQA}}, and if the alternatives do the same, no problem, I will change the questionnaires that uses this. But this feature (or dirty trick, or workaround) is so useful that I am sure that if others realize this, they will use it als well (maybe we should keep this silently.....)
2. Probably I am missing something stupid: but how are default values supported in 1.92? I do not know how to do it in text boxes or radio boxes.
3. Indeed I want the do the calculations in EM. But as an example: let's say I have 40 questions (q1-q20). First I want to calculate a raw total. There are 10 subscores, with completely different calculations. In order to make the calculation understandable, I want to break the calculations in parts. As far as I understand, in EM the whole calculation is done on one line of code, or am I missing something.
After that the standard score is calculated. But I dont want to keep the raw score, that is just a temporary intermediate variable.
As a non-programmer with 40 years of programming experience I would say that the simples way to do this is using local variables and assignments.
At this moment I do the calculations in spss. I could send you the calculations, and if there is a good way of doing this in EM, I am perfectly satisfied.
Frans
The administrator has disabled public write access.

Re: {INSERTANS:{SGQ}} in 1.92rc1 2 years 10 months ago #71877

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
fransmarcelissen-

@1 - perhaps we should have a mechanisms for people to report custom JavaScript that appears broken in 1.92 so that we can see how much, if any, of it can be supported. Of course, just using Forum and bug tracker may be sufficient for this.

@2 - Default answers are supported just as in 1.91+. You have to select from a drop-down list. So, we'd need to add a new text entry widget to let people use EM in defaults. We also would want to let defaults apply to a larger range of questions; and let defaults be assigned at the sub-question level. So, defaults don't support what you need yet.

@3 For calculations, you can have as many Equation question types as you want. You might need a dozen for what you're describing, including some that are intermediate variables and aren't really needed in the database.

Why don't you post some of the SPSS calculations and I can show you concretely how you'd do it in EM.

@3 does raise a good point, however. Right now, all questions have variables assigned to them in the database. These include boilerplate questions (type 'X'), which never have a value. For people like me who create a lot of equations (50% or more of which are intermediate values, so I don't need the results stored), that means that all those empty variables in the database means that my surveys must be shorter.

I think we should add the option to optionally exclude certain variables in the database. 'X' could always be excluded. What I've done with other clients is to have them specify a prefix for all the variables they don't care about - like "_tmp" - and then have the database generation skip those variables.

/Tom
The administrator has disabled public write access.

Re: {INSERTANS:{SGQ}} in 1.92rc1 2 years 10 months ago #71880

  • fransmarcelissen
  • fransmarcelissen's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 169
  • Thank you received: 31
  • Karma: 10
Hi Tom,
I understand that you are a supporter of declarative programming (programs without assignments or side effects). It requires another way of thinking and I agree I can do 99% of my calculations with that.
I still have the problem with the default values of text fields ({if ('{INSERTANS:{SGQ}}'==''){ $('#answer'+'{SGQ}').val('Some value');}})
The administrator has disabled public write access.

Re: {INSERTANS:{SGQ}} in 1.92rc1 2 years 10 months ago #71891

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
fransmarcelissen-

In retrospect, there is a way to do what you want:
({if ('{INSERTANS:{SGQ}}'==''){ $('#answer'+'{SGQ}').val('Some value');}})

can be done this way in JavaScript:
if (document.getElementById(LEMval('{SGQ}.shown')).value=='') {
document.getElementById(LEMval('{SGQ}.jsVarName')).value='Some Value';
}

The JQuery equivalent may also work:
if ($(LEMval('{SGQ}.shown')).val()=='') { $(LEMval('{SGQ}.jsVarName')).val('Some Value');
}

Both of these approaches use the EM-based JavaScript function LEMval() which accesses the variable attributes at run-time. Take a look at em_javascript.js for details.

If that doesn't work, it may not be hard to tweak it so that it does.

This also gives you more power than INSERTANS:SGQA, since often people want the internal coded value (which would be LEMval('{SGQ}.code')), or the assessment score (LEMval('{SGQ}.value')) rather than the display value - e.g. the language-specific text shown, which is what INSERTANS:SGQA means.

/Tom
The administrator has disabled public write access.

Re: {INSERTANS:{SGQ}} in 1.92rc1 2 years 10 months ago #71895

  • fransmarcelissen
  • fransmarcelissen's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 169
  • Thank you received: 31
  • Karma: 10
Thanks Tom,
Frans
The administrator has disabled public write access.

Re: {INSERTANS:{SGQ}} in 1.92rc1 2 years 10 months ago #71898

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5426
  • Thank you received: 307
  • Karma: 252
You're welcome :-)

If our hints have been helpful and you enjoy limesurvey please consider a donation to the team .
We do all this in our free time and you don't have to pay a penny for this software.

Without your help we can't keep this project alive.

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.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.271 seconds
Donation Image