EDIT: The original question was unclear, not well-posed, posted too early and too much verbose. After having some rest and digging more in deep the issue, I am now able to answer by myself to almost the underlying points.
The general presentation and expectations are remained unchanged and the adopted solution is explained for people who would want to solve a similar issue. The question now deals only on how to "reset" the quiz when one has already activate the "Verify" button.
The aim is to display interactive multiple choice questions or quiz (MCQ) within a PDF handbook. The used tools are: hyperref
, ocgx2
, tikz
and tcolorbox
packages from TeXLive on Linux with Evince/Atril PDF viewer (Okular does not support OCGs). The result is obtained with the LuaLaTeX engine (pdfLaTeX should work).
The goal is here to display the quiz as in the first link below (whithout database at a first step: the quiz and its solution will be further recorded with the help of the tcolorbox
package functionalities), but also to be able to mimic the layout of a MOOC platform (e.g. a French one: Fun MOOC). That is to say, on one hand, displaying the quiz with its proposals (rather straightforward with ocgx2
) and, on the other hand, delegating the display of the solution to some clickable buttons to check, to reset, and to give explanations about the responses (and to save the score in a further work).
This general behaviour is wanted both for single and multiple solution MCQs.
A first approach for single solution MCQ with OCGs is given by:
(1) Multiple choice questions linked to solutions using Optional Content Groups (OCG)
Other useful links for starting with OCGs are AlexG's answers to the following questions:
(2) Clickable checkmarks in pdf with ocgs
(3) OCGX and hyperref: visibility and clickability of overlapping links
The key point is also to consider the AG's answer to this question:
(4) Creating a lot of checkbox'es to make visible/invisible arrows using tikzpicture
environment
Borrowing the code from the fourth above link, it is quite straightforward to add an efficient "Reset" button, both to single and multiple solution MCQs. By the way, with no effort, one can also propose a "Select all" button for the multiple solution quiz.
To display the selected results (correct or not) after clicking the "Verify" button is also possible. It is done in a direct way for single solution MCQ, thanks to AG's answer in the fourth link above. As far as the multiple solution MCQ is concerned, the proposed solution is not elegant nor clever (there is still some misunderstood things): our skills are limited and certainly someone could improve this solution. Nevertheless, it works.
So the only remainded issue is the ability to "reset" the quiz automatically when one has already click on the "Verify" button, but when one wants to test other proposals. In such a case, the results are displayed without to have to click again the "Verify" button. (May be I'am still not clear... Test the MWE).
MWE EDIT 3 − 2019-05-23: Taking into account the comments
\documentclass{article}
\usepackage{xparse}
\usepackage{etoolbox}
\usepackage{xcolor}
\usepackage{fontawesome}
\usepackage{tikz}
\usepackage{calc}
\usepackage{tcolorbox}
\usepackage{hyperref}
\usepackage[tikz]{ocgx2}
\tcbuselibrary{%
skins,
breakable,
xparse,
}
\hypersetup{%
pdfborder=0 0 0,% no border to links
colorlinks=true,%
linkcolor=gray,
}
\definecolor{buttongray}{RGB}{200, 200, 200}
\tikzset{%
quizbutton/.style={
shape=rectangle, rounded corners=1pt,
text=black, draw=#1!90,
top color=#1!15!white, bottom color=#1!75,
inner xsep=6pt, inner ysep=2pt,
},
}
\tcbset{
quizquestionstyle/.style={
breakable, enhanced jigsaw,
colframe=black!75,
colback=black!2!white,
coltitle=red!75!black,
fonttitle={\normalfont\strut},
boxrule=0.4pt, boxsep=0pt, arc=0.8pt,
left=6pt, right=6pt,
attach title to upper={\par\vspace{6pt}},
before skip=4pt, after skip=6pt,
},
}
\newcounter{quizquestion}
\newcounter{mcqproposal}% Multiple choice counter within a quiz question
\newcounter{mcqquiztotal}[quizquestion]% Total proposition counter within a quiz question
\newcounter{mcqsolutiontotal}[quizquestion]% Total number of (multiple) solutions within a quiz question
\newlength{\checkboxwidth}
\newlength{\checkgap}
\setlength{\checkgap}{0.5em}
\newlength{\symbolwidth}
\setlength{\symbolwidth}{10pt}
% \faCheck width = 10.O pt; \faTimes width = 7.85pt => same width in a box
\newcommand{\checktick}{%
\makebox[\symbolwidth][c]{%
\textcolor{green!60!black}{\normalfont\normalsize\faCheck}%
}%
}
\newcommand{\crosstick}{%
\makebox[\symbolwidth][c]{%
\textcolor{red!60!black}{\normalfont\normalsize\faTimes}%
}%
}
%-- Only one answer to multiple choice question (stared environment)
%- Defining a single solution MCQ environment
\NewTColorBox[use counter=quizquestion]{quizquestion*}{o g}{%
% Syntax − #1 = more tcbox options, #2 = optional title
quizquestionstyle,
label={quizquestion:\thetcbcounter},
lowerbox=ignored,
IfValueTF={#2}%
{title=\textbf{Quiz~\thetcbcounter\enspace---\enspace#2}}%
{before upper=\textcolor{tcbcol@title}{\textbf{Quiz~\thetcbcounter}}\vspace*{2pt}},
IfValueTF={#1}{#1}{},% More options
}
%- Traditional presentation of checked radio buttons
%- For inspiration and example, see the answers of Heiko Oberdiek to:
%- https://tex.stackexchange.com/questions/236041/how-to-typeset-a-radio-button
%- Here, we just adapt our needs to the 'Fontawesome' icons
\newlength{\radius}
\settowidth{\radius}{\normalfont\normalsize\faCircleThin}
\addtolength{\radius}{-2.0pt}
%- Empty radio button
\newcommand{\freeRadioButton}{%
\raisebox{-4pt}{%
\begin{tikzpicture}
\fill[color=white, radius=0.6\radius] circle;
\node[color=gray] {\normalfont\normalsize\faCircleThin};
\end{tikzpicture}%
}%
}
%- Checked radio button
\newcommand{\checkedRadioButton}{%
\raisebox{-4pt}{%
\begin{tikzpicture}
\fill[color=green!60!black, radius=0.6\radius] circle;
\node[color=gray] {\normalfont\normalsize\faCircleThin};
\fill[color=white, radius=1.4pt] circle;
\end{tikzpicture}%
}%
}
%- Defining a radio buttons command for layer switching
\NewDocumentCommand{\layerRadioButton}{m m m m}{% From Alexander Grann's answers on TeX.SE
% Syntax − #1: radiobutton group name, #2: layer name, #3: layer id, #4: initial visibility
\switchocg{#3}{\freeRadioButton}%
\settowidth{\checkboxwidth}{\freeRadioButton}%
\begin{ocg}[radiobtngrp=#1]{#2}{#3}{#4}%
\hspace*{-\checkboxwidth}%
\textcolor{green!60!black}{\checkedRadioButton}%
\end{ocg}%
}
%- Defining a proposition for single solution MCQ
\NewDocumentCommand{\mcqproposalSingle}{o m}{%
% Syntax − #1 = more tcbox options, #2 = answering proposal
\begin{tcolorbox}[%
breakable, enhanced,
notitle, colframe=black!60, colback=white,
boxrule=0.2pt, arc=0.4pt, boxsep = 0pt,
left = 4pt, right = 4pt,
top = 4pt, bottom = 4pt,
before skip=4pt, after skip=4pt,
IfValueTF={#1}{#1}{},% More options
]
\stepcounter{mcqproposal}%
\stepcounter{mcqquiztotal}%
\parbox[t]{16pt}{%
%\hspace*{2pt}%
\layerRadioButton{Choice:\thequizquestion}%
{mcqproposalsingle:\themcqproposal}{mcqproposalsingleref:\themcqproposal}{off}%
}%
\parbox[t]{\linewidth-16pt}{#2}%
\end{tcolorbox}%
}
%- Defining the verification command/button for single solution MCQ
\NewDocumentCommand{\verifySingle}{m}{%
% Syntax − #1 = the solely correct answer
\noindent%
\switchocg{checkchoiceref:\thequizquestion}{%
\begin{tikzpicture}
\node[quizbutton=buttongray] (checksolutionbutton)
{\strut\footnotesize\textbf{Verify}};%
\end{tikzpicture}%
}%
\begin{ocg}{CheckChoice:\thequizquestion}{checkchoiceref:\thequizquestion}{off}
\hspace*{\checkgap}% Horizontal space between the button and the checkmark
\foreach \X in {1,...,\value{mcqquiztotal}} {%
\ifnum\X=#1
\begin{ocg}[radiobtngrp=Choices:\thequizquestion]{mcqproposalsingle:\X}{mcqproposalsingleref:\X}{off}%
\ifnum\numexpr\X=1\relax%
\else
\hspace*{-\symbolwidth}%
\fi
\raisebox{5pt}{\checktick}%
\end{ocg}%
\else
\begin{ocg}[radiobtngrp=Choices:\thequizquestion]{mcqproposalsingle:\X}{mcqproposalsingleref:\X}{off}%
\ifnum\numexpr\X=1\relax%
\else
\hspace*{-\symbolwidth}%
\fi
\raisebox{5pt}{\crosstick}%
\end{ocg}%
\fi
}%
\end{ocg}%
}
%- Resetting a single solution MCQ
\NewDocumentCommand{\resetSingle}{}{%
\def\ocglist{}%
\foreach \X in {1,...,\value{mcqquiztotal}} {\xdef\ocglist{\ocglist\space mcqproposalsingleref:\X}}%
\hideocg{\ocglist}{%
\begin{tikzpicture}
\node[quizbutton=buttongray] (resetbutton)
{\strut\footnotesize\textbf{Reset}};
\end{tikzpicture}%
}%
}
%- Applying the different commands for a MCQ with a single solution
\AtBeginEnvironment{quizquestion*}{%
\setcounter{mcqproposal}{0}%
\let\mcqproposal\mcqproposalSingle%
\let\verifyMCQ\verifySingle%
\let\resetMCQ\resetSingle%
}
%-- Several answers to multiple choices question (normal i.e. not stared environment)
%- Defining a multiple solution MCQ environment
\NewTColorBox[use counter=quizquestion]{quizquestion}{o g}{%
% Syntax − #1 = more options, #2 = optional title
quizquestionstyle,
label={quizquestion:\thetcbcounter},
lowerbox=ignored,
IfValueTF={#2}%
{title=\textbf{Quiz~\thetcbcounter\enspace---\enspace#2}}%
{before upper=\textcolor{tcbcol@title}{\textbf{Quiz~\thetcbcounter}}\vspace*{2pt}},
IfValueTF={#1}{#1}{},% More options
}
%- Empty check button
\newcommand{\freeButton}{%
\raisebox{-4pt}{%
\begin{tikzpicture}
\node[color=gray] {\normalfont\normalsize\faSquareO};
\end{tikzpicture}%
}%
}
%- Checked button
\newcommand{\checkedButton}{%
\raisebox{-4pt}{%
\begin{tikzpicture}
\node[color=gray] {%
%\normalfont\normalsize\faSquareO%
\hspace*{-\checkboxwidth}\textcolor{green!60!black}{\faCheck}};
\end{tikzpicture}%
}%
}
%- Check box command for layer switching
\NewDocumentCommand{\layerCheckBox}{m m m}{% From Alexander Grann's answers on TeX.SE
% Syntax − #1: layer name, #2: layer id, #3: initial visibility
\switchocg{#2}{\freeButton}%
\settowidth{\checkboxwidth}{\freeButton}%
\begin{ocg}{#1}{#2}{#3}
\checkedButton%
\end{ocg}%
}
\NewDocumentCommand{\layerCheckBoxMultiple}{m m m}{% From Alexander Grann's answers on TeX.SE:
% https://tex.stackexchange.com/questions/481812/
% Syntax − #1: switch id,
% #2: layer ids to be toggled (space separated if multiple ids),
% #3: initial visibility
\switchocg{#1 #2}{\faSquareO}%
\settowidth{\checkboxwidth}{\normalfont\normalsize\faSquareO}%
\begin{ocg}{\ifx\nil#1\nil#2\else#1\fi}{\ifx\nil#1\nil#2\else#1\fi}{#3}
\hspace*{-\checkboxwidth}\textcolor{green!60!black}{\faCheck}%
\end{ocg}%
}
%- Defining a proposition for multiple solution MCQ
\NewDocumentCommand{\mcqproposalMultiple}{o m}{%
% Syntax − #1 = more tcbox options, #2 = answering proposal
\begin{tcolorbox}[%
breakable, enhanced,
notitle, colframe=black!60, colback=white,
boxrule=0.2pt, arc=0.4pt, boxsep = 0pt,
left = 4pt, right = 4pt,
top = 4pt, bottom = 4pt,
before skip=4pt, after skip=4pt,
IfValueTF={#1}{#1}{},% More options
]
\stepcounter{mcqproposal}%
\stepcounter{mcqquiztotal}%
\parbox[t]{16pt}{%
\hspace*{2pt}%
%- Old
\layerCheckBox{mcqproposalmultiple:\themcqproposal}{mcqproposalmultipleref:\themcqproposal}{off}%
%- New
%\layerCheckBoxMultiple{}{mcqproposalmultipleref:\themcqproposal}{off}%
}%
\parbox[t]{\linewidth-16pt}{#2}%
\end{tcolorbox}%
\newtoggle{Question\thequizquestion:\themcqproposal}%
}
%- Defining the verification command/button for multiple solution MCQ (awful syntax)
\NewDocumentCommand{\verifyMultiple}{m m g g g}{% Up to five correct answers: obvious minimum = 2
% Syntax − The different integers arguments are referenced to the different proposals
\newbool{Question\thequizquestion:#1}\boolfalse{Question\thequizquestion:#1}%
\newbool{Question\thequizquestion:#2}\boolfalse{Question\thequizquestion:#2}%
\IfValueT{#3}{%
\newbool{Question\thequizquestion:#3}%
\boolfalse{Question\thequizquestion:#3}%
}%
\IfValueT{#4}{%
\newbool{Question\thequizquestion:#4}%
\boolfalse{Question\thequizquestion:#4}%
}%
\IfValueT{#5}{%
\newbool{Question\thequizquestion:#5}%
\boolfalse{Question\thequizquestion:#5}%
}%
\noindent%
\switchocg{checkchoicemultipleref:\thequizquestion}{%
\begin{tikzpicture}
\node[quizbutton=buttongray]
(checksolutionmultiplebutton) {\strut\footnotesize\textbf{Verify}};
\end{tikzpicture}%
}
\begin{ocg}{CheckChoiceMultiple:\thequizquestion}{checkchoicemultipleref:\thequizquestion}{off}
\hspace{6.5pt}% <-- Empirical value to adjust the checkmark position like for the single solution! WHY?!!?
\hspace*{\checkgap}% Horizontal space between the button and the checkmark
\IfValueTF{#3}{%
\IfValueTF{#4}{%
\IfValueTF{#5}{%
\switchocg{mcqproposalmultipleref:#1 mcqproposalmultipleref:#2 %
mcqproposalmultipleref:#3 mcqproposalmultipleref:#4 mcqproposalmultipleref:#5}{}%
\begin{ocg}{mcqproposalmultiple:#1}{mcqproposalmultipleref:#1}{off}%
\begin{ocg}{mcqproposalmultiple:#2}{mcqproposalmultipleref:#2}{off}%
\begin{ocg}{mcqproposalmultiple:#3}{mcqproposalmultipleref:#3}{off}%
\begin{ocg}{mcqproposalmultiple:#4}{mcqproposalmultipleref:#4}{off}%
\begin{ocg}{mcqproposalmultiple:#5}{mcqproposalmultipleref:#5}{off}%
\raisebox{5pt}{\checktick}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
}{% If value #5 False
\foreach \X in {1,...,\value{mcqquiztotal}} {%
\foreach \Y in {1,...,\X} {%
\foreach \Z in {1,...,\Y} {%
\foreach \U in {1,...,\Z} {%
\ifbool{Question\thequizquestion:#1}{}{%
\ifbool{Question\thequizquestion:#2}{}{%
\ifbool{Question\thequizquestion:#3}{}{%
\ifbool{Question\thequizquestion:#4}{}{%
\ifnum\U=\Z
\relax%
\else
\ifnum\Z=\Y
\relax%
\else
\ifnum\Y=\X
\relax
\else
\hspace*{-\symbolwidth}%
%\X{:}\Y{:}\Z{:}\U{}\space%
\ifnum\U=#1
\ifnum\Z=#2
\ifnum\Y=#3
\ifnum\X=#4
\switchocg{mcqproposalmultipleref:\X mcqproposalmultipleref:\Y %
mcqproposalmultipleref:\Z mcqproposalmultipleref:\U}{}%
\begin{ocg}{mcqproposalmultiple:\X}{mcqproposalmultipleref:\X}{off}%
\begin{ocg}{mcqproposalmultiple:\Y}{mcqproposalmultipleref:\Y}{off}%
\begin{ocg}{mcqproposalmultiple:\Z}{mcqproposalmultipleref:\Z}{off}%
\begin{ocg}{mcqproposalmultiple:\U}{mcqproposalmultipleref:\U}{off}%
\raisebox{5pt}{\checktick}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\else
\switchocg{mcqproposalmultipleref:\X mcqproposalmultipleref:\Y %
mcqproposalmultipleref:\Z mcqproposalmultipleref:\U}{}%
\begin{ocg}{mcqproposalmultiple:\X}{mcqproposalmultipleref:\X}{off}%
\begin{ocg}{mcqproposalmultiple:\Y}{mcqproposalmultipleref:\Y}{off}%
\begin{ocg}{mcqproposalmultiple:\Z}{mcqproposalmultipleref:\Z}{off}%
\begin{ocg}{mcqproposalmultiple:\U}{mcqproposalmultipleref:\U}{off}%
\raisebox{5pt}{\crosstick}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\fi
\else
\switchocg{mcqproposalmultipleref:\X mcqproposalmultipleref:\Y %
mcqproposalmultipleref:\Z mcqproposalmultipleref:\U}{}%
\begin{ocg}{mcqproposalmultiple:\X}{mcqproposalmultipleref:\X}{off}%
\begin{ocg}{mcqproposalmultiple:\Y}{mcqproposalmultipleref:\Y}{off}%
\begin{ocg}{mcqproposalmultiple:\Z}{mcqproposalmultipleref:\Z}{off}%
\begin{ocg}{mcqproposalmultiple:\U}{mcqproposalmultipleref:\U}{off}%
\raisebox{5pt}{\crosstick}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\fi
\else
\switchocg{mcqproposalmultipleref:\X mcqproposalmultipleref:\Y %
mcqproposalmultipleref:\Z mcqproposalmultipleref:\U}{}%
\begin{ocg}{mcqproposalmultiple:\X}{mcqproposalmultipleref:\X}{off}%
\begin{ocg}{mcqproposalmultiple:\Y}{mcqproposalmultipleref:\Y}{off}%
\begin{ocg}{mcqproposalmultiple:\Z}{mcqproposalmultipleref:\Z}{off}%
\begin{ocg}{mcqproposalmultiple:\U}{mcqproposalmultipleref:\U}{off}%
\raisebox{5pt}{\crosstick}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\fi
\else
\switchocg{mcqproposalmultipleref:\X mcqproposalmultipleref:\Y %
mcqproposalmultipleref:\Z mcqproposalmultipleref:\U}{}%
\begin{ocg}{mcqproposalmultiple:\X}{mcqproposalmultipleref:\X}{off}%
\begin{ocg}{mcqproposalmultiple:\Y}{mcqproposalmultipleref:\Y}{off}%
\begin{ocg}{mcqproposalmultiple:\Z}{mcqproposalmultipleref:\Z}{off}%
\begin{ocg}{mcqproposalmultiple:\U}{mcqproposalmultipleref:\U}{off}%
\raisebox{5pt}{\crosstick}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\fi
\fi
\fi
\fi
}%
}%
}%
}%
}%
}%
}%
}%
}% End if value #5
}{% If value #4 false
\foreach \X in {1,...,\value{mcqquiztotal}} {%
\foreach \Y in {1,...,\X} {%
\foreach \Z in {1,...,\Y} {%
\ifbool{Question\thequizquestion:#1}{}{%
\ifbool{Question\thequizquestion:#2}{}{%
\ifbool{Question\thequizquestion:#3}{}{%
\ifnum\Z=\Y
\relax%
\else
\ifnum\Y=\X
\relax%
\else
\hspace*{-\symbolwidth}%
%\X{:}\Y{:}\Z{}\space%
\ifnum\Z=#1
\ifnum\Y=#2
\ifnum\X=#3
\switchocg{mcqproposalmultipleref:\X mcqproposalmultipleref:\Y mcqproposalmultipleref:\Z}{}%
\begin{ocg}{mcqproposalmultiple:\X}{mcqproposalmultipleref:\X}{off}%
\begin{ocg}{mcqproposalmultiple:\Y}{mcqproposalmultipleref:\Y}{off}%
\begin{ocg}{mcqproposalmultiple:\Z}{mcqproposalmultipleref:\Z}{off}%
\raisebox{5pt}{\checktick}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\else
\switchocg{mcqproposalmultipleref:\X mcqproposalmultipleref:\Y mcqproposalmultipleref:\Z}{}%
\begin{ocg}{mcqproposalmultiple:\X}{mcqproposalmultipleref:\X}{off}%
\begin{ocg}{mcqproposalmultiple:\Y}{mcqproposalmultipleref:\Y}{off}%
\begin{ocg}{mcqproposalmultiple:\Z}{mcqproposalmultipleref:\Z}{off}%
\raisebox{5pt}{\crosstick}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\fi%
\else
\switchocg{mcqproposalmultipleref:\X mcqproposalmultipleref:\Y mcqproposalmultipleref:\Z}{}%
\begin{ocg}{mcqproposalmultiple:\X}{mcqproposalmultipleref:\X}{off}%
\begin{ocg}{mcqproposalmultiple:\Y}{mcqproposalmultipleref:\Y}{off}%
\begin{ocg}{mcqproposalmultiple:\Z}{mcqproposalmultipleref:\Z}{off}%
\raisebox{5pt}{\crosstick}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\fi%
\else
\switchocg{mcqproposalmultipleref:\X mcqproposalmultipleref:\Y mcqproposalmultipleref:\Z}{}%
\begin{ocg}{mcqproposalmultiple:\X}{mcqproposalmultipleref:\X}{off}%
\begin{ocg}{mcqproposalmultiple:\Y}{mcqproposalmultipleref:\Y}{off}%
\begin{ocg}{mcqproposalmultiple:\Z}{mcqproposalmultipleref:\Z}{off}%
\raisebox{5pt}{\crosstick}%
\end{ocg}%
\end{ocg}%
\end{ocg}%
\fi%
\fi
\fi
}%
}%
}%
}%
}%
}%
}% End if value #4
}{% If value #3 false
\foreach \X in {1,...,\value{mcqquiztotal}} {%
\foreach \Y in {1,...,\X} {%
\ifbool{Question\thequizquestion:#1}{}{%
\ifbool{Question\thequizquestion:#2}{}{%
\ifnum\Y=\X
\relax%
\else
%\X{:}\Y{}\space%
\hspace*{-\symbolwidth}%
\ifnum\Y=#1
\ifnum\X=#2
\switchocg{mcqproposalmultipleref:\X mcqproposalmultipleref:\Y}{}%
\begin{ocg}{mcqproposalmultiple:\X}{mcqproposalmultipleref:\X}{off}%
\begin{ocg}{mcqproposalmultiple:\Y}{mcqproposalmultipleref:\Y}{off}%
\raisebox{5pt}{\checktick}%
\end{ocg}%
\end{ocg}%
\else
\switchocg{mcqproposalmultipleref:\X mcqproposalmultipleref:\Y}{}%
\begin{ocg}{mcqproposalmultiple:\X}{mcqproposalmultipleref:\X}{off}%
\begin{ocg}{mcqproposalmultiple:\Y}{mcqproposalmultipleref:\Y}{off}%
\raisebox{5pt}{\crosstick}%
\end{ocg}%
\end{ocg}%
\fi%
\else
\switchocg{mcqproposalmultipleref:\X mcqproposalmultipleref:\Y}{}%
\begin{ocg}{mcqproposalmultiple:\X}{mcqproposalmultipleref:\X}{off}%
\begin{ocg}{mcqproposalmultiple:\Y}{mcqproposalmultipleref:\Y}{off}%
\raisebox{5pt}{\crosstick}%
\end{ocg}%
\end{ocg}%
\fi%
\fi%
}%
}%
}%
}%
}% End if value #3
\end{ocg}% End of 'Verify' OCG definition
}
%- Resetting and/or selecting all items of a multiple solution MCQ
\NewDocumentCommand{\resetMultiple}{}{%
\def\ocglist{}%
\foreach \X in {1,...,\value{mcqquiztotal}} {\xdef\ocglist{\ocglist\space mcqproposalmultipleref:\X}}%
\showocg{\ocglist}{%
\begin{tikzpicture}
\node[quizbutton=buttongray] (selectallbutton)
{\strut\footnotesize\textbf{Select all}};
\end{tikzpicture}%
}%
\qquad%
\hideocg{\ocglist}{%
\begin{tikzpicture}
\node[quizbutton=buttongray] (resetbutton)
{\strut\footnotesize\textbf{Reset}};
\end{tikzpicture}%
}%
}
%- Applying the different commands for a MCQ with multiple solutions
\AtBeginEnvironment{quizquestion}{%
\setcounter{mcqproposal}{0}%
\let\mcqproposal\mcqproposalMultiple%
\let\verifyMCQ\verifyMultiple%
\let\resetMCQ\resetMultiple%
}
\begin{document}
% Single solution MCQ
%--------------------
\begin{quizquestion*}{A relevant statement}
In short, what is the color of a black cat?
Choose the answer.
\mcqproposal[before skip=8pt]{The color is obviously red.}
\mcqproposal{The color may be green.}
\mcqproposal{The color is black.}
\mcqproposal[after skip=8pt]{The color is undoubtedly yellow.}
\verifyMCQ{3}
\qquad\hspace{3cm}\resetMCQ
\end{quizquestion*}
% Multiple solutions MCQ
%-----------------------
\begin{quizquestion}{Test of knowledge}
What are the different colors of an RGB image?
Check off the three exact assertions.
\mcqproposal[before skip=8pt]{Green.}
\mcqproposal{Yellow.}
\mcqproposal{Blue.}
\mcqproposal{Red.}
\mcqproposal[after skip=8pt]{Cyan.}
% Must be given in ascending order: if not => wrong results
%\verifyMCQ{1}{4}% Test with 2 correct choices
\verifyMCQ{1}{3}{4}% Correct answer of this particular quiz (3 choices)
%\verifyMCQ{1}{3}{4}{5}% Test with 4 correct choices
%\verifyMCQ{1}{2}{3}{4}{5}% Test with 5 correct choices
\qquad\hspace{3cm}\resetMCQ
\end{quizquestion}
\end{document}