시험 문서 수업에서 객관식 문제의 솔루션을 사용자 정의하는 방법은 무엇입니까?

시험 문서 수업에서 객관식 문제의 솔루션을 사용자 정의하는 방법은 무엇입니까?

내 문서가 이 이미지처럼 표시되기를 원합니다.

\documentclass[cancelspace,10pt]{exam}
\usepackage{multicol}
%**********************************************************  End of Listing Setting
\usepackage[explicit]{titlesec}
\usepackage[dotinlabels]{titletoc}
\usepackage{pifont}
\usepackage{times,color}
\usepackage{tikz}
\usepackage{circuitikz}
\usepackage{enumerate}

\usepackage{xepersian}
% *********************************************************** Document Font
\settextfont[Scale=1.2]{B Nazanin}
%*******************************************
\renewcommand*\questionlabel{\color{blue}\thequestion-}
\renewcommand*\thechoice{\arabic{choice}} 
\renewcommand*\choicelabel{\thechoice)}
%*******************************answer
\renewcommand{\solutiontitle}{\noindent\textbf{solution:}\par\noindent}
\shadedsolutions
\definecolor{SolutionColor}{rgb}{0.8,0.9,1}
\printanswers
% *********************************************************** begin Doc
%\DefaultMathsDigits
\begin{document}
% ----------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%end-title
\begin{persian}
\begin{questions}
% *********************************************************** Start Doc

\begin{latin}
%#############################################################################
% *********************************************************** Start     QUESTION #1
\question
She's not very .............. in the way she treats her children;they may be punished today for somthing they were rewarded for yesterday!
% *********************************************************** Choices
\begin{multicols}{4}
\begin{choices}
        %****************************************************************************     Choice 1
    \choice
    a
    %****************************************************************************     Choice 2
    \choice
           b
    %****************************************************************************     Choice 3
    \choice
    c
    %****************************************************************************     Choice 4
    \choice
    d
\end{choices}
\end{multicols}
  \begin{solutionorbox}[2in]

a

\end{solutionorbox}
% *********************************************************** End QUESTION #1


\end{latin}
\end{questions}
\end{persian}
\end{document}

답변1

이 코드를 사용하여 코드를 수정할 수 있다고 생각합니다.

\documentclass{exam}

\usepackage{xcolor}
\usepackage{ifthen}

\shadedsolutions
\definecolor{SolutionColor}{rgb}{0.8,0.9,1}
\printanswers

\newcommand{\answer}{unknown}

\newcommand{\correct}[1]
{
    \ifthenelse{\equal{#1}{a}}{\renewcommand{\answer}{The first }}{}
    \ifthenelse{\equal{#1}{b}}{\renewcommand{\answer}{The second }}{}
    \ifthenelse{\equal{#1}{c}}{\renewcommand{\answer}{The third }}{}
    \ifthenelse{\equal{#1}{d}}{\renewcommand{\answer}{The fourth }}{}

    \renewcommand{\solutiontitle}{\noindent \textbf{Solution:} \answer option is correct.\par\noindent}

    \begin{solutionorbox}[2in]
        #1 
    \end{solutionorbox}
}

\begin{document}

\correct{a}

\correct{b}

\correct{c}

\correct{d}

\end{document}

표시됩니다

여기에 이미지 설명을 입력하세요

편집하다

편집된 명령에서는 숫자 형식으로 MUST 형식 \correct을 입력해야 합니다 . 귀하의 예에서 옵션은 , , 또는 입니다 .\correct{option}{the answer}option1234

\documentclass{exam}

\usepackage{xcolor}
\usepackage{ifthen}

\usepackage{fmtcount}

\shadedsolutions
\definecolor{SolutionColor}{rgb}{0.8,0.9,1}
\printanswers

\newcommand{\correct}[2]
{ 
    \renewcommand{\solutiontitle}{\noindent \textbf{Solution:} The \textcolor{red}{\ordinalstringnum{#1}} option is correct.\par\noindent}

    \begin{solutionorbox}[2in]
        \textcolor{red}{#2}
    \end{solutionorbox}
}

\begin{document}

\correct{1}{c}

\correct{2}{d}

\correct{1}{You should choose this as your answer}

\correct{2}{I think this is the right answer}

\end{document}

여기에 이미지 설명을 입력하세요

두 번째 편집:

\newcommand{\correct}[2]위의 코드를 이 코드로 바꾸세요 .

\newcommand{\answer}{unknown}

\newcommand{\correct}[2]
{    

   \ifthenelse{\equal{#1}{1}}{\renewcommand{\answer}{pertama }}{}
   \ifthenelse{\equal{#1}{2}}{\renewcommand{\answer}{kedua }}{}
   \ifthenelse{\equal{#1}{3}}{\renewcommand{\answer}{ketiga }}{}
   \ifthenelse{\equal{#1}{4}}{\renewcommand{\answer}{keempat }}{}


   \renewcommand{\solutiontitle}{\noindent \textbf{Solution:} The \answer option is correct.\par\noindent}

   \begin{solutionorbox}[2in]
       #2
   \end{solutionorbox}
}

페르시아어를 사용해야 하는 경우 pertama, kedua, ketigakeempat를 원하는 언어로 바꾸세요.

답변2

가능한 해결책이 하나 있습니다. \CorrectSolution선택적 인수로 전달될 선택적 인수를 사용하여 명령을 정의했습니다 solutionorbox.

\CorrectSolution[2in]

정답을 선택하기 위해 환경 \coreectoption내에서 사용되는 명령은 다음 과 같습니다 .choices

\begin{choices}
    \correctoption{a}
    \choice b
    \choice c
    \choice d
\end{choices}

그런 다음 \CorrectSolution자동으로 정답의 값을 가져와 패키지의 도움을 받아 연관된 순서 문자열로 변환합니다 fmtcount.

코드:

\documentclass[cancelspace,10pt]{exam}
\usepackage{multicol}
\usepackage{fmtcount}
\usepackage{color}

\renewcommand*\questionlabel{\color{blue}\thequestion-}
\renewcommand*\thechoice{\arabic{choice}} 
\renewcommand*\choicelabel{\thechoice)}

%*******************************answer
\renewcommand{\solutiontitle}{\noindent\textbf{solution:}\par\noindent}
\shadedsolutions
\definecolor{SolutionColor}{rgb}{0.8,0.9,1}

\newcounter{tmp}
\newcommand\correctoption[1]{\gdef\Correctoption{#1}\choice#1\setcounter{tmp}{\value{choice}}}
\newcommand\CorrectSolution[1][-1t]{%
  \begin{solutionorbox}[#1]
    The  \ordinalstring{tmp} option is correct.\par\Correctoption  
  \end{solutionorbox}%
}

\printanswers

\begin{document}

\begin{questions}
\question
She's not very .............. in the way she treats her children;they may be punished today for somthing they were rewarded for yesterday!
\begin{multicols}{4}
\begin{choices}
    \correctoption{a}
    \choice b
    \choice c
    \choice d
\end{choices}
\end{multicols}
\CorrectSolution[2in]

\question
What is the answer to the ultimate question of life, the universe, and everything?\begin{multicols}{4}
\begin{choices}
    \choice 15
    \choice 23
    \choice $\pi$
    \correctoption{42}
    \choice 31
\end{choices}
\end{multicols}
\CorrectSolution[2in]

\end{questions}

\end{document}

여기에 이미지 설명을 입력하세요

내 시스템에는 해당 글꼴이 없기 때문에 B Nazanin해당 줄을 주석 처리했습니다. 답변과 관련이 없는 패키지와 설정도 제거했습니다.

관련 정보