Để có thể hoán đổi vị trí các phương án trắc nghiệm trong gói ex_test trực tiếp trên LaTeX, ta tiến hành chèn đoạn code bên dưới trước \begin{document}, sau đó thực thi chương trình.
%Sao chép toàn bộ mã bên dưới và dán trước \begin{document}
%Tạo mã random các phương án
\newcommand{\choiceEX}[5][0]{
\setlength\tabmaxwidth{\linewidth-0.02\dorongfix-\widthalpha-3\fboxsep}
\setlength\fourthtabwidth{0.25\linewidth-0.02\dorongfix-\widthalpha-3\fboxsep}
\setlength\halftabwidth{0.5\linewidth-0.02\dorongfix-\widthalpha-3\fboxsep}
\settowidth\widthcha{#2}
\ifdim\widthch<\widthcha\relax\setlength{\widthch}{\widthcha}\fi%
\settowidth\widthchb{#3}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
\settowidth\widthchc{#4}%
\ifdim\widthch<\widthchc\relax\setlength{\widthch}{\widthchc}\fi%
\settowidth\widthchd{#5}%
\ifdim\widthch<\widthchd\relax\setlength{\widthch}{\widthchd}\fi%
\ifthenelse{\equal{#1}{0}}
{
\ifdim\widthch<\fourthtabwidth
\boncot{#2}{#3}{#4}{#5}
\else\ifdim\widthch<\halftabwidth
\haicot{#2}{#3}{#4}{#5}
\else
\motcot{#2}{#3}{#4}{#5}
\fi\fi
}
{
\ifthenelse{\equal{#1}{1}}
{
\def\parskipchoice{0.2cm}
\motcot{#2}{#3}{#4}{#5}}
{
\ifthenelse{\equal{#1}{2}}
{
\def\parskipchoice{0.2cm}
\haicot{#2}{#3}{#4}{#5}}
{
\ifthenelse{\equal{#1}{4}}
{
\def\parskipchoice{0.2cm}
\boncot{#2}{#3}{#4}{#5}}
{
\def\parskipchoice{#1}
\ifdim\widthch<\fourthtabwidth
\boncot{#2}{#3}{#4}{#5}
\else\ifdim\widthch<\halftabwidth
\haicot{#2}{#3}{#4}{#5}
\else
\motcot{#2}{#3}{#4}{#5}
\fi\fi
}}}}
}
\def\choiceRandom{off}
\renewcommand{\choice}[5][\choiceRandom]{
\def\randomON{ON}
\ifx\randomON\choiceRandom
\pgfmathsetmacro{\dung}{int(random(2,25))}
\ifnum\dung=2\choiceEX{#2}{#3}{#4}{#5}\fi
\ifnum\dung=3\choiceEX{#2}{#3}{#5}{#4}\fi
\ifnum\dung=4\choiceEX{#2}{#4}{#3}{#5}\fi
\ifnum\dung=5\choiceEX{#2}{#4}{#5}{#3}\fi
\ifnum\dung=6\choiceEX{#2}{#5}{#3}{#4}\fi
\ifnum\dung=7\choiceEX{#2}{#5}{#4}{#3}\fi
\ifnum\dung=8\choiceEX{#3}{#2}{#4}{#5}\fi
\ifnum\dung=9\choiceEX{#3}{#2}{#5}{#4}\fi
\ifnum\dung=10\choiceEX{#3}{#4}{#2}{#5}\fi
\ifnum\dung=11\choiceEX{#3}{#4}{#5}{#2}\fi
\ifnum\dung=12\choiceEX{#3}{#5}{#2}{#4}\fi
\ifnum\dung=13\choiceEX{#3}{#5}{#4}{#2}\fi
\ifnum\dung=14\choiceEX{#4}{#2}{#3}{#5}\fi
\ifnum\dung=15\choiceEX{#4}{#2}{#5}{#3}\fi
\ifnum\dung=16\choiceEX{#4}{#3}{#2}{#5}\fi
\ifnum\dung=17\choiceEX{#4}{#3}{#5}{#2}\fi
\ifnum\dung=18\choiceEX{#4}{#5}{#2}{#3}\fi
\ifnum\dung=19\choiceEX{#4}{#5}{#3}{#2}\fi
\ifnum\dung=20\choiceEX{#5}{#2}{#3}{#4}\fi
\ifnum\dung=21\choiceEX{#5}{#2}{#4}{#3}\fi
\ifnum\dung=22\choiceEX{#5}{#3}{#2}{#4}\fi
\ifnum\dung=23\choiceEX{#5}{#3}{#4}{#2}\fi
\ifnum\dung=24\choiceEX{#5}{#4}{#2}{#3}\fi
\ifnum\dung=25\choiceEX{#5}{#4}{#3}{#2}\fi
\else
\choiceEX{#2}{#3}{#4}{#5}
\fi
}
%Kết thúc mã random các phương án
\def\choiceRandom{ON}%Tắt tùy chọn này nếu không muốn random
0 Nhận xét