Hi, sorry, there were some mails missing on the ML. I'll try to summarize the situation (everything is there further down theoretically).
So, to summarize, I believe the application is creating a custom single
choice question. Doing so requires using undocumented APIs, which
obviously is somewhat tricky …
The original non-functional code did the following:
\newcommand{\fastrow}[2]{
\sdaps_qobject_begin:nnn { fastrow } { Choice } { #2}
\sdaps_checkbox_set_type:n {singlechoice}
#1 &
\sdaps_answer:n { #2}
\sdaps_checkbox:nn {#2} {0} {} &
\sdaps_checkbox:nn {#2} {1} {} &
\sdaps_checkbox:nn {#2} {2} {} &
\sdaps_checkbox:nn {#2} {3} {} &
\sdaps_checkbox:nn {#2} {4} {} \\
\hline
\sdaps_qobject_end:n { fastrow }
}
What we want to achieve here is one question with multiple answers. So,
the idea is that if parameter #2 is e.g. "fast1" then the result
contains fast1=1, fast2=2, … depending on which box is checked.
This code has some "obvious" issues:
* The question type is "Choice" which is a multiple choice question.
* The variable (first parameter of \sdaps_checkbox:nn) must be unique,
or else things will go wrong in the core. This relates to the first
point.
So, to fix this, we need to:
* Change the question type to "Option"
* Remove the #2 parameter from the checkboxes (this parameter should
just be empty)
* Add a call to "\sdaps_qobject_append_var:n {#2}" right after the
"\sdaps_qobject_begin:nnn"
* I believe you should add an "\sdaps_answer:n" for each of the
checkboxes. Maybe it works without and you just get a None value for
the answer string, which really doesn't matter for you.
So, it seems like I simply forgot the ":n". As an explanation, in
LaTeX3 the convention is that the parameters are denoted like that. "n"
is the normal case but one can generate variations to e.g. pass a
variable directly, which would be "V" rather than "n".
Benjamin
PS: Another option might be creating a range, that would work by:
* Change it to use "Range" question type
* Remove the \sdaps_answer:n" call
* Add call to "\sdaps_range:nnn { lower } {1} { low answer }"
* Add call to "\sdaps_range:nnn { upper } {4} { high answer }"
On Tue, 2018-12-04 at 16:05 +0100, Santiago Timón wrote:
> I have tried \sdaps_qobject_append_var but I get a LaTex error
> ! Undefined control sequence.
> \fastrow ...{Choice}{#2}\sdaps_qobject_append_var
>
> {fastrow}\sdaps_checkbox_s...
>
> Just made those slight changes in my command
> \newcommand{\fastrow}[2]{
> \sdaps_qobject_begin:nnn { } { Choice } { #2}
> \sdaps_qobject_append_var {fastrow}
> \sdaps_checkbox_set_type:n {singlechoice}
> #1 &
> \sdaps_answer:n { #2}
> \sdaps_checkbox:nn {#2} {0} &
> \sdaps_checkbox:nn {#2} {1} &
> \sdaps_checkbox:nn {#2} {2} &
> \sdaps_checkbox:nn {#2} {3} &
> \sdaps_checkbox:nn {#2} {4} \\
> \hline
> \sdaps_qobject_end:n { }
> }
>
> What I want to do is having this sort of singlechoice group:
> \begin{choicegroup}[var=fast, singlechoice]{FAST - Alkohol screening
> test}
> \choice[val=0]{0}
> \choice[val=1]{1}
> \choice[val=2]{2}
> \choice[val=3]{3}
> \choice[val=4]{4}
> \question[var=1]{1. text}
> \question[var=2]{2. text}
> \question[var=3]{3. text}
> \question[var=4]{4. text}
> \end{choicegroup}
>
> In my custom table. I think I'm getting closer to understand the
> directions you are pointing out, but still don't manage to get the
> full grisp...
>
> El mar., 4 dic. 2018 a las 14:52, Benjamin Berg (<
> [email protected]>) escribió:
> > Eh, i should read properly ...
> >
> > More/different changes are needed. The question type agould be
> > choice, and the first argument (variable) should be *empty*.
> > Instead yhere is a separate command to set the variable of the
> > question (i think \sdaps_context_add_var or so) which needs to be
> > used.
> >
> > Need to read the code to look it up.
> >
> > Benjamin
> >
> > On Tuesday, 4 December 2018, Benjamin Berg wrote:
> > > And, my phone refuses to add the CC (will resend to list later).
> > >
> > > On Tuesday, 4 December 2018, Santiago Timón wrote:
> > > > Not at all! I also didn't notice...
> > > >
> > > > El mar., 4 dic. 2018 a las 13:41, Benjamin Berg (<
> > [email protected]>)
> > > > escribió:
> > > >
> > > > > Do you mind if I share it with the list? I forgot to include
> > it in my
> > > > > reply.
> > > > >
> > > > > Benjamin
> > > > >
> > > > > On Tuesday, 4 December 2018, Santiago Timón wrote:
> > > > > > Hi Benjamin, thanks for the help.
> > > > > >
> > > > > > I should've posted the code, sorry. I'm just using simple
> > tabular
> > > > > > environment like this:
> > > > > > \begin{tabular} {|m{5cm}| m{1.5cm}| m{2.5cm} |m{2cm}|
> > m{2cm}| m{1.5cm}|
> > > > > > m{5cm}|}
> > > > > > \hline
> > > > > > \textbf{FAST - Alkohol screening test} &
> > \multicolumn{5}{l|}{Sett ring
> > > > > > rundt svaret. Spm 2-4 tas kun dersom 1-2 poeng på spm 1} \\
> > > > > > \hline
> > > > > > &
> > > > > > Aldri\newline(0 poeng) &
> > > > > > Sjeldnere enn månedlig\newline(1 poeng) &
> > > > > > Månedlig\newline(2 poeng) &
> > > > > > Ukentlig\newline(3 poeng) &
> > > > > > Daglig eller nesten daglig\newline(4 poeng) \\
> > > > > > \hline
> > > > > > \fastrow{1. Hvor ofte drikker du 8 (for menn)/6 (for
> > kvinner)
> > > > > > alkoholenheter eller mer ved samme anledning?}{fast1}
> > > > > > \fastrow{2. Hvor ofte i løpet av siste året har det vært
> > umulig å huske
> > > > > hva
> > > > > > som hendte kvelden før p.g.a. drikking?}{fast2}
> > > > > > \fastrow{3. Hvor ofte i løpet av siste året har du ikke
> > klart å gjøre det
> > > > > > som var normalt forventet av deg, p.g.a. drikking?}{fast3}
> > > > > > % last section sub header
> > > > > > &
> > > > > > Nei\newline(0 poeng) &
> > > > > > \multicolumn{2}{c|}{Ja én gang\newline(2 poeng)}
> > > > > > &
> > > > > > \multicolumn{2}{c|}{Ja, flere ganger\newline(4 poeng)}
> > > > > > \\
> > > > > > \hline
> > > > > > \fastrowlast{4. Siste året har en
> > slektning/venn/helsearbeider bekymret
> > > > > seg
> > > > > > over drikkingen din eller antydet at du bør redusere?}
> > > > > >
> > > > > > \end{tabular}
> > > > > >
> > > > > > In the \fastrow command I have tried two approaches to
> > generate the
> > > > > > checkboxes. The first one with just one answer for the four
> > of them
> > > > > >
> > > > > > \newcommand{\fastrow}[2]{
> > > > > > \sdaps_qobject_begin:nnn { fastrow } { Choice } { #2}
> > > > > >
> > > > > > \sdaps_checkbox_set_type:n {singlechoice}
> > > > > > #1 &
> > > > > > \sdaps_answer:n { #2}
> > > > > > \sdaps_checkbox:nn {#2} {0} {} &
> > > > > > \sdaps_checkbox:nn {#2} {1} {} &
> > > > > > \sdaps_checkbox:nn {#2} {2} {} &
> > > > > > \sdaps_checkbox:nn {#2} {3} {} &
> > > > > > \sdaps_checkbox:nn {#2} {4} {} \\
> > > > > > \hline
> > > > > > \sdaps_qobject_end:n { fastrow }
> > > > > > }
> > > > > >
> > > > > > which raises an assertion error in sdaps/setup/buddies.py
> > at line 114
> > > > > >
> > > > > > And the other approach includes an \sdaps_answer for each
> > checkbox, but
> > > > > if
> > > > > > I don't add something like suffix, it just overwrites each
> > checkbox
> > > > > > variable.
> > > > > > \newcommand{\fastrow}[2]{
> > > > > > \sdaps_qobject_begin:nnn { fastrow } { Choice } { #2}
> > > > > > \sdaps_checkbox_set_type:n {singlechoice}
> > > > > > #1 &
> > > > > > \sdaps_answer:n { #2} \sdaps_checkbox:nn {#2} {0} {} &
> > > > > > \sdaps_answer:n { #2} \sdaps_checkbox:nn {#2} {1} {} &
> > > > > > \sdaps_answer:n { #2} \sdaps_checkbox:nn {#2} {2} {} &
> > > > > > \sdaps_answer:n { #2} \sdaps_checkbox:nn {#2} {3} {} &
> > > > > > \sdaps_answer:n { #2} \sdaps_checkbox:nn {#2} {4} {} \\
> > > > > > \hline
> > > > > > \sdaps_qobject_end:n { fastrow }
> > > > > > }
> > >
> > > You should change that to question type Option (rather than
> > Choice) and then write the numbers into the second argument to
> > \sdaps_checkbox:nn (first is variable, second is value).
> > >
> > >
> > > > > > I could definitely live having fast1_1...fast_4 in the
> > resulting CSV and
> > > > > > set the actual value from which checkbox was checked but,
> > ideally, I
> > > > > would
> > > > > > rather have "fast1 = 4" if the last checkbox was checked.
> > > > > >
> > > > > > This is the correspondent output in .sdaps file for fast1
> > question:
> > > > > > [377]QObject-Choice=2.9. fast1
> > > > > > [378]Answer[2.9]=fast1
> > > > > >
> > > > >
> > [379]Box[2.9]=Checkbox,3,198.05234pt,416.31906pt,9.95845pt,9.95845p
> > t,ellipse,1.00374pt,fast1,0
> > > > > > [380]Answer[2.9]=fast1
> > > > > >
> > > > >
> > [381]Box[2.9]=Checkbox,3,253.13145pt,416.31906pt,9.95845pt,9.95845p
> > t,ellipse,1.00374pt,fast1,1
> > > > > > [382]Answer[2.9]=fast1
> > > > > >
> > > > >
> > [383]Box[2.9]=Checkbox,3,336.66333pt,416.31906pt,9.95845pt,9.95845p
> > t,ellipse,1.00374pt,fast1,2
> > > > > > [384]Answer[2.9]=fast1
> > > > > >
> > > > >
> > [385]Box[2.9]=Checkbox,3,405.96883pt,416.31906pt,9.95845pt,9.95845p
> > t,ellipse,1.00374pt,fast1,3
> > > > > > [386]Answer[2.9]=fast1
> > > > > >
> > > > >
> > [387]Box[2.9]=Checkbox,3,475.27432pt,416.31906pt,9.95845pt,9.95845p
> > t,ellipse,1.00374pt,fast1,4
> > > > > >
> > > > > > I hope there is some workaround. I'm sure that most of this
> > stuff is
> > > > > wrong
> > > > > > given my almost inexistent LaTex skills.
> > > > > >
> > > > > > Thanks again,
> > > > > > Santi
> > > > > >
> > > > > > El lun., 3 dic. 2018 a las 19:37, Benjamin Berg (<
> > > > > [email protected]>)
> > > > > > escribió:
> > > > > >
> > > > > > > Hmm,
> > > > > > >
> > > > > > > I suspect the issue is the tabular environment you are
> > using. The SDAPS
> > > > > > > metadata output can be affected by e.g
> > > > > > > tabularx ecpanding the content multiple times (this in
> > turn causes
> > > > > > > \sdaps_qobject_begin to be executed too often).
> > > > > > >
> > > > > > > You could have a look at the generated .sdaps file to see
> > if something
> > > > > > > like that is happening.
> > > > > > >
> > > > > > > I wonder if there is an easy workaround for your case. It
> > would help to
> > > > > > > have the not-working code as an example to try things.
> > > > > > >
> > > > > > > Benjamin
> > > > > > >
> > > > > > > On Friday, 30 November 2018, Santiago Timón wrote:
> > > > > > > > Hi!
> > > > > > > >
> > > > > > > > For a bit of context. My project is aiming at having an
> > OMR-ready
> > > > > Case
> > > > > > > > Report Form and we feel like SDAPS is perfect for our
> > needs.
> > > > > > > >
> > > > > > > > Taking the autocross example I'm trying to use
> > checkboxes and
> > > > > textboxes
> > > > > > > in
> > > > > > > > custom tables, but I'm not managing to get something
> > like
> > > > > choicegroup to
> > > > > > > > work.
> > > > > > > >
> > > > > > > > I was able to use a custom table to display checkboxes
> > like this:
> > > > > > > > [image: image.png]
> > > > > > > >
> > > > > > > > each row is generated with the following command:
> > > > > > > > \newcommand{\medrow}[2]{
> > > > > > > > \sdaps_qobject_begin:nnn { medrow } { Choice } { #2}
> > > > > > > > #1 & \sdaps_answer:n { #2} \sdaps_checkbox:nn {#2} { }
> > {} &
> > > > > > > > \inlinefilltextbox{1.2cm}{#2_dossage} &
> > > > > > > > \inlinefilltextbox{1.2cm}{#2_indication} \\[0.8cm]
> > > > > > > > \sdaps_qobject_end:n { medrow }
> > > > > > > > }
> > > > > > > > And it works like a charm for the CSV export to have
> > each one as a
> > > > > > > specific
> > > > > > > > variable.
> > > > > > > >
> > > > > > > > So with just one choice per question/answer is working.
> > However, I
> > > > > don't
> > > > > > > > know how to make it multichoice, like this table for
> > the FAST test:
> > > > > > > > [image: image.png]
> > > > > > > > I guess I could have a separate answer per checkbox,
> > but rather have
> > > > > them
> > > > > > > > related to a variable, like using optiongroup.
> > > > > > > >
> > > > > > > > I have been looking at the code and, when it gets down
> > to base latex
> > > > > I
> > > > > > > > start to become lost, as my LaTex skills are pretty
> > much close to
> > > > > basic.
> > > > > > > >
> > > > > > > > Thanks for your help!
> > > > > > > >
> > > > > > > > Santi
> > > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Santi
> > > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Santi
> > >
>
>
signature.asc
Description: This is a digitally signed message part
