Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Points question xsim package precision decimal #114

Closed
fabinholima opened this issue Jun 7, 2023 · 2 comments
Closed

Points question xsim package precision decimal #114

fabinholima opened this issue Jun 7, 2023 · 2 comments

Comments

@fabinholima
Copy link

fabinholima commented Jun 7, 2023

How can I customize the score accurately as a 1.0 is not able to recognize.

Look in MWE

I like show points 1.0 and 2.0, if points is major 1.001 show in points questions, how change this

 \usepackage{tikz}
 \usepackage{needspace}
\usepackage[no-files]{xsim}

\newcommand*\circled[2]{\tikz[baseline=(char.base)]{
        \node[shape=circle,fill,inner sep=2pt, text=white] (char) {#1};}}
%%%%%-Custom Xsim exercises %%%%%
\DeclareExerciseEnvironmentTemplate{custom}
{%\item[\GetExerciseProperty{counter}]
    \Needspace*{0\baselineskip}
    \noindent
    \circled{\XSIMmixedcase{\GetExerciseProperty{counter}}}~~~%
    \noindent
    \IfInsideSolutionF{%
        \GetExercisePropertyT{points}{ % notice the space
            (%
            \printgoal{\PropertyValue}
            \IfExerciseGoalSingularTF{points}
            {%\XSIMtranslate{point}
            }
            %{\XSIMtranslate{points}}%
            )%
        }
}}
{\vspace{\baselineskip}}


\xsimsetup{
    collect = false,
    exercise/within = section,
    exercise/template = custom,
    exercise/the-counter =  \arabic{exercise},
}



\begin{document}

\begin{exercise}[points=1.0]
Example 1
\end{exercise}


\begin{exercise}[points=1.001]
Example 1
\end{exercise}



\begin{exercise}[points=2.0]
    Example 2
\end{exercise}




\begin{exercise}[points=1.5]
    Example 3
\end{exercise}
\end{document}```


@muzimuzhi
Copy link

muzimuzhi commented Jun 8, 2023

By applying a zero filling number format (\pgfmathprintnumber is provided by pgfmath, which is auto loaded by tikz)

\xsimsetup{
  goal-print={\pgfmathprintnumber[fixed zerofill,precision=1]{#1}}
}

If in the future l3fp provides its way to round and zero fill a decimal number (see latex3/latex3#1226), setting goal-print=\fpeval{func_name(#1)}) will work too.

Before After
image image

Full example (the missing \documentclass line is added)

\documentclass{article}
\usepackage{tikz}
\usepackage{needspace}
\usepackage[no-files]{xsim}

\xsimsetup{
  goal-print={\pgfmathprintnumber[fixed zerofill,precision=1]{#1}}
}

\newcommand*\circled[2]{\tikz[baseline=(char.base)]{
        \node[shape=circle,fill,inner sep=2pt, text=white] (char) {#1};}}
%%%%%-Custom Xsim exercises %%%%%
\DeclareExerciseEnvironmentTemplate{custom}
{%\item[\GetExerciseProperty{counter}]
    \Needspace*{0\baselineskip}
    \noindent
    \circled{\XSIMmixedcase{\GetExerciseProperty{counter}}}~~~%
    \noindent
    \IfInsideSolutionF{%
        \GetExercisePropertyT{points}{ % notice the space
            (%
            \printgoal{\PropertyValue}
            \IfExerciseGoalSingularTF{points}
              {\XSIMtranslate{point}}
              {\XSIMtranslate{points}}%
            )%
        }
}}
{\vspace{\baselineskip}}


\xsimsetup{
    collect = false,
    exercise/within = section,
    exercise/template = custom,
    exercise/the-counter =  \arabic{exercise},
}

\begin{document}
\begin{exercise}[points=1.0]
    Example 1
\end{exercise}

%\begin{exercise}[points=1.001]
%    Example 1
%\end{exercise}

\begin{exercise}[points=2.0]
    Example 2
\end{exercise}

\begin{exercise}[points=1.5]
    Example 3
\end{exercise}
\end{document}

@fabinholima
Copy link
Author

Perfect thanks very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants