From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/103625 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Jeroen Newsgroups: gmane.comp.tex.context Subject: Fwd: Question and Answer Iteration Date: Wed, 13 Mar 2019 12:37:09 +0000 Message-ID: References: <8762dac5-fcd5-5339-2f89-1b25abe350d2@gmail.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2099647327949167925==" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="268917"; mail-complaints-to="usenet@blaine.gmane.org" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed Mar 13 13:36:24 2019 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 esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h437M-0017eQ-An for gctc-ntg-context-518@m.gmane.org; Wed, 13 Mar 2019 13:36:20 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id B907EFC211; Wed, 13 Mar 2019 13:35:52 +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 zxqDblDhp7LC; Wed, 13 Mar 2019 13:35:50 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id D9C72FC20E; Wed, 13 Mar 2019 13:35:50 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 66454FC20C for ; Wed, 13 Mar 2019 13:35:49 +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 OTgXWpF8efLJ for ; Wed, 13 Mar 2019 13:35:48 +0100 (CET) Original-Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 9F833FC208 for ; Wed, 13 Mar 2019 13:35:48 +0100 (CET) Original-Received: by mail-qt1-f181.google.com with SMTP id k2so1635605qtm.1 for ; Wed, 13 Mar 2019 05:35:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=mcOvs7S6TQx/R94KOkEg1WQy1SRp+py3lJZZN53rWaA=; b=LvZEGeLxqJQTHa6pdUdM3sQ6L1y5bdDOrtr/ynbw5nlq6JNShVRJJ578QTN0wa79ra gURcZc3Ndq9PkKKfKslIPGBlnq40l8ztNeKVPe1QB9uOcU6l9x7ti9PrglB29ozyWwoS 5EM6AA2tKJPosiBgOdlsiHIG50IeMgZoTwmh4i4XpGwYEHGntx8THjHyOQRdTD1N+tLo hU324cBeqW2n7b4SkukwbdsXAR9TSXDAxkuWHvVGw4V/q4N8dJEQxQKrF85xhsX9npWo GPQgrBEHVNrkKFaUiW/6UKlXFYX06cm1joYheBFOL7TZkjo06SBWZj6o2+puKZZU47ET dXKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=mcOvs7S6TQx/R94KOkEg1WQy1SRp+py3lJZZN53rWaA=; b=gu9GS+VrBZRGNyub97edVprxOPYO+T3ArtfXf94w0PA965InooxwRjThhJDdLo2+sJ Hm7nsASkTRcUaqhvweYECFUqPv8L0xitAVd1w45HmO6SGs5X4bFIEoG+7bJ4bxvbPCb7 6MtPTS6DsvPNhKpRetk/mVl3xtKJS5WnnXmnHcTwBgsuS3h7jWGl4j6X6nVBwFDNJ4al 50dScaJsohCX0oO3cEK+xtrbX4IGG2gp/gMcOjZ8Yks/3GJIeKCXANWoe15kfSkvjNbV nmP9hWI5V+EvAmnUkf3S4UmhYl2b0V2QHxBA+uc6xTfSn6AbxEEyLvrvn4Gzka33NF4h GhOg== X-Gm-Message-State: APjAAAWqKRpvh1EM7Jl8PKRgwQm0xKW2mRjyMakg6F4c04Mat+FU9+Gd zeZYvjVgfg5KZ+K2U21sZ4CnoV6IIXCRCOSGZSpdY1F+ X-Google-Smtp-Source: APXvYqwuv0pVSxGX4fwT5eIJMD6E/vA6uhWyYqSDT9GCP4kYzj7CGC9rMg/OVlvYyNBGyu7JXNEnqFalT90MKhdrWcA= X-Received: by 2002:a0c:b597:: with SMTP id g23mr34069293qve.142.1552480545736; Wed, 13 Mar 2019 05:35:45 -0700 (PDT) In-Reply-To: <8762dac5-fcd5-5339-2f89-1b25abe350d2@gmail.com> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 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:103625 Archived-At: --===============2099647327949167925== Content-Type: multipart/alternative; boundary="000000000000730dd90583f90b93" --000000000000730dd90583f90b93 Content-Type: text/plain; charset="UTF-8" This worked very well, thanks. I now want at the end of each chapter some questions with the chapter number in the follow-up number, and then at the end of the document a separate chapter with the answers with matching numbers. In general for a single QA section this works, but now I start distributing it over a number of chapters, the question and answer numbering seems to be an issue. Would the define require a change? % QUESTION AND ANSWER \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={\black Question}, titledistance=2em, width=fit, distance=0.5em, headstyle=bold, number=yes, prefix=yes, prefixsegments=chapter, alternative=serried, headcommand=\QuestionTextCommand] \defineenumeration [answer] [text={\black Answer}, width=fit, distance=0.5em, headstyle=bold, number=yes, prefix=yes, prefixsegments=chapter, alternative=serried, headcommand=\AnswerTextCommand] \defineblock[answer] % END SETUP \starttext \chapter{Chap1} \section{End of Chapter Questions} \startquestion Question 1 \stopquestion \beginanswer \startanswer Answer 1 \stopanswer \endanswer \startquestion Question 2 \stopquestion \beginanswer \startanswer Answer 2 \stopanswer \endanswer \chapter{Chap2} \section{End of Chapter Questions} \startquestion Question 1 \stopquestion \beginanswer \startanswer Answer 1 \stopanswer \endanswer \startquestion Question 2 \stopquestion \beginanswer \startanswer Answer 2 \stopanswer \endanswer \Chapter{End of Chapter Answers} \section{Answers Chapter 1} \useblocks[answer] \section{Answers Chapter 2} \useblocks[answer] \stoptext I have it working with a single chapter: % QUESTION AND ANSWER \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={\black Question}, titledistance=2em, width=fit, distance=0.5em, headstyle=bold, number=yes, prefix=yes, prefixsegments=chapter, alternative=serried, headcommand=\QuestionTextCommand] \defineenumeration [answer] [text={\black Answer}, width=fit, distance=0.5em, headstyle=bold, number=yes, prefix=yes, prefixsegments=chapter, alternative=serried, headcommand=\AnswerTextCommand] \defineblock[answer] % END SETUP \starttext \chapter{Chap1} \section{End of Chapter Questions} \startquestion Question 1 \stopquestion \beginanswer \startanswer Answer 1 \stopanswer \endanswer \startquestion Question 2 \stopquestion \beginanswer \startanswer Answer 2 \stopanswer \endanswer \useblocks[answer] \stoptext --000000000000730dd90583f90b93 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This worked very well, t= hanks. I now want at the end of each chapter=C2=A0some questions with the c= hapter number in the follow-up number, and then at the end of the document = a separate chapter with the answers with matching numbers. In general for a= single QA section this works, but now I start distributing it over a numbe= r of chapters, the question and answer numbering seems to be an issue. Woul= d the define require a change?



% QUESTION AND ANSWER

\define[1]\QuestionTextCommand
=C2= =A0 {\doglobal\increment\QuestionCounter
=C2=A0=C2=A0 \pagereference[que= stion:\QuestionCounter]%
=C2=A0=C2=A0 \doifreferencefoundelse{answer:\Qu= estionCounter}
=C2=A0=C2=A0=C2=A0=C2=A0 {\goto{#1}[answer:\QuestionCount= er]}
=C2=A0=C2=A0=C2=A0=C2=A0 {#1}}

=
\define[1]\AnswerTextCommand
=C2=A0 {\d= oglobal\increment\AnswerCounter
=C2=A0=C2=A0 \pagereference[answer:\Answ= erCounter]%
=C2=A0=C2=A0 \doifreferencefoundelse{question:\AnswerCounter= }
=C2=A0=C2=A0=C2=A0=C2=A0 {\goto{#1}[question:\AnswerCounter]}
=C2= =A0=C2=A0=C2=A0=C2=A0 {#1}}

\defineenumeration
=C2=A0 [question]
=C2=A0 [te= xt=3D{\black Question},
=C2=A0=C2=A0 titledistance=3D2em,
=C2=A0=C2= =A0 width=3Dfit,
=C2=A0=C2=A0 distance=3D0.5em,
=C2=A0=C2=A0 headstyl= e=3Dbold,
=C2=A0=C2=A0 number=3Dyes,
=C2=A0=C2=A0 prefix=3Dyes,
= =C2=A0=C2=A0 prefixsegments=3Dchapter,
=C2=A0=C2=A0 alternative=3Dserrie= d,
=C2=A0=C2=A0 headcommand=3D\QuestionTextCommand]

\defineenumeration
=C2= =A0 [answer]
=C2=A0 [text=3D{\black Answer},
=C2=A0=C2=A0 width=3Dfit= ,
=C2=A0=C2=A0 distance=3D0.5em,
=C2=A0=C2=A0 headstyle=3Dbold,
= =C2=A0=C2=A0 number=3Dyes,
=C2=A0=C2=A0 prefix=3Dyes,
=C2=A0=C2=A0 pr= efixsegments=3Dchapter,
=C2=A0=C2=A0 alternative=3Dserried,
=C2=A0=C2= =A0 headcommand=3D\AnswerTextCommand]

<= /div>
\defineblock[answer]

% END SETUP

\starttext

\chapter{Chap1}<= /div>

\secti= on{End of Chapter Questions}

\startquestion Question 1 \stopquestion
\beginans= wer \startanswer Answer 1 \stopanswer \endanswer
\startquestion Question= 2 \stopquestion
\beginanswer \startanswer Answer 2 \stopanswer \endansw= er

\ch= apter{Chap2}

\section{End of Chapter Questions}
<= br>
\startquestion Question 1 \stopquestion=
\beginanswer \startanswer Answer 1 \stopanswer \endanswer
\startques= tion Question 2 \stopquestion
\beginanswer \startanswer Answer 2 \stopan= swer \endanswer

\Chapter{End of Chapter Answers}
=
\section{Answers Chapter 1}

\useblocks[answe= r]

\se= ction{Answers Chapter 2}

\useblocks[answer]

<= /div>
\stoptext
<= br>


I have it working with a single chapter:<= /div>

% QUES= TION AND ANSWER

\define[1]\QuestionTextCommand
=C2=A0 {\doglobal\increment\Que= stionCounter
=C2=A0=C2=A0 \pagereference[question:\QuestionCounter]%
= =C2=A0=C2=A0 \doifreferencefoundelse{answer:\QuestionCounter}
=C2=A0=C2= =A0=C2=A0=C2=A0 {\goto{#1}[answer:\QuestionCounter]}
=C2=A0=C2=A0=C2=A0= =C2=A0 {#1}}

\define[1]\AnswerTextCommand
=C2=A0 {\doglobal\increment\AnswerCo= unter
=C2=A0=C2=A0 \pagereference[answer:\AnswerCounter]%
=C2=A0=C2= =A0 \doifreferencefoundelse{question:\AnswerCounter}
=C2=A0=C2=A0=C2=A0= =C2=A0 {\goto{#1}[question:\AnswerCounter]}
=C2=A0=C2=A0=C2=A0=C2=A0 {#1= }}

\de= fineenumeration
=C2=A0 [question]
=C2=A0 [text=3D{\black Question},=C2=A0=C2=A0 titledistance=3D2em,
=C2=A0=C2=A0 width=3Dfit,
=C2=A0= =C2=A0 distance=3D0.5em,
=C2=A0=C2=A0 headstyle=3Dbold,
=C2=A0=C2=A0 = number=3Dyes,
=C2=A0=C2=A0 prefix=3Dyes,
=C2=A0=C2=A0 prefixsegments= =3Dchapter,
=C2=A0=C2=A0 alternative=3Dserried,
=C2=A0=C2=A0 headcomm= and=3D\QuestionTextCommand]

\defineenumeration
=C2=A0 [answer]
=C2=A0 [text= =3D{\black Answer},
=C2=A0=C2=A0 width=3Dfit,
=C2=A0=C2=A0 distance= =3D0.5em,
=C2=A0=C2=A0 headstyle=3Dbold,
=C2=A0=C2=A0 number=3Dyes,=C2=A0=C2=A0 prefix=3Dyes,
=C2=A0=C2=A0 prefixsegments=3Dchapter,
= =C2=A0=C2=A0 alternative=3Dserried,
=C2=A0=C2=A0 headcommand=3D\AnswerTe= xtCommand]

\defineblock[answer]

% END SETUP

<= div class=3D"gmail_quote">\starttext

\chapter{Chap1}

\section{End of Chapter Questions}=

\star= tquestion Question 1 \stopquestion
\beginan= swer \startanswer Answer 1 \stopanswer \endanswer
\startquestion Questio= n 2 \stopquestion
\beginanswer \startanswer Answer 2 \stopanswer \endans= wer

\u= seblocks[answer]

\stoptext
--000000000000730dd90583f90b93-- --===============2099647327949167925== 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 X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============2099647327949167925==--