diff options
author | Karl Berry <karl@freefriends.org> | 2016-07-30 23:11:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-07-30 23:11:21 +0000 |
commit | ef63475b97ba5f335f4b642c65af6f39982a00d2 (patch) | |
tree | 4a855450950adb4559fa2cbbe4b01a171602d2a5 /Master/texmf-dist/tex/latex/esami/esami.sty | |
parent | 467990204e7f3a87879281268759ba31fe0ac56d (diff) |
esami (27jul16)
git-svn-id: svn://tug.org/texlive/trunk@41774 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/esami/esami.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/esami/esami.sty | 264 |
1 files changed, 149 insertions, 115 deletions
diff --git a/Master/texmf-dist/tex/latex/esami/esami.sty b/Master/texmf-dist/tex/latex/esami/esami.sty index d198f79e5bc..257a2ff4647 100644 --- a/Master/texmf-dist/tex/latex/esami/esami.sty +++ b/Master/texmf-dist/tex/latex/esami/esami.sty @@ -2,8 +2,8 @@ %% This is file `esami.sty', %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% esami.sty package, 2015-02-25 %% -%% Copyright (C) 2008-2015 G. Messineo e S. Vassallo %% +%% esami.sty package, 2016-07-25 %% +%% Copyright (C) 2008-2016 G. Messineo e S. Vassallo %% %% %% %% This program can be redistributed and/or modified %% %% under the terms of the LaTeX Project Public License %% @@ -27,14 +27,18 @@ %Modified the algorithm of choice of a variant of an exercise, now completely deterministic. % Added the command \cmd{\Acapo}. Added the serbian localization (latin alphabet). %The compilation produces a new file with the list of the chosen exercises. +% Version 2.1 +% 2016/07/25 +%Modified es-german.lng and es-spanish.lng for an error in the input of the solutions. Introduced the macro randestrai. +%Introduced the macro FPsignpol. Introduced a control on the total points of the exercises. Solved the incompatibility +%with babel for the Spanish language. Removed the incompatibility between the command \fillin and the commands \sempli and \semplix. \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{esami} - [2015/02/25 v2.0 An Exam Construction Package] + [2016/07/25 v2.1 An Exam Construction Package] % +=============================+ % | THE OPTIONS | % +=============================+ -%\usepackage{etex} \newif\ifes@language \es@languagefalse \DeclareOption{italian}{\InputIfFileExists{es-\CurrentOption.lng}% { \es@languagetrue \typeout{esami: VerrĂ usata la lingua italiana}}% @@ -86,12 +90,11 @@ \AtEndDocument{ \immediate\closeout\loe \immediate\closeout\parametri -\immediate\closeout\sols -%%%%% 2013-06-03 % +\immediate\closeout\sols % \stringasol} %%%% }%%% for solutions \DeclareOption{nosolutions}{\es@solutionsfalse}%%% no solutions (default) -\newif\ifes@noquizsolutions \es@noquizsolutionstrue % NEW 2014 +\newif\ifes@noquizsolutions \es@noquizsolutionstrue \DeclareOption{noquizsolutions}{\es@noquizsolutionstrue} \DeclareOption{quizsolutions}{\es@noquizsolutionsfalse} \DeclareOption*{\InputIfFileExists{esami-\CurrentOption.cfg}{}%%% reads a configuration file @@ -99,9 +102,9 @@ {\es@cfgerrormessagelong} }} \newif\ifes@autopst \es@autopstfalse%%% Do I need auto-pst? -\newif\ifes@pst \es@pstfalse%%% Do I need pstricks? %%% NEW for tikz 2014.3.3 +\newif\ifes@pst \es@pstfalse%%% Do I need pstricks? \DeclareOption{autopstoff}{\es@psttrue \es@autopstfalse}%%% autopstpdf inactive (default) % -\DeclareOption{autopston}{\es@psttrue \es@autopsttrue }%%%% autopstpdf active %%% NEW for tikz 2014.3.3 +\DeclareOption{autopston}{\es@psttrue \es@autopsttrue }%%%% autopstpdf active \newif\ifes@prova \es@provafalse \DeclareOption{prova}{\es@solutionstrue \es@provatrue \es@randomizeChoicesfalse \es@noquizsolutionsfalse}%%% for the file "totale-versioni" \DeclareOption{correzione}{\es@correzionetrue \es@solutionsfalse}%%% to print all the exercises with solutions only @@ -249,7 +252,7 @@ \newcount\tmp@quest %%% the number of the exercise \newcount\@probselN %%% in \selectrandomlyn \newcount\@shfctr \newcount\@shfA \newcount\@shfB %%% In "\shuffle" -\newcount\icount %%% contatore per mischiare esercizi +\newcount\icount %%% counter to shuffle exercises \newcount\io \newcount\inizio \inizio=1 @@ -277,8 +280,11 @@ \renewcommand{\theesquestionnoii}{\alph{esquestionnoii}} \newcounter{esquestionnoiii} \renewcommand{\theesquestionnoiii}{\roman{esquestionnoiii}} +%\newdimen\punteggio %% NEW 2016/04/11 to check the total score of exercises +%\setlength{\punteggio}{0pt} +\newcommand\checkpoints\relax +\def\es@primo{1433} -\def\es@primo{1237} %========================================================% % test % @@ -367,16 +373,16 @@ % Maths % %========================================================% -\ifes@param -\newcommand{\FPsv}[2][0]{(#2)}%%% \FPsv shows oparations -\newcommandx{\FPval}[3][2=0]{\expandafter\def\csname#1\endcsname{(#1)} -\immediate\write\params{%%% writes on a file - \string\textbf\string{\string\noindent\space \es@parametermessagea{#1}{#3} - \string}\string\newline}} -\else +%\ifes@param +%\newcommand{\FPsv}[2][0]{(#2)}%%% \FPsv shows oparations +%\newcommandx{\FPval}[3][2=0]{\expandafter\def\csname#1\endcsname{(#1)} +%\immediate\write\params{%%% writes on a file +% \string\textbf\string{\string\noindent\space \es@parametermessagea{#1}{#3} +% \string}\string\newline}} +%\else \newcommand{\FPsv}[2][0]{\FPeval{\fp@tmpa}{clip(round(#2:#1))}\numprint{\fp@tmpa}}%%% It does operations with #1 decimals and with the "param" option it shows operations \newcommandx{\FPval}[3][2=0]{\FPeval{#1}{clip(round(#3:#2))}}%% it works like \FPsv with the option param, like \FPeval otherwise -\fi +%\fi %========================================================% % fractions % %========================================================% @@ -459,6 +465,15 @@ } %========================================================% +% Coefficients of polynomial % +%========================================================% + +\newcommand{\FPsignpol}[2] %%% adapted from code contributed by Hjalmar Basile NEW 2016/04/11 +{\FPval\tempsign{#1} +\ifnum \tempsign<0 {\semplix{\tempsign}{1}#2}\else \ifnum \tempsign>0{+\semplix{\tempsign}{1}#2}\else{}\fi\fi +} + +%========================================================% % Commands adapted from exerquiz % %========================================================% @@ -467,6 +482,8 @@ \def\es@l@l{\normalsize\normalfont(d)} \newcommand\PTs{\def\es@star{x}\@PTs} \def\@PTs#1{% +%\addtolength{\punteggio}{#1 pt} %% NEW 2016/04/11 to check the total score of exercises +%\global\punteggio=\punteggio \gdef\es@PTs{#1}\ifx\es@PTs\@empty\gdef\es@PTs{1}\fi \global\let\esPTs=\es@PTs\global\let\es@PTs=\@empty \if\es@star*\else\PTs@Hook\fi @@ -476,6 +493,34 @@ \let\qMark@Hook\@empty \newcommand{\post@questionsHook}{} \newcommand{\punti}{} +%%=========================================================================% +%% Modified commands for parametric version in "totale-versioni" % +%%=========================================================================% +%%%% +%\ifes@param +%\renewcommand{\FPsv}[2][0]{(#2)}%%% \FPsv shows oparations +%\renewcommandx{\FPval}[3][2=0]{\expandafter\def\csname#1\endcsname{(#1)} +%\immediate\write\params{%%% writes on a file +% \string\textbf\string{\string\noindent\space \es@parametermessagea{#1}{#3} +% \string}\string\newline}} +%\renewcommand{\FPsignpol}[2]{+(#1)#2} %%% adapted from code contributed by Hjalmar Basile NEW 2016/04/11 +%\renewcommand{\simpsqrt}[2]{\sqrt[#1]{(#2)}}%%% \simpsqrt shows operations +%\renewcommand{\sempli}[2]{%%% all simplifications become \frac +% \ifthenelse{\equal{#2}{1}}{(#1)}{\frac{#1}{#2}}} +% \renewcommand{\semplix}[2]{% +% \ifthenelse{\equal{#2}{1}}{(#1)}{\frac{#1}{#2}}} +% \renewcommand{\sempliz}[2]{% +% \ifthenelse{\equal{#2}{1}}{(#1)}{\frac{#1}{#2}}} +% \renewcommand{\esempli}[2]{% +% \ifthenelse{\equal{#2}{1}}{(#1)}{\frac{#1}{#2}}} +% \PTsHook{\emph{(\esPTs\ \ifthenelse{\equal{\esPTs}{\detokenize{1}}}{\es@pointname}{\es@pointsname})} % +% \ifes@test +% \immediate\closeout\params +% \fi +% } +%\fi + + %========================================================% % Commands adapted from eqexam % @@ -529,7 +574,6 @@ } %%%%%%% Fill in %%%%%% -%%%% NEW fillin 2013-06-03 \newcommand\fillinproblem{\es@fillintrue% \ifes@solutions \immediate\openout\parametri=qf\nome q\romannumeral\tmp@quest e\thevers.parametri.tex @@ -562,13 +606,12 @@ } %%%%% Other commands %%%%%% +\newcommand\stepverssols{\immediate\write\sols{\string\begin{minipage}{.33\string\textwidth}{\string\large\string\textbf{\es@solutionname\ \versionname\ n. \thevers}}}} +\newcommand\closeverssols{\immediate\write\sols{\string\end{minipage}}} -\newcommand\stepvers{\stepcounter{vers}\ifes@solutions -\immediate\write\sols{\string\begin{minipage}{.33\string\textwidth} -{\string\large\string\textbf{\es@solutionname\ \versionname\ n. \thevers}}} +\newcommand\stepvers{\stepcounter{vers}\ifes@solutions\stepverssols \immediate\write\loe{\versionname\space n. \thevers}\fi} -\newcommand\closevers{\newpage\setcounter{page}{1}\setcounter{ex@no}{0}\ifes@solutions\immediate\write\sols{\string\end{minipage} - \string\vspace{5ex}} + \newcommand\closevers{\newpage\setcounter{page}{1}\setcounter{ex@no}{0}\ifes@solutions\closeverssols \immediate\write\loe{\space} \immediate\write\loe{\space} \fi} @@ -620,7 +663,7 @@ \stepcounter{n@par}% \setcounter{fp@contatore}{-\value{vers}}% \randomi=\randomico% -\addtocounter{fp@contatore}{-#3}% +\ifnum#3>0 \addtocounter{fp@contatore}{-#3} \else \addtocounter{fp@contatore}{#3}\fi \whiledo{\value{fp@contatore}<\value{questionno}}{\nextrandom\stepcounter{fp@contatore}}% \setrannum{\tmp@a}{#3}{#4}% \def\rand@ne{#5}%%% checks the parameter (adapted from rangen) @@ -653,80 +696,6 @@ \randomi=\number\old@randomi%%% restores the seed }% \fi -%%%%%% Alternative definitions of \FPsetpar with different randomization process (we left them for archive purposes) %%%% - -%\newcommandx{\FPsetpar}[5][1=\seme,5={}]{% -%\stepcounter{n@par} -%\FPeval\diff{round(#4-#3+1:0)} -%\pdfsetrandomseed #1 -%\setcounter{fp@contatore}{-\value{vers}}% -%\tmp@cnt=\pdfuniformdeviate \diff -%\FPeval\tmp@seed{round(#1+\then@par:0)} -%\pdfsetrandomseed \tmp@seed %%% aggiunta 2010.04.19 -%\addtocounter{fp@contatore}{-#3} -%\FPeval\tmp@seed{round(tmp@seed+\thevers:0)} -%\pdfsetrandomseed \tmp@seed%%% aggiunta 2010.04.19 -%\whiledo{\value{fp@contatore}<\value{questionno}} -%{\tmp@cnt=\pdfuniformdeviate \diff \stepcounter{fp@contatore}} -%\FPeval{fp@tmp}{round((1-1/\diff)*\number\tmp@cnt+#3:0)} -% \def\rand@ne{#5} -% \ifx\rand@ne\@empty\else\loopCnt=0\relax -% \@whilenum\loopCnt<\maxLoopLimit\do{% -% \rnd@cnt=1\relax -% \@for\ne@@tmp:=\rand@ne\do{% -% \ifnum\fp@tmp=\ne@@tmp\relax -% \multiply\rnd@cnt0\relax -% \else -% \multiply\rnd@cnt1\relax -% \fi -% } -% \ifnum\rnd@cnt=1\relax -% \loopCnt=\maxLoopLimit -% \else -% \advance\loopCnt1\relax -% \ifnum\loopCnt=\maxLoopLimit -% \PackageWarning{esami}{Non sono state soddisfatte tutte le condizioni -% dopo \maxLoopLimit\space tentativi} -% \else -% \tmp@cnt=\pdfuniformdeviate \diff -% \FPeval{fp@tmp}{round((1-1/\diff)*\number\tmp@cnt+#3:0)} -% \fi -% \fi -% }% -% \fi -%\FPeval{#2}{round((1-1/\diff)*\number\tmp@cnt+#3:0)}} -% -%\newcommand{\FPsetpar}[4][\seme]{% -%\gdef\#2min{#3} -% \gdef\#2max{#4} -%\old@randomi=\number\randomi -%\stepcounter{n@par} -%\setcounter{fp@contatore}{-\value{vers}} -%\setrannum{\tmp@cnt}{#3}{#4} -%\randomi=#1 -%\advance\randomi\value{n@par} -%\addtocounter{fp@contatore}{-#3} -%\advance\randomi\value{vers} -%\whiledo{\value{fp@contatore}<\value{questionno}}{\nextrandom\stepcounter{fp@contatore}}%{\nextrandom\setrannum{\tmp@cnt}{#3}{#4} \stepcounter{fp@contatore}} -%\setrannum{\tmp@cnt}{#3}{#4} -%%\def\s@ss{#2} -%\FPeval{#2}{round(\number\tmp@cnt:0)} -%\ifes@fillin -% \expandafter\immediate\write\parametri{\string\FPeval\string{#2\string}\string{round(\number\tmp@cnt:0)\string}} -% \fi -% \randomi=\number\old@randomi -%} -% -%\newcommand{\FPsetpar}[4][\seme]{% -%\setcounter{fp@contatore}{-\value{vers}} -%\FPeval\dud{round(#1:0)} -%\FPseed=\dud -%\whiledo{\value{fp@contatore}<\value{questionno}}{ -%\FPrandom\tmp@cnt -%\FPeval{#2}{trunc((#4+1-#3)*tmp@cnt+#3:0)} -%\stepcounter{fp@contatore} -%} -%} %%%% Command for random sign (taken from rangen) %%%%% \newcommand{\RandS}{% @@ -737,8 +706,17 @@ - \fi}% -%%% Modified commands for parametric version in "totale-versioni" +%=========================================================================% +% Modified commands for parametric version in "totale-versioni" % +%=========================================================================% +%%% \ifes@param +\renewcommand{\FPsv}[2][0]{(#2)}%%% \FPsv shows oparations +\renewcommandx{\FPval}[3][2=0]{\expandafter\def\csname#1\endcsname{(#1)} +\immediate\write\params{%%% writes on a file + \string\textbf\string{\string\noindent\space \es@parametermessagea{#1}{#3} + \string}\string\newline}} +\renewcommand{\FPsignpol}[2]{+(#1)#2} %%% adapted from code contributed by Hjalmar Basile NEW 2016/04/11 \renewcommand{\simpsqrt}[2]{\sqrt[#1]{(#2)}}%%% \simpsqrt shows operations \renewcommand{\sempli}[2]{%%% all simplifications become \frac \ifthenelse{\equal{#2}{1}}{(#1)}{\frac{#1}{#2}}} @@ -927,7 +905,6 @@ \fi \fi -%%%% NEW fillin 2013-06-03 \newcommand{\newfillinproblem}[1]{ \newproblem{\fillinproblem #1}} %%%%%%%% \selectrandomly %%%%%%% @@ -1018,7 +995,6 @@ \global\advance\j@m by 1\relax }} -%%%%%%%%%%%% NEW 2013-06-05 %%% working with datasets of exercises (you can choose more than one exercise from a file) \newif\ifes@db %% to work with datasets @@ -1071,13 +1047,10 @@ \def\defitem{% \advance\icount by1 - %%% IT defines a macro called "\prbl n" where "n" is the number of the item. + %%% It defines a macro called "\prbl n" where "n" is the number of the item. \expandafter\def \csname prbl\romannumeral\icount \endcsname } - -%\def\@getitems#1#2#3{\rand@getitems{#2}{#3}[#1]}% - \newcommand{\esercizidb}[1]{ \icount=0 \input{#1.tex}% @@ -1110,8 +1083,6 @@ \ifnum\io > 0 \repeat \par} - - % +=============================+ % | ENVIRONMENTS | % +=============================+ @@ -1133,6 +1104,12 @@ \ifes@twocolumns \end{multicols} \fi + % \ifdim\punteggio=\punti pt %% NEW 2016/04/11 to check the total score of exercises +% \else +% \PackageError{esami}{\es@pointerrorshort} {\es@pointerrorlong} +% \fi +% \global\punteggio=0pt +\checkpoints \end{shortquiz} } @@ -1339,7 +1316,7 @@ } \def\@findendans{\@ifnextchar\end{}{\expandafter\@findendans\@gobble}} -\ifes@noquizsolutions %%%% NEW 2014 solutions for test +\ifes@noquizsolutions \def\solution@sq{\gobbleenv} \def\endsolution@sq{\endgobbleenv} \else @@ -1505,11 +1482,60 @@ \fi } { +\checkpoints \end{exercise*} \ifes@param \immediate\closeout\params \fi } +%%%%%%%% Problem in minipage + +\newenvironment{problemmp}[1][]{%%% it's like exercise, but with points +\es@testfalse +\begin{minipage}{\linewidth} %%% new 2016/02/19 +\renewcommand{\punti}{#1} +\ifes@solutionsonly\else\examenddef\fi +\begin{exercise} +\ifes@prova +\else +\ifes@solutions +\immediate\write\loe{\es@exercisename\space \theex@no:\space \probchosen} +\fi +\fi +} +{ +\end{exercise} +\end{minipage}%%% new 2016/02/19 +\ifes@param +\immediate\closeout\params +\fi} + +\newenvironment{problemmp*}[1][]{\es@testfalse +\begin{minipage}{\linewidth} %%% new 2016/02/19 +\renewcommand{\punti}{#1} +\ifes@solutionsonly\else\examenddef\fi +\begin{exercise*} +\ifes@prova +\else +\ifes@solutions +\immediate\write\loe{\es@exercisename\space \theex@no:\space \probchosen} +\fi +\fi +} +{ +%\ifdim\punteggio=\punti pt +% \else +% \PackageError{esami}{\es@pointerrorshort} +% {\es@pointerrorlong} +% \fi +% \global\punteggio=0pt %% NEW 2016/04/11 to check the total score of exercises +\checkpoints +\end{exercise*} +\end{minipage}%%% new 2016/02/19 +\ifes@param +\immediate\closeout\params +\fi } + %%%%%%%% Domanda %%%%%%%% %%%% (it can be used to hide the text of the exercise and print only the solution) %%% @@ -1768,7 +1794,7 @@ \newcommand\shuf@ifch[3]{% #2=the input item \ifthenelse{\not\equal{\shuf@ch}{#1}}{\stepcounter{shuf@lop}\expandafter\edef\csname #2\theshuf@lop\endcsname{#3}}{}% } -\newcommand\es@item[2]{%%% #1=the list #2=name of the input item +\newcommand\esami@item[2]{%%% #1=the list #2=name of the input item \edef\es@Lista{\zap@space#1 \@empty}% \@for\shuf@ch:=\es@Lista\do{% \shuf@ifch{}{#2}{\shuf@ch}% @@ -1777,7 +1803,7 @@ \newcommand{\sh@chex}[2]{%%% #1=the list #2=name of the input item \setcounter{shuf@lop}{0}% \renewcommand{\theshuf@lop}{\roman{shuf@lop}}% -\es@item{#1}{#2}% +\esami@item{#1}{#2}% \renewcommand{\theshuf@lop}{\arabic{shuf@lop}}% } @@ -1873,9 +1899,18 @@ }% \fi -%%% \esestrai is the user command to extract exercises from the list #2 leaving out #1 elements. +%%% \esestrai is the user command to extract exercises from the list #2 leaving out #1 elements. -\newcommand{\estraies}[2][0]{\randes@trai[#1]{#2}{tmp@out} +\newcommand{\estraies}[2][0]{\es@trai[#1]{#2}{tmp@out} + \tmp@cnt=\value{shuf@lop} + \advance\tmp@cnt by -#1 + \loop + \selectrandomly{\cartella/\csname tmp@out\romannumeral\tmp@cnt\endcsname} + \advance\tmp@cnt by-1 + \ifnum\tmp@cnt>0 + \repeat}% +%%% New user command to (randomly) extract exercises from the list #2 leaving out #1 elements. NEW 2015.09.14 +\newcommand{\randestraies}[2][0]{\randes@trai[#1]{#2}{tmp@out} \tmp@cnt=\value{shuf@lop} \advance\tmp@cnt by -#1 \loop @@ -1950,7 +1985,6 @@ } \fi -%%%% new 2013-06-05 %%% another shuffling macro \newcommand{\shuffle}[3][]{% %%% this command has been adapted from probsoln \@shfctr=1\relax |