ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Creating cloze texts
@ 2016-09-02 13:27 Florian Leupold
  2016-09-04 10:03 ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Leupold @ 2016-09-02 13:27 UTC (permalink / raw)
  To: ntg-context


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

Dear list,

I would like to create cloze texts for my students with ConTeXt.

Ideally, I would have a command \cloze[<width>]{<solution>} with the following functionality:

1) \cloze{<solution>} would insert an underlined gap in the text with a width of (say) 1.3 times the width of solution and puts the solution on top of it with centered alignment. I will then color the text read if the mode is ‘teacher’ and in white if not.
2) \cloze[<width>]{<solution>} would do the same, but with a fixed width of the underline. The solution should then be flush left, maybe with a horizontal space of \quad.
3) The underline should allow for line breaks and hyphenation, but not such that only empty space is broken into the next line of left in the previous (see MNWE).

In this way, the student’s and teacher’s versions of the script will look exactly the same, except for the visible solution in the teacher’s version.

The macro \underbar does a good job in terms of line breaks and hyphenation. But it is "too smart" in the sense that it does not underline horizontal spaces. The MNWE below showcases problems with my naive attempts to achieve underlining:
- CLOZE 1 does not have any extra space.
- CLOZE 2 does not underline the horizontal spaces.
- CLOZE 3 does not show the underline, supposedly because the first text elements in it are white.
- CLOZE 4 shows that introducing fake characters is not a good idea anyways because the cloze is broken without any “real” solution in the first line.
- CLOZE 5 shows the same for trailing space.

MNWE:
\starttext
\input ward
\underbar{\color[red]{CLOZE 1}}
\input ward
\underbar{\quad\color[red]{CLOZE 2}\quad}
\input ward
\underbar{\color[white]{x}\quad\color[red]{CLOZE 3}\quad\color[white]{x}}
\input ward
\underbar{\color[green]{x}\quad\color[red]{CLOZE 4}\quad\color[white]{x}}
\input ward
space \underbar{\color[red]{CLOZE 5}\qquad\color[white]{x}} space
\input ward
\stoptext

I would greatly appreciate help with this problem.

Thanks so much in advance!
Florian


[-- Attachment #1.2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 842 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Creating cloze texts
  2016-09-02 13:27 Creating cloze texts Florian Leupold
@ 2016-09-04 10:03 ` Hans Hagen
  2016-09-04 12:14   ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2016-09-04 10:03 UTC (permalink / raw)
  To: ntg-context

On 9/2/2016 3:27 PM, Florian Leupold wrote:
> Dear list,
>
> I would like to create cloze texts for my students with ConTeXt.
>
> Ideally, I would have a command \cloze[<width>]{<solution>} with the following functionality:
>
> 1) \cloze{<solution>} would insert an underlined gap in the text with a width of (say) 1.3 times the width of solution and puts the solution on top of it with centered alignment. I will then color the text read if the mode is ‘teacher’ and in white if not.
> 2) \cloze[<width>]{<solution>} would do the same, but with a fixed width of the underline. The solution should then be flush left, maybe with a horizontal space of \quad.
> 3) The underline should allow for line breaks and hyphenation, but not such that only empty space is broken into the next line of left in the previous (see MNWE).
>
> In this way, the student’s and teacher’s versions of the script will look exactly the same, except for the visible solution in the teacher’s version.
>
> The macro \underbar does a good job in terms of line breaks and hyphenation. But it is "too smart" in the sense that it does not underline horizontal spaces. The MNWE below showcases problems with my naive attempts to achieve underlining:
> - CLOZE 1 does not have any extra space.
> - CLOZE 2 does not underline the horizontal spaces.
> - CLOZE 3 does not show the underline, supposedly because the first text elements in it are white.
> - CLOZE 4 shows that introducing fake characters is not a good idea anyways because the cloze is broken without any “real” solution in the first line.
> - CLOZE 5 shows the same for trailing space.
>
> MNWE:
> \starttext
> \input ward
> \underbar{\color[red]{CLOZE 1}}
> \input ward
> \underbar{\quad\color[red]{CLOZE 2}\quad}
> \input ward
> \underbar{\color[white]{x}\quad\color[red]{CLOZE 3}\quad\color[white]{x}}
> \input ward
> \underbar{\color[green]{x}\quad\color[red]{CLOZE 4}\quad\color[white]{x}}
> \input ward
> space \underbar{\color[red]{CLOZE 5}\qquad\color[white]{x}} space
> \input ward
> \stoptext
>
> I would greatly appreciate help with this problem.

\definebar[ClozedBar][underbar][continue=yes]

\unexpanded\def\Clozed#1{\ClozedBar{\zwj#1\zwj}}

\starttext

\input ward
\Clozed{\color[red]{CLOZE 1}}
\input ward
\Clozed{\quad\color[red]{CLOZE 2}\quad}
\input ward
\Clozed{\color[white]{x}\quad\color[red]{CLOZE 3}\quad\color[white]{x}}
\input ward
\Clozed{\color[green]{x}\quad\color[red]{CLOZE 4}\quad\color[white]{x}}
\input ward
space \Clozed{\color[red]{CLOZE 5}\qquad\color[white]{x}} space
\input ward

\stoptext


-- 

-----------------------------------------------------------------
                                           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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Creating cloze texts
  2016-09-04 10:03 ` Hans Hagen
@ 2016-09-04 12:14   ` Hans Hagen
  2016-09-04 14:28     ` Florian Leupold
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2016-09-04 12:14 UTC (permalink / raw)
  To: ntg-context

On 9/4/2016 12:03 PM, Hans Hagen wrote:

> \definebar[ClozedBar][underbar][continue=yes]
>
> \unexpanded\def\Clozed#1{\ClozedBar{\zwj#1\zwj}}
>
> \starttext
>
> \input ward
> \Clozed{\color[red]{CLOZE 1}}
> \input ward
> \Clozed{\quad\color[red]{CLOZE 2}\quad}
> \input ward
> \Clozed{\color[white]{x}\quad\color[red]{CLOZE 3}\quad\color[white]{x}}
> \input ward
> \Clozed{\color[green]{x}\quad\color[red]{CLOZE 4}\quad\color[white]{x}}
> \input ward
> space \Clozed{\color[red]{CLOZE 5}\qquad\color[white]{x}} space
> \input ward
>
> \stoptext

in next beta you can specify an empty option which will remove the text 
(otherwise one can still copy it from the pdf):

\definebar[ClozedBar][underbar][continue=yes,empty=yes]


-----------------------------------------------------------------
                                           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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Creating cloze texts
  2016-09-04 12:14   ` Hans Hagen
@ 2016-09-04 14:28     ` Florian Leupold
  2016-09-04 14:32       ` Florian Leupold
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Leupold @ 2016-09-04 14:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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


> On 04.09.16, at 14:14, Hans Hagen <pragma@wxs.nl> wrote:
> 
> On 9/4/2016 12:03 PM, Hans Hagen wrote:
> 
>> \definebar[ClozedBar][underbar][continue=yes]
>> 
>> \unexpanded\def\Clozed#1{\ClozedBar{\zwj#1\zwj}}
>> 
>> \starttext
>> 
>> \input ward
>> \Clozed{\color[red]{CLOZE 1}}
>> \input ward
>> \Clozed{\quad\color[red]{CLOZE 2}\quad}
>> \input ward
>> \Clozed{\color[white]{x}\quad\color[red]{CLOZE 3}\quad\color[white]{x}}
>> \input ward
>> \Clozed{\color[green]{x}\quad\color[red]{CLOZE 4}\quad\color[white]{x}}
>> \input ward
>> space \Clozed{\color[red]{CLOZE 5}\qquad\color[white]{x}} space
>> \input ward
>> 
>> \stoptext
> 
> in next beta you can specify an empty option which will remove the text (otherwise one can still copy it from the pdf):
> 
> \definebar[ClozedBar][underbar][continue=yes,empty=yes]
> 
> 
> -----------------------------------------------------------------
>                                          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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

Dear Hans,

thanks a lot for your solution!

I have added "color=black” to \definebar to prevent the bar’s color from changing at a line break, which happens otherwise:

\definebar[ClozedBar][underbar][continue=yes]
%\definebar[ClozedBar][underbar][continue=yes, color=black]
\unexpanded\def\Clozed#1{\ClozedBar{\zwj\quad#1\quad\zwj}}
\starttext
\Clozed{\color[red]{CLOZE 1}} text text text text text text text text text text text
\Clozed{\color[red]{CLOZE 2 CLOZE 2}}
\stoptext

Now the extra space is hardcoded by \quad. I guess it’s not so easy then to make the underbar’s width a factor times the input text width? Or, alternatively, an explicitly given width?

Cheers,
Florian

[-- Attachment #1.2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 842 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Creating cloze texts
  2016-09-04 14:28     ` Florian Leupold
@ 2016-09-04 14:32       ` Florian Leupold
  0 siblings, 0 replies; 5+ messages in thread
From: Florian Leupold @ 2016-09-04 14:32 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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


> On 04.09.16, at 16:28, Florian Leupold <fleupold@posteo.net> wrote:
> 
> 
>> On 04.09.16, at 14:14, Hans Hagen <pragma@wxs.nl> wrote:
>> 
>> On 9/4/2016 12:03 PM, Hans Hagen wrote:
>> 
>>> \definebar[ClozedBar][underbar][continue=yes]
>>> 
>>> \unexpanded\def\Clozed#1{\ClozedBar{\zwj#1\zwj}}
>>> 
>>> \starttext
>>> 
>>> \input ward
>>> \Clozed{\color[red]{CLOZE 1}}
>>> \input ward
>>> \Clozed{\quad\color[red]{CLOZE 2}\quad}
>>> \input ward
>>> \Clozed{\color[white]{x}\quad\color[red]{CLOZE 3}\quad\color[white]{x}}
>>> \input ward
>>> \Clozed{\color[green]{x}\quad\color[red]{CLOZE 4}\quad\color[white]{x}}
>>> \input ward
>>> space \Clozed{\color[red]{CLOZE 5}\qquad\color[white]{x}} space
>>> \input ward
>>> 
>>> \stoptext
>> 
>> in next beta you can specify an empty option which will remove the text (otherwise one can still copy it from the pdf):
>> 
>> \definebar[ClozedBar][underbar][continue=yes,empty=yes]
>> 
>> 
>> -----------------------------------------------------------------
>>                                         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://tex.aanhet.net
>> archive  : http://foundry.supelec.fr/projects/contextrev/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
> 
> Dear Hans,
> 
> thanks a lot for your solution!
> 
> I have added "color=black” to \definebar to prevent the bar’s color from changing at a line break, which happens otherwise:
> 
> \definebar[ClozedBar][underbar][continue=yes]
> %\definebar[ClozedBar][underbar][continue=yes, color=black]
> \unexpanded\def\Clozed#1{\ClozedBar{\zwj\quad#1\quad\zwj}}
> \starttext
> \Clozed{\color[red]{CLOZE 1}} text text text text text text text text text text text
> \Clozed{\color[red]{CLOZE 2 CLOZE 2}}
> \stoptext
> 
> Now the extra space is hardcoded by \quad. I guess it’s not so easy then to make the underbar’s width a factor times the input text width? Or, alternatively, an explicitly given width?
> 
> Cheers,
> Florian
> ___________________________________________________________________________________
> 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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

ADDENDUM:

There is still another problem: The fixed leading space may be eaten away by a line break.

\definebar[ClozedBar][underbar][continue=yes, color=black]
\unexpanded\def\Clozed#1{\ClozedBar{\zwj\quad#1\quad\zwj}}

\starttext
\Clozed{\color[red]{CLOZE 1}} text text text text text text text text text text text text text
\Clozed{\color[red]{CLOZE 2 CLOZE 2}}
\stoptext



[-- Attachment #1.2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 842 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2016-09-04 14:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-02 13:27 Creating cloze texts Florian Leupold
2016-09-04 10:03 ` Hans Hagen
2016-09-04 12:14   ` Hans Hagen
2016-09-04 14:28     ` Florian Leupold
2016-09-04 14:32       ` Florian Leupold

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).