public function writeShufflingState(Shuffling $shufflingState)
    {
        try {
            $this->writeIdentifier($shufflingState->getResponseIdentifier());
            $shufflingGroups = $shufflingState->getShufflingGroups();
            $this->writeTinyInt(count($shufflingGroups));
            
            foreach ($shufflingGroups as $shufflingGroup) {
                $this->writeShufflingGroup($shufflingGroup);
            }
        } catch (BinaryStreamAccessException $e) {
            $msg = "An error occured while writing a shufflingState.";
            throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::SHUFFLING_STATE, $e);
        }
    }