# How to randomise the order of items in a tasks environment?

I have set up a document with a structure like this

\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{exsheets}

\newcommand{\righty}{$\checkmark$}
\newcommand{\checky}{$\Box$}

\SetupExSheets{counter-format=se.qu,counter-within=section}

\begin{document}

\begin{question}
How much do you like your teacher?
\task I hate them to death
...
\end{question}

\end{document}


As you can see, this document is generating the solutions to the questions at the moment. I would now like to add a switch to generate the unanswered questions as well, randomizing the items in the task environments.

Is something like this possible without changing the current structure? I have right about 250 questions inside that document, so it would be in my best interest not to change each of these, but best practice is always appreciated. I'm sorry for that kind of request, but I'm far too new to such tasks that I would knew where to start.

Adding the switch is as easy as this:

\newif\ifanswers

\newcommand{\righty}{\ifanswers$\checkmark$\else\checky\fi}


With this you only need to comment or uncomment \answerstrue for the two versions of the document.

Shuffling the items of the tasks environment is not that hard either albeit a hack because it requires a redefinition of a tasks internal. Be aware that the order will be shuffled differently each time you re-compile:

\ExplSyntaxOn
{
\bool_if:NT \l__tasks_debug_bool { \dim_set:Nn \fboxsep {0pt} }
{#2}
{ }
}
\ExplSyntaxOff


The complete example:

\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{amssymb}
\usepackage{exsheets}

\newcommand{\righty}{\ifanswers$\checkmark$\else\checky\fi}
\newcommand{\checky}{$\Box$}

\SetupExSheets{counter-format=se.qu,counter-within=section}

\ExplSyntaxOn
{
\bool_if:NT \l__tasks_debug_bool { \dim_set:Nn \fboxsep {0pt} }
{#2}
{ }
}
\ExplSyntaxOff

\begin{document}

\begin{question}
How much do you like your teacher?