ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Otared Kavian <otared@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Clickable question/answer numbers
Date: Wed, 2 Nov 2016 21:04:37 +0100	[thread overview]
Message-ID: <72F9D2F7-1726-42EF-B764-32A8168D3AC4@gmail.com> (raw)
In-Reply-To: <CAHy-LL810+j5vMC5AU77meANJfn6k7X0si4MfnxVRLQp8cV-BQ@mail.gmail.com>

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
___________________________________________________________________________________

  reply	other threads:[~2016-11-02 20:04 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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
     [not found] <mailman.245.1478488929.2018.ntg-context@ntg.nl>
2016-11-07 12:19 ` Jeong Dal
2016-11-07 12:46   ` Otared Kavian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=72F9D2F7-1726-42EF-B764-32A8168D3AC4@gmail.com \
    --to=otared@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).