ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: Clickable question/answer numbers
       [not found] <mailman.245.1478488929.2018.ntg-context@ntg.nl>
@ 2016-11-07 12:19 ` Jeong Dal
  2016-11-07 12:46   ` Otared Kavian
  0 siblings, 1 reply; 20+ messages in thread
From: Jeong Dal @ 2016-11-07 12:19 UTC (permalink / raw)
  To: ntg-context

Dear Otared,

It is not the problem of your code. 
Strangely, the code you just sent to me is stopped by the same reason during the compilation
even though it does not contain the word “myanswer”.
After removing *.tmc file, the error disappear.  
I still don’t know why such an error occurred.

Anyway, I got a nice sample which is very useful.

Thank you.

Best regards,

Dalyoung
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-07 12:19 ` Clickable question/answer numbers Jeong Dal
@ 2016-11-07 12:46   ` Otared Kavian
  0 siblings, 0 replies; 20+ messages in thread
From: Otared Kavian @ 2016-11-07 12:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Dalyoung,

Yes I see what your problem might had been. Recently ConTeXt creates a fine named FILENAME.tuc when one typesets FILENAME.tex. This *.tuc file creates difficulties when the typesetting is stopped for some reason or another, because then at times it is impossible to typeset again the same file even if the error has been fixed.

Maybe we have to ask Hans whether this behavior is intended or not: in any case one has to remove that *.tuc file manually in order to typeset again.

Best regards: OK

> On 7 Nov 2016, at 13:19, Jeong Dal <haksan@me.com> wrote:
> 
> Dear Otared,
> 
> It is not the problem of your code. 
> Strangely, the code you just sent to me is stopped by the same reason during the compilation
> even though it does not contain the word “myanswer”.
> After removing *.tmc file, the error disappear.  
> I still don’t know why such an error occurred.
> 
> Anyway, I got a nice sample which is very useful.
> 
> Thank you.
> 
> Best regards,
> 
> Dalyoung
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-06 11:55                           ` Wolfgang Schuster
@ 2016-11-06 14:46                             ` Otared Kavian
  0 siblings, 0 replies; 20+ messages in thread
From: Otared Kavian @ 2016-11-06 14:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Wolfgang, Hi Mikael,

Thanks Wolfgang! I didn’t know that \beginBLOCKNAME \endBLOCKNAME cannot be used in other macros… There is some mystery in this for me.

Now with 
	\doifnotmode{*trialtypesetting}
everything works as expected. 

Since I don’t know whether, nor where on the wiki, this can be wikified, for the archives and for other possible users, I copy below the entire example which allows to have interactive Questions and Answers. One can also easily add a chapter for Hints, if necessary.

Best regrads: OK

%%%% begin interactive-question-answer.tex
%%%% Here, following Wolfgang Schuster's ideas, 
%%%% we define some macros allowing to couple
%%%% Questions and Answers in an automatic way
%%%% Upon clicking on an interactive title for Question or Answer
%%%% one goes to the corresponding Answer or Question

\setupinteraction[state=start]

% We define two counters which follow the numbers
% appearing in Question and Answer

\newcounter\QuestionCounter
\newcounter\AnswerCounter

% We create two commands to be used in the
% enumeration environments
% Note that the check for trial typestting 
% \doifnotmode{*trialtypesetting}
% is necessary in order to avoid unwanted incrementation
\define[1]\QuestionTextCommand
  {\doifnotmode{*trialtypesetting}
     {\doglobal\increment\QuestionCounter
      \pagereference[question:\QuestionCounter]}%
   \doifreferencefoundelse{answer:\QuestionCounter}
     {\goto{#1}[answer:\QuestionCounter]}
     {#1}}

\define[1]\AnswerTextCommand
  {\doifnotmode{*trialtypesetting}
     {\doglobal\increment\AnswerCounter
      \pagereference[answer:\AnswerCounter]}%
   \doifreferencefoundelse{question:\AnswerCounter}
     {\goto{#1}[question:\AnswerCounter]}
     {#1}}

% We define here two enumeration environments for
% Questions and Answers
\defineenumeration[question]
	[text=Question,
	headcommand=\QuestionTextCommand,
	number=yes,
	prefix=yes,
	prefixsegments=chapter,
	coupling=answer]

\defineenumeration[answer]
	[text=Answer,
	headcommand=\AnswerTextCommand,
	number=yes,
	prefix=yes,
	prefixsegments=chapter,
	coupling=question]

% Each question is followed immediately by its answer.
% The answers are put in a block which will be used later
\defineblock[answer]
\hideblocks[answer]

% We define a command used after a  
% Question for which no Answer is provided
% Since the block commands 
% \beginanswer ... \endanswer
% cannot be used directly in a macro definition
% we use a trick...
% In the buffer the two counters associated to Answer
% are incremented...
\startbuffer[noanswer]
    \beginanswer
    \doglobal\increment\AnswerCounter
    \incrementcounter[answer]
    \endanswer
\stopbuffer

% ...and then the above buffer is invoked
\define\noanswer
  {\getbuffer[noanswer]}

% example of use:
\starttext
\startchapter[title=Questions]

\startquestion[q:1]
Prove that ${\rm e}\sim 2.73$ is irrational.
    
This is the first question, with its own reference, for later use.
\stopquestion
    
\beginanswer
\startanswer
This is the answer to the first question (to \in{Question}[q:1]).
\stopanswer
\endanswer

\startquestion 
This is the second question, without its own reference.
\stopquestion
    
\beginanswer
\startanswer[a:Test]
This is the answer to the second question. 

(Note that this answer has a reference named \type{a:Test}).
\stopanswer
\endanswer

\startquestion[q:Obvious]
This is the third question, an easy one, without a given solution.
\stopquestion

% we increment here the counters for Answer
\noanswer

\startquestion[q:2]
This is the fourth question with its own reference.
\stopquestion

\beginanswer
\startanswer
This is the answer to the fourth question: use the result of \in{question}[q:1].
\stopanswer
\endanswer

\startquestion 
This is the fifth question, without its own reference. 

({\it Hint:} look again at \in{Question}[q:Obvious]).
\stopquestion
    
\beginanswer
\startanswer
This is the answer to the fifth question. Read again \in{Answer}[a:Test].
\stopanswer
\endanswer  

\stopchapter

% Here we say ownnumber=1, in order to match the prefix 
% of numbers associated to Answer
\startchapter[ownnumber=1,title=Answers and solutions]
\useblocks[answer]
\stopchapter

\stoptext
%%%% end interactive-question-answer.tex

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-06 10:43                         ` Otared Kavian
@ 2016-11-06 11:55                           ` Wolfgang Schuster
  2016-11-06 14:46                             ` Otared Kavian
  0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Schuster @ 2016-11-06 11:55 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2442 bytes --]

> Otared Kavian <mailto:otared@gmail.com>
> 6. November 2016 um 11:43
> Hi Wolfgang,
>
> Thanks for the solution you sent yesterday.
> Your solutions solves the problem I was fighting with, but when I try 
> to apply it to my real document there is an issue when some questions 
> don’t have answers. This prevents the synchronization of Questions and 
> Answers if one doesn't issue the commands
> \beginanswer
> \incrementcounter[answer]
> \endanswer
>
> right after a question without an answer. And when the above commands 
> are issued, the last Question does not show the link to its 
> corresponding Answer.
>
> Below is your modified example where one can see the problem (please 
> see the fifth Question in the source below).
>
> Best regards: OK
> %%%% begin example-ws.tex
>
> \setupinteraction[state=start]
>
> \newcounter\QuestionCounter
> \newcounter\AnswerCounter
>
> \define[1]\QuestionTextCommand
>   {\doglobal\increment\QuestionCounter
>    \pagereference[question:\QuestionCounter]%
>    \doifreferencefoundelse{answer:\QuestionCounter}
>      {\goto{#1}[answer:\QuestionCounter]}
>      {#1}}
>
> \define[1]\AnswerTextCommand
>   {\doglobal\increment\AnswerCounter
>    \pagereference[answer:\AnswerCounter]%
>    \doifreferencefoundelse{question:\AnswerCounter}
>      {\goto{#1}[question:\AnswerCounter]}
>      {#1}}
Add a check for triatypesetting mode to increment \QuestionCounter
only once for each question.

\define[1]\QuestionTextCommand
   {\doifnotmode{*trialtypesetting}
      {\doglobal\increment\QuestionCounter
       \pagereference[question:\QuestionCounter]}%
    \doifreferencefoundelse{answer:\QuestionCounter}
      {\goto{#1}[answer:\QuestionCounter]}
      {#1}}

\define[1]\AnswerTextCommand
   {\doifnotmode{*trialtypesetting}
      {\doglobal\increment\AnswerCounter
       \pagereference[answer:\AnswerCounter]}%
    \doifreferencefoundelse{question:\AnswerCounter}
      {\goto{#1}[question:\AnswerCounter]}
      {#1}}
> %% Why this command generates an erreor?
> \define\noanswer{%
> \beginanswer
> \incrementcounter[answer]
> \endanswer}
The block environment can’t be used within a definition but
you put the content in a bufer and call then the buffer content
with your \noanswer command.

\startbuffer[noanswer]
     \beginanswer
     \doglobal\increment\AnswerCounter
     \incrementcounter[answer]
     \endanswer
\stopbuffer

\define\noanswer
   {\getbuffer[noanswer]}

Wolfgang

[-- Attachment #1.2: Type: text/html, Size: 5098 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-05 18:14                       ` Wolfgang Schuster
@ 2016-11-06 10:43                         ` Otared Kavian
  2016-11-06 11:55                           ` Wolfgang Schuster
  0 siblings, 1 reply; 20+ messages in thread
From: Otared Kavian @ 2016-11-06 10:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 7150 bytes --]

Hi Wolfgang,

Thanks for the solution you sent yesterday.
Your solutions solves the problem I was fighting with, but when I try to apply it to my real document there is an issue when some questions don’t have answers. This prevents the synchronization of Questions and Answers if one doesn't issue the commands
 
	\beginanswer
	\incrementcounter[answer]
	\endanswer

right after a question without an answer. And when the above commands are issued, the last Question does not show the link to its corresponding Answer.

Below is your modified example where one can see the problem (please see the fifth Question in the source below).

Best regards: OK
%%%% begin example-ws.tex

\setupinteraction[state=start]

\newcounter\QuestionCounter
\newcounter\AnswerCounter

\define[1]\QuestionTextCommand
  {\doglobal\increment\QuestionCounter
   \pagereference[question:\QuestionCounter]%
   \doifreferencefoundelse{answer:\QuestionCounter}
     {\goto{#1}[answer:\QuestionCounter]}
     {#1}}

\define[1]\AnswerTextCommand
  {\doglobal\increment\AnswerCounter
   \pagereference[answer:\AnswerCounter]%
   \doifreferencefoundelse{question:\AnswerCounter}
     {\goto{#1}[question:\AnswerCounter]}
     {#1}}

\defineenumeration[question]
	[text=Question,
	headcommand=\QuestionTextCommand,
	number=yes,
	prefix=yes,
	prefixsegments=chapter,
	coupling=answer]

\defineenumeration[answer]
	[text=Answer,
	headcommand=\AnswerTextCommand,
	number=yes,
	prefix=yes,
	prefixsegments=chapter,
	coupling=question]

\defineblock[answer]

%% Why this command generates an erreor?
\define\noanswer{%
	\beginanswer
		\incrementcounter[answer]
	\endanswer}

\define\PrintCounterValues{Here \type{\QuestionCounter = }\QuestionCounter.\par
Here \type{\AnswerCounter = }\AnswerCounter.\par
Here \type{\rawcountervalue[question] = }\rawcountervalue[question].\par
Here \type{\rawcountervalue[answer] = }\rawcountervalue[answer].
}


\starttext
\startchapter[title=Questions]

\startquestion[q:1]
Prove that ${\rm e}\sim 2.73$ is irrational.
    
This is the first question, with its own reference, for later use.

\PrintCounterValues
\stopquestion
    
\beginanswer
\startanswer
This is the answer to the first question (to \in{Question}[q:1]).

\PrintCounterValues
\stopanswer
\endanswer

\startquestion 
This is the second question, without its own reference.
    
\PrintCounterValues
\stopquestion
    
\beginanswer
\startanswer[a:2]
This is the answer to the second question.

\PrintCounterValues
\stopanswer
\endanswer

\startquestion
This is the third question, an easy one, without a given solution.

\PrintCounterValues
\stopquestion

%\noanswer\ % this generates an error…
\beginanswer
%\increment\AnswerCounter
%\incrementcounter[AnswerCounter]
%\increment\QuestionCounter
%\incrementcounter[QuestionCounter]
\incrementcounter[answer]
%\incrementcounter[question]
\endanswer

\startquestion[q:2]
This is the fourth question with its own reference.

\PrintCounterValues
\stopquestion

\beginanswer
\startanswer
This is the answer to the fourth question: use the result of \in{question}[q:1].

\PrintCounterValues
\stopanswer
\endanswer
    
\startquestion 
This is the fifth question, without its own reference. (This Question is not linked to its Answer).

\PrintCounterValues
\stopquestion
    
\beginanswer
\startanswer
This is the answer to the fifth question. Read again \in{Answer}[a:2].

\PrintCounterValues
\stopanswer
\endanswer  
    
\page

\stopchapter

\startchapter[ownnumber=1,title=Answers and solutions]
\useblocks[answer]
\stopchapter

\stoptext
%%%% end example

> On 5 Nov 2016, at 19:14, Wolfgang Schuster <schuster.wolfgang@gmail.com> wrote:
> 
>> Otared Kavian <mailto:otared@gmail.com> 5. November 2016 um 18:34
>> Hi Wolfgang, Hi Mikael,
>> 
>> Thank you both for your great inputs!
>> 
>> I tried to modify the code each of you sent yesterday in order to « couple » automatically each question with its answer, using the keyword « coupling=… », but somehow I am unable to create automatic references by extracting the number of each question or that of each answer, for example by using \rawcountervalue,
>> or \currentconstructionnumber. Strangely the latter gives the name of the construction and not a number: is it on purpose?
> The \currentconstructionnumber command contains the name of the counter but getting the counter value won’t help because it comes too late.
>> The solution Wolfgang proposes today, using the new keyword referenceprefix, is almost perfect: however would it possible to create a version of
>> « currentconstructionreference » which creates a reference named for instance
>> answer:NumberOfCurentConstruction
> The referenceprefix key is only usefull when you set the reference by hand.
>> The reason for which I need such a construction is that in a document with hundreds or more exercise —> hint —> solution, it would be handy to avoid creating each time a manual reference, and then one would navigate from a Question to its Hint and then  back to the Question or go to its Answer.
> When you always all three elements (question, hint and answer) you can increment
> a counter at the begin of each element and create a page reference which contains
> the value of the counter.
> 
> Below is a modified version of my previous example for this method.
> 
> %%%% begin example
> \setupinteraction[state=start]
> 
> \define[1]\QuestionTextCommand
>   {\doglobal\increment\QuestionCounter
>    \pagereference[question:\QuestionCounter]%
>    \doifreferencefoundelse{answer:\QuestionCounter}
>      {\goto{#1}[answer:\QuestionCounter]}
>      {#1}}
> 
> \define[1]\AnswerTextCommand
>   {\doglobal\increment\AnswerCounter
>    \pagereference[answer:\AnswerCounter]%
>    \doifreferencefoundelse{question:\AnswerCounter}
>      {\goto{#1}[question:\AnswerCounter]}
>      {#1}}
> 
> \defineenumeration
>   [question]
>   [text=Question,
>    headcommand=\QuestionTextCommand]
> 
> \defineenumeration
>   [answer]
>   [text=Answer,
>    headcommand=\AnswerTextCommand]
> 
> \defineblock[answer]
> 
> \startbuffer
>     %
>     \startquestion
>     \input knuth
>     \stopquestion
>     %
>     \beginanswer
>         \startanswer
>         \input knuth
>         \stopanswer
>     \endanswer
>     %
> \stopbuffer
> 
> \starttext
> 
> \dorecurse{10}{\getbuffer}
> 
> \page
> 
> \useblocks[answer]
> 
> \stoptext
> %%%% end example
> 
> Wolfgang
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 15518 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-05 17:34                     ` Otared Kavian
@ 2016-11-05 18:14                       ` Wolfgang Schuster
  2016-11-06 10:43                         ` Otared Kavian
  0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Schuster @ 2016-11-05 18:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2674 bytes --]

> Otared Kavian <mailto:otared@gmail.com>
> 5. November 2016 um 18:34
> Hi Wolfgang, Hi Mikael,
>
> Thank you both for your great inputs!
>
> I tried to modify the code each of you sent yesterday in order to « 
> couple » automatically each question with its answer, using the 
> keyword « coupling=… », but somehow I am unable to create automatic 
> references by extracting the number of each question or that of each 
> answer, for example by using \rawcountervalue,
> or \currentconstructionnumber. Strangely the latter gives the name of 
> the construction and not a number: is it on purpose?
The \currentconstructionnumber command contains the name of the counter 
but getting the counter value won’t help because it comes too late.
> The solution Wolfgang proposes today, using the new keyword 
> referenceprefix, is almost perfect: however would it possible to 
> create a version of
> « currentconstructionreference » which creates a reference named for 
> instance
> answer:NumberOfCurentConstruction
The referenceprefix key is only usefull when you set the reference by hand.
> The reason for which I need such a construction is that in a document 
> with hundreds or more exercise —> hint —> solution, it would be handy 
> to avoid creating each time a manual reference, and then one would 
> navigate from a Question to its Hint and then  back to the Question or 
> go to its Answer.
When you always all three elements (question, hint and answer) you can 
increment
a counter at the begin of each element and create a page reference which 
contains
the value of the counter.

Below is a modified version of my previous example for this method.

%%%% begin example
\setupinteraction[state=start]

\define[1]\QuestionTextCommand
   {\doglobal\increment\QuestionCounter
    \pagereference[question:\QuestionCounter]%
    \doifreferencefoundelse{answer:\QuestionCounter}
      {\goto{#1}[answer:\QuestionCounter]}
      {#1}}

\define[1]\AnswerTextCommand
   {\doglobal\increment\AnswerCounter
    \pagereference[answer:\AnswerCounter]%
    \doifreferencefoundelse{question:\AnswerCounter}
      {\goto{#1}[question:\AnswerCounter]}
      {#1}}

\defineenumeration
   [question]
   [text=Question,
    headcommand=\QuestionTextCommand]

\defineenumeration
   [answer]
   [text=Answer,
    headcommand=\AnswerTextCommand]

\defineblock[answer]

\startbuffer
     %
     \startquestion
     \input knuth
     \stopquestion
     %
     \beginanswer
         \startanswer
         \input knuth
         \stopanswer
     \endanswer
     %
\stopbuffer

\starttext

\dorecurse{10}{\getbuffer}

\page

\useblocks[answer]

\stoptext
%%%% end example

Wolfgang

[-- Attachment #1.2: Type: text/html, Size: 4777 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-05 12:38                   ` Wolfgang Schuster
  2016-11-05 12:43                     ` Mikael P. Sundqvist
@ 2016-11-05 17:34                     ` Otared Kavian
  2016-11-05 18:14                       ` Wolfgang Schuster
  1 sibling, 1 reply; 20+ messages in thread
From: Otared Kavian @ 2016-11-05 17:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 3330 bytes --]

Hi Wolfgang, Hi Mikael,

Thank you both for your great inputs!

I tried to modify the code each of you sent yesterday in order to « couple » automatically each question with its answer, using the keyword « coupling=… », but somehow I am unable to create automatic references by extracting the number of each question or that of each answer, for example by using \rawcountervalue,
or \currentconstructionnumber. Strangely the latter gives the name of the construction and not a number: is it on purpose?

The solution Wolfgang proposes today, using the new keyword referenceprefix, is almost perfect: however would it possible to create a version of
« currentconstructionreference » which creates a reference named for instance
answer:NumberOfCurentConstruction

The reason for which I need such a construction is that in a document with hundreds or more exercise —> hint —> solution, it would be handy to avoid creating each time a manual reference, and then one would navigate from a Question to its Hint and then  back to the Question or go to its Answer.

Best regards: OK


> On 5 Nov 2016, at 13:38, Wolfgang Schuster <schuster.wolfgang@gmail.com> wrote:
> 
>> Mikael P. Sundqvist <mailto:mickep@gmail.com> 4. November 2016 um 16:33
>> Thank you very much Wolfgang!
>> 
>> Now I can get exactly what I need, see the example below (also tested
>> with my larger document, available at
>> http://www.maths.lth.se/matematiklth/personal/mickep/analysB2ht16/analys-context.pdf <http://www.maths.lth.se/matematiklth/personal/mickep/analysB2ht16/analys-context.pdf>).
>> 
>> I'm very happy about this solution. Also, thanks to Hans for giving us
>> this very nice tool (I usually only write to the list when I have
>> problems, sorry)!
> With the new beta you can set a default prefix for enumeration references,
> i.e. you can write \startquestion[knuth] in your document without the need
> to add a question or answer prefix.
> 
> \setupinteraction[state=start]
> 
> \define[1]\QuestionTextCommand
>   {\doifreferencefoundelse{answer:\currentconstructionreference}
>      {\goto{#1}[answer:\currentconstructionreference]}
>      {#1}}
> 
> \define[1]\AnswerTextCommand
>   {\doifreferencefoundelse{question:\currentconstructionreference}
>      {\goto{#1}[question:\currentconstructionreference]}
>      {#1}}
> 
> \defineenumeration
>   [question]
>   [text=Question,
>    headcommand=\QuestionTextCommand,
>    referenceprefix=question]
> 
> \defineenumeration
>   [answer]
>   [text=Answer,
>    headcommand=\AnswerTextCommand,
>    referenceprefix=answer]
> 
> \starttext
> 
> \startquestion[knuth]
> \input knuth
> \stopquestion
> 
> \page
> 
> \startanswer[knuth]
> \input knuth
> \stopanswer
> 
> \stoptext
> 
> Wolfgang
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 6542 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-05 12:38                   ` Wolfgang Schuster
@ 2016-11-05 12:43                     ` Mikael P. Sundqvist
  2016-11-05 17:34                     ` Otared Kavian
  1 sibling, 0 replies; 20+ messages in thread
From: Mikael P. Sundqvist @ 2016-11-05 12:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear Wolfgang,

thank you for the information. I will probably do that in next
document, since it seems convenient.

Best regards, Mikael



On Sat, Nov 5, 2016 at 1:38 PM, Wolfgang Schuster
<schuster.wolfgang@gmail.com> wrote:
> Mikael P. Sundqvist
> 4. November 2016 um 16:33
> Thank you very much Wolfgang!
>
> Now I can get exactly what I need, see the example below (also tested
> with my larger document, available at
> http://www.maths.lth.se/matematiklth/personal/mickep/analysB2ht16/analys-context.pdf).
>
> I'm very happy about this solution. Also, thanks to Hans for giving us
> this very nice tool (I usually only write to the list when I have
> problems, sorry)!
>
> With the new beta you can set a default prefix for enumeration references,
> i.e. you can write \startquestion[knuth] in your document without the need
> to add a question or answer prefix.
>
> \setupinteraction[state=start]
>
> \define[1]\QuestionTextCommand
>   {\doifreferencefoundelse{answer:\currentconstructionreference}
>      {\goto{#1}[answer:\currentconstructionreference]}
>      {#1}}
>
> \define[1]\AnswerTextCommand
>   {\doifreferencefoundelse{question:\currentconstructionreference}
>      {\goto{#1}[question:\currentconstructionreference]}
>      {#1}}
>
> \defineenumeration
>   [question]
>   [text=Question,
>    headcommand=\QuestionTextCommand,
>    referenceprefix=question]
>
> \defineenumeration
>   [answer]
>   [text=Answer,
>    headcommand=\AnswerTextCommand,
>    referenceprefix=answer]
>
> \starttext
>
> \startquestion[knuth]
> \input knuth
> \stopquestion
>
> \page
>
> \startanswer[knuth]
> \input knuth
> \stopanswer
>
> \stoptext
>
> Wolfgang
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-04 15:33                 ` Mikael P. Sundqvist
@ 2016-11-05 12:38                   ` Wolfgang Schuster
  2016-11-05 12:43                     ` Mikael P. Sundqvist
  2016-11-05 17:34                     ` Otared Kavian
  0 siblings, 2 replies; 20+ messages in thread
From: Wolfgang Schuster @ 2016-11-05 12:38 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1396 bytes --]

> Mikael P. Sundqvist <mailto:mickep@gmail.com>
> 4. November 2016 um 16:33
> Thank you very much Wolfgang!
>
> Now I can get exactly what I need, see the example below (also tested
> with my larger document, available at
> http://www.maths.lth.se/matematiklth/personal/mickep/analysB2ht16/analys-context.pdf).
>
> I'm very happy about this solution. Also, thanks to Hans for giving us
> this very nice tool (I usually only write to the list when I have
> problems, sorry)!
With the new beta you can set a default prefix for enumeration references,
i.e. you can write \startquestion[knuth] in your document without the need
to add a question or answer prefix.

\setupinteraction[state=start]

\define[1]\QuestionTextCommand
   {\doifreferencefoundelse{answer:\currentconstructionreference}
      {\goto{#1}[answer:\currentconstructionreference]}
      {#1}}

\define[1]\AnswerTextCommand
   {\doifreferencefoundelse{question:\currentconstructionreference}
      {\goto{#1}[question:\currentconstructionreference]}
      {#1}}

\defineenumeration
   [question]
   [text=Question,
    headcommand=\QuestionTextCommand,
    referenceprefix=question]

\defineenumeration
   [answer]
   [text=Answer,
    headcommand=\AnswerTextCommand,
    referenceprefix=answer]

\starttext

\startquestion[knuth]
\input knuth
\stopquestion

\page

\startanswer[knuth]
\input knuth
\stopanswer

\stoptext

Wolfgang

[-- Attachment #1.2: Type: text/html, Size: 2718 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-04 11:50               ` Wolfgang Schuster
@ 2016-11-04 15:33                 ` Mikael P. Sundqvist
  2016-11-05 12:38                   ` Wolfgang Schuster
  0 siblings, 1 reply; 20+ messages in thread
From: Mikael P. Sundqvist @ 2016-11-04 15:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Thank you very much Wolfgang!

Now I can get exactly what I need, see the example below (also tested
with my larger document, available at
http://www.maths.lth.se/matematiklth/personal/mickep/analysB2ht16/analys-context.pdf).

I'm very happy about this solution. Also, thanks to Hans for giving us
this very nice tool (I usually only write to the list when I have
problems, sorry)!

Best regards, Mikael

\definecolor[contrastcolor][darkred]
\defineintermediatecolor[contrastbgcolor][0.6,contrastcolor,white]

\setupinteraction[state=start,color=,contrastcolor=,style=]

\defineblock[answer]
\hideblocks[answer]

\def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}

\def\myheadcommand#1{\goto{Question #1}[A:\currentconstructionreference]}

\defineenumeration[question][
text=,
title=yes,
titlestyle=,
titlecolor=black,
headcommand={\myheadcommand},
headstyle={\sc},
headcolor=contrastcolor,
style=,
alternative=serried,
width=fit,
number=yes,
prefix=yes,
prefixsegments=chapter,
way=bychapter,
indentnext=no,
indenting=yes,
before={\testpage[2]\blank[big]},
after={\blank[big,samepage]},
]

\starttext

\section{A section with questions}

\startquestion[Q:test]{This is a title}
This is a question with title.
\stopquestion

\beginanswer
\myanswer[Q:test]
This is an answer
\endanswer

\startquestion[Q:test2]
This is a question without title.
\startformula
(a+b)^2=a^2+ab+ba+b^2.
\stopformula
\stopquestion

\beginanswer
\myanswer[Q:test2]
This is an answer.
\endanswer


\startquestion
This is a question without reference. It cannot have any answer.
\stopquestion


\page[yes]

\subject{Answers}

\useblocks[answer]

\stoptext

On Fri, Nov 4, 2016 at 12:50 PM, Wolfgang Schuster
<schuster.wolfgang@gmail.com> wrote:
> Mikael P. Sundqvist
> 3. November 2016 um 16:14
> Dear Otared (and others),
>
> while waiting for Hans reply on the \namedenumerationparameter and
> \enumerationparameter, this is the best I could do. Now, only
> "Question" is clickable and not the number, but I think I could live
> with that if no other solution show up.
>
> The reference value is set in a group and can only be accessed within this
> group
> but you can use \currentconstructionreference to access it.
>
> \setupinteraction[state=start]
>
> \define[1]\QuestionTextCommand
>
> {\doifreferencefoundelse{answer:\cldcontext{lpeg.match(lpeg.secondofsplit(":"),"\currentconstructionreference")}}
>
> {\goto{#1}[answer:\cldcontext{lpeg.match(lpeg.secondofsplit(":"),"\currentconstructionreference")}]}
>      {#1}}
>
> \define[1]\AnswerTextCommand
>
> {\doifreferencefoundelse{question:\cldcontext{lpeg.match(lpeg.secondofsplit(":"),"\currentconstructionreference")}}
>
> {\goto{#1}[question:\cldcontext{lpeg.match(lpeg.secondofsplit(":"),"\currentconstructionreference")}]}
>      {#1}}
>
> \defineenumeration [question]
> [text=Question,headcommand=\QuestionTextCommand]
> \defineenumeration [answer]   [text=Answer,headcommand=\AnswerTextCommand]
>
> \starttext
>
> \startquestion[question:knuth]
> \input knuth
> \stopquestion
>
> \page
>
> \startanswer[answer:knuth]
> \input knuth
> \stopanswer
>
> \stoptext
>
> Wolfgang
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-03 15:14             ` Mikael P. Sundqvist
  2016-11-04  8:10               ` Otared Kavian
@ 2016-11-04 11:50               ` Wolfgang Schuster
  2016-11-04 15:33                 ` Mikael P. Sundqvist
  1 sibling, 1 reply; 20+ messages in thread
From: Wolfgang Schuster @ 2016-11-04 11:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1376 bytes --]

> Mikael P. Sundqvist <mailto:mickep@gmail.com>
> 3. November 2016 um 16:14
> Dear Otared (and others),
>
> while waiting for Hans reply on the \namedenumerationparameter and
> \enumerationparameter, this is the best I could do. Now, only
> "Question" is clickable and not the number, but I think I could live
> with that if no other solution show up.
The reference value is set in a group and can only be accessed within 
this group
but you can use \currentconstructionreference to access it.

\setupinteraction[state=start]

\define[1]\QuestionTextCommand
   
{\doifreferencefoundelse{answer:\cldcontext{lpeg.match(lpeg.secondofsplit(":"),"\currentconstructionreference")}}
      
{\goto{#1}[answer:\cldcontext{lpeg.match(lpeg.secondofsplit(":"),"\currentconstructionreference")}]}
      {#1}}

\define[1]\AnswerTextCommand
   
{\doifreferencefoundelse{question:\cldcontext{lpeg.match(lpeg.secondofsplit(":"),"\currentconstructionreference")}}
      
{\goto{#1}[question:\cldcontext{lpeg.match(lpeg.secondofsplit(":"),"\currentconstructionreference")}]}
      {#1}}

\defineenumeration [question] 
[text=Question,headcommand=\QuestionTextCommand]
\defineenumeration [answer]   [text=Answer,headcommand=\AnswerTextCommand]

\starttext

\startquestion[question:knuth]
\input knuth
\stopquestion

\page

\startanswer[answer:knuth]
\input knuth
\stopanswer

\stoptext

Wolfgang

[-- Attachment #1.2: Type: text/html, Size: 2537 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-03 15:14             ` Mikael P. Sundqvist
@ 2016-11-04  8:10               ` Otared Kavian
  2016-11-04 11:50               ` Wolfgang Schuster
  1 sibling, 0 replies; 20+ messages in thread
From: Otared Kavian @ 2016-11-04  8:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Mikael,

Thank you for sharing the solution you found!

Your definitions suit me too, but in any case I’ll play with your code to see whether using the concept of « coupling » between each exercise and its solution (or hint, if one adds them) could allow the creation of an automatic interaction link between them, so that one can remove the necessity of adding manually a reference to each exercise and each solution.

Best regards: OK


> On 3 Nov 2016, at 16:14, Mikael P. Sundqvist <mickep@gmail.com> wrote:
> 
> Dear Otared (and others),
> 
> while waiting for Hans reply on the \namedenumerationparameter and
> \enumerationparameter, this is the best I could do. Now, only
> "Question" is clickable and not the number, but I think I could live
> with that if no other solution show up.
> 
> Best regards, Mikael
> 
> \usemodule[references-show]
> 
> \setupinteraction[state=start,color=,contrastcolor=,style=]
> 
> \defineblock[answer]
> \hideblocks[answer]
> 
> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
> 
> 
> \defineenumeration[exercise][
> text=Question,
> title=yes,
> titlestyle=,
> titlecolor=black,
> headstyle={\sc},
> headcolor=darkred,
> style=,
> number=yes,
> ]
> 
> 
> 
> \def\startquestion{\dodoubleempty\dostartquestion}
> 
> \long\def\dostartquestion[#1][#2]#3\stopquestion{%
>  \iffirstargument
>    \setupenumeration[exercise][text={\goto{Question}[A:#1]}]
>    \ifsecondargument
>      \startexercise[#1]{#2}
>    \else
>      \startexercise[#1]
>    \fi
>  \else
>    \setupenumeration[exercise][text=Question]
>    \startexercise
>  \fi
>  #3
> }
> 
> \def\stopquestion{\stopexercise}
> 
> 
> \starttext
> 
> \section{A section with questions}
> 
> \startquestion[Q:test][This is a title]
> This is a question with title.
> \stopquestion
> 
> \beginanswer
> \myanswer[Q:test]
> This is an answer
> \endanswer
> 
> \startquestion[Q:test2]
> This is a question without title.
> \startformula
> (a+b)^2=a^2+ab+ba+b^2.
> \stopformula
> \stopquestion
> 
> \beginanswer
> \myanswer[Q:test2]
> This is an answer.
> \endanswer
> 
> 
> \startquestion
> This is a question without reference. It cannot have any answer.
> \stopquestion
> 
> 
> \page[yes]
> 
> \subject{Answers}
> 
> \useblocks[answer]
> 
> \stoptext
> 
> On Thu, Nov 3, 2016 at 12:58 PM, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>> Dear Hans,
>> 
>> This seems to be exactly what I need, but I cannot get it to work.
>> With the example below nothing comes from those
>> commands (I just updated my standalone to the latest one). On the
>> other hand, with text instead of reference it works.
>> 
>> Best regards, Mikael
>> 
>> \defineenumeration[question][
>> text=Question,
>> ]
>> 
>> \starttext
>> \startquestion[test]
>> This question has reference
>> \namedenumerationparameter{question}{reference} which could also
>> be achieved via \enumerationparameter{reference}. On the other hand,
>> \namedenumerationparameter{question}{text}
>> gives Question as assumed.
>> \stopquestion
>> 
>> \startquestion[reference=test2]
>> This question has reference
>> \namedenumerationparameter{question}{reference} which could also
>> be achieved via \enumerationparameter{reference}. On the other hand,
>> \namedenumerationparameter{question}{text}
>> gives Question as assumed.
>> \stopquestion
>> \stoptext
>> 
>> On Thu, Nov 3, 2016 at 10:34 AM, Hans Hagen <pragma@wxs.nl> wrote:
>>> On 11/2/2016 9:58 PM, Mikael P. Sundqvist wrote:
>>>> 
>>>> Dear Otared,
>>>> 
>>>> thank you again. This is somehow a proof that it should work. In my
>>>> real document I use the title to name some exercises (after old
>>>> exams), and I don't see how that can be combined with your solution.
>>>> 
>>>> If someone else reads this: I think the question boils down to the
>>>> following:
>>>> 
>>>> \startquestion[Q:test]
>>>> How can I here automatically get access to to the string "Q:test"?
>>>> \stopquestion
>>> 
>>> 
>>> it depends what automatically means
>>> 
>>> \enumerationparameter{reference}
>>> 
>>> or
>>> 
>>> \namedenumerationparameter{question}{reference}
>>> 
>>> 
>>>> Best regards, Mikael
>>>> 
>>>> On Wed, Nov 2, 2016 at 9:04 PM, Otared Kavian <otared@gmail.com> wrote:
>>>>> 
>>>>> Hi Mikael,
>>>>> 
>>>>> A partial solution to the feature we are discussing is contained in the
>>>>> example below, but somone more aware of ConTeXtish coding might improve it.
>>>>> It is not satisfactory in that one has to define twice \startquestion and
>>>>> \StartQuestion, \beginanswer and \BeginAnswer, and more importantly one
>>>>> cannot generate automatically the references (I tried \getnumber[question]
>>>>> and such to append to Q:\getnumber[question] for instance, but something
>>>>> does not work…).
>>>>> 
>>>>> Le me know if you find a satisfactory solution…
>>>>> 
>>>>> Best regards: OK
>>>>> %%% begin interactive-question-answer.tex
>>>>> \setupinteraction[state=start,color=,contrastcolor=,style=]
>>>>> 
>>>>> \defineblock[answer]
>>>>> \hideblocks[answer]
>>>>> 
>>>>> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
>>>>> 
>>>>> \define[1]\AnswerToQuestion{Question \goto{(see Solution)}[A:Q:#1]}
>>>>> 
>>>>> 
>>>>> \define[1]\StartQuestion{\startquestion[reference=Q:#1,title={\AnswerToQuestion{#1}}]}
>>>>> 
>>>>> \define[1]\BeginAnswer{\beginanswer\myanswer[Q:#1]}
>>>>> 
>>>>> \defineenumeration[question][
>>>>>        text=, %Question,
>>>>>        headcolor=darkred,
>>>>>        title=yes,
>>>>>        titleleft=,
>>>>>        titleright={.},
>>>>>        width=fit,
>>>>>        number=yes,
>>>>>        prefix=yes,
>>>>>        prefixsegments=section,
>>>>>        ]
>>>>> 
>>>>> \starttext
>>>>> 
>>>>> \section{A section with questions}
>>>>> 
>>>>> \StartQuestion{test}
>>>>> 
>>>>> Prove that $(a +b)^2 = a^2 + 2ab + b^2$ for all $a,b\in{\Bbb R}$.
>>>>> 
>>>>> \BeginAnswer{test}
>>>>> 
>>>>> Indeed $(a+b)^2 = (a+b)(a+b) = a^2 + ab + ba +b^2 = a^2 + 2ab +b^2$ since
>>>>> $ba=ba$.
>>>>> \endanswer
>>>>> 
>>>>> \stopquestion
>>>>> 
>>>>> \page[yes]
>>>>> 
>>>>> \startsection[title={Answers to all questions}]
>>>>> 
>>>>> \useblocks[answer]
>>>>> 
>>>>> \stopsection
>>>>> \stoptext
>>>>> %%% end interactive-question-answer.tex
>>>>> 
>>>>>> On 2 Nov 2016, at 16:16, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>>>>>> 
>>>>>> Dear Otared (and list),
>>>>>> 
>>>>>> thank you for your reply and support.
>>>>>> 
>>>>>> The links from the answers to the questions work as wanted with my
>>>>>> solution, it is the links from the questions to the answers that do
>>>>>> not.
>>>>>> 
>>>>>> I guess I need something like
>>>>>> 
>>>>>> headcommand={\in{Question}[A:###]},
>>>>>> 
>>>>>> where ### is the reference tag I set. But I don't know what to change
>>>>>> the ### into (or if that would work).
>>>>>> 
>>>>>> Best regards, Mikael
>>>>>> 
>>>>>> On Wed, Nov 2, 2016 at 1:52 PM, Otared Kavian <otared@gmail.com> wrote:
>>>>>>> 
>>>>>>> Hi Mikael,
>>>>>>> 
>>>>>>> I had a similar question some time ago, but I wanted to add a sort of
>>>>>>> automatic referencing of questions and answers (and interaction going from
>>>>>>> questions to answers and back).
>>>>>>> 
>>>>>>> If you accept the hurdle of adding manual references, in your case you
>>>>>>> can add (for instance…)
>>>>>>> 
>>>>>>>       \goto{:-)}[Q:test]
>>>>>>> 
>>>>>>> to the end of your answer to go back to the respective question. But
>>>>>>> when you have several dozens of such references to add manually, it is not a
>>>>>>> good idea.
>>>>>>> 
>>>>>>> However I could not find a way to code the items (that is the
>>>>>>> questions) in such a way that each adds automatically a unique reference,
>>>>>>> and so I am interested too in the solution of the problem you mention.
>>>>>>> 
>>>>>>> Best regards: OK
>>>>>>> 
>>>>>>> 
>>>>>>>> On 2 Nov 2016, at 12:43, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>>>>>>>> 
>>>>>>>> Dear list,
>>>>>>>> 
>>>>>>>> I have a pretty large text with a lot of questions and answers, and
>>>>>>>> want the user(students) to be able to click in the pdf to go from a
>>>>>>>> certain exercise to its answer, and back. I have a solution (see
>>>>>>>> below) to go from answers to questions, but not the other way around.
>>>>>>>> I simply have no idea on how to make the red text (in the head) in the
>>>>>>>> example question clickable with the answer on the next page as target.
>>>>>>>> As you can see, the answer has a tag A:Q:test (I want to set these
>>>>>>>> automatically in that manner), and clicking the green text I get to
>>>>>>>> the correct place. I just don't see how to make the "Question 1.1"
>>>>>>>> clickable with that target.
>>>>>>>> 
>>>>>>>> I hope I make myself clear. If it matters, in the solution one could
>>>>>>>> assume that the optional tag of the \startquestion \stopquestion is
>>>>>>>> given for all questions.
>>>>>>>> 
>>>>>>>> Best regards, Mikael
>>>>>>>> 
>>>>>>>> %% qa.tex
>>>>>>>> \setupinteraction[state=start,color=,contrastcolor=,style=]
>>>>>>>> 
>>>>>>>> \defineblock[answer]
>>>>>>>> \hideblocks[answer]
>>>>>>>> 
>>>>>>>> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
>>>>>>>> 
>>>>>>>> \defineenumeration[question][
>>>>>>>> text=Question,
>>>>>>>> headcolor=darkred,
>>>>>>>> width=fit,
>>>>>>>> number=yes,
>>>>>>>> prefix=yes,
>>>>>>>> prefixsegments=section,
>>>>>>>> ]
>>>>>>>> 
>>>>>>>> \starttext
>>>>>>>> 
>>>>>>>> \section{A section with questions}
>>>>>>>> 
>>>>>>>> \startquestion[Q:test]
>>>>>>>> Solve this question!
>>>>>>>> \stopquestion
>>>>>>>> 
>>>>>>>> We could, however, click \color[darkyellow]{\in{Answer}[A:Q:test]}.
>>>>>>>> 
>>>>>>>> \beginanswer
>>>>>>>> \myanswer[Q:test]
>>>>>>>> What question? The answer is \quotation{do it yourself}!
>>>>>>>> \endanswer
>>>>>>>> 
>>>>>>>> \page[yes]
>>>>>>>> 
>>>>>>>> \subject{Answers}
>>>>>>>> 
>>>>>>>> \useblocks[answer]
>>>>>>>> 
>>>>>>>> \stoptext
>>>>>>>> 
>>>>>>>> <qa.pdf>___________________________________________________________________________________
>>>>>>>> If your question is of interest to others as well, please add an entry
>>>>>>>> to the Wiki!
>>>>>>>> 
>>>>>>>> maillist : ntg-context@ntg.nl /
>>>>>>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>>>>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>>>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>>>>>> wiki     : http://contextgarden.net
>>>>>>>> 
>>>>>>>> ___________________________________________________________________________________
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> ___________________________________________________________________________________
>>>>>>> If your question is of interest to others as well, please add an entry
>>>>>>> to the Wiki!
>>>>>>> 
>>>>>>> maillist : ntg-context@ntg.nl /
>>>>>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>>>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>>>>> wiki     : http://contextgarden.net
>>>>>>> 
>>>>>>> ___________________________________________________________________________________
>>>>>> 
>>>>>> 
>>>>>> ___________________________________________________________________________________
>>>>>> If your question is of interest to others as well, please add an entry
>>>>>> to the Wiki!
>>>>>> 
>>>>>> maillist : ntg-context@ntg.nl /
>>>>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>>>> wiki     : http://contextgarden.net
>>>>>> 
>>>>>> ___________________________________________________________________________________
>>>>> 
>>>>> 
>>>>> 
>>>>> ___________________________________________________________________________________
>>>>> If your question is of interest to others as well, please add an entry to
>>>>> the Wiki!
>>>>> 
>>>>> maillist : ntg-context@ntg.nl /
>>>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>>> wiki     : http://contextgarden.net
>>>>> 
>>>>> ___________________________________________________________________________________
>>>> 
>>>> 
>>>> ___________________________________________________________________________________
>>>> If your question is of interest to others as well, please add an entry to
>>>> the Wiki!
>>>> 
>>>> maillist : ntg-context@ntg.nl /
>>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>> wiki     : http://contextgarden.net
>>>> 
>>>> ___________________________________________________________________________________
>>>> 
>>> 
>>> 
>>> --
>>> 
>>> -----------------------------------------------------------------
>>>                                          Hans Hagen | PRAGMA ADE
>>>              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>>>       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
>>> -----------------------------------------------------------------
>>> 
>>> ___________________________________________________________________________________
>>> If your question is of interest to others as well, please add an entry to
>>> the Wiki!
>>> 
>>> maillist : ntg-context@ntg.nl /
>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>> wiki     : http://contextgarden.net
>>> ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-03 11:58           ` Mikael P. Sundqvist
@ 2016-11-03 15:14             ` Mikael P. Sundqvist
  2016-11-04  8:10               ` Otared Kavian
  2016-11-04 11:50               ` Wolfgang Schuster
  0 siblings, 2 replies; 20+ messages in thread
From: Mikael P. Sundqvist @ 2016-11-03 15:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear Otared (and others),

while waiting for Hans reply on the \namedenumerationparameter and
\enumerationparameter, this is the best I could do. Now, only
"Question" is clickable and not the number, but I think I could live
with that if no other solution show up.

Best regards, Mikael

\usemodule[references-show]

\setupinteraction[state=start,color=,contrastcolor=,style=]

\defineblock[answer]
\hideblocks[answer]

\def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}


\defineenumeration[exercise][
text=Question,
title=yes,
titlestyle=,
titlecolor=black,
headstyle={\sc},
headcolor=darkred,
style=,
number=yes,
]



\def\startquestion{\dodoubleempty\dostartquestion}

\long\def\dostartquestion[#1][#2]#3\stopquestion{%
  \iffirstargument
    \setupenumeration[exercise][text={\goto{Question}[A:#1]}]
    \ifsecondargument
      \startexercise[#1]{#2}
    \else
      \startexercise[#1]
    \fi
  \else
    \setupenumeration[exercise][text=Question]
    \startexercise
  \fi
  #3
}

\def\stopquestion{\stopexercise}


\starttext

\section{A section with questions}

\startquestion[Q:test][This is a title]
This is a question with title.
\stopquestion

\beginanswer
\myanswer[Q:test]
This is an answer
\endanswer

\startquestion[Q:test2]
This is a question without title.
\startformula
(a+b)^2=a^2+ab+ba+b^2.
\stopformula
\stopquestion

\beginanswer
\myanswer[Q:test2]
This is an answer.
\endanswer


\startquestion
This is a question without reference. It cannot have any answer.
\stopquestion


\page[yes]

\subject{Answers}

\useblocks[answer]

\stoptext

On Thu, Nov 3, 2016 at 12:58 PM, Mikael P. Sundqvist <mickep@gmail.com> wrote:
> Dear Hans,
>
> This seems to be exactly what I need, but I cannot get it to work.
> With the example below nothing comes from those
> commands (I just updated my standalone to the latest one). On the
> other hand, with text instead of reference it works.
>
> Best regards, Mikael
>
> \defineenumeration[question][
> text=Question,
> ]
>
> \starttext
> \startquestion[test]
> This question has reference
> \namedenumerationparameter{question}{reference} which could also
> be achieved via \enumerationparameter{reference}. On the other hand,
> \namedenumerationparameter{question}{text}
> gives Question as assumed.
> \stopquestion
>
> \startquestion[reference=test2]
> This question has reference
> \namedenumerationparameter{question}{reference} which could also
> be achieved via \enumerationparameter{reference}. On the other hand,
> \namedenumerationparameter{question}{text}
> gives Question as assumed.
> \stopquestion
> \stoptext
>
> On Thu, Nov 3, 2016 at 10:34 AM, Hans Hagen <pragma@wxs.nl> wrote:
>> On 11/2/2016 9:58 PM, Mikael P. Sundqvist wrote:
>>>
>>> Dear Otared,
>>>
>>> thank you again. This is somehow a proof that it should work. In my
>>> real document I use the title to name some exercises (after old
>>> exams), and I don't see how that can be combined with your solution.
>>>
>>> If someone else reads this: I think the question boils down to the
>>> following:
>>>
>>> \startquestion[Q:test]
>>> How can I here automatically get access to to the string "Q:test"?
>>> \stopquestion
>>
>>
>> it depends what automatically means
>>
>> \enumerationparameter{reference}
>>
>> or
>>
>> \namedenumerationparameter{question}{reference}
>>
>>
>>> Best regards, Mikael
>>>
>>> On Wed, Nov 2, 2016 at 9:04 PM, Otared Kavian <otared@gmail.com> wrote:
>>>>
>>>> Hi Mikael,
>>>>
>>>> A partial solution to the feature we are discussing is contained in the
>>>> example below, but somone more aware of ConTeXtish coding might improve it.
>>>> It is not satisfactory in that one has to define twice \startquestion and
>>>> \StartQuestion, \beginanswer and \BeginAnswer, and more importantly one
>>>> cannot generate automatically the references (I tried \getnumber[question]
>>>> and such to append to Q:\getnumber[question] for instance, but something
>>>> does not work…).
>>>>
>>>> Le me know if you find a satisfactory solution…
>>>>
>>>> Best regards: OK
>>>> %%% begin interactive-question-answer.tex
>>>> \setupinteraction[state=start,color=,contrastcolor=,style=]
>>>>
>>>> \defineblock[answer]
>>>> \hideblocks[answer]
>>>>
>>>> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
>>>>
>>>> \define[1]\AnswerToQuestion{Question \goto{(see Solution)}[A:Q:#1]}
>>>>
>>>>
>>>> \define[1]\StartQuestion{\startquestion[reference=Q:#1,title={\AnswerToQuestion{#1}}]}
>>>>
>>>> \define[1]\BeginAnswer{\beginanswer\myanswer[Q:#1]}
>>>>
>>>> \defineenumeration[question][
>>>>         text=, %Question,
>>>>         headcolor=darkred,
>>>>         title=yes,
>>>>         titleleft=,
>>>>         titleright={.},
>>>>         width=fit,
>>>>         number=yes,
>>>>         prefix=yes,
>>>>         prefixsegments=section,
>>>>         ]
>>>>
>>>> \starttext
>>>>
>>>> \section{A section with questions}
>>>>
>>>> \StartQuestion{test}
>>>>
>>>> Prove that $(a +b)^2 = a^2 + 2ab + b^2$ for all $a,b\in{\Bbb R}$.
>>>>
>>>> \BeginAnswer{test}
>>>>
>>>> Indeed $(a+b)^2 = (a+b)(a+b) = a^2 + ab + ba +b^2 = a^2 + 2ab +b^2$ since
>>>> $ba=ba$.
>>>> \endanswer
>>>>
>>>> \stopquestion
>>>>
>>>> \page[yes]
>>>>
>>>> \startsection[title={Answers to all questions}]
>>>>
>>>> \useblocks[answer]
>>>>
>>>> \stopsection
>>>> \stoptext
>>>> %%% end interactive-question-answer.tex
>>>>
>>>>> On 2 Nov 2016, at 16:16, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>>>>>
>>>>> Dear Otared (and list),
>>>>>
>>>>> thank you for your reply and support.
>>>>>
>>>>> The links from the answers to the questions work as wanted with my
>>>>> solution, it is the links from the questions to the answers that do
>>>>> not.
>>>>>
>>>>> I guess I need something like
>>>>>
>>>>> headcommand={\in{Question}[A:###]},
>>>>>
>>>>> where ### is the reference tag I set. But I don't know what to change
>>>>> the ### into (or if that would work).
>>>>>
>>>>> Best regards, Mikael
>>>>>
>>>>> On Wed, Nov 2, 2016 at 1:52 PM, Otared Kavian <otared@gmail.com> wrote:
>>>>>>
>>>>>> Hi Mikael,
>>>>>>
>>>>>> I had a similar question some time ago, but I wanted to add a sort of
>>>>>> automatic referencing of questions and answers (and interaction going from
>>>>>> questions to answers and back).
>>>>>>
>>>>>> If you accept the hurdle of adding manual references, in your case you
>>>>>> can add (for instance…)
>>>>>>
>>>>>>        \goto{:-)}[Q:test]
>>>>>>
>>>>>> to the end of your answer to go back to the respective question. But
>>>>>> when you have several dozens of such references to add manually, it is not a
>>>>>> good idea.
>>>>>>
>>>>>> However I could not find a way to code the items (that is the
>>>>>> questions) in such a way that each adds automatically a unique reference,
>>>>>> and so I am interested too in the solution of the problem you mention.
>>>>>>
>>>>>> Best regards: OK
>>>>>>
>>>>>>
>>>>>>> On 2 Nov 2016, at 12:43, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>>>>>>>
>>>>>>> Dear list,
>>>>>>>
>>>>>>> I have a pretty large text with a lot of questions and answers, and
>>>>>>> want the user(students) to be able to click in the pdf to go from a
>>>>>>> certain exercise to its answer, and back. I have a solution (see
>>>>>>> below) to go from answers to questions, but not the other way around.
>>>>>>> I simply have no idea on how to make the red text (in the head) in the
>>>>>>> example question clickable with the answer on the next page as target.
>>>>>>> As you can see, the answer has a tag A:Q:test (I want to set these
>>>>>>> automatically in that manner), and clicking the green text I get to
>>>>>>> the correct place. I just don't see how to make the "Question 1.1"
>>>>>>> clickable with that target.
>>>>>>>
>>>>>>> I hope I make myself clear. If it matters, in the solution one could
>>>>>>> assume that the optional tag of the \startquestion \stopquestion is
>>>>>>> given for all questions.
>>>>>>>
>>>>>>> Best regards, Mikael
>>>>>>>
>>>>>>> %% qa.tex
>>>>>>> \setupinteraction[state=start,color=,contrastcolor=,style=]
>>>>>>>
>>>>>>> \defineblock[answer]
>>>>>>> \hideblocks[answer]
>>>>>>>
>>>>>>> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
>>>>>>>
>>>>>>> \defineenumeration[question][
>>>>>>> text=Question,
>>>>>>> headcolor=darkred,
>>>>>>> width=fit,
>>>>>>> number=yes,
>>>>>>> prefix=yes,
>>>>>>> prefixsegments=section,
>>>>>>> ]
>>>>>>>
>>>>>>> \starttext
>>>>>>>
>>>>>>> \section{A section with questions}
>>>>>>>
>>>>>>> \startquestion[Q:test]
>>>>>>> Solve this question!
>>>>>>> \stopquestion
>>>>>>>
>>>>>>> We could, however, click \color[darkyellow]{\in{Answer}[A:Q:test]}.
>>>>>>>
>>>>>>> \beginanswer
>>>>>>> \myanswer[Q:test]
>>>>>>> What question? The answer is \quotation{do it yourself}!
>>>>>>> \endanswer
>>>>>>>
>>>>>>> \page[yes]
>>>>>>>
>>>>>>> \subject{Answers}
>>>>>>>
>>>>>>> \useblocks[answer]
>>>>>>>
>>>>>>> \stoptext
>>>>>>>
>>>>>>> <qa.pdf>___________________________________________________________________________________
>>>>>>> If your question is of interest to others as well, please add an entry
>>>>>>> to the Wiki!
>>>>>>>
>>>>>>> maillist : ntg-context@ntg.nl /
>>>>>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>>>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>>>>> wiki     : http://contextgarden.net
>>>>>>>
>>>>>>> ___________________________________________________________________________________
>>>>>>
>>>>>>
>>>>>>
>>>>>> ___________________________________________________________________________________
>>>>>> If your question is of interest to others as well, please add an entry
>>>>>> to the Wiki!
>>>>>>
>>>>>> maillist : ntg-context@ntg.nl /
>>>>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>>>> wiki     : http://contextgarden.net
>>>>>>
>>>>>> ___________________________________________________________________________________
>>>>>
>>>>>
>>>>> ___________________________________________________________________________________
>>>>> If your question is of interest to others as well, please add an entry
>>>>> to the Wiki!
>>>>>
>>>>> maillist : ntg-context@ntg.nl /
>>>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>>> wiki     : http://contextgarden.net
>>>>>
>>>>> ___________________________________________________________________________________
>>>>
>>>>
>>>>
>>>> ___________________________________________________________________________________
>>>> If your question is of interest to others as well, please add an entry to
>>>> the Wiki!
>>>>
>>>> maillist : ntg-context@ntg.nl /
>>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>> wiki     : http://contextgarden.net
>>>>
>>>> ___________________________________________________________________________________
>>>
>>>
>>> ___________________________________________________________________________________
>>> If your question is of interest to others as well, please add an entry to
>>> the Wiki!
>>>
>>> maillist : ntg-context@ntg.nl /
>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>> wiki     : http://contextgarden.net
>>>
>>> ___________________________________________________________________________________
>>>
>>
>>
>> --
>>
>> -----------------------------------------------------------------
>>                                           Hans Hagen | PRAGMA ADE
>>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>>        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
>> -----------------------------------------------------------------
>>
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to
>> the Wiki!
>>
>> maillist : ntg-context@ntg.nl /
>> http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-03  9:34         ` Hans Hagen
@ 2016-11-03 11:58           ` Mikael P. Sundqvist
  2016-11-03 15:14             ` Mikael P. Sundqvist
  0 siblings, 1 reply; 20+ messages in thread
From: Mikael P. Sundqvist @ 2016-11-03 11:58 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 10953 bytes --]

Dear Hans,

This seems to be exactly what I need, but I cannot get it to work.
With the example below nothing comes from those
commands (I just updated my standalone to the latest one). On the
other hand, with text instead of reference it works.

Best regards, Mikael

\defineenumeration[question][
text=Question,
]

\starttext
\startquestion[test]
This question has reference
\namedenumerationparameter{question}{reference} which could also
be achieved via \enumerationparameter{reference}. On the other hand,
\namedenumerationparameter{question}{text}
gives Question as assumed.
\stopquestion

\startquestion[reference=test2]
This question has reference
\namedenumerationparameter{question}{reference} which could also
be achieved via \enumerationparameter{reference}. On the other hand,
\namedenumerationparameter{question}{text}
gives Question as assumed.
\stopquestion
\stoptext

On Thu, Nov 3, 2016 at 10:34 AM, Hans Hagen <pragma@wxs.nl> wrote:
> On 11/2/2016 9:58 PM, Mikael P. Sundqvist wrote:
>>
>> Dear Otared,
>>
>> thank you again. This is somehow a proof that it should work. In my
>> real document I use the title to name some exercises (after old
>> exams), and I don't see how that can be combined with your solution.
>>
>> If someone else reads this: I think the question boils down to the
>> following:
>>
>> \startquestion[Q:test]
>> How can I here automatically get access to to the string "Q:test"?
>> \stopquestion
>
>
> it depends what automatically means
>
> \enumerationparameter{reference}
>
> or
>
> \namedenumerationparameter{question}{reference}
>
>
>> Best regards, Mikael
>>
>> On Wed, Nov 2, 2016 at 9:04 PM, Otared Kavian <otared@gmail.com> wrote:
>>>
>>> Hi Mikael,
>>>
>>> A partial solution to the feature we are discussing is contained in the
>>> example below, but somone more aware of ConTeXtish coding might improve it.
>>> It is not satisfactory in that one has to define twice \startquestion and
>>> \StartQuestion, \beginanswer and \BeginAnswer, and more importantly one
>>> cannot generate automatically the references (I tried \getnumber[question]
>>> and such to append to Q:\getnumber[question] for instance, but something
>>> does not work…).
>>>
>>> Le me know if you find a satisfactory solution…
>>>
>>> Best regards: OK
>>> %%% begin interactive-question-answer.tex
>>> \setupinteraction[state=start,color=,contrastcolor=,style=]
>>>
>>> \defineblock[answer]
>>> \hideblocks[answer]
>>>
>>> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
>>>
>>> \define[1]\AnswerToQuestion{Question \goto{(see Solution)}[A:Q:#1]}
>>>
>>>
>>> \define[1]\StartQuestion{\startquestion[reference=Q:#1,title={\AnswerToQuestion{#1}}]}
>>>
>>> \define[1]\BeginAnswer{\beginanswer\myanswer[Q:#1]}
>>>
>>> \defineenumeration[question][
>>>         text=, %Question,
>>>         headcolor=darkred,
>>>         title=yes,
>>>         titleleft=,
>>>         titleright={.},
>>>         width=fit,
>>>         number=yes,
>>>         prefix=yes,
>>>         prefixsegments=section,
>>>         ]
>>>
>>> \starttext
>>>
>>> \section{A section with questions}
>>>
>>> \StartQuestion{test}
>>>
>>> Prove that $(a +b)^2 = a^2 + 2ab + b^2$ for all $a,b\in{\Bbb R}$.
>>>
>>> \BeginAnswer{test}
>>>
>>> Indeed $(a+b)^2 = (a+b)(a+b) = a^2 + ab + ba +b^2 = a^2 + 2ab +b^2$ since
>>> $ba=ba$.
>>> \endanswer
>>>
>>> \stopquestion
>>>
>>> \page[yes]
>>>
>>> \startsection[title={Answers to all questions}]
>>>
>>> \useblocks[answer]
>>>
>>> \stopsection
>>> \stoptext
>>> %%% end interactive-question-answer.tex
>>>
>>>> On 2 Nov 2016, at 16:16, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>>>>
>>>> Dear Otared (and list),
>>>>
>>>> thank you for your reply and support.
>>>>
>>>> The links from the answers to the questions work as wanted with my
>>>> solution, it is the links from the questions to the answers that do
>>>> not.
>>>>
>>>> I guess I need something like
>>>>
>>>> headcommand={\in{Question}[A:###]},
>>>>
>>>> where ### is the reference tag I set. But I don't know what to change
>>>> the ### into (or if that would work).
>>>>
>>>> Best regards, Mikael
>>>>
>>>> On Wed, Nov 2, 2016 at 1:52 PM, Otared Kavian <otared@gmail.com> wrote:
>>>>>
>>>>> Hi Mikael,
>>>>>
>>>>> I had a similar question some time ago, but I wanted to add a sort of
>>>>> automatic referencing of questions and answers (and interaction going from
>>>>> questions to answers and back).
>>>>>
>>>>> If you accept the hurdle of adding manual references, in your case you
>>>>> can add (for instance…)
>>>>>
>>>>>        \goto{:-)}[Q:test]
>>>>>
>>>>> to the end of your answer to go back to the respective question. But
>>>>> when you have several dozens of such references to add manually, it is not a
>>>>> good idea.
>>>>>
>>>>> However I could not find a way to code the items (that is the
>>>>> questions) in such a way that each adds automatically a unique reference,
>>>>> and so I am interested too in the solution of the problem you mention.
>>>>>
>>>>> Best regards: OK
>>>>>
>>>>>
>>>>>> On 2 Nov 2016, at 12:43, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>>>>>>
>>>>>> Dear list,
>>>>>>
>>>>>> I have a pretty large text with a lot of questions and answers, and
>>>>>> want the user(students) to be able to click in the pdf to go from a
>>>>>> certain exercise to its answer, and back. I have a solution (see
>>>>>> below) to go from answers to questions, but not the other way around.
>>>>>> I simply have no idea on how to make the red text (in the head) in the
>>>>>> example question clickable with the answer on the next page as target.
>>>>>> As you can see, the answer has a tag A:Q:test (I want to set these
>>>>>> automatically in that manner), and clicking the green text I get to
>>>>>> the correct place. I just don't see how to make the "Question 1.1"
>>>>>> clickable with that target.
>>>>>>
>>>>>> I hope I make myself clear. If it matters, in the solution one could
>>>>>> assume that the optional tag of the \startquestion \stopquestion is
>>>>>> given for all questions.
>>>>>>
>>>>>> Best regards, Mikael
>>>>>>
>>>>>> %% qa.tex
>>>>>> \setupinteraction[state=start,color=,contrastcolor=,style=]
>>>>>>
>>>>>> \defineblock[answer]
>>>>>> \hideblocks[answer]
>>>>>>
>>>>>> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
>>>>>>
>>>>>> \defineenumeration[question][
>>>>>> text=Question,
>>>>>> headcolor=darkred,
>>>>>> width=fit,
>>>>>> number=yes,
>>>>>> prefix=yes,
>>>>>> prefixsegments=section,
>>>>>> ]
>>>>>>
>>>>>> \starttext
>>>>>>
>>>>>> \section{A section with questions}
>>>>>>
>>>>>> \startquestion[Q:test]
>>>>>> Solve this question!
>>>>>> \stopquestion
>>>>>>
>>>>>> We could, however, click \color[darkyellow]{\in{Answer}[A:Q:test]}.
>>>>>>
>>>>>> \beginanswer
>>>>>> \myanswer[Q:test]
>>>>>> What question? The answer is \quotation{do it yourself}!
>>>>>> \endanswer
>>>>>>
>>>>>> \page[yes]
>>>>>>
>>>>>> \subject{Answers}
>>>>>>
>>>>>> \useblocks[answer]
>>>>>>
>>>>>> \stoptext
>>>>>>
>>>>>> <qa.pdf>___________________________________________________________________________________
>>>>>> If your question is of interest to others as well, please add an entry
>>>>>> to the Wiki!
>>>>>>
>>>>>> maillist : ntg-context@ntg.nl /
>>>>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>>>> wiki     : http://contextgarden.net
>>>>>>
>>>>>> ___________________________________________________________________________________
>>>>>
>>>>>
>>>>>
>>>>> ___________________________________________________________________________________
>>>>> If your question is of interest to others as well, please add an entry
>>>>> to the Wiki!
>>>>>
>>>>> maillist : ntg-context@ntg.nl /
>>>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>>> wiki     : http://contextgarden.net
>>>>>
>>>>> ___________________________________________________________________________________
>>>>
>>>>
>>>> ___________________________________________________________________________________
>>>> If your question is of interest to others as well, please add an entry
>>>> to the Wiki!
>>>>
>>>> maillist : ntg-context@ntg.nl /
>>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>> wiki     : http://contextgarden.net
>>>>
>>>> ___________________________________________________________________________________
>>>
>>>
>>>
>>> ___________________________________________________________________________________
>>> If your question is of interest to others as well, please add an entry to
>>> the Wiki!
>>>
>>> maillist : ntg-context@ntg.nl /
>>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>> wiki     : http://contextgarden.net
>>>
>>> ___________________________________________________________________________________
>>
>>
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to
>> the Wiki!
>>
>> maillist : ntg-context@ntg.nl /
>> http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki     : http://contextgarden.net
>>
>> ___________________________________________________________________________________
>>
>
>
> --
>
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

[-- Attachment #2: ctx-listexample16.pdf --]
[-- Type: application/pdf, Size: 9853 bytes --]

[-- Attachment #3: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-02 20:58       ` Mikael P. Sundqvist
@ 2016-11-03  9:34         ` Hans Hagen
  2016-11-03 11:58           ` Mikael P. Sundqvist
  0 siblings, 1 reply; 20+ messages in thread
From: Hans Hagen @ 2016-11-03  9:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 11/2/2016 9:58 PM, Mikael P. Sundqvist wrote:
> Dear Otared,
>
> thank you again. This is somehow a proof that it should work. In my
> real document I use the title to name some exercises (after old
> exams), and I don't see how that can be combined with your solution.
>
> If someone else reads this: I think the question boils down to the following:
>
> \startquestion[Q:test]
> How can I here automatically get access to to the string "Q:test"?
> \stopquestion

it depends what automatically means

\enumerationparameter{reference}

or

\namedenumerationparameter{question}{reference}

> Best regards, Mikael
>
> On Wed, Nov 2, 2016 at 9:04 PM, Otared Kavian <otared@gmail.com> wrote:
>> Hi Mikael,
>>
>> A partial solution to the feature we are discussing is contained in the example below, but somone more aware of ConTeXtish coding might improve it.
>> It is not satisfactory in that one has to define twice \startquestion and \StartQuestion, \beginanswer and \BeginAnswer, and more importantly one cannot generate automatically the references (I tried \getnumber[question] and such to append to Q:\getnumber[question] for instance, but something does not work…).
>>
>> Le me know if you find a satisfactory solution…
>>
>> Best regards: OK
>> %%% begin interactive-question-answer.tex
>> \setupinteraction[state=start,color=,contrastcolor=,style=]
>>
>> \defineblock[answer]
>> \hideblocks[answer]
>>
>> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
>>
>> \define[1]\AnswerToQuestion{Question \goto{(see Solution)}[A:Q:#1]}
>>
>> \define[1]\StartQuestion{\startquestion[reference=Q:#1,title={\AnswerToQuestion{#1}}]}
>>
>> \define[1]\BeginAnswer{\beginanswer\myanswer[Q:#1]}
>>
>> \defineenumeration[question][
>>         text=, %Question,
>>         headcolor=darkred,
>>         title=yes,
>>         titleleft=,
>>         titleright={.},
>>         width=fit,
>>         number=yes,
>>         prefix=yes,
>>         prefixsegments=section,
>>         ]
>>
>> \starttext
>>
>> \section{A section with questions}
>>
>> \StartQuestion{test}
>>
>> Prove that $(a +b)^2 = a^2 + 2ab + b^2$ for all $a,b\in{\Bbb R}$.
>>
>> \BeginAnswer{test}
>>
>> Indeed $(a+b)^2 = (a+b)(a+b) = a^2 + ab + ba +b^2 = a^2 + 2ab +b^2$ since $ba=ba$.
>> \endanswer
>>
>> \stopquestion
>>
>> \page[yes]
>>
>> \startsection[title={Answers to all questions}]
>>
>> \useblocks[answer]
>>
>> \stopsection
>> \stoptext
>> %%% end interactive-question-answer.tex
>>
>>> On 2 Nov 2016, at 16:16, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>>>
>>> Dear Otared (and list),
>>>
>>> thank you for your reply and support.
>>>
>>> The links from the answers to the questions work as wanted with my
>>> solution, it is the links from the questions to the answers that do
>>> not.
>>>
>>> I guess I need something like
>>>
>>> headcommand={\in{Question}[A:###]},
>>>
>>> where ### is the reference tag I set. But I don't know what to change
>>> the ### into (or if that would work).
>>>
>>> Best regards, Mikael
>>>
>>> On Wed, Nov 2, 2016 at 1:52 PM, Otared Kavian <otared@gmail.com> wrote:
>>>> Hi Mikael,
>>>>
>>>> I had a similar question some time ago, but I wanted to add a sort of automatic referencing of questions and answers (and interaction going from questions to answers and back).
>>>>
>>>> If you accept the hurdle of adding manual references, in your case you can add (for instance…)
>>>>
>>>>        \goto{:-)}[Q:test]
>>>>
>>>> to the end of your answer to go back to the respective question. But when you have several dozens of such references to add manually, it is not a good idea.
>>>>
>>>> However I could not find a way to code the items (that is the questions) in such a way that each adds automatically a unique reference, and so I am interested too in the solution of the problem you mention.
>>>>
>>>> Best regards: OK
>>>>
>>>>
>>>>> On 2 Nov 2016, at 12:43, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>>>>>
>>>>> Dear list,
>>>>>
>>>>> I have a pretty large text with a lot of questions and answers, and
>>>>> want the user(students) to be able to click in the pdf to go from a
>>>>> certain exercise to its answer, and back. I have a solution (see
>>>>> below) to go from answers to questions, but not the other way around.
>>>>> I simply have no idea on how to make the red text (in the head) in the
>>>>> example question clickable with the answer on the next page as target.
>>>>> As you can see, the answer has a tag A:Q:test (I want to set these
>>>>> automatically in that manner), and clicking the green text I get to
>>>>> the correct place. I just don't see how to make the "Question 1.1"
>>>>> clickable with that target.
>>>>>
>>>>> I hope I make myself clear. If it matters, in the solution one could
>>>>> assume that the optional tag of the \startquestion \stopquestion is
>>>>> given for all questions.
>>>>>
>>>>> Best regards, Mikael
>>>>>
>>>>> %% qa.tex
>>>>> \setupinteraction[state=start,color=,contrastcolor=,style=]
>>>>>
>>>>> \defineblock[answer]
>>>>> \hideblocks[answer]
>>>>>
>>>>> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
>>>>>
>>>>> \defineenumeration[question][
>>>>> text=Question,
>>>>> headcolor=darkred,
>>>>> width=fit,
>>>>> number=yes,
>>>>> prefix=yes,
>>>>> prefixsegments=section,
>>>>> ]
>>>>>
>>>>> \starttext
>>>>>
>>>>> \section{A section with questions}
>>>>>
>>>>> \startquestion[Q:test]
>>>>> Solve this question!
>>>>> \stopquestion
>>>>>
>>>>> We could, however, click \color[darkyellow]{\in{Answer}[A:Q:test]}.
>>>>>
>>>>> \beginanswer
>>>>> \myanswer[Q:test]
>>>>> What question? The answer is \quotation{do it yourself}!
>>>>> \endanswer
>>>>>
>>>>> \page[yes]
>>>>>
>>>>> \subject{Answers}
>>>>>
>>>>> \useblocks[answer]
>>>>>
>>>>> \stoptext
>>>>> <qa.pdf>___________________________________________________________________________________
>>>>> If your question is of interest to others as well, please add an entry to the Wiki!
>>>>>
>>>>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>>> wiki     : http://contextgarden.net
>>>>> ___________________________________________________________________________________
>>>>
>>>> ___________________________________________________________________________________
>>>> If your question is of interest to others as well, please add an entry to the Wiki!
>>>>
>>>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>> wiki     : http://contextgarden.net
>>>> ___________________________________________________________________________________
>>> ___________________________________________________________________________________
>>> If your question is of interest to others as well, please add an entry to the Wiki!
>>>
>>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>> wiki     : http://contextgarden.net
>>> ___________________________________________________________________________________
>>
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>>
>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-02 20:04     ` Otared Kavian
@ 2016-11-02 20:58       ` Mikael P. Sundqvist
  2016-11-03  9:34         ` Hans Hagen
  0 siblings, 1 reply; 20+ messages in thread
From: Mikael P. Sundqvist @ 2016-11-02 20:58 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear Otared,

thank you again. This is somehow a proof that it should work. In my
real document I use the title to name some exercises (after old
exams), and I don't see how that can be combined with your solution.

If someone else reads this: I think the question boils down to the following:

\startquestion[Q:test]
How can I here automatically get access to to the string "Q:test"?
\stopquestion

Best regards, Mikael

On Wed, Nov 2, 2016 at 9:04 PM, Otared Kavian <otared@gmail.com> wrote:
> Hi Mikael,
>
> A partial solution to the feature we are discussing is contained in the example below, but somone more aware of ConTeXtish coding might improve it.
> It is not satisfactory in that one has to define twice \startquestion and \StartQuestion, \beginanswer and \BeginAnswer, and more importantly one cannot generate automatically the references (I tried \getnumber[question] and such to append to Q:\getnumber[question] for instance, but something does not work…).
>
> Le me know if you find a satisfactory solution…
>
> Best regards: OK
> %%% begin interactive-question-answer.tex
> \setupinteraction[state=start,color=,contrastcolor=,style=]
>
> \defineblock[answer]
> \hideblocks[answer]
>
> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
>
> \define[1]\AnswerToQuestion{Question \goto{(see Solution)}[A:Q:#1]}
>
> \define[1]\StartQuestion{\startquestion[reference=Q:#1,title={\AnswerToQuestion{#1}}]}
>
> \define[1]\BeginAnswer{\beginanswer\myanswer[Q:#1]}
>
> \defineenumeration[question][
>         text=, %Question,
>         headcolor=darkred,
>         title=yes,
>         titleleft=,
>         titleright={.},
>         width=fit,
>         number=yes,
>         prefix=yes,
>         prefixsegments=section,
>         ]
>
> \starttext
>
> \section{A section with questions}
>
> \StartQuestion{test}
>
> Prove that $(a +b)^2 = a^2 + 2ab + b^2$ for all $a,b\in{\Bbb R}$.
>
> \BeginAnswer{test}
>
> Indeed $(a+b)^2 = (a+b)(a+b) = a^2 + ab + ba +b^2 = a^2 + 2ab +b^2$ since $ba=ba$.
> \endanswer
>
> \stopquestion
>
> \page[yes]
>
> \startsection[title={Answers to all questions}]
>
> \useblocks[answer]
>
> \stopsection
> \stoptext
> %%% end interactive-question-answer.tex
>
>> On 2 Nov 2016, at 16:16, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>>
>> Dear Otared (and list),
>>
>> thank you for your reply and support.
>>
>> The links from the answers to the questions work as wanted with my
>> solution, it is the links from the questions to the answers that do
>> not.
>>
>> I guess I need something like
>>
>> headcommand={\in{Question}[A:###]},
>>
>> where ### is the reference tag I set. But I don't know what to change
>> the ### into (or if that would work).
>>
>> Best regards, Mikael
>>
>> On Wed, Nov 2, 2016 at 1:52 PM, Otared Kavian <otared@gmail.com> wrote:
>>> Hi Mikael,
>>>
>>> I had a similar question some time ago, but I wanted to add a sort of automatic referencing of questions and answers (and interaction going from questions to answers and back).
>>>
>>> If you accept the hurdle of adding manual references, in your case you can add (for instance…)
>>>
>>>        \goto{:-)}[Q:test]
>>>
>>> to the end of your answer to go back to the respective question. But when you have several dozens of such references to add manually, it is not a good idea.
>>>
>>> However I could not find a way to code the items (that is the questions) in such a way that each adds automatically a unique reference, and so I am interested too in the solution of the problem you mention.
>>>
>>> Best regards: OK
>>>
>>>
>>>> On 2 Nov 2016, at 12:43, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>>>>
>>>> Dear list,
>>>>
>>>> I have a pretty large text with a lot of questions and answers, and
>>>> want the user(students) to be able to click in the pdf to go from a
>>>> certain exercise to its answer, and back. I have a solution (see
>>>> below) to go from answers to questions, but not the other way around.
>>>> I simply have no idea on how to make the red text (in the head) in the
>>>> example question clickable with the answer on the next page as target.
>>>> As you can see, the answer has a tag A:Q:test (I want to set these
>>>> automatically in that manner), and clicking the green text I get to
>>>> the correct place. I just don't see how to make the "Question 1.1"
>>>> clickable with that target.
>>>>
>>>> I hope I make myself clear. If it matters, in the solution one could
>>>> assume that the optional tag of the \startquestion \stopquestion is
>>>> given for all questions.
>>>>
>>>> Best regards, Mikael
>>>>
>>>> %% qa.tex
>>>> \setupinteraction[state=start,color=,contrastcolor=,style=]
>>>>
>>>> \defineblock[answer]
>>>> \hideblocks[answer]
>>>>
>>>> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
>>>>
>>>> \defineenumeration[question][
>>>> text=Question,
>>>> headcolor=darkred,
>>>> width=fit,
>>>> number=yes,
>>>> prefix=yes,
>>>> prefixsegments=section,
>>>> ]
>>>>
>>>> \starttext
>>>>
>>>> \section{A section with questions}
>>>>
>>>> \startquestion[Q:test]
>>>> Solve this question!
>>>> \stopquestion
>>>>
>>>> We could, however, click \color[darkyellow]{\in{Answer}[A:Q:test]}.
>>>>
>>>> \beginanswer
>>>> \myanswer[Q:test]
>>>> What question? The answer is \quotation{do it yourself}!
>>>> \endanswer
>>>>
>>>> \page[yes]
>>>>
>>>> \subject{Answers}
>>>>
>>>> \useblocks[answer]
>>>>
>>>> \stoptext
>>>> <qa.pdf>___________________________________________________________________________________
>>>> If your question is of interest to others as well, please add an entry to the Wiki!
>>>>
>>>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>>> wiki     : http://contextgarden.net
>>>> ___________________________________________________________________________________
>>>
>>> ___________________________________________________________________________________
>>> If your question is of interest to others as well, please add an entry to the Wiki!
>>>
>>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>> wiki     : http://contextgarden.net
>>> ___________________________________________________________________________________
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>>
>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-02 15:16   ` Mikael P. Sundqvist
@ 2016-11-02 20:04     ` Otared Kavian
  2016-11-02 20:58       ` Mikael P. Sundqvist
  0 siblings, 1 reply; 20+ messages in thread
From: Otared Kavian @ 2016-11-02 20:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Mikael,

A partial solution to the feature we are discussing is contained in the example below, but somone more aware of ConTeXtish coding might improve it.
It is not satisfactory in that one has to define twice \startquestion and \StartQuestion, \beginanswer and \BeginAnswer, and more importantly one cannot generate automatically the references (I tried \getnumber[question] and such to append to Q:\getnumber[question] for instance, but something does not work…).

Le me know if you find a satisfactory solution…

Best regards: OK
%%% begin interactive-question-answer.tex
\setupinteraction[state=start,color=,contrastcolor=,style=]

\defineblock[answer]
\hideblocks[answer]

\def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}

\define[1]\AnswerToQuestion{Question \goto{(see Solution)}[A:Q:#1]}

\define[1]\StartQuestion{\startquestion[reference=Q:#1,title={\AnswerToQuestion{#1}}]}

\define[1]\BeginAnswer{\beginanswer\myanswer[Q:#1]}

\defineenumeration[question][
	text=, %Question,
	headcolor=darkred,
	title=yes,
	titleleft=,
	titleright={.},
	width=fit,
	number=yes,
	prefix=yes,
	prefixsegments=section,
	]

\starttext

\section{A section with questions}

\StartQuestion{test}

Prove that $(a +b)^2 = a^2 + 2ab + b^2$ for all $a,b\in{\Bbb R}$.

\BeginAnswer{test}

Indeed $(a+b)^2 = (a+b)(a+b) = a^2 + ab + ba +b^2 = a^2 + 2ab +b^2$ since $ba=ba$.
\endanswer

\stopquestion

\page[yes]

\startsection[title={Answers to all questions}]

\useblocks[answer]

\stopsection
\stoptext
%%% end interactive-question-answer.tex

> On 2 Nov 2016, at 16:16, Mikael P. Sundqvist <mickep@gmail.com> wrote:
> 
> Dear Otared (and list),
> 
> thank you for your reply and support.
> 
> The links from the answers to the questions work as wanted with my
> solution, it is the links from the questions to the answers that do
> not.
> 
> I guess I need something like
> 
> headcommand={\in{Question}[A:###]},
> 
> where ### is the reference tag I set. But I don't know what to change
> the ### into (or if that would work).
> 
> Best regards, Mikael
> 
> On Wed, Nov 2, 2016 at 1:52 PM, Otared Kavian <otared@gmail.com> wrote:
>> Hi Mikael,
>> 
>> I had a similar question some time ago, but I wanted to add a sort of automatic referencing of questions and answers (and interaction going from questions to answers and back).
>> 
>> If you accept the hurdle of adding manual references, in your case you can add (for instance…)
>> 
>>        \goto{:-)}[Q:test]
>> 
>> to the end of your answer to go back to the respective question. But when you have several dozens of such references to add manually, it is not a good idea.
>> 
>> However I could not find a way to code the items (that is the questions) in such a way that each adds automatically a unique reference, and so I am interested too in the solution of the problem you mention.
>> 
>> Best regards: OK
>> 
>> 
>>> On 2 Nov 2016, at 12:43, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>>> 
>>> Dear list,
>>> 
>>> I have a pretty large text with a lot of questions and answers, and
>>> want the user(students) to be able to click in the pdf to go from a
>>> certain exercise to its answer, and back. I have a solution (see
>>> below) to go from answers to questions, but not the other way around.
>>> I simply have no idea on how to make the red text (in the head) in the
>>> example question clickable with the answer on the next page as target.
>>> As you can see, the answer has a tag A:Q:test (I want to set these
>>> automatically in that manner), and clicking the green text I get to
>>> the correct place. I just don't see how to make the "Question 1.1"
>>> clickable with that target.
>>> 
>>> I hope I make myself clear. If it matters, in the solution one could
>>> assume that the optional tag of the \startquestion \stopquestion is
>>> given for all questions.
>>> 
>>> Best regards, Mikael
>>> 
>>> %% qa.tex
>>> \setupinteraction[state=start,color=,contrastcolor=,style=]
>>> 
>>> \defineblock[answer]
>>> \hideblocks[answer]
>>> 
>>> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
>>> 
>>> \defineenumeration[question][
>>> text=Question,
>>> headcolor=darkred,
>>> width=fit,
>>> number=yes,
>>> prefix=yes,
>>> prefixsegments=section,
>>> ]
>>> 
>>> \starttext
>>> 
>>> \section{A section with questions}
>>> 
>>> \startquestion[Q:test]
>>> Solve this question!
>>> \stopquestion
>>> 
>>> We could, however, click \color[darkyellow]{\in{Answer}[A:Q:test]}.
>>> 
>>> \beginanswer
>>> \myanswer[Q:test]
>>> What question? The answer is \quotation{do it yourself}!
>>> \endanswer
>>> 
>>> \page[yes]
>>> 
>>> \subject{Answers}
>>> 
>>> \useblocks[answer]
>>> 
>>> \stoptext
>>> <qa.pdf>___________________________________________________________________________________
>>> If your question is of interest to others as well, please add an entry to the Wiki!
>>> 
>>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>> wiki     : http://contextgarden.net
>>> ___________________________________________________________________________________
>> 
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>> 
>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-02 12:52 ` Otared Kavian
@ 2016-11-02 15:16   ` Mikael P. Sundqvist
  2016-11-02 20:04     ` Otared Kavian
  0 siblings, 1 reply; 20+ messages in thread
From: Mikael P. Sundqvist @ 2016-11-02 15:16 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear Otared (and list),

thank you for your reply and support.

The links from the answers to the questions work as wanted with my
solution, it is the links from the questions to the answers that do
not.

I guess I need something like

headcommand={\in{Question}[A:###]},

where ### is the reference tag I set. But I don't know what to change
the ### into (or if that would work).

Best regards, Mikael

On Wed, Nov 2, 2016 at 1:52 PM, Otared Kavian <otared@gmail.com> wrote:
> Hi Mikael,
>
> I had a similar question some time ago, but I wanted to add a sort of automatic referencing of questions and answers (and interaction going from questions to answers and back).
>
> If you accept the hurdle of adding manual references, in your case you can add (for instance…)
>
>         \goto{:-)}[Q:test]
>
> to the end of your answer to go back to the respective question. But when you have several dozens of such references to add manually, it is not a good idea.
>
> However I could not find a way to code the items (that is the questions) in such a way that each adds automatically a unique reference, and so I am interested too in the solution of the problem you mention.
>
> Best regards: OK
>
>
>> On 2 Nov 2016, at 12:43, Mikael P. Sundqvist <mickep@gmail.com> wrote:
>>
>> Dear list,
>>
>> I have a pretty large text with a lot of questions and answers, and
>> want the user(students) to be able to click in the pdf to go from a
>> certain exercise to its answer, and back. I have a solution (see
>> below) to go from answers to questions, but not the other way around.
>> I simply have no idea on how to make the red text (in the head) in the
>> example question clickable with the answer on the next page as target.
>> As you can see, the answer has a tag A:Q:test (I want to set these
>> automatically in that manner), and clicking the green text I get to
>> the correct place. I just don't see how to make the "Question 1.1"
>> clickable with that target.
>>
>> I hope I make myself clear. If it matters, in the solution one could
>> assume that the optional tag of the \startquestion \stopquestion is
>> given for all questions.
>>
>> Best regards, Mikael
>>
>> %% qa.tex
>> \setupinteraction[state=start,color=,contrastcolor=,style=]
>>
>> \defineblock[answer]
>> \hideblocks[answer]
>>
>> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
>>
>> \defineenumeration[question][
>> text=Question,
>> headcolor=darkred,
>> width=fit,
>> number=yes,
>> prefix=yes,
>> prefixsegments=section,
>> ]
>>
>> \starttext
>>
>> \section{A section with questions}
>>
>> \startquestion[Q:test]
>> Solve this question!
>> \stopquestion
>>
>> We could, however, click \color[darkyellow]{\in{Answer}[A:Q:test]}.
>>
>> \beginanswer
>> \myanswer[Q:test]
>> What question? The answer is \quotation{do it yourself}!
>> \endanswer
>>
>> \page[yes]
>>
>> \subject{Answers}
>>
>> \useblocks[answer]
>>
>> \stoptext
>> <qa.pdf>___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>>
>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Clickable question/answer numbers
  2016-11-02 11:43 Mikael P. Sundqvist
@ 2016-11-02 12:52 ` Otared Kavian
  2016-11-02 15:16   ` Mikael P. Sundqvist
  0 siblings, 1 reply; 20+ messages in thread
From: Otared Kavian @ 2016-11-02 12:52 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Mikael,

I had a similar question some time ago, but I wanted to add a sort of automatic referencing of questions and answers (and interaction going from questions to answers and back). 

If you accept the hurdle of adding manual references, in your case you can add (for instance…)

	\goto{:-)}[Q:test]

to the end of your answer to go back to the respective question. But when you have several dozens of such references to add manually, it is not a good idea.

However I could not find a way to code the items (that is the questions) in such a way that each adds automatically a unique reference, and so I am interested too in the solution of the problem you mention.

Best regards: OK


> On 2 Nov 2016, at 12:43, Mikael P. Sundqvist <mickep@gmail.com> wrote:
> 
> Dear list,
> 
> I have a pretty large text with a lot of questions and answers, and
> want the user(students) to be able to click in the pdf to go from a
> certain exercise to its answer, and back. I have a solution (see
> below) to go from answers to questions, but not the other way around.
> I simply have no idea on how to make the red text (in the head) in the
> example question clickable with the answer on the next page as target.
> As you can see, the answer has a tag A:Q:test (I want to set these
> automatically in that manner), and clicking the green text I get to
> the correct place. I just don't see how to make the "Question 1.1"
> clickable with that target.
> 
> I hope I make myself clear. If it matters, in the solution one could
> assume that the optional tag of the \startquestion \stopquestion is
> given for all questions.
> 
> Best regards, Mikael
> 
> %% qa.tex
> \setupinteraction[state=start,color=,contrastcolor=,style=]
> 
> \defineblock[answer]
> \hideblocks[answer]
> 
> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
> 
> \defineenumeration[question][
> text=Question,
> headcolor=darkred,
> width=fit,
> number=yes,
> prefix=yes,
> prefixsegments=section,
> ]
> 
> \starttext
> 
> \section{A section with questions}
> 
> \startquestion[Q:test]
> Solve this question!
> \stopquestion
> 
> We could, however, click \color[darkyellow]{\in{Answer}[A:Q:test]}.
> 
> \beginanswer
> \myanswer[Q:test]
> What question? The answer is \quotation{do it yourself}!
> \endanswer
> 
> \page[yes]
> 
> \subject{Answers}
> 
> \useblocks[answer]
> 
> \stoptext
> <qa.pdf>___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Clickable question/answer numbers
@ 2016-11-02 11:43 Mikael P. Sundqvist
  2016-11-02 12:52 ` Otared Kavian
  0 siblings, 1 reply; 20+ messages in thread
From: Mikael P. Sundqvist @ 2016-11-02 11:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 1479 bytes --]

Dear list,

I have a pretty large text with a lot of questions and answers, and
want the user(students) to be able to click in the pdf to go from a
certain exercise to its answer, and back. I have a solution (see
below) to go from answers to questions, but not the other way around.
I simply have no idea on how to make the red text (in the head) in the
example question clickable with the answer on the next page as target.
As you can see, the answer has a tag A:Q:test (I want to set these
automatically in that manner), and clicking the green text I get to
the correct place. I just don't see how to make the "Question 1.1"
clickable with that target.

I hope I make myself clear. If it matters, in the solution one could
assume that the optional tag of the \startquestion \stopquestion is
given for all questions.

Best regards, Mikael

%% qa.tex
\setupinteraction[state=start,color=,contrastcolor=,style=]

\defineblock[answer]
\hideblocks[answer]

\def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}

\defineenumeration[question][
text=Question,
headcolor=darkred,
width=fit,
number=yes,
prefix=yes,
prefixsegments=section,
]

\starttext

\section{A section with questions}

\startquestion[Q:test]
Solve this question!
\stopquestion

We could, however, click \color[darkyellow]{\in{Answer}[A:Q:test]}.

\beginanswer
\myanswer[Q:test]
What question? The answer is \quotation{do it yourself}!
\endanswer

\page[yes]

\subject{Answers}

\useblocks[answer]

\stoptext

[-- Attachment #2: qa.pdf --]
[-- Type: application/pdf, Size: 13435 bytes --]

[-- Attachment #3: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2016-11-07 12:46 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.245.1478488929.2018.ntg-context@ntg.nl>
2016-11-07 12:19 ` Clickable question/answer numbers Jeong Dal
2016-11-07 12:46   ` Otared Kavian
2016-11-02 11:43 Mikael P. Sundqvist
2016-11-02 12:52 ` Otared Kavian
2016-11-02 15:16   ` Mikael P. Sundqvist
2016-11-02 20:04     ` Otared Kavian
2016-11-02 20:58       ` Mikael P. Sundqvist
2016-11-03  9:34         ` Hans Hagen
2016-11-03 11:58           ` Mikael P. Sundqvist
2016-11-03 15:14             ` Mikael P. Sundqvist
2016-11-04  8:10               ` Otared Kavian
2016-11-04 11:50               ` Wolfgang Schuster
2016-11-04 15:33                 ` Mikael P. Sundqvist
2016-11-05 12:38                   ` Wolfgang Schuster
2016-11-05 12:43                     ` Mikael P. Sundqvist
2016-11-05 17:34                     ` Otared Kavian
2016-11-05 18:14                       ` Wolfgang Schuster
2016-11-06 10:43                         ` Otared Kavian
2016-11-06 11:55                           ` Wolfgang Schuster
2016-11-06 14:46                             ` Otared Kavian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).