There are list of exam questions (as example 1-20). This list is divided on two parts (1-10, 11-20). Examination ticket contain two questions, first from first part and second from second part. This questions have to choose randomly without repetitions. Question random choose without repetition is solved before with \pgfmathdeclarerandomlist
command.
But before examination tickets will generated questions list have to displayed in sequential order. So list were defined as:
\listadd{\mIqlist}{}%
\forcsvlist{\listadd\mIqlist}{{This, is},{is},{a},{very},{long},{text},{split},{in},{many}}
\listadd{\mIIqlist}{}%
\forcsvlist{\listadd\mIIqlist}{{than},{thirty},{items},{in},{here,}{but},{he},{did},{not}}
And for random purpose:
%вопросы первого блока
\newcounter{firsttotal}
\newcounter{firstcurr}
\setcounter{firsttotal}{9} %общее кол-во вопросов должно совпадать с кол-вом вопросов в списке
\newcommand\declarefirst{
\pgfmathdeclarerandomlist{firstlist}{\mIqlist}}
\declarefirst
%вопросы второго блока
\newcounter{secondtotal}
\newcounter{secondcurr}
\setcounter{secondtotal}{9} %общее кол-во вопросов должно совпадать с кол-вом вопросов в списке
\newcommand\declaresecond{
\pgfmathdeclarerandomlist{secondlist}{\mIIqlist}}
\declaresecond
%макрос \prunelist для удаления уже выбраных из списка вопросов для избежания повторений в первой итерации
\makeatletter
\def\prunelist#1{
\expandafter\edef\csname pgfmath@randomlist@#1\endcsname
{\the\numexpr\csname pgfmath@randomlist@#1\endcsname-1\relax}
\count@\pgfmath@randomtemp
\loop
\expandafter\let
\csname pgfmath@randomlist@#1@\the\count@\expandafter\endcsname
\csname pgfmath@randomlist@#1@\the\numexpr\count@+1\relax\endcsname
\ifnum\count@<\csname pgfmath@randomlist@#1\endcsname\relax
\advance\count@\@ne
\repeat}
\makeatother
%печатать вопрос из первого списка (выбирается случайным образом)
\newcommand\printfirst{
\pgfmathrandomitem{\z}{firstlist}
\z
\prunelist{firstlist}
\addtocounter{firstcurr}{1}
\ifnum \value{firstcurr} = \value{firsttotal} \setcounter{firstcurr}{0}\declarefirst \fi
}
%печатать вопрос из второго списка (выбирается случайным образом)
\newcommand\printsecond{
\pgfmathrandomitem{\z}{secondlist}
\z
\prunelist{secondlist}
\addtocounter{secondcurr}{1}
\ifnum \value{secondcurr} = \value{secondtotal} \setcounter{secondcurr}{0}\declaresecond \fi
}
In document sequential list displayed as:
\begin{enumerate}[label={\arabic*.}]
\renewcommand*{\do}[1]{\item {#1}}
\dolistloop{\mIqlist}
\dolistloop{\mIIqlist}
\end{enumerate}
And in exam ticket:
\forloop{ct}{0}{\value{ct} < \value{TotalNum}}
{
....
1.\printfirst \newline\newline
2.\printsecond \newline
....
}
But while compile error occurs:
! Missing $ inserted.
<inserted text>
$
l.101 }
%forloop
This error occure while I try \printfirst
or \printsecond
.
As I understand this error is associated with list separator |
symbol.
How can I fix it?
expl3