
네덜란드 교사로서 나의 성적 척도는 1,0에서 10,0까지입니다. 등급 계산은 세 가지 변수, 즉 N-항; 학생의 점수; 시험의 총 점수입니다.
내 시험에서 각 테이블에 채점 척도의 특정 부분([1,0;3,2] 및 [3,3;5,4])이 포함된 4개의 분리된 테이블로 구성된 채점 테이블을 자동으로 생성하고 싶습니다. 및 [5,5;7,7] 및 [7,8;10,0].
N-term=1,0이고 총 점수(0점 포함)가 4로 나누어지면 길이가 같은 4개의 테이블이 생성됩니다. 다른 많은 경우에는 그렇지 않습니다. 아래 예를 참조하세요.
다음은 N항이 0,0이고 총 개수가 47개인 경우의 예입니다.
지금까지 대부분의 트릭을 수행하는 코드가 있습니다. 그러나 문제는 각 분리된 테이블의 길이가 코드에서 수동으로 결정된다는 것입니다. 이 작업도 자동으로 진행되었으면 좋겠습니다.
이전 동급생이 코드를 작성했습니다. 대부분의 경우 어떻게 작동하는지 잘 모르겠습니다.
테이블 만들기는 foreach 루프를 사용하여 작동합니다. 사용되는 것은 \i
후보자의 점수를 의미하며, 테이블의 끝은 특정 점수에 해당하는 등급에 따라 달라집니다.
어쩌면 \foreach \i in {0,...,\GetNumPoints} \while 1,0 =< \NormFormule =< 3.2
그와 비슷한 것이 더 잘 작동할 수도 있습니다. 그러나 나는 그것이 어떻게 이루어질 수 있는지 전혀 모릅니다.
어떤 제안이 있으십니까?
\documentclass[addpoints]{exam}
\usepackage{tikz}
%-----------------------------------------
% The Nterm determines which grade correspends to which grade; this is normally a number between 0,0 and 2,0
%-----------------------------------------
\newcommand{\Nterm}{1.0}
%-----------------------------------------
% This is some prework that needs to be done
%-----------------------------------------
\makeatletter
\providecommand{\exam@numpoints}{1}%
\newcommand{\GetNumPoints}{\exam@numpoints}%
\newcommand*{\@MyTempTableTokens}{}%
\newtoks\@tabtoks
%%% assignments to \@tabtoks must be global, because they are done in \foreach
\newcommand\AddTableTokens[1]{\global\@tabtoks\expandafter{\the\@tabtoks#1}}
\newcommand\eAddTableTokens[1]{%
\protected@edef\@MyTempTableTokens{#1}%
\expandafter\AddTableTokens\expandafter{\@MyTempTableTokens}}
%%% variable should always be operated on either always locally or always globally
\newcommand*\ResetTableTokens{\global\@tabtoks{}}
\newcommand*\PrintTableTokens{\the\@tabtoks}
\makeatother
\newcommand*{\NormFormule}[1]{%
\pgfmathparse{
\ifdim \Nterm pt < 1 pt
max(
9 * ( #1 / \GetNumPoints ) + \Nterm ,
1 + ( #1 * ( 9 / \GetNumPoints ) * 0.5 ),
10 - ( \GetNumPoints - #1 ) * ( 9 / \GetNumPoints ) * 2
)
\else
min(
9 * ( #1 / \GetNumPoints ) + \Nterm ,
1 + ( #1 * ( 9 / \GetNumPoints ) * 2 ),
10 - ( \GetNumPoints - #1 ) * ( 9 / \GetNumPoints ) * 0.5
)
\fi
}
\pgfmathprintnumber[fixed, precision=1, fixed zerofill, use comma]{\pgfmathresult}}
%-----------------------------------------
% This is the command for making the table; which works fine. Except for needing to manually define the length of the specific tables
%-----------------------------------------
\newcommand{\maketable}{\bigskip
\Huge Grading Table\bigskip\\\normalsize
\ResetTableTokens
\foreach \i in {0,...,14} %THIS IS WHERE I GOT STUCK!
{\eAddTableTokens{\i & \noexpand\NormFormule{\i} \\}}{}
\begin{minipage}[t]{.23\textwidth}\centering$(1{,}0-3{,}2)$\\
\begin{tabular}{|c|c|}
\hline
\textbf{score}&\textbf{grade}\\\hline\centering
\PrintTableTokens
\hline
\end{tabular}
\end{minipage}
\ResetTableTokens
\foreach \i in {15,...,29} {\eAddTableTokens{\i & \noexpand\NormFormule{\i} \\}}
\begin{minipage}[t]{.23\textwidth}\centering$(3{,}3-5{,}4)$\\
\begin{tabular}{|c|c|}
\hline
\textbf{score}&\textbf{grade}\\\hline\centering
\PrintTableTokens
\hline
\end{tabular}
\end{minipage}
\ResetTableTokens
\foreach \i in {30,...,44} {\eAddTableTokens{\i & \noexpand\NormFormule{\i} \\}}
\begin{minipage}[t]{.23\textwidth}\centering$(5{,}5-7{,}7)$\\
\begin{tabular}{|c|c|}
\hline
\textbf{score}&\textbf{grade}\\\hline\centering
\PrintTableTokens
\hline
\end{tabular}
\end{minipage}
\ResetTableTokens
\foreach \i in {45,...,\GetNumPoints} {\eAddTableTokens{\i & \noexpand\NormFormule{\i} \\}}
\begin{minipage}[t]{.23\textwidth}\centering$(7{,}8-10{,}0)$\\
\begin{tabular}{|c|c|}
\hline
\textbf{score}&\textbf{grade}\\\hline\centering
\PrintTableTokens
\hline
\end{tabular}
\end{minipage}
}
%-----------------------------------------
% And here the actual exam begins
%-----------------------------------------
\begin{document}
\begin{questions}
\question[60]
The content of this question is irrelevant.
\end{questions}
\maketable
\end{document}
답변1
장기적으로 유지 관리가 더 쉽다고 생각하기 때문에 expl3 구문을 사용하여 전체 코드를 다시 작성했습니다. 또한 이렇게 해서 상황이 좀 더 쉬워졌습니다. siunitx
패키지를 사용하여 숫자 형식을 지정 했습니다 .
내 생각에 이 코드는 여러분이 원하는 것입니다. 필요한 등급 척도를 사용하여 4개의 열을 출력합니다. 열의 길이는 얻을 수 있는 포인트 수에 따라 다릅니다.
\documentclass[addpoints]{exam}
% use siunitx to format numbers
\usepackage{siunitx}
\sisetup{
round-mode = places,
round-precision = 1,
output-decimal-marker = {,}
}
\ExplSyntaxOn
% variable that stores the amount of exam points
\fp_new:N \g_kenadams_exampoints_exampoints_fp
\fp_gset:Nn \g_kenadams_exampoints_exampoints_fp { 1.0 }
% variable that stores the nterm
\fp_new:N \g_kenadams_exampoints_nterm_fp
\fp_gset:Nn \g_kenadams_exampoints_nterm_fp { 1.0 }
% command to change the nterm
\NewDocumentCommand{\SetPointsNterm}{ m }{
\fp_gset:Nn \g_kenadams_exampoints_nterm_fp { #1 }
}
\makeatletter
% internal command to retrieve the current amount of exam points
% set by the exam class
\cs_new:Npn \kenadams_exampoints_update: {
\cs_if_exist:cT { exam@numpoints } {
\fp_gset:Nn \g_kenadams_exampoints_exampoints_fp { \exam@numpoints }
}
}
\makeatother
% internal command to calculate a score from a given point value
% the logic is taken over from the original code
\cs_new:Npn \kenadams_exampoints_calculatescore:n #1 {
\fp_eval:n {
round( \g_kenadams_exampoints_nterm_fp < 1 ?
max(
9 * ( #1 / \g_kenadams_exampoints_exampoints_fp ) + \g_kenadams_exampoints_nterm_fp ,
1 + ( #1 * ( 9 / \g_kenadams_exampoints_exampoints_fp ) * 0.5 ),
10 - ( \g_kenadams_exampoints_exampoints_fp - #1 ) * ( 9 / \g_kenadams_exampoints_exampoints_fp ) * 2
)
:
min(
9 * ( #1 / \g_kenadams_exampoints_exampoints_fp ) + \g_kenadams_exampoints_nterm_fp ,
1 + ( #1 * ( 9 / \g_kenadams_exampoints_exampoints_fp ) * 2 ),
10 - ( \g_kenadams_exampoints_exampoints_fp - #1 ) * ( 9 / \g_kenadams_exampoints_exampoints_fp ) * 0.5
)
, 1 , 1 )
}
}
% internal variable (counter) that stores the current table row
\int_new:N \g_kenadams_exampoints_tablerow_int
% internal command to create a part of the set of tables
\cs_new:Npn \kenadams_exampoints_tablepart:nnn #1 #2 {
% clearing temporary sequence variable
\seq_clear:N \l_tmpa_seq
% stepwise increase table row number as long as
% the calculated score from this value is less than #2
\fp_do_until:nNnn { \kenadams_exampoints_calculatescore:n { \g_kenadams_exampoints_tablerow_int } } > { #2 } {
% add formatted table row to sequence variable
\seq_put_right:Nx \l_tmpa_seq {
\int_use:N \g_kenadams_exampoints_tablerow_int &
\num { \kenadams_exampoints_calculatescore:n { \g_kenadams_exampoints_tablerow_int } }
}
\int_gincr:N \g_kenadams_exampoints_tablerow_int
}
\begin{minipage}[t]{.23\textwidth} \centering (\num{#1}--\num{#2}) \\
\begin{tabular}{ | c | c | }
\hline
\textbf{score} & \textbf{grade} \\ \hline
% insert the values stored in the sequence variable
% and add \\ after each item
\seq_use:Nn \l_tmpa_seq { \\ } \\
\hline
\end{tabular}
\end{minipage}
}
% command to print the grading table
\NewDocumentCommand{\MakePointsTable}{ }{
% retrieve current amount of exam points
\kenadams_exampoints_update:
% reset table row counter
\int_gzero:N \g_kenadams_exampoints_tablerow_int
\bigskip
\Huge Grading ~ Table
\bigskip \par
\normalsize
% typeset the four parts of the grading table
\kenadams_exampoints_tablepart:nnn { 1.0 } { 3.2 }
\kenadams_exampoints_tablepart:nnn { 3.3 } { 5.4 }
\kenadams_exampoints_tablepart:nnn { 5.5 } { 7.7 }
\kenadams_exampoints_tablepart:nnn { 7.8 } { 10.0 }
}
\ExplSyntaxOff
%-----------------------------------------
% The Nterm determines which grade correspends to which grade; this is normally a number between 0,0 and 2,0
%-----------------------------------------
\SetPointsNterm{1.0}
\begin{document}
\begin{questions}
\question[60]
The content of this question is irrelevant.
\end{questions}
\MakePointsTable
\end{document}
당신 은 \question[47]
얻을 것입니다 :
그리고 당신 \question[47]
은 \SetPointsNterm{0.0}
얻을 것입니다 :