From cdbdc383307e5585391076143f1a790aeacc220f Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Mon, 18 Feb 2013 23:54:20 +0000
Subject: exsheets (18feb13)

git-svn-id: svn://tug.org/texlive/trunk@29155 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/exsheets/exsheets.sty | 40 +++++++++++++++++++----
 1 file changed, 33 insertions(+), 7 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/exsheets/exsheets.sty')

diff --git a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
index 6ac2e4dddc0..8ad8e86a9a7 100644
--- a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
+++ b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
@@ -31,8 +31,8 @@
 % If you have any ideas, questions, suggestions or bugs to report, please
 % feel free to contact me.
 % ----------------------------------------------------------------------------
-\def\exsheets@date{2013/01/21}
-\def\exsheets@version{0.7a}
+\def\exsheets@date{2013/02/17}
+\def\exsheets@version{0.7b}
 
 \RequirePackage { expl3 , xparse }
 \ProvidesExplPackage
@@ -50,6 +50,7 @@
 \int_new:N   \l__exsheets_tmpb_int
 \int_new:N   \l__exsheets_tmpc_int
 \int_new:N   \l__exsheets_tmpd_int
+\int_new:N   \l__exsheets_tmpe_int
 \dim_new:N   \l__exsheets_tmpa_dim
 \seq_new:N   \l__exsheets_tmpa_seq
 \fp_new:N    \l__exsheets_tmpa_fp
@@ -570,7 +571,11 @@
               { \int_use:N \l__exsheets_tmpa_int }
           }
         \cs_set:cpn { __exsheets_variation_ \int_to_roman:n { #1 } :n } ##1
-          { ##1 \use:c { __exsheets_variation_ \int_to_roman:n { #1 + 1 } :n } }
+          {
+            ##1
+            \cs_set:Npn \exsheets_last_variant: { ##1 }
+            \use:c { __exsheets_variation_ \int_to_roman:n { #1 + 1 } :n }
+          }
       }
       {
         \msg_warning:nnxx { exsheets } { variant }
@@ -580,6 +585,8 @@
 
 \cs_new:Npn \exsheets_vary:w
   { \__exsheets_variation_i:n }
+  
+\cs_new:Npn \exsheets_last_variant: { }
 
 \cs_new:Npn \__exsheets_generate_variation_auxiliary:n #1
   {
@@ -604,6 +611,9 @@
 \NewDocumentCommand \vary { }
   { \exsheets_vary:w }
 
+\NewDocumentCommand \lastvariant { }
+  { \exsheets_last_variant: }
+
 % initiate: two variations, first is default
 \SetVariations { 2 }
 \variant    { 1 }
@@ -1484,12 +1494,24 @@
           }
           {
             \int_gincr:N \g__exsheets_questions_id_int
+            \int_set:Nn \l__exsheets_tmpa_int
+              {
+                \int_mod:nn
+                  { \g__exsheets_questions_id_int }
+                  { \g__exsheets_selection_number_int }
+              }
+            \int_compare:nT { \l__exsheets_tmpa_int = 0 }
+              {
+                \int_set_eq:NN
+                  \l__exsheets_tmpa_int
+                  \g__exsheets_selection_number_int
+              }
             \exp_args:NNx
-            \prop_get:NnN \g__exsheets_questions_id_prop
-              {  \int_use:N \g__exsheets_questions_id_int }
-              \l_tmpa_tl
+            \prop_get:NnN \g__exsheets_selected_questions_prop
+              {  \int_use:N \l__exsheets_tmpa_int }
+              \l__exsheets_tmpa_tl
             \bool_if:NF \l__exsheets_include_all_bool
-              { \__exsheets_select_question_by_id:V \l_tmpa_tl }
+              { \__exsheets_select_question_by_id:V \l__exsheets_tmpa_tl }
           }
       }
   }
@@ -1573,6 +1595,9 @@
 \cs_new:Npn \__exsheets_save_solution:n #1
   {
     % save for later use
+    \bool_if:NTF \l__exsheets_include_all_bool
+      { \int_set:Nn \l__exsheets_tmpe_int { \g__exsheets_questions_id_int -1 } }
+      { \int_set_eq:NN \l__exsheets_tmpe_int \g__exsheets_questions_id_int }
     \prop_gput:Nff \g__exsheets_solutions_content_prop
       { \int_use:N \g__exsheets_questions_id_int }
       { #1 }
@@ -2406,6 +2431,7 @@ HISTORY:
                          than before
 2013/01/21 v0.7a       - added option `auto-label' and questions key `label',
                          also added question properties `ref' and `pageref'
+2013/02/17 v0.7b       - bug fix: question selection by ID now works again
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-- 
cgit v1.2.3

