public function instantiate($config = 0, $sessionId = '')
    {
        // If not provided, generate a session ID.
        if (empty($sessionId) === true) {
            $sessionId = uniqid('qtism', true);
        }

        try {
            $session = $this->getManager()->createAssessmentTestSession($this->getAssessmentTest(), null, $config);
            $session->setSessionId($sessionId);

            return $session;
        } catch (Exception $e) {
            $msg = "An error occured while instantiating the given AssessmentTest.";
            throw new StorageException($msg, StorageException::INSTANTIATION, $e);
        }
    }