Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: ExpressionManager: Question variable access and answercount function

ExpressionManager: Question variable access and answercount function 2 Jahre 5 Monate her #77238

  • Steve
  • Steves Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 494
  • Dank erhalten: 46
  • Karma: 17
Hello,

I don't know if it is a bug but if I use a multiple choice question I cannot access the question itself. In the attached survey I can access the subquestions/answers of the "Interesse" question: "Interesse_1", "Interesse_2", ... . But if I try to use {Interesse} EM tells me the variable is undefined.
So it would be nice to have access to the question and not only the subquestions, e.g. if you want to use {Interesse.question}.

The second problem I encounterd is the count() function. Okay, it's not a problem but the expression seems to get very long if you have to count many answers (in my example 58 answers). Instead of
So, dann schauen wir mal. Insgesamt gibt es in dieser Season 58 Serien. Von diesen Serien zeigst du an count(Interesse_1, Interesse_2, Interesse_3, Interesse_4, Interesse_5, Interesse_6, Interesse_7, Interesse_8, Interesse_9, Interesse_10, Interesse_11, Interesse_12, Interesse_13, Interesse_14, Interesse_15, Interesse_16, Interesse_17, Interesse_18, Interesse_19, Interesse_20, Interesse_21, Interesse_22, Interesse_23, Interesse_24, Interesse_25, Interesse_26, Interesse_27, Interesse_28, Interesse_29, Interesse_30, Interesse_31, Interesse_32, Interesse_33, Interesse_34, Interesse_35, Interesse_36, Interesse_37, Interesse_38, Interesse_39, Interesse_40, Interesse_41, Interesse_42, Interesse_43, Interesse_44, Interesse_45, Interesse_46, Interesse_47, Interesse_48, Interesse_49, Interesse_50, Interesse_51, Interesse_52, Interesse_53, Interesse_54, Interesse_55, Interesse_56, Interesse_57, Interesse_58) ein Interesse und möchtest count(AktivMitver_1, AktivMitver_2, AktivMitver_3, AktivMitver_4, AktivMitver_5, AktivMitver_6, AktivMitver_7, AktivMitver_8, AktivMitver_9, AktivMitver_10, AktivMitver_11, AktivMitver_12, AktivMitver_13, AktivMitver_14, AktivMitver_15, AktivMitver_16, AktivMitver_17, AktivMitver_18, AktivMitver_19, AktivMitver_20, AktivMitver_21, AktivMitver_22, AktivMitver_23, AktivMitver_24, AktivMitver_25, AktivMitver_26, AktivMitver_27, AktivMitver_28, AktivMitver_29, AktivMitver_30, AktivMitver_31, AktivMitver_32, AktivMitver_33, AktivMitver_34, AktivMitver_35, AktivMitver_36, AktivMitver_37, AktivMitver_38, AktivMitver_39, AktivMitver_40, AktivMitver_41, AktivMitver_42, AktivMitver_43, AktivMitver_44, AktivMitver_45, AktivMitver_46, AktivMitver_47, AktivMitver_48, AktivMitver_49, AktivMitver_50, AktivMitver_51, AktivMitver_52, AktivMitver_53, AktivMitver_54, AktivMitver_55, AktivMitver_56, AktivMitver_57, AktivMitver_58) aktiv mitverfolgen. Du kennst bereits count(VorherKennen_1, VorherKennen_2, VorherKennen_3, VorherKennen_4, VorherKennen_5, VorherKennen_6, VorherKennen_7, VorherKennen_8, VorherKennen_9, VorherKennen_10, VorherKennen_11, VorherKennen_12, VorherKennen_13, VorherKennen_14, VorherKennen_15, VorherKennen_16, VorherKennen_17, VorherKennen_18, VorherKennen_19, VorherKennen_20, VorherKennen_21, VorherKennen_22, VorherKennen_23, VorherKennen_24, VorherKennen_25, VorherKennen_26, VorherKennen_27, VorherKennen_28, VorherKennen_29, VorherKennen_30, VorherKennen_31, VorherKennen_32, VorherKennen_33, VorherKennen_34, VorherKennen_35, VorherKennen_36, VorherKennen_37, VorherKennen_38, VorherKennen_39, VorherKennen_40, VorherKennen_41, VorherKennen_42, VorherKennen_43, VorherKennen_44, VorherKennen_45, VorherKennen_46, VorherKennen_47, VorherKennen_48, VorherKennen_49, VorherKennen_50, VorherKennen_51, VorherKennen_52, VorherKennen_53, VorherKennen_54, VorherKennen_55, VorherKennen_56, VorherKennen_57, VorherKennen_58) Serien und count(BesondersNeugierig_1, BesondersNeugierig_2, BesondersNeugierig_3, BesondersNeugierig_4, BesondersNeugierig_5, BesondersNeugierig_6, BesondersNeugierig_7, BesondersNeugierig_8, BesondersNeugierig_9, BesondersNeugierig_10, BesondersNeugierig_11, BesondersNeugierig_12, BesondersNeugierig_13, BesondersNeugierig_14, BesondersNeugierig_15, BesondersNeugierig_16, BesondersNeugierig_17, BesondersNeugierig_18, BesondersNeugierig_19, BesondersNeugierig_20, BesondersNeugierig_21, BesondersNeugierig_22, BesondersNeugierig_23, BesondersNeugierig_24, BesondersNeugierig_25, BesondersNeugierig_26, BesondersNeugierig_27, BesondersNeugierig_28, BesondersNeugierig_29, BesondersNeugierig_30, BesondersNeugierig_31, BesondersNeugierig_32, BesondersNeugierig_33, BesondersNeugierig_34, BesondersNeugierig_35, BesondersNeugierig_36, BesondersNeugierig_37, BesondersNeugierig_38, BesondersNeugierig_39, BesondersNeugierig_40, BesondersNeugierig_41, BesondersNeugierig_42, BesondersNeugierig_43, BesondersNeugierig_44, BesondersNeugierig_45, BesondersNeugierig_46, BesondersNeugierig_47, BesondersNeugierig_48, BesondersNeugierig_49, BesondersNeugierig_50, BesondersNeugierig_51, BesondersNeugierig_52, BesondersNeugierig_53, BesondersNeugierig_54, BesondersNeugierig_55, BesondersNeugierig_56, BesondersNeugierig_57, BesondersNeugierig_58) Serien machen dich besonders neugierig. 
it might be a bit shorter to write something like
So, dann schauen wir mal. Insgesamt gibt es in dieser Season 58 Serien. Von diesen Serien zeigst du an count(getAnswers(Interesse)) ein Interesse und möchtest ...
where getAnswers(Qcode) returns a comma-separated string of all answer for question Qcode.

Another function/method might be a comparision method like getAnswersComp(Qcode, comparision). E.G. getAnswersComp(Interesse, "=='Y'") so you can use comparision (perhaps useful if you want to do something with the sum() function).
Anhang:
Mit freundlichen Grüßen/Best regards,

Stefan Gohlke
LimeSurvey Team
Letzte Änderung: 2 Jahre 5 Monate her von Steve.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: ExpressionManager: Question variable access and answercount function 2 Jahre 5 Monate her #77252

  • TMSWhite
  • TMSWhites Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 759
  • Dank erhalten: 82
  • Karma: 36
Steve-

The solution to the count() problem is already on the wish list (see section about "this" and related variables).

For accessing the whole question (and not just the sub-question), that would be a minor extension to EM to clarify or sub-divide the attributes. So, perhaps .question should be the trigger question, and .subquestion should be the sub-question text.

For getAnswers(Qcode), there is already a answersList field in the generated JavaScript. It would be easy to add the ability to say Qcode.answewrList.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: ExpressionManager: Question variable access and answercount function 2 Jahre 4 Monate her #77283

  • Steve
  • Steves Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 494
  • Dank erhalten: 46
  • Karma: 17
Hello,

I'm not sure if I understand you correctly. Do you plan to use "count(this.NAOK)" to count the number of answers available (e.g. "There are {count(this.NAOK)} subquestions/answers for this question") or the number of answers given (e.g. "You selected {count(this.NAOK)} answers from this question")?

What do you reference with "this"? The question/Qcode that is currently used? Can you give an example for the use of this in this case (perhaps for the "Interesse" example mentioned in the first post)?

I read the "Access to Variables" part in the EM documentation again and I think I now understand how it works. In my opinion this part is difficult to understand, some points are not very clear. It's not that difficult for certain question types but if Qcode_AnswerID comes into play some people might be very confused.

So let's think about adding some more information/explanation and or restructuring it a bit. It might be important to point out that it depends on the question type if you use "Qcode" to acess the whole question AND it answer(s) (like gender.shown) or you access a subquestion/"answer" (like Interesse_1.value). This should be mentioned before the variable/properties table is shown. If you access the subquestion/answer (like Interesse_1) you cannot access the "parent question" (like Interesse). It might be a good idea to add this note, people might think you can do something like MyArrayQuestion.question or MyArrayQuestion.valueNAOK.

In the table it would be a good idea to make it clear which variables are used for the question itself and which are used to get the answer (or even use two tables). For example .qid is used for the question itself and doesn't change if you select/change the answer while .value changes with the answer given by the participant.

About ".question" and ".subquestion", I think it might confuse people even more. Say we use "Interesse_2" which is a subquestion/answer of "Interesse". So "Interesse_2.subquestion" might let you think you want to get something from a subquestion under "Interesse_2". ".question" is okay but perhaps ".parentQuestion" is better: e.g. "Interesse_2.parentQuestion".
Mit freundlichen Grüßen/Best regards,

Stefan Gohlke
LimeSurvey Team
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: ExpressionManager: Question variable access and answercount function 2 Jahre 4 Monate her #77287

  • TMSWhite
  • TMSWhites Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 759
  • Dank erhalten: 82
  • Karma: 36
Steve-

I'd be happy to have you edit the documentation to improve it. I've tried to focus more on ensuring we have working demo surveys the demonstrate all of the new functionality. We (you?) should add some pages that describe each of the available demos, and probably even provide a link to them (in case people don't have access to their /docs/demosurveys directory.

For this.suffix, the ideas was to expand it to a comma separate list of the questions variable names. So, say you have question q1, and sub-questions sq1-sq4, this.suffix would expand to q1_sq1.suffix, q1_sq2.suffix, q1_sq3.suffix, q1_sq4.suffix. That way, if you did:
count(this.NAOK)

it would expand to:
count(q1_sq1.NAOK, q1_sq2.NAOK, q1_sq3.NAOK, q1_sq4.NAOK)

We also might need some better naming. I've been calling the new variable naming Qcode, but, as you say, it can be confusing. Any suggestions on what to call the new style of naming to distinguish it from SGQA naming? That might help reduce the confusion about .question and .subquestion. Creating new variables that just have the Q part and A suffix and only support some extensions (like .question) is possible, but a little tricky because I'd need to do additional validation that the restricted subset of extensions exist for the Q names as opposed to the QA names. Right now, all suffixes exist for all "Qcodes", so I don't need to apply additional logic.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Ladezeit der Seite: 0.365 Sekunden
Donation Image