public function setIdentifier($identifier, $collisionFree = false){

        $returnValue = false;
        if(empty($identifier) || is_null($identifier)){
            common_Logger::w('ss');
            throw new \InvalidArgumentException("Id must not be empty");
        }

        if($this->isIdentifierAvailable($identifier)){
            $returnValue = true;
        }else{
            if($collisionFree){
                $identifier = $this->generateIdentifier($identifier);
                $returnValue = true;
            }else{
                $relatedItem = $this->getRelatedItem();
                if(!is_null($relatedItem)){
                    $identifiedElements = $relatedItem->getIdentifiedElements();
                }
                common_Logger::w("Tried to set non unique identifier ".$identifier, array('TAOITEMS', 'QTI'));
                throw new \InvalidArgumentException("The identifier \"{$identifier}\" is already in use");
            }
        }

        if($returnValue){
            $this->identifier = $identifier;
        }

        return $returnValue;
    }
public function setIdentifier($identifier, $collisionFree = false){

        $returnValue = false;
        if(empty($identifier) || is_null($identifier)){
            common_Logger::w('ss');
            throw new \InvalidArgumentException("Id must not be empty");
        }

        if($this->isIdentifierAvailable($identifier)){
            $returnValue = true;
        }else{
            if($collisionFree){
                $identifier = $this->generateIdentifier($identifier);
                $returnValue = true;
            }else{
                $relatedItem = $this->getRelatedItem();
                if(!is_null($relatedItem)){
                    $identifiedElements = $relatedItem->getIdentifiedElements();
                }
                common_Logger::w("Tried to set non unique identifier ".$identifier, array('TAOITEMS', 'QTI'));
                throw new \InvalidArgumentException("The identifier \"{$identifier}\" is already in use");
            }
        }

        if($returnValue){
            $this->identifier = $identifier;
        }

        return $returnValue;
    }
public function setIdentifier ( $ identifier , $ collisionFree = false ) { $ returnValue = false ; if ( empty ( $ identifier ) || is_null ( $ identifier ) ) { common_Logger :: w ( 'ss' ) ; throw new \ InvalidArgumentException ( "Id must not be empty" ) ; } if ( $ this -> isIdentifierAvailable ( $ identifier ) ) { $ returnValue = true ; } else { if ( $ collisionFree ) { $ identifier = $ this -> generateIdentifier ( $ identifier ) ; $ returnValue = true ; } else { $ relatedItem = $ this -> getRelatedItem ( ) ; if ( ! is_null ( $ relatedItem ) ) { $ identifiedElements = $ relatedItem -> getIdentifiedElements ( ) ; } common_Logger :: w ( "Tried to set non unique identifier " . $ identifier , array ( 'TAOITEMS' , 'QTI' ) ) ; throw new \ InvalidArgumentException ( "The identifier \"{$identifier}\" is already in use" ) ; } } if ( $ returnValue ) { $ this -> identifier = $ identifier ; } return $ returnValue ; }
Set a unique identifier.
If the identifier is already given to another qti element in the same item an InvalidArgumentException is thrown.
The option collisionFree allows to ensure that a new identifier is generated if a collision happens

@access public
@author Sam, <sam@taotesting.com>
@param  string id
@return boolean
Set a unique identifier . If the identifier is already given to another qti element in the same item an InvalidArgumentException is thrown . The option collisionFree allows to ensure that a new identifier is generated if a collision happens