'For a choicegroup with shuffle="true", shuffles the choices in-place in the given tree
based on the seed. Otherwise does nothing.
Raises LoncapaProblemError if both shuffle and answer-pool are active:
a problem should use one or the other but not both.
Does nothing if the tree has already been processed.'

def do_shuffle(self, tree, problem):

    choicegroups = tree.xpath('choicegroup[@shuffle="true"]')
    if choicegroups:
        choicegroup = choicegroups[0]
        if (choicegroup.get('answer-pool') is not None):
            _ = self.capa_system.i18n.ugettext
            msg = _('Do    not    use    shuffle    and    answer-pool    at    the    same    time')
            raise LoncapaProblemError(msg)
        if self.has_shuffle():
            return
        self._has_shuffle = True
        ordering = list(choicegroup.getchildren())
        for choice in ordering:
            choicegroup.remove(choice)
        ordering = self.shuffle_choices(ordering, self.get_rng(problem))
        for choice in ordering:
            choicegroup.append(choice)
