hplgit / doconce

Lightweight markup language - document once, include anywhere
http://hplgit.github.io/doconce/doc/web/index.html
Other
309 stars 60 forks source link

Add new commands to hide answers/solutions or move them to end of document #191

Closed aless80 closed 4 years ago

aless80 commented 4 years ago

Issue #182 "Add answers_at_end option and review behavior for solutions_at_end" help users to move all solutions/answer to exercises to a separate section in the end of the document. When dealing with documents that have to be regularly updated such as course material, DocOnce users would need new functionality to control only part of the solutions/answers by hiding or moving them to the end of the document.

A user could add a DocOnce command that modifies how exercises write out solutions/answers from its place in the code until a new command brings back the normal behavior for solutions/answers. This comand should be allowed to be placed anywhere in the DocOnce text. See this example:

========= Week 1 – Electric field =========
label{ch:week01}

!anshide
!soldocend

#This is the text for chapter 1:
# #include "../chapters/week01/week01.do.txt"
!split

#These are some exercises. Answers will be suppressed, Solutions will be moved to end of document 
# #include "../chapters/week01/exer-week01/week01_ex1.do.txt"

#Restore normal behaviour for Solutions and Answers
!soloff
!ansoff

========= Week 2 – Gauss' law =========
label{ch:week02}

#This is the text for chapter 2:
# #include "../chapters/week02/week02.do.txt"
!split

#These are some exercises for week 2
# #include "../chapters/week02/exer-week02/week02_ex1.do.txt"

The example above introduces new commands: !<sol or ans><behavior>, where <behavior> can be "hide", "docend", and "off" to restore the default behaviour. The six commands I proposed are: !solhide !soldocend !soloff !anshide !ansdocend !ansoff