idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
56,800
public function getAssets ( PortableElementObject $ object , $ type = null ) { $ assets = [ ] ; if ( is_null ( $ type ) || ( $ type == 'runtime' ) ) { $ assets = [ 'runtime' => $ object -> getRuntimePath ( ) ] ; } if ( is_null ( $ type ) || ( $ type == 'creator' ) ) { if ( ! empty ( $ object -> getCreator ( ) ) ) { $ a...
Return all assets of a portable element in a array of string Path is relative to Portable Element location
56,801
public function validFile ( $ source , $ file ) { if ( ! file_exists ( $ source ) ) { throw new PortableElementParserException ( 'Unable to locate extracted zip file.' ) ; } $ filePath = rtrim ( $ source , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . preg_replace ( '/^\.\//' , '' , $ file ) ; if ( file_exists ( $ file...
Valid a file if exists or alias
56,802
private function createFailure ( $ userMessage , $ model = null ) { $ typeIdentifier = is_null ( $ model ) ? 'unknown type' : $ model -> getTypeIdentifier ( ) ; $ message = 'The portable element cannot be registered "' . $ typeIdentifier . '", reason: ' . $ userMessage ; \ common_Logger :: w ( $ message ) ; return Repo...
Create a formatted failure report and log a warning
56,803
protected function loadNamespaces ( ) { $ namespaces = [ ] ; foreach ( $ this -> queryXPath ( 'namespace::*' ) as $ node ) { $ name = preg_replace ( '/xmlns(:)?/' , '' , $ node -> nodeName ) ; if ( $ name !== 'xml' ) { $ namespaces [ $ name ] = $ node -> nodeValue ; } } ksort ( $ namespaces ) ; foreach ( $ namespaces a...
Load xml namespaces into the item model
56,804
protected function loadSchemaLocations ( DOMElement $ itemData ) { $ schemaLoc = preg_replace ( '/\s+/' , ' ' , trim ( $ itemData -> getAttributeNS ( $ itemData -> lookupNamespaceURI ( 'xsi' ) , 'schemaLocation' ) ) ) ; $ schemaLocToken = explode ( ' ' , $ schemaLoc ) ; $ schemaCount = count ( $ schemaLocToken ) ; if (...
Load xml schema locations into the item model
56,805
protected function buildOutcomeDeclaration ( DOMElement $ data ) { $ outcome = new OutcomeDeclaration ( $ this -> extractAttributes ( $ data ) ) ; $ data = simplexml_import_dom ( $ data ) ; if ( isset ( $ data -> defaultValue ) ) { if ( ! is_null ( $ data -> defaultValue -> value ) ) { $ outcome -> setDefaultValue ( ( ...
Short description of method buildOutcomeDeclaration
56,806
protected function buildTemplateResponseProcessing ( DOMElement $ data ) { $ returnValue = null ; if ( $ data -> hasAttribute ( 'template' ) && $ data -> childNodes -> length === 0 ) { $ templateUri = ( string ) $ data -> getAttribute ( 'template' ) ; $ returnValue = new Template ( $ templateUri ) ; } elseif ( $ data -...
Short description of method buildTemplateResponseProcessing
56,807
protected function buildResponseProcessing ( DOMElement $ data , Item $ item ) { $ returnValue = null ; try { $ returnValue = $ this -> buildTemplateResponseProcessing ( $ data ) ; try { $ returnValue = TemplatesDriven :: takeOverFrom ( $ returnValue , $ item ) ; } catch ( TakeoverFailedException $ e ) { } } catch ( Un...
Short description of method buildResponseProcessing
56,808
protected function buildCustomResponseProcessing ( DOMElement $ data ) { $ responseRules = array ( ) ; $ data = simplexml_import_dom ( $ data ) ; $ returnValue = new Custom ( $ responseRules , $ data -> asXml ( ) ) ; return $ returnValue ; }
Short description of method buildCustomResponseProcessing
56,809
private function buildObject ( DOMElement $ data ) { $ attributes = $ this -> extractAttributes ( $ data ) ; $ returnValue = new QtiObject ( $ attributes ) ; if ( $ data -> hasChildNodes ( ) ) { $ nonEmptyChild = $ this -> getNonEmptyChildren ( $ data ) ; if ( count ( $ nonEmptyChild ) == 1 && reset ( $ nonEmptyChild )...
Short description of method buildObject
56,810
private function getPortableElementSubclasses ( $ superClassName ) { $ subClasses = [ ] ; foreach ( PortableModelRegistry :: getRegistry ( ) -> getModels ( ) as $ model ) { $ portableElementClass = $ model -> getQtiElementClassName ( ) ; if ( is_subclass_of ( $ portableElementClass , $ superClassName ) ) { $ subClasses...
Return the list of registered php portable element subclasses
56,811
private function getPortableElementClass ( DOMElement $ data , $ superClassName , $ portableElementNodeName ) { $ portableElementClasses = $ this -> getPortableElementSubclasses ( $ superClassName ) ; foreach ( $ this -> item -> getNamespaces ( ) as $ name => $ uri ) { foreach ( $ portableElementClasses as $ class ) { ...
Get the PCI class associated to a dom node based on its namespace Returns null if not a known PCI model
56,812
private function buildCustomInteraction ( DOMElement $ data ) { $ interaction = null ; $ pciClass = $ this -> getPciClass ( $ data ) ; if ( ! empty ( $ pciClass ) ) { $ ns = null ; foreach ( $ this -> item -> getNamespaces ( ) as $ name => $ uri ) { if ( $ pciClass :: NS_URI === $ uri ) { $ ns = new QtiNamespace ( $ ur...
Parse and build a custom interaction object
56,813
private function buildInfoControl ( DOMElement $ data ) { $ infoControl = null ; $ picClass = $ this -> getPicClass ( $ data ) ; if ( ! empty ( $ picClass ) ) { $ ns = null ; foreach ( $ this -> item -> getNamespaces ( ) as $ name => $ uri ) { if ( $ picClass :: NS_URI === $ uri ) { $ ns = new QtiNamespace ( $ uri , $ ...
Parse and build a info control
56,814
public function setClassificationMapping ( $ propertyUri , $ classificationValue ) { if ( empty ( $ propertyUri ) || ! is_string ( $ propertyUri ) ) { throw new MetadataExtractionException ( __ ( 'PropertyUri to map has to a valid uri' ) ) ; } if ( empty ( $ classificationValue ) || ! is_string ( $ classificationValue ...
Set the association between property uri and value to find into classification metadata source
56,815
public function setItem ( \ core_kernel_classes_Resource $ item ) { $ this -> item = $ item ; $ this -> loadXml ( $ item ) ; return $ this ; }
Set item to extract
56,816
private function loadXml ( \ core_kernel_classes_Resource $ item ) { $ itemService = Service :: singleton ( ) ; try { $ xml = $ itemService -> getXmlByRdfItem ( $ item ) ; if ( empty ( $ xml ) ) { throw new ExtractorException ( 'No content found for item ' . $ item -> getUri ( ) ) ; } } catch ( FileNotFoundException $ ...
Load Dom & Xpath of xml item content & register xpath namespace
56,817
public function run ( ) { $ this -> extractInteractions ( ) ; $ this -> data = $ line = [ ] ; foreach ( $ this -> interactions as $ interaction ) { foreach ( $ this -> columns as $ column => $ config ) { if ( isset ( $ config [ 'callback' ] ) && method_exists ( $ this , $ config [ 'callback' ] ) ) { $ params = [ ] ; if...
Launch interactions extraction Transform interactions array to output data Use callback & valuesAsColumns
56,818
protected function sanitizeNodeToValue ( $ value ) { $ first = strpos ( $ value , '>' ) + 1 ; $ last = strrpos ( $ value , '<' ) - $ first ; $ value = substr ( $ value , $ first , $ last ) ; $ value = str_replace ( '"' , "'" , $ value ) ; return trim ( $ value ) ; }
Remove first and last xml tag from string Transform variable to string value
56,819
public function getChoices ( $ interaction ) { $ return = [ ] ; if ( isset ( $ interaction [ 'choices' ] ) ) { $ i = 1 ; foreach ( $ interaction [ 'choices' ] as $ identifier => $ choice ) { $ return [ 'choice_identifier_' . $ i ] = $ identifier ; $ return [ 'choice_label_' . $ i ] = ( $ choice ) ? : '' ; $ i ++ ; } if...
Callback to retrieve all choices Add dynamic column to have same columns number as other
56,820
public static function takeOverFrom ( ResponseProcessing $ responseProcessing , Item $ item ) { $ returnValue = null ; if ( $ responseProcessing instanceof static ) { $ returnValue = $ responseProcessing ; } elseif ( $ responseProcessing instanceof Template ) { $ rp = new Summation ( $ item , 'SCORE' ) ; foreach ( $ it...
Short description of method takeOverFrom
56,821
public function getInteractionResponseProcessing ( ResponseDeclaration $ response ) { foreach ( $ this -> components as $ irp ) { if ( $ irp -> getResponse ( ) == $ response ) { $ returnValue = $ irp ; break ; } } if ( is_null ( $ returnValue ) ) { throw new common_Exception ( 'No interactionResponseProcessing defined ...
Short description of method getInteractionResponseProcessing
56,822
public function getIRPByOutcome ( OutcomeDeclaration $ outcome ) { foreach ( $ this -> components as $ irp ) { if ( $ irp -> getOutcome ( ) == $ outcome ) { $ returnValue = $ irp ; break ; } } return $ returnValue ; }
Short description of method getIRPByOutcome
56,823
public function replace ( InteractionResponseProcessing $ newInteractionResponseProcessing ) { $ oldkey = null ; foreach ( $ this -> components as $ key => $ component ) { if ( $ component -> getResponse ( ) == $ newInteractionResponseProcessing -> getResponse ( ) ) { $ oldkey = $ key ; break ; } } if ( ! is_null ( $ o...
Short description of method replace
56,824
public function takeNoticeOfAddedInteraction ( Interaction $ interaction , Item $ item ) { $ irp = InteractionResponseProcessing :: create ( MatchCorrectTemplate :: CLASS_ID , $ interaction -> getResponse ( ) , $ item ) ; $ this -> add ( $ irp ) ; }
Short description of method takeNoticeOfAddedInteraction
56,825
public function takeNoticeOfRemovedInteraction ( Interaction $ interaction , Item $ item ) { $ irpExisted = false ; foreach ( $ this -> components as $ key => $ irp ) { if ( $ irp -> getResponse ( ) === $ interaction -> getResponse ( ) ) { unset ( $ this -> components [ $ key ] ) ; $ irpExisted = true ; break ; } } if ...
Short description of method takeNoticeOfRemovedInteraction
56,826
public function getForm ( ResponseDeclaration $ response ) { $ formContainer = new CompositeResponseOptions ( $ this , $ response ) ; $ returnValue = $ formContainer -> getForm ( ) ; return $ returnValue ; }
Short description of method getForm
56,827
private function serializePortableProperties ( $ properties , $ ns = '' , $ nsUri = '' , $ name = null , $ element = null ) { $ document = null ; $ result = '' ; if ( $ element === null ) { $ document = new \ DomDocument ( ) ; $ element = $ ns ? $ document -> createElementNS ( $ nsUri , $ ns . ':properties' ) : $ docum...
Serialize an associative array of pci properties into a pci xml
56,828
private function extractProperties ( DOMElement $ propertiesNode , $ ns = '' ) { $ properties = array ( ) ; $ ns = $ ns ? trim ( $ ns , ':' ) . ':' : '' ; foreach ( $ propertiesNode -> childNodes as $ prop ) { if ( $ prop instanceof DOMElement ) { switch ( $ prop -> tagName ) { case $ ns . 'entry' : case $ ns . 'proper...
Parse a pci properties dom node into an associative array
56,829
protected function setMappings ( array $ mappings = array ( ) ) { foreach ( $ mappings as $ mapping ) { if ( ! $ mapping instanceof ImsManifestMapping ) { $ msg = "The mappings argument must be an array composed of ImsManifestMapping objects" ; throw new InvalidArgumentException ( $ msg ) ; } } $ this -> mappings = $ m...
Set the ImsManifestMapping objects of this injector .
56,830
public function addMapping ( ImsManifestMapping $ mapping ) { $ mappings = $ this -> getMappings ( ) ; $ ns = $ mapping -> getNamespace ( ) ; if ( isset ( $ mappings [ $ ns ] ) === false ) { $ mappings [ $ ns ] = $ mapping ; } $ this -> setMappings ( $ mappings ) ; }
Add an XML mapping to this Manifest Extractor .
56,831
public function removeMapping ( ImsManifestMapping $ mapping ) { $ mappings = $ this -> getMappings ( ) ; if ( ( $ key = array_search ( $ mapping , $ mappings , true ) ) !== false ) { unset ( $ mappings [ $ key ] ) ; } }
Remove an already registered ImsManifestMapping .
56,832
protected function createMetadataElement ( MetadataValue $ metadata , DOMElement $ metadataNode , $ map , DOMDocument $ imsManifest ) { $ path = $ metadata -> getPath ( ) ; $ path = array_reverse ( $ path ) ; $ uniqNodes = [ ] ; if ( $ metadata instanceof ClassificationValue ) { $ uniqNodes = array ( 'taxonPath' , 'sou...
Add an element based on MetadataValue object to DomDocument
56,833
public function isBlacklisted ( $ assetPath ) { foreach ( $ this -> blacklist as $ pattern ) { if ( preg_match ( $ pattern , $ assetPath ) === 1 ) { return true ; } } return false ; }
Allow to know if a path is blacklisted or not
56,834
public function validate ( $ schema = '' ) { if ( empty ( $ schema ) ) { $ dom = new DOMDocument ( '1.0' , 'UTF-8' ) ; switch ( $ this -> sourceType ) { case self :: SOURCE_FLYFILE : if ( $ this -> source -> exists ( ) ) { $ dom -> load ( $ this -> source -> read ( ) ) ; } break ; case self :: SOURCE_FILE : $ dom -> lo...
Run the validation process
56,835
public function load ( $ resolveXInclude = false ) { $ returnValue = null ; if ( ! $ this -> valid ) { libxml_use_internal_errors ( true ) ; } $ xml = new DOMDocument ( ) ; switch ( $ this -> sourceType ) { case self :: SOURCE_FLYFILE : if ( $ this -> source -> exists ( ) ) { $ xml -> load ( $ this -> source -> read ( ...
load the file content parse it and build the a QTI_Item instance
56,836
public function getReportMessages ( ) { $ messages = array ( ) ; foreach ( $ this -> report as $ subReport ) { $ errors = [ ] ; if ( $ subReport -> containsError ( ) ) { $ errors = $ subReport -> getErrors ( ) ; } $ messages [ ] = array ( 'message' => $ subReport -> getMessage ( ) , 'details' => $ errors ) ; } return $...
Extract all report messages to simple array
56,837
public function compileJson ( ) { $ report = $ this -> internalCompile ( ) ; if ( $ report -> getType ( ) == common_report_Report :: TYPE_SUCCESS ) { list ( $ item , $ publicDirectory , $ privateDirectory ) = $ report -> getData ( ) ; $ report -> setData ( [ $ item -> getUri ( ) , $ publicDirectory -> getId ( ) , $ pri...
Generate JSON version of item
56,838
private function getItemPortableElements ( Element $ qtiItem ) { $ portableElementService = new PortableElementService ( ) ; $ portableElementService -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; return [ 'pci' => $ portableElementService -> getPortableElementByClass ( PortableElementService :: PORTABLE_CL...
Get the portable elements data in use in the item
56,839
private function getMetadataProperties ( ) { $ triples = $ this -> getResource ( ) -> getRdfTriples ( ) ; $ properties = [ ] ; foreach ( $ triples as $ triple ) { $ properties [ $ triple -> predicate ] = $ triple -> object ; } $ properties [ '@uri' ] = $ this -> getResource ( ) -> getUri ( ) ; return $ properties ; }
Get the item properties as compiled metadata
56,840
public function initForm ( ) { $ this -> form = new \ tao_helpers_form_xhtml_Form ( 'export' ) ; $ this -> form -> setDecorators ( array ( 'element' => new \ tao_helpers_form_xhtml_TagWrapper ( array ( 'tag' => 'div' ) ) , 'group' => new \ tao_helpers_form_xhtml_TagWrapper ( array ( 'tag' => 'div' , 'cssClass' => 'form...
Create a form
56,841
public function initElements ( ) { $ date = new \ DateTime ( ) ; $ filename = 'metadata-' . $ date -> format ( 'ymd' ) ; $ nameElt = \ tao_helpers_form_FormFactory :: getElement ( 'filename' , 'Textbox' ) ; $ nameElt -> setDescription ( __ ( 'File name' ) ) ; $ nameElt -> setValue ( $ filename ) ; $ nameElt -> setUnit ...
Init filename field
56,842
public function fetch ( $ identifier , $ version = null ) { $ portableElements = $ this -> getAllVersions ( $ identifier ) ; if ( is_null ( $ version ) ) { $ this -> krsortByVersion ( $ portableElements ) ; return $ this -> getModel ( ) -> createDataObject ( reset ( $ portableElements ) ) ; } if ( isset ( $ portableEle...
Fetch a portable element with identifier & version
56,843
private function get ( $ identifier ) { $ fileSystem = $ this -> getConfigFileSystem ( ) ; if ( $ fileSystem -> has ( $ identifier ) ) { return json_decode ( $ fileSystem -> read ( $ identifier ) , true ) ; } return false ; }
Retrieve the given element from list of portable element
56,844
public function removeAll ( ) { $ portableElements = $ this -> getAll ( ) ; foreach ( $ portableElements as $ identifier => $ versions ) { $ this -> removeAllVersions ( $ identifier ) ; } }
Unregister all previously registered pci in all version Remove all assets
56,845
protected function getFilesFromPortableElement ( PortableElementObject $ object ) { $ validator = $ object -> getModel ( ) -> getValidator ( ) ; return $ validator -> getAssets ( $ object ) ; }
Get list of files following Pci Model
56,846
protected function getRuntime ( PortableElementObject $ object ) { $ object = $ this -> fetch ( $ object -> getTypeIdentifier ( ) , $ object -> getVersion ( ) ) ; $ runtime = $ object -> toArray ( ) ; $ runtime [ 'model' ] = $ object -> getModelId ( ) ; $ runtime [ 'xmlns' ] = $ object -> getNamespace ( ) ; $ runtime [...
Return the runtime of a portable element
56,847
public function export ( PortableElementObject $ object ) { $ zip = new \ ZipArchive ( ) ; $ path = $ this -> getZipLocation ( $ object ) ; if ( $ zip -> open ( $ path , \ ZipArchive :: CREATE ) !== TRUE ) { throw new \ common_Exception ( 'Unable to create zipfile ' . $ path ) ; } $ manifest = $ this -> getManifest ( $...
Export a portable element to a zip package
56,848
public function getFileSystem ( ) { if ( ! $ this -> storage ) { $ this -> storage = $ this -> getServiceLocator ( ) -> get ( PortableElementFileStorage :: SERVICE_ID ) ; $ this -> storage -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; $ this -> storage -> setModel ( $ this -> getModel ( ) ) ; } return $ th...
Get the fly filesystem based on OPTION_FS configuration
56,849
public function getBaseUrl ( PortableElementObject $ object ) { $ object = $ this -> fetch ( $ object -> getTypeIdentifier ( ) , $ object -> getVersion ( ) ) ; return $ this -> getFileSystem ( ) -> getFileUrl ( $ object ) ; }
Return the absolute url of PCI storage
56,850
protected function setMetaDataProperties ( array $ config ) { if ( empty ( $ this -> metaDataProperties ) ) { $ itemTypes = $ this -> item -> getTypes ( ) ; $ classType = reset ( $ itemTypes ) ; if ( ! $ classType -> isClass ( ) ) { throw new ExtractorException ( 'Item class type do not exists' ) ; } $ this -> metaData...
Setting the meta data properties available for export .
56,851
public function inject ( $ identifier , $ resource ) { if ( ! $ resource instanceof \ core_kernel_classes_Resource ) { throw new MetadataImportException ( __ ( 'Metadata import requires an instance of core_kernel_classes_Resource to inject metadata' ) ) ; } parent :: inject ( $ identifier , $ resource ) ; }
Inject an identified metadata value to a resource
56,852
public function guard ( $ identifier , $ context = '' ) { foreach ( $ this -> getGuardians ( ) as $ guardian ) { if ( $ guardian instanceof ContextualMetadataGuardian && $ guardian -> getContext ( ) !== $ context ) { continue ; } if ( $ this -> hasMetadataValue ( $ identifier ) ) { \ common_Logger :: i ( __ ( 'Guard fo...
Guard a metadata identifier at import
56,853
public function classLookUp ( $ identifier , & $ createdClasses ) { $ targetClass = false ; foreach ( $ this -> getClassLookUp ( ) as $ classLookup ) { if ( $ this -> hasMetadataValue ( $ identifier ) ) { \ common_Logger :: i ( __ ( 'Target Class Lookup for resource "%s"...' , $ identifier ) ) ; if ( ( $ targetClass = ...
Lookup classes for a metadata identifier at import
56,854
public function unregister ( $ key , $ name ) { if ( empty ( $ key ) || empty ( $ name ) ) { throw new \ common_Exception ( __ ( 'Unregister method expects $key and $name parameters.' ) ) ; } if ( is_object ( $ name ) ) { $ name = get_class ( $ name ) ; } switch ( $ key ) { case self :: GUARDIAN_KEY : $ this -> unregis...
Unregister an instances
56,855
protected function registerMetadataService ( ) { if ( $ this -> getServiceLocator ( ) -> has ( MetadataService :: SERVICE_ID ) ) { $ metadataService = $ this -> getServiceLocator ( ) -> get ( MetadataService :: SERVICE_ID ) ; } else { $ metadataService = $ this -> getServiceManager ( ) -> build ( MetadataService :: cla...
Allow to register into the config the current importer service
56,856
public function getValidElementTypes ( ) { return array ( 'oat\\taoQtiItem\\model\\qti\\Img' , 'oat\\taoQtiItem\\model\\qti\\Math' , 'oat\\taoQtiItem\\model\\qti\\feedback\\Feedback' , \ oat \ taoQtiItem \ model \ qti \ QtiObject :: class , 'oat\\taoQtiItem\\model\\qti\\Tooltip' , 'oat\\taoQtiItem\\model\\qti\\interact...
return the list of available element classes
56,857
public function load ( ) { $ returnValue = array ( ) ; $ xml = false ; switch ( $ this -> sourceType ) { case self :: SOURCE_FILE : $ xml = simplexml_load_file ( $ this -> source ) ; break ; case self :: SOURCE_URL : $ xmlContent = tao_helpers_Request :: load ( $ this -> source , true ) ; $ xml = simplexml_load_string ...
Extract the resources informations about the items and build a list a QTI_Resource
56,858
public function getValue ( $ returnObject = false ) { $ returnValue = null ; if ( ! is_null ( $ this -> value ) ) { $ returnValue = ( $ returnObject ) ? $ this -> value : $ this -> value -> getValue ( ) ; } return $ returnValue ; }
Return the value of the attribute in base type int string null
56,859
public function setValue ( $ value ) { $ returnValue = false ; if ( ! is_null ( $ value ) ) { try { $ value = new static :: $ type ( $ value ) ; if ( ! is_null ( $ value ) ) { $ this -> value = $ value ; $ returnValue = true ; } } catch ( DatatypeException $ de ) { $ type = '(' . gettype ( $ value ) . ')' ; if ( $ type...
Set the attribute value
56,860
public function isApplicable ( $ relativePath ) { $ xincluded = array ( ) ; foreach ( $ this -> getQtiModel ( ) -> getComposingElements ( 'oat\taoQtiItem\model\qti\Xinclude' ) as $ xincludeElement ) { $ xincluded [ ] = $ xincludeElement -> attr ( 'href' ) ; \ common_Logger :: i ( "Xinclude component found in resource '...
Check if current file . xml is shared stimulus
56,861
public function handle ( $ absolutePath , $ relativePath ) { $ sharedFiles = $ this -> getSharedFiles ( ) ; $ md5 = md5_file ( $ absolutePath ) ; if ( isset ( $ sharedFiles [ $ md5 ] ) ) { \ common_Logger :: i ( 'Auxiliary file \'' . $ absolutePath . '\' linked to shared storage.' ) ; return $ sharedFiles [ $ md5 ] ; }...
Handle the process to manage shared stimulus files
56,862
public function addSharedFile ( $ key , $ value ) { $ sharedFiles = $ this -> getSharedFiles ( ) ; $ sharedFiles [ $ key ] = $ value ; $ this -> setSharedFiles ( $ sharedFiles ) ; return $ this ; }
Add a shared file
56,863
public function validate ( PortableElementObject $ object , $ source = null , $ validationGroup = array ( ) ) { $ validator = $ object -> getModel ( ) -> getValidator ( ) ; Validator :: validate ( $ object , $ validator , $ validationGroup ) ; if ( $ source ) { $ validator -> validateAssets ( $ object , $ source ) ; } ...
Validate a model using associated validator
56,864
public function unregisterModel ( PortableElementObject $ object ) { $ registry = $ object -> getModel ( ) -> getRegistry ( ) ; $ registry -> delete ( $ object ) ; return true ; }
Unregister the portable element
56,865
public function export ( $ type , $ identifier , $ version = null ) { $ model = $ this -> getPortableModelRegistry ( ) -> getModel ( $ type ) ; $ object = $ model -> getRegistry ( ) -> fetch ( $ identifier , $ version ) ; if ( is_null ( $ object ) ) { throw new PortableElementNotFoundException ( 'Unable to find a PCI a...
Export a model with files into a ZIP
56,866
public function import ( $ type , $ zipFile ) { $ parser = $ this -> getPortableModelRegistry ( ) -> getModel ( $ type ) -> getPackageParser ( ) ; $ source = $ parser -> extract ( $ zipFile ) ; $ object = $ parser -> getModel ( ) -> createDataObject ( $ parser -> getManifestContent ( $ zipFile ) ) ; $ this -> registerM...
Import a Portable element from an uploaded zip file
56,867
public function getValidPortableElementFromZipSource ( $ type , $ zipFile ) { $ parser = $ this -> getPortableModelRegistry ( ) -> getModel ( $ type ) -> getPackageParser ( ) ; $ source = $ parser -> extract ( $ zipFile ) ; $ object = $ parser -> getModel ( ) -> createDataObject ( $ parser -> getManifestContent ( $ zip...
Extract a valid model from a zip
56,868
protected function getDirectoryParsers ( ) { $ parsers = array ( ) ; $ models = $ this -> getPortableModelRegistry ( ) -> getModels ( ) ; foreach ( $ models as $ key => $ model ) { if ( $ model -> getDirectoryParser ( ) instanceof PortableElementDirectoryParser ) { $ parsers [ ] = $ model -> getDirectoryParser ( ) ; } ...
Return all directory parsers from configuration
56,869
public function getValidPortableElementFromDirectorySource ( $ directory ) { $ parserMatched = null ; $ parsers = $ this -> getDirectoryParsers ( ) ; foreach ( $ parsers as $ parser ) { if ( $ parser -> hasValidPortableElement ( $ directory ) ) { $ parserMatched = $ parser ; } } if ( is_null ( $ parserMatched ) ) { thr...
Extract a valid model from a directory
56,870
public function getPortableElementByIdentifier ( $ type , $ identifier , $ version = null ) { $ model = $ this -> getPortableModelRegistry ( ) -> getModel ( $ type ) ; $ registry = $ model -> getRegistry ( ) ; if ( $ registry -> has ( $ identifier , $ version ) ) { return $ registry -> fetch ( $ identifier , $ version ...
Get model from identifier & version
56,871
public function registerFromDirectorySource ( $ directory ) { $ object = $ this -> getValidPortableElementFromDirectorySource ( $ directory ) ; if ( is_null ( $ object ) ) { throw new PortableElementNotFoundException ( 'No valid portable element model found in the directory ' . $ directory ) ; } return $ this -> regist...
Register a model from a directory based on manifest . json
56,872
public function getFileStream ( PortableElementObject $ object , $ file ) { return $ object -> getModel ( ) -> getRegistry ( ) -> getFileStream ( $ object , $ file ) ; }
Return the stream of a file model
56,873
public function getPortableElementByClass ( $ portableElementClass , Element $ qtiItem , $ useVersionAlias = false ) { $ portableElements = [ ] ; $ identifiers = array_map ( function ( $ portableElement ) { return $ portableElement -> getTypeIdentifier ( ) ; } , $ qtiItem -> getComposingElements ( $ portableElementClas...
Get the array of portable elements used in qti item object by its php class
56,874
public function setBaseUrlToPortableData ( & $ data ) { $ model = $ this -> getPortableModelRegistry ( ) -> getModel ( $ data [ 'model' ] ) ; $ portableObject = $ model -> createDataObject ( $ data ) ; $ data [ 'baseUrl' ] = $ model -> getRegistry ( ) -> getBaseUrl ( $ portableObject ) ; return $ data ; }
Set the base url to a portable element data array
56,875
public function inject ( $ target , array $ values ) { if ( ! $ target instanceof \ core_kernel_classes_Resource ) { $ msg = "The given target is not an instance of core_kernel_classes_Resource." ; throw new MetadataInjectionException ( $ msg ) ; } $ types = $ target -> getTypes ( ) ; $ targetClass = reset ( $ types ) ...
Inject dynamically a metadata to an item property
56,876
protected function getTemplateQtiVariables ( ) { $ variables = parent :: getTemplateQtiVariables ( ) ; $ tag = static :: $ qtiTagName ; $ ns = $ this -> getXIncludeNamespace ( ) ; if ( empty ( $ ns ) ) { $ relatedItem = $ this -> getRelatedItem ( ) ; if ( ! is_null ( $ relatedItem ) ) { $ ns = 'xi' ; $ relatedItem -> a...
Get the variables for the qti template rendering
56,877
public function getXIncludeNamespace ( ) { $ ns = '' ; $ relatedItem = $ this -> getRelatedItem ( ) ; if ( ! is_null ( $ relatedItem ) ) { foreach ( $ relatedItem -> getNamespaces ( ) as $ name => $ uri ) { if ( strpos ( $ uri , 'XInclude' ) > 0 ) { $ ns = $ name ; break ; } } } return $ ns ; }
Get the xml namespace of the xinclude
56,878
public function validate ( $ source ) { $ this -> assertSourceAsDirectory ( $ source ) ; $ definitionFiles = $ this -> getModel ( ) -> getDefinitionFiles ( ) ; foreach ( $ definitionFiles as $ file ) { if ( ! file_exists ( $ source . DIRECTORY_SEPARATOR . $ file ) ) { throw new PortableElementParserException ( 'A porta...
Validate the source directory
56,879
public function getManifestContent ( $ source ) { $ content = json_decode ( file_get_contents ( $ source . DIRECTORY_SEPARATOR . $ this -> getModel ( ) -> getManifestName ( ) ) , true ) ; if ( json_last_error ( ) === JSON_ERROR_NONE ) { return $ content ; } throw new common_Exception ( 'Portable element manifest is not...
Return the manifest content found in the source directory as json array
56,880
protected function getAssets ( \ core_kernel_classes_Resource $ item , $ lang ) { $ qtiItem = Service :: singleton ( ) -> getDataItemByRdfItem ( $ item , $ lang ) ; if ( is_null ( $ qtiItem ) ) { return [ ] ; } $ assetParser = new AssetParser ( $ qtiItem , $ this -> getStorageDirectory ( $ item , $ lang ) ) ; $ assetPa...
Get the item s assets
56,881
protected function getStorageDirectory ( \ core_kernel_classes_Resource $ item , $ lang ) { $ itemService = \ taoItems_models_classes_ItemsService :: singleton ( ) ; $ directory = $ itemService -> getItemDirectory ( $ item , $ lang ) ; $ path = str_replace ( $ lang , '' , $ directory -> getPrefix ( ) ) ; return $ itemS...
Get the item s directory
56,882
protected function getMetadataExporter ( ) { if ( ! $ this -> metadataExporter ) { $ this -> metadataExporter = $ this -> getServiceManager ( ) -> get ( MetadataService :: SERVICE_ID ) -> getExporter ( ) ; } return $ this -> metadataExporter ; }
Get the service to export Metadata
56,883
public static function buildResponseRule ( SimpleXMLElement $ data ) { $ returnValue = null ; switch ( $ data -> getName ( ) ) { case 'exitResponse' : $ returnValue = new ExitResponse ( ) ; break ; case 'setOutcomeValue' : $ identifier = ( string ) $ data [ 'identifier' ] ; $ children = array ( ) ; foreach ( $ data -> ...
Short description of method buildResponseRule
56,884
private static function buildResponseCondition ( SimpleXMLElement $ data ) { $ responseCondition = new ResponseCondition ( ) ; foreach ( $ data -> children ( ) as $ child ) { switch ( $ child -> getName ( ) ) { case 'responseIf' : case 'responseElseIf' : $ subchildren = null ; foreach ( $ child -> children ( ) as $ sub...
Short description of method buildResponseCondition
56,885
public function toQTI ( ) { $ returnValue = ( string ) '' ; $ returnValue = '<responseCondition> <responseIf> <isNull> <variable identifier="' . $ this -> getResponse ( ) -> getIdentifier ( ) . '" /> </isNull> <setOutcomeValue identifier="' . $ this -> getOutcome ( ...
although no ResponseRules are nescessary to have no responseProcessing add some rules to associate the interaction response with a sepcific
56,886
public function getPlugins ( ) { $ config = [ ] ; $ registry = self :: getRegistry ( ) ; if ( $ registry -> isRegistered ( self :: CREATOR ) ) { $ config = $ registry -> get ( self :: CREATOR ) ; } if ( ! isset ( $ config [ 'plugins' ] ) ) { return [ ] ; } return $ config [ 'plugins' ] ; }
Quick access to the plugins
56,887
public function run ( ) { $ this -> data = [ ] ; if ( empty ( $ this -> item ) || ! ( $ this -> item instanceof \ core_kernel_classes_Resource ) ) { throw new ExtractorException ( 'Export item not set.' ) ; } $ properties = [ ] ; foreach ( $ this -> columns as $ config ) { $ properties [ ] = $ config [ 'property' ] ; }...
Get ontology values of requested item properties
56,888
public function validate ( $ source ) { try { $ this -> assertSourceAsFile ( $ source ) ; if ( ! QtiPackage :: isValidZip ( $ source ) ) { throw new PortableElementParserException ( 'Source package is not a valid zip.' ) ; } } catch ( common_Exception $ e ) { throw new PortableElementParserException ( 'A problem has oc...
Validate the zip package
56,889
public function extract ( $ source ) { $ tmpDirectory = null ; $ this -> assertSourceAsFile ( $ source ) ; $ folder = \ tao_helpers_File :: createTempDir ( ) ; $ zip = new ZipArchive ( ) ; if ( $ zip -> open ( $ source ) === true ) { if ( \ tao_helpers_File :: checkWhetherArchiveIsBomb ( $ zip ) ) { throw new PortableE...
Extract zip package into temp directory
56,890
public static function build ( SimpleXMLElement $ data ) { $ returnValue = null ; $ expression = null ; $ expressionName = $ data -> getName ( ) ; $ attributes = array ( ) ; foreach ( $ data -> attributes ( ) as $ key => $ value ) { $ attributes [ $ key ] = ( string ) $ value ; } $ expressionClass = 'oat\\taoQtiItem\\m...
Short description of method build
56,891
protected function getTemplateQtiVariables ( ) { $ tooltipId = $ this -> getAttributeValue ( 'aria-describedby' ) ; $ variables = parent :: getTemplateQtiVariables ( ) ; $ variables [ 'tooltipId' ] = $ tooltipId ; $ variables [ 'content' ] = ( string ) $ this -> getContent ( ) ; return $ variables ; }
Add tooltip id & content to template variables
56,892
public function getFile ( ) { if ( $ this -> hasRequestParameter ( 'file' ) ) { $ file = urldecode ( $ this -> getRequestParameter ( 'file' ) ) ; $ filePathTokens = explode ( '/' , $ file ) ; $ typeIdentifier = array_shift ( $ filePathTokens ) ; $ relPath = implode ( DIRECTORY_SEPARATOR , $ filePathTokens ) ; $ this ->...
Get a file of a custom interaction
56,893
private function renderFile ( $ typeIdentifier , $ relPath ) { if ( tao_helpers_File :: securityCheck ( $ relPath , true ) ) { $ folder = $ this -> getImplementationDirectory ( $ typeIdentifier ) ; $ filename = $ folder . $ relPath ; if ( ! file_exists ( $ filename ) && file_exists ( $ filename . '.js' ) ) { $ filename...
Render the file to the browser
56,894
public function getMapping ( $ type = '' ) { $ returnValue = array ( ) ; if ( $ type == 'area' ) { $ returnValue = $ this -> areaMapping ; } else { $ returnValue = $ this -> mapping ; } return ( array ) $ returnValue ; }
Short description of method getMapping
56,895
public function setMapping ( $ map , $ type = '' ) { if ( $ type == 'area' ) { $ this -> areaMapping = $ map ; } else { $ this -> mapping = $ map ; } }
Short description of method setMapping
56,896
public function correctToJSON ( ) { $ returnValue = null ; try { $ correctResponses = $ this -> getCorrectResponses ( ) ; if ( count ( $ correctResponses ) ) { $ returnValue = taoQTI_models_classes_Matching_VariableFactory :: createJSONVariableFromQTIData ( $ this -> getIdentifier ( ) , $ this -> getAttributeValue ( 'c...
get the correct response in JSON format . If no correct response defined null .
56,897
public function areaMapToJson ( ) { $ returnValue = null ; $ mapping = $ this -> getMapping ( 'area' ) ; if ( count ( $ mapping ) ) { $ returnValue = Array ( ) ; $ returnValue [ 'identifier' ] = $ this -> getIdentifier ( ) ; $ returnValue [ 'defaultValue' ] = $ this -> mappingDefaultValue ; if ( $ this -> hasAttribute ...
Short description of method areaMapToJson
56,898
public function mapToJSON ( ) { $ returnValue = null ; $ mapping = $ this -> getMapping ( ) ; if ( count ( $ mapping ) ) { $ returnValue = Array ( ) ; $ returnValue [ 'identifier' ] = $ this -> getIdentifier ( ) ; $ returnValue [ 'defaultValue' ] = $ this -> mappingDefaultValue ; if ( $ this -> hasAttribute ( 'areaMapp...
get the mapping in JSON format . If no mapping defined return null .
56,899
public function toForm ( ) { $ returnValue = null ; $ interaction = $ this -> getAssociatedInteraction ( ) ; if ( $ interaction instanceof Interaction ) { $ responseFormClass = '\\oat\\taoQtiItem\\controller\\QTIform\\response\\' . ucfirst ( strtolower ( $ interaction -> getType ( ) ) ) . 'Interaction' ; if ( class_exi...
Short description of method toForm