From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/96770 Path: news.gmane.org!.POSTED!not-for-mail From: Wolfgang Schuster Newsgroups: gmane.comp.tex.context Subject: Re: Clickable question/answer numbers Date: Sun, 06 Nov 2016 12:55:53 +0100 Message-ID: <581F1A49.1080001@gmail.com> References: <72F9D2F7-1726-42EF-B764-32A8168D3AC4@gmail.com> <75102198-e5ea-c9b7-1979-a5e3d6c6c042@wxs.nl> <581C7610.9060501@gmail.com> <581DD2DC.8000302@gmail.com> <6255F7AC-396B-486E-B560-F5E42188F559@gmail.com> <581E2183.6050600@gmail.com> <13F55FB9-088F-4245-8DD0-D493B636829D@gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8597538438963740391==" X-Trace: blaine.gmane.org 1478433421 1156 195.159.176.226 (6 Nov 2016 11:57:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 6 Nov 2016 11:57:01 +0000 (UTC) User-Agent: Postbox 5.0.5 (Macintosh/20161020) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Nov 06 12:56:56 2016 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c3M3y-000648-68 for gctc-ntg-context-518@m.gmane.org; Sun, 06 Nov 2016 12:56:38 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 8AAFF1D344; Sun, 6 Nov 2016 12:56:09 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N6ZHP-JvIFia; Sun, 6 Nov 2016 12:56:08 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id C4BD81D34E; Sun, 6 Nov 2016 12:56:08 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id C8F6A1D346 for ; Sun, 6 Nov 2016 12:56:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FRP2DTTbY4-2 for ; Sun, 6 Nov 2016 12:56:07 +0100 (CET) Original-Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 583E11D344 for ; Sun, 6 Nov 2016 12:55:57 +0100 (CET) Original-Received: by mail-wm0-f41.google.com with SMTP id f82so69427001wmf.1 for ; Sun, 06 Nov 2016 03:55:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to; bh=C0CpwDhFKpdghv5P9mGvCdj5LJVRNeJJgtvzK715c14=; b=yHrmAuZ+jkoPvSrH7tfUAZ8yToGLu8q6mUIB1R736gd2uVrXEi2en68MuBgKzNxCIF F+JUFt4az/9uzdPmo56MXA7L1Hm/iQ0uyubQDcPuTMPFAlHBeOiZUBMKF8OaO7nHpN4q UlNt0+cBuulnF+b8nPDvHdXbgAGCvrSrA2tblzjjyqT/Aj44lO17M235Aa0oLVlvPUSx kPmWq4Wz9XfGWYzkzvHsxAE3miUNoO1lervHXXzwqAaHsxVIA/hzNS4kxV64KEtRzk3M k0pOxdVcvdKXW/3jO0u6tj8SvW5krSjVWozvlv754iRqGlmXtohLysUZhEqZ+2NyR79k Yr6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to; bh=C0CpwDhFKpdghv5P9mGvCdj5LJVRNeJJgtvzK715c14=; b=PRUn9FbOMm7eqnERodhbtDZx9518DLETx1YtKDYIcbh70w604gl+BzR9WqVojQ+iym Bhxxdt0oRbCYo5fHZ5P/tB/wqfTu8KBOqEmnEVxNQ6/wcXxfHuKKkMSzt3I8+GdhS4XS OCqoaBHL3ncd7M9njYnGv/211NQ594XGPsGOKdhAKe2vnsTSv+RRt6agYflyH6kluSYF TEMY9mgunKsGJL4Vw1/tm5QdBUBodedGdUjJKUoZKAi07s9P9aBbcs89rlDSW1+nRz+B gAftFUSZYQAZQc4e2IFVAyS5oa+Zsew3v8wFvWaaU0sVGFStndBM9ncDiq1XnXhgeRYQ Mbog== X-Gm-Message-State: ABUngvfWrkDvByFixg1dD+b2ZpVVWERLsNlCMqVtVXj/ElQ2TXdovqPkf4yXQSSOmgGOtQ== X-Received: by 10.194.223.74 with SMTP id qs10mr1558092wjc.155.1478433356546; Sun, 06 Nov 2016 03:55:56 -0800 (PST) Original-Received: from keima.localdomain (x2f21ca1.dyn.telefonica.de. [2.242.28.161]) by smtp.gmail.com with ESMTPSA id k74sm7267768wmd.18.2016.11.06.03.55.55 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 06 Nov 2016 03:55:55 -0800 (PST) In-Reply-To: <13F55FB9-088F-4245-8DD0-D493B636829D@gmail.com> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.org gmane.comp.tex.context:96770 Archived-At: This is a multi-part message in MIME format. --===============8597538438963740391== Content-Type: multipart/alternative; boundary="------------020908060602000801000006" This is a multi-part message in MIME format. --------------020908060602000801000006 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit > Otared Kavian > 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 --------------020908060602000801000006 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
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
--------------020908060602000801000006-- --===============8597538438963740391== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f --===============8597538438963740391==--