idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
56,900 | public static function validateQtiXml ( $ qti ) { $ dom = self :: loadQtiXml ( $ qti ) ; $ returnValue = $ dom -> saveXML ( ) ; $ parserValidator = new Parser ( $ returnValue ) ; $ parserValidator -> validate ( ) ; if ( ! $ parserValidator -> isValid ( ) ) { common_Logger :: w ( 'Invalid QTI output: ' . PHP_EOL . ' ' .... | Validate a QTI XML string . |
56,901 | public static function checkEmptyMedia ( $ qti ) { $ doc = new DOMDocument ( ) ; $ doc -> loadHTML ( self :: loadQtiXml ( $ qti ) -> saveXML ( ) ) ; $ imgs = $ doc -> getElementsByTagName ( 'img' ) ; foreach ( $ imgs as $ img ) { if ( empty ( $ img -> getAttribute ( 'src' ) ) ) { throw new QtiModelException ( 'image ha... | Simple function to check if the item is not missing any of the required asset configuration path |
56,902 | public static function addRequiredResources ( $ sourceDirectory , $ relativeSourceFiles , $ prefix , core_kernel_classes_Resource $ item , $ lang ) { $ returnValue = array ( ) ; $ directory = taoItems_models_classes_ItemsService :: singleton ( ) -> getItemDirectory ( $ item , $ lang ) ; foreach ( $ relativeSourceFiles ... | Add a list of required resources files to an RDF item and keeps the relative path structure For instances required css js etc . |
56,903 | public static function sanitizeQtiXml ( $ qti ) { $ doc = self :: loadQtiXml ( $ qti ) ; $ xpath = new \ DOMXpath ( $ doc ) ; foreach ( $ xpath -> query ( "//*[local-name() = 'itemBody']//*[@style]" ) as $ elementWithStyle ) { $ elementWithStyle -> removeAttribute ( 'style' ) ; } $ ids = array ( ) ; foreach ( $ xpath -... | Remove invalid elements and attributes from QTI XML . |
56,904 | public static function loadQtiXml ( $ file ) { if ( $ file instanceof File ) { $ qti = $ file -> read ( ) ; } else if ( preg_match ( "/^<\?xml(.*)?/m" , trim ( $ file ) ) ) { $ qti = $ file ; } else if ( is_file ( $ file ) ) { $ qti = file_get_contents ( $ file ) ; } else { throw new \ common_exception_Error ( "Wrong p... | Load QTI xml and return DOMDocument instance . If string is not valid xml then QtiModelException will be thrown . |
56,905 | public function getCompositionRules ( ) { $ subExpressions = array ( ) ; foreach ( $ this -> components as $ irp ) { $ subExpressions [ ] = new CommonExpression ( 'variable' , array ( 'identifier' => $ irp -> getOutcome ( ) -> getIdentifier ( ) ) ) ; } $ sum = new CommonExpression ( 'sum' , array ( ) ) ; $ sum -> setSu... | Short description of method getCompositionRules |
56,906 | public function getCompositionQTI ( ) { $ returnValue = ( string ) '' ; $ returnValue .= '<setOutcomeValue identifier="' . $ this -> outcomeIdentifier . '"><sum>' ; foreach ( $ this -> components as $ irp ) { $ returnValue .= '<variable identifier="' . $ irp -> getOutcome ( ) -> getIdentifier ( ) . '" />' ; } $ returnV... | Short description of method getCompositionQTI |
56,907 | public function load ( $ removeUnfoundHref = false ) { $ xincludes = $ this -> getXIncludes ( ) ; foreach ( $ xincludes as $ xinclude ) { $ href = $ xinclude -> attr ( 'href' ) ; if ( ! empty ( $ href ) ) { try { $ asset = $ this -> resolver -> resolve ( $ href ) ; $ filePath = $ asset -> getMediaSource ( ) -> download... | Load parse the item and resolve all xinclude |
56,908 | private function parseCustomElementMarkup ( CustomInteraction $ customElement ) { $ xincludes = array ( ) ; $ xml = new DOMDocument ( ) ; $ xml -> formatOutput = true ; $ loadSuccess = $ xml -> loadXML ( $ customElement -> getMarkup ( ) ) ; $ node = $ xml -> documentElement ; if ( $ loadSuccess && ! is_null ( $ node ) ... | Parse and load xinclude located in custom element markup |
56,909 | private function loadXInclude ( XInclude $ xinclude , $ filePath ) { $ xml = new DOMDocument ( ) ; $ loadSuccess = $ xml -> load ( $ filePath ) ; $ node = $ xml -> documentElement ; if ( $ loadSuccess && ! is_null ( $ node ) ) { $ parser = new ParserFactory ( $ xml ) ; $ parser -> loadContainerStatic ( $ node , $ xincl... | load an xml string into the body of the XInclude |
56,910 | private function getXIncludes ( ) { $ xincludes = array ( ) ; foreach ( $ this -> qtiItem -> getComposingElements ( ) as $ element ) { if ( $ element instanceof XInclude ) { $ xincludes [ ] = $ element ; } } return $ xincludes ; } | Find the xinclude elements in the qti item |
56,911 | private function getCustomElements ( ) { $ customElements = array ( ) ; foreach ( $ this -> qtiItem -> getComposingElements ( ) as $ element ) { if ( $ element instanceof PortableCustomInteraction ) { $ customElements [ ] = $ element ; } } return $ customElements ; } | Find the custom elements in the qti item |
56,912 | public function getUserMessage ( ) { $ name = $ this -> getElement ( ) -> localName ; $ line = $ this -> getElement ( ) -> getLineNo ( ) ; return sprintf ( __ ( 'The QTI class "%1$s" located at line "%2$d" is currently not supported.' ) , $ name , $ line ) ; } | Returns a human - readable message describing the error that occurred . |
56,913 | public static function parseElementXml ( SimpleXMLElement $ xml ) { $ attributes = array ( ) ; foreach ( $ xml -> attributes ( ) as $ name => $ value ) { $ attributes [ $ name ] = ( string ) $ value ; } $ returnValue = array ( 'qtiClass' => $ xml -> getName ( ) ) ; if ( count ( $ attributes ) ) { $ returnValue [ 'attri... | Parse a generic QTI element node into an array |
56,914 | public static function parseExpressionXml ( SimpleXMLElement $ xml ) { $ returnValue = self :: parseElementXml ( $ xml ) ; $ value = trim ( $ xml ) ; $ expressions = array ( ) ; foreach ( $ xml -> children ( ) as $ child ) { $ expressions [ ] = self :: parseExpressionXml ( $ child ) ; } if ( count ( $ expressions ) ) {... | Parse a QTI expression node into an array |
56,915 | public static function parseResponseRuleXml ( SimpleXMLElement $ xml ) { $ returnValue = self :: parseElementXml ( $ xml ) ; foreach ( $ xml -> children ( ) as $ child ) { $ returnValue [ 'expression' ] = self :: parseExpressionXml ( $ child ) ; break ; } return $ returnValue ; } | Parse a QTI responseRule node into an array |
56,916 | private static function parseResponseRulesContainerXml ( SimpleXMLElement $ xml ) { $ returnValue = self :: parseElementXml ( $ xml ) ; $ responseRules = array ( ) ; foreach ( $ xml -> children ( ) as $ child ) { $ name = $ child -> getName ( ) ; $ methodName = 'parse' . ucfirst ( $ name ) . 'Xml' ; if ( method_exists ... | Parse a generic QTI element node that contains responseRules as children into an array |
56,917 | protected function updateItem ( \ oat \ taoQtiItem \ model \ qti \ Item $ item , $ itemFile ) { $ changed = false ; $ responses = $ item -> getResponses ( ) ; $ interactions = $ item -> getInteractions ( ) ; $ usedResponses = [ ] ; foreach ( $ interactions as $ interaction ) { $ usedResponses [ ] = $ interaction -> att... | Remove unused response declaration from the items and rp template misuse |
56,918 | public static function createByTemplate ( $ templateUri , ResponseDeclaration $ response , Item $ item ) { $ returnValue = null ; switch ( $ templateUri ) { case ResponseTemplate :: MATCH_CORRECT : $ returnValue = self :: create ( MatchCorrectTemplate :: CLASS_ID , $ response , $ item ) ; break ; case ResponseTemplate ... | Short description of method createByTemplate |
56,919 | public function extract ( $ resource ) { if ( ! $ resource instanceof \ core_kernel_classes_Resource ) { throw new MetadataExtractionException ( __ ( 'The given target is not an instance of core_kernel_classes_Resource' ) ) ; } $ identifier = \ tao_helpers_Uri :: getUniqueId ( $ resource -> getUri ( ) ) ; $ metadata = ... | Extract resource metadata and transform it to ClassificationMetadataValue |
56,920 | public static function saveCssFile ( \ core_kernel_classes_resource $ item , $ lang , $ styleSheetPath , $ cssArr ) { $ directory = \ taoItems_models_classes_ItemsService :: singleton ( ) -> getItemDirectory ( $ item , $ lang ) ; $ file = $ directory -> getFile ( $ styleSheetPath ) ; if ( empty ( $ cssArr ) && $ file -... | Stores an css array in the file |
56,921 | public static function downloadCssFile ( \ core_kernel_classes_resource $ item , $ lang , $ styleSheetPath ) { $ directory = \ taoItems_models_classes_ItemsService :: singleton ( ) -> getItemDirectory ( $ item , $ lang ) ; $ file = $ directory -> getFile ( $ styleSheetPath ) ; if ( $ file -> exists ( ) ) { return $ fil... | Download existing CSS file |
56,922 | public static function loadCssFile ( \ core_kernel_classes_resource $ item , $ lang , $ styleSheet ) { $ directory = \ taoItems_models_classes_ItemsService :: singleton ( ) -> getItemDirectory ( $ item , $ lang ) ; $ file = $ directory -> getFile ( $ styleSheet ) ; if ( ! $ file -> exists ( ) ) { \ common_Logger :: d (... | Loads the content of a css file into a css array Returns an empty stylesheet if it does not yet exist |
56,923 | public static function getRubricBlocks ( tao_models_classes_service_StorageDirectory $ directory , $ view ) { $ returnValue = array ( ) ; $ elements = self :: getContentVariableElements ( $ directory ) ; foreach ( $ elements as $ serial => $ data ) { if ( isset ( $ data [ 'qtiClass' ] ) && $ data [ 'qtiClass' ] == 'rub... | Get rubric block visible by the given view |
56,924 | public static function getFeedbacks ( tao_models_classes_service_StorageDirectory $ directory , AssessmentItemSession $ itemSession ) { $ returnValue = array ( ) ; $ feedbackClasses = array ( 'modalFeedback' , 'feedbackInline' , 'feedbackBlock' ) ; $ elements = self :: getContentVariableElements ( $ directory ) ; $ out... | Get the feedback to be displayed on an AssessmentItemSession |
56,925 | public function remove ( $ themeIds ) { $ themeIds = ( array ) $ themeIds ; foreach ( $ themeIds as $ themeId ) { $ prefixedId = $ this -> getPrefixedThemeId ( $ themeId ) ; if ( ! $ this -> themeExists ( $ prefixedId ) ) { continue ; } $ this -> registry -> unregisterTheme ( $ prefixedId ) ; } $ this -> logInfo ( 'Ite... | Remove themes from the configuration |
56,926 | public function reset ( ) { $ map = $ this -> registry -> getMap ( ) ; if ( empty ( $ map [ 'items' ] [ 'available' ] ) ) { return false ; } foreach ( $ map [ 'items' ] [ 'available' ] as $ theme ) { if ( $ theme [ 'id' ] === 'tao' || 0 !== strpos ( $ theme [ 'id' ] , $ this -> extensionId ) ) { continue ; } $ this -> ... | Reset the item theme registry to its initial values |
56,927 | public function themeExists ( $ themeId ) { $ prefixedId = $ this -> getPrefixedThemeId ( $ themeId ) ; $ map = $ this -> registry -> getMap ( ) ; if ( empty ( $ map [ 'items' ] [ 'available' ] ) ) { return false ; } foreach ( $ map [ 'items' ] [ 'available' ] as $ theme ) { if ( $ theme [ 'id' ] === $ prefixedId ) { r... | Is a theme already registered? |
56,928 | protected function getPrefixedThemeId ( $ themeId ) { if ( $ themeId === 'tao' ) { return $ themeId ; } if ( preg_match ( '~^' . $ this -> extensionId . '[A-Z]~' , $ themeId ) ) { return $ themeId ; } return $ this -> extensionId . ucfirst ( $ themeId ) ; } | Prefix theme id base on extension id from calling class . Pass through if already prefixed |
56,929 | public static function getQtiFileContent ( core_kernel_classes_Resource $ item , $ language = '' ) { $ itemDirectory = taoItems_models_classes_ItemsService :: singleton ( ) -> getItemDirectory ( $ item , $ language ) ; return $ itemDirectory -> getFile ( self :: FILE ) -> read ( ) ; } | Get content of qti . xml following an item + language |
56,930 | public function getExportForm ( core_kernel_classes_Resource $ resource ) { if ( $ resource instanceof \ core_kernel_classes_Class ) { $ formData = [ 'class' => $ resource ] ; } else { $ formData = [ 'class' => $ this -> getClass ( $ resource ) ] ; } $ form = new MetadataExporterForm ( $ formData ) ; return $ form -> g... | Create MetadataExporterForm with class uri |
56,931 | protected function getClassToExport ( $ uri ) { $ resource = $ this -> getResource ( $ uri ) ; if ( $ resource -> isClass ( ) ) { $ classToExport = $ this -> getClass ( $ uri ) ; } else { $ classToExport = reset ( $ resource -> getTypes ( ) ) ; } return $ classToExport ; } | Get class to export from resource uri or class uri If parameter is null check id http parameter |
56,932 | public function createItem ( ) { if ( ! \ tao_helpers_Request :: isAjax ( ) ) { throw new common_exception_BadRequest ( 'wrong request mode' ) ; } $ clazz = new \ core_kernel_classes_Resource ( $ this -> getRequestParameter ( 'id' ) ) ; if ( $ clazz -> isClass ( ) ) { $ clazz = new \ core_kernel_classes_Class ( $ clazz... | create a new QTI item |
56,933 | protected function getCreatorConfig ( core_kernel_classes_Resource $ item ) { $ config = new CreatorConfig ( ) ; $ ext = \ common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'taoQtiItem' ) ; $ creatorConfig = $ ext -> getConfig ( 'qtiCreator' ) ; if ( is_array ( $ creatorConfig ) ) { foreach ( $ creato... | Get the configuration of the Item Creator |
56,934 | public function addInteraction ( Interaction $ interaction , $ body ) { $ returnValue = false ; if ( ! is_null ( $ interaction ) ) { $ returnValue = $ this -> getBody ( ) -> setElement ( $ interaction , $ body ) ; } return ( bool ) $ returnValue ; } | Short description of method addInteraction |
56,935 | public function removeInteraction ( Interaction $ interaction ) { $ returnValue = false ; if ( ! is_null ( $ interaction ) ) { $ returnValue = $ this -> getBody ( ) -> removeElement ( $ interaction ) ; } return ( bool ) $ returnValue ; } | Short description of method removeInteraction |
56,936 | public function setOutcomes ( $ outcomes ) { $ this -> outcomes = array ( ) ; foreach ( $ outcomes as $ outcome ) { if ( ! $ outcome instanceof OutcomeDeclaration ) { throw new \ InvalidArgumentException ( "wrong entry in outcomes list" ) ; } $ this -> addOutcome ( $ outcome ) ; } } | Short description of method setOutcomes |
56,937 | public function addOutcome ( OutcomeDeclaration $ outcome ) { $ this -> outcomes [ $ outcome -> getSerial ( ) ] = $ outcome ; $ outcome -> setRelatedItem ( $ this ) ; } | add an outcome declaration to the item |
56,938 | public function getOutcome ( $ serial ) { $ returnValue = null ; if ( ! empty ( $ serial ) ) { if ( isset ( $ this -> outcomes [ $ serial ] ) ) { $ returnValue = $ this -> outcomes [ $ serial ] ; } } return $ returnValue ; } | Short description of method getOutcome |
56,939 | public function removeOutcome ( OutcomeDeclaration $ outcome ) { $ returnValue = ( bool ) false ; if ( ! is_null ( $ outcome ) ) { if ( isset ( $ this -> outcomes [ $ outcome -> getSerial ( ) ] ) ) { unset ( $ this -> outcomes [ $ outcome -> getSerial ( ) ] ) ; $ returnValue = true ; } } else { common_Logger :: w ( 'Tr... | Short description of method removeOutcome |
56,940 | public function toXHTML ( $ options = array ( ) , & $ filtered = array ( ) ) { $ template = static :: getTemplatePath ( ) . '/xhtml.item.tpl.php' ; $ variables = $ this -> getAttributeValues ( ) ; $ variables [ 'stylesheets' ] = array ( ) ; foreach ( $ this -> getStylesheets ( ) as $ stylesheet ) { $ variables [ 'style... | Short description of method toXHTML |
56,941 | public function toArray ( $ filterVariableContent = false , & $ filtered = array ( ) ) { $ data = parent :: toArray ( $ filterVariableContent , $ filtered ) ; $ data [ 'namespaces' ] = $ this -> getNamespaces ( ) ; $ data [ 'schemaLocations' ] = $ this -> getSchemaLocations ( ) ; $ data [ 'stylesheets' ] = $ this -> ge... | Serialize item object into json format handy to be used in js |
56,942 | private function isQtiItem ( core_kernel_classes_Resource $ itemResource ) { $ itemService = taoItems_models_classes_ItemsService :: singleton ( ) ; return $ itemService -> hasItemModel ( $ itemResource , [ ItemModel :: MODEL_URI ] ) ; } | Check if the resource in argument is a valid qti item |
56,943 | private function getItemContent ( core_kernel_classes_Resource $ itemResource , $ langCode = '' ) { if ( $ this -> isQtiItem ( $ itemResource ) ) { $ itemContent = Service :: singleton ( ) -> getDataItemByRdfItem ( $ itemResource , $ langCode ) -> toXML ( ) ; if ( ! empty ( $ itemContent ) ) { return simplexml_load_str... | Get the item content for a qti item resource |
56,944 | private function setItemContent ( SimpleXMLElement $ content , core_kernel_classes_Resource $ itemResource ) { if ( $ this -> isQtiItem ( $ itemResource ) ) { return Service :: singleton ( ) -> saveXmlItemToRdfItem ( $ content -> asXML ( ) , $ itemResource ) ; } return false ; } | Set the item content for a qti item resource |
56,945 | public function getBodyStyles ( core_kernel_classes_Resource $ itemResource , $ langCode = '' ) { $ itemContent = $ this -> getItemContent ( $ itemResource , $ langCode ) ; if ( is_null ( $ itemContent ) ) { throw new \ common_Exception ( 'cannot find valid qti item content' ) ; } else { $ classAttr = ( string ) $ item... | Get the array of body style classes set to the itemBody of a qti item |
56,946 | public function addBodyStyles ( $ styleNames , core_kernel_classes_Resource $ itemResource , $ langCode = '' ) { $ itemContent = $ this -> getItemContent ( $ itemResource , $ langCode ) ; if ( ! is_null ( $ itemContent ) && ! empty ( $ styleNames ) ) { $ classAttr = ( string ) $ itemContent -> itemBody [ 'class' ] ; fo... | Add an array of body style classes to the itemBody of a qti item |
56,947 | public function getClassBodyStyles ( core_kernel_classes_Class $ itemClass ) { $ usages = [ ] ; $ union = [ ] ; $ intersect = [ ] ; $ items = $ itemClass -> getInstances ( true ) ; $ i = 0 ; foreach ( $ items as $ item ) { if ( $ this -> isQtiItem ( $ item ) ) { try { $ styles = $ this -> getBodyStyles ( $ item ) ; $ u... | Get an array that give the style usage within an tao item subclasses . It only takes into account qti item with a no - empty content |
56,948 | public function addClassBodyStyles ( $ styleNames , core_kernel_classes_Class $ itemClass , $ recursive = true ) { $ updatedItems = [ ] ; $ items = $ itemClass -> getInstances ( $ recursive ) ; foreach ( $ items as $ item ) { if ( $ this -> isQtiItem ( $ item ) ) { if ( $ this -> addBodyStyles ( $ styleNames , $ item )... | Add an array of body style classes to the itemBody of all qti items in given class |
56,949 | public function removeClassBodyStyles ( $ styleNames , core_kernel_classes_Class $ itemClass , $ recursive = true ) { $ updatedItems = [ ] ; $ items = $ itemClass -> getInstances ( $ recursive ) ; foreach ( $ items as $ item ) { if ( $ this -> isQtiItem ( $ item ) ) { if ( $ this -> removeBodyStyles ( $ styleNames , $ ... | Remove an array of body style classes from the itemBody of all qti items in given class |
56,950 | public function inject ( $ identifier , $ imsManifest ) { if ( ! $ imsManifest instanceof \ DOMDocument ) { throw new MetadataExportException ( __ ( 'Metadata export requires an instance of DomManifest to inject metadata' ) ) ; } parent :: inject ( $ identifier , $ imsManifest ) ; } | Inject an identified metadata value to a dom IMS manifest |
56,951 | protected function registerMetadataService ( ) { $ metadataService = $ this -> getServiceLocator ( ) -> get ( MetadataService :: SERVICE_ID ) ; $ metadataService -> setOption ( MetadataService :: EXPORTER_KEY , $ this ) ; $ this -> getServiceManager ( ) -> register ( MetadataService :: SERVICE_ID , $ metadataService ) ... | Allow to register into the config the current exporter service |
56,952 | public function loadAssetHandler ( $ assetHandler ) { if ( ! $ assetHandler instanceof AssetHandler ) { throw new AssetManagerException ( 'Asset handler "' . get_class ( $ assetHandler ) . '" is not supported by AssetManager' ) ; } $ this -> assetHandlers [ ] = $ assetHandler ; return $ this ; } | Load an asset handler associated |
56,953 | public function importAuxiliaryFiles ( QtiResource $ qtiItemResource ) { $ qtiFile = $ this -> getSource ( ) . \ helpers_File :: urlToPath ( $ qtiItemResource -> getFile ( ) ) ; foreach ( $ qtiItemResource -> getAuxiliaryFiles ( ) as $ auxiliaryFile ) { $ absolutePath = $ this -> getAbsolutePath ( $ auxiliaryFile ) ; $... | Import auxiliaryFile e . q . css js ... |
56,954 | public function importDependencyFiles ( QtiResource $ qtiItemResource , $ dependencies ) { $ qtiFile = $ this -> getSource ( ) . \ helpers_File :: urlToPath ( $ qtiItemResource -> getFile ( ) ) ; foreach ( $ qtiItemResource -> getDependencies ( ) as $ dependenciesFile ) { if ( ! isset ( $ dependencies [ $ dependenciesF... | Import dependencies files |
56,955 | public function toForm ( ) { $ returnValue = null ; $ choiceFormClass = '\\oat\\taoQtiItem\\controller\\QTIform\\choice\\' . ucfirst ( static :: $ qtiTagName ) ; if ( ! class_exists ( $ choiceFormClass ) ) { throw new QtiModelException ( "the class {$choiceFormClass} does not exist" ) ; } else { $ formContainer = new $... | Return the form to edit the current instance |
56,956 | public static function isAllowed ( $ type ) { return ( ! empty ( $ type ) && ( in_array ( $ type , self :: $ allowedTypes ) ) ) || self :: isAssessmentItem ( $ type ) || self :: isAssessmentTest ( $ type ) ; } | Check if the given type is allowed as a QTI Resource |
56,957 | public function toJSON ( ) { $ outcomeValue = null ; if ( $ this -> defaultValue != '' ) { $ outcomeValue = Array ( $ this -> defaultValue ) ; } else if ( $ this -> getAttributeValue ( 'baseType' ) == 'integer' || $ this -> getAttributeValue ( 'baseType' ) == 'float' ) { $ outcomeValue = Array ( 0 ) ; } else { $ outcom... | get the outcome in JSON format |
56,958 | public function getUserMessage ( ) { $ requestedUri = $ this -> getRequestedUri ( ) ; if ( empty ( $ requestedUri ) === true ) { return __ ( 'An unexpected error occured while dealing with Response Processing.' ) ; } else { return __ ( 'The Response Processing Template "%s" is not supported.' , $ this -> getRequestedUr... | Returns a human - readable message describing the error that occured . |
56,959 | public function unregisterFiles ( PortableElementObject $ object , $ files ) { $ deleted = true ; $ filesystem = $ this -> getFileStorage ( ) ; foreach ( $ files as $ relPath ) { $ fileId = $ this -> getPrefix ( $ object ) . $ relPath ; if ( ! $ filesystem -> has ( $ fileId ) ) { throw new \ common_Exception ( 'File do... | Unregister files by removing them from FileSystem |
56,960 | public function getAllStyles ( ) { $ styles = [ ] ; foreach ( self :: getRegistry ( ) -> getMap ( ) as $ id => $ styleData ) { $ styles [ $ id ] = $ styleData ; } return $ styles ; } | Get all styles available from the registry |
56,961 | public function register ( $ id , $ styleData ) { if ( self :: getRegistry ( ) -> isRegistered ( $ id ) ) { common_Logger :: w ( 'Style already registered' ) ; } if ( $ this -> isValidStyleData ( $ styleData ) ) { self :: getRegistry ( ) -> set ( $ id , $ styleData ) ; } else { common_Logger :: w ( 'Invalid style data ... | Register a style |
56,962 | public function setElement ( Element $ qtiElement , $ body = '' , $ integrityCheck = true , $ requiredPlaceholder = true ) { return $ this -> setElements ( array ( $ qtiElement ) , $ body , $ integrityCheck , $ requiredPlaceholder ) ; } | add one qtiElement into the body if the body content is not specified it appends to the end |
56,963 | public function edit ( $ body , $ integrityCheck = false ) { if ( ! is_string ( $ body ) ) { throw new InvalidArgumentException ( 'a QTI container must have a body of string type' ) ; } if ( $ integrityCheck && ! $ this -> checkIntegrity ( $ body ) ) { return false ; } $ this -> body = $ body ; return true ; } | modify the content of the body |
56,964 | public function checkIntegrity ( $ body , & $ missingElements = null ) { $ returnValue = true ; foreach ( $ this -> elements as $ element ) { if ( strpos ( $ body , $ element -> getPlaceholder ( ) ) === false ) { $ returnValue = false ; if ( is_array ( $ missingElements ) ) { $ missingElements [ $ element -> getSerial ... | Check if modifying the body won t have an element placeholder deleted |
56,965 | public function getElement ( $ serial ) { $ returnValue = null ; if ( isset ( $ this -> elements [ $ serial ] ) ) { $ returnValue = $ this -> elements [ $ serial ] ; } return $ returnValue ; } | Get the element by its serial |
56,966 | public function getElements ( $ className = '' ) { $ returnValue = array ( ) ; if ( $ className ) { foreach ( $ this -> elements as $ serial => $ element ) { if ( $ element instanceof $ className ) { $ returnValue [ $ serial ] = $ element ; } } } else { $ returnValue = $ this -> elements ; } return $ returnValue ; } | Get all elements of the given type Returns all elements if class name is not specified |
56,967 | public function toQTI ( ) { $ returnValue = $ this -> getBody ( ) ; foreach ( $ this -> elements as $ element ) { $ returnValue = str_replace ( $ element -> getPlaceholder ( ) , $ element -> toQTI ( ) , $ returnValue ) ; } return ( string ) $ returnValue ; } | Export the data to QTI XML format |
56,968 | public function importDeferred ( ) { try { if ( $ this -> getRequestMethod ( ) != Request :: HTTP_POST ) { throw new \ common_exception_NotImplemented ( 'Only post method is accepted to import Qti package.' ) ; } $ task = ImportQtiItem :: createTask ( $ this -> getUploadedPackage ( ) , $ this -> getDestinationClass ( )... | Import item package through the task queue . |
56,969 | protected function addExtraReturnData ( EntityInterface $ taskLogEntity ) { $ data = [ ] ; if ( $ taskLogEntity -> getReport ( ) ) { $ plainReport = $ this -> getPlainReport ( $ taskLogEntity -> getReport ( ) ) ; $ itemsReport = array_slice ( $ plainReport , 2 ) ; foreach ( $ itemsReport as $ itemReport ) { if ( isset ... | Add extra values to the JSON returned . |
56,970 | protected function getUploadedPackage ( ) { if ( ! $ this -> hasRequestParameter ( self :: RESTITEM_PACKAGE_NAME ) ) { throw new \ common_exception_MissingParameter ( self :: RESTITEM_PACKAGE_NAME , __CLASS__ ) ; } $ file = \ tao_helpers_Http :: getUploadedFile ( self :: RESTITEM_PACKAGE_NAME ) ; if ( ! in_array ( $ fi... | Return a valid uploaded file |
56,971 | public function createQtiItem ( ) { try { if ( $ this -> getRequestMethod ( ) != Request :: HTTP_POST ) { throw new \ common_exception_NotImplemented ( 'Only post method is accepted to create empty item.' ) ; } $ label = $ this -> hasRequestParameter ( 'label' ) ? $ this -> getRequestParameter ( 'label' ) : '' ; $ item... | Create an empty item |
56,972 | public function export ( ) { try { if ( $ this -> getRequestMethod ( ) != Request :: HTTP_GET ) { throw new \ common_exception_NotImplemented ( 'Only GET method is accepted to export QIT Item.' ) ; } if ( ! $ this -> hasRequestParameter ( 'id' ) ) { $ this -> returnFailure ( new \ common_exception_MissingParameter ( 'r... | render an item as a Qti zip package |
56,973 | public function createClass ( ) { try { $ class = $ this -> createSubClass ( new \ core_kernel_classes_Class ( TaoOntology :: ITEM_CLASS_URI ) ) ; $ result = [ 'message' => __ ( 'Class successfully created.' ) , 'class-uri' => $ class -> getUri ( ) , ] ; $ this -> returnSuccess ( $ result ) ; } catch ( \ common_excepti... | Create an Item Class |
56,974 | public static function getResourcesFromManifest ( SimpleXMLElement $ source ) { $ returnValue = array ( ) ; if ( $ source -> getName ( ) != 'manifest' ) { throw new ParsingException ( "incorrect manifest root tag" ) ; } $ resourceNodes = $ source -> xpath ( "//*[name(.)='resource']" ) ; foreach ( $ resourceNodes as $ r... | Enables you to build the QTI_Resources from a manifest xml data node Content Packaging 1 . 1 ) |
56,975 | public function resetAttributes ( ) { $ this -> attributes = array ( ) ; foreach ( $ this -> getUsedAttributes ( ) as $ attributeClass ) { if ( class_exists ( $ attributeClass ) && is_subclass_of ( $ attributeClass , 'oat\\taoQtiItem\\model\\qti\\attribute\\Attribute' ) ) { $ attribute = new $ attributeClass ( ) ; $ th... | Reset the attributes values to the default values defined by the standard |
56,976 | public function removeAttributeValue ( $ name ) { if ( isset ( $ this -> attributes [ $ name ] ) ) { $ this -> attributes [ $ name ] -> setNull ( ) ; } } | Remove the actual value of an attribute distinguish from empty value |
56,977 | public function setAttribute ( $ name , $ value ) { $ returnValue = false ; if ( is_null ( $ value ) ) { return $ returnValue ; } if ( isset ( $ this -> attributes [ $ name ] ) ) { $ datatypeClass = $ this -> attributes [ $ name ] -> getType ( ) ; if ( is_subclass_of ( $ datatypeClass , 'oat\\taoQtiItem\\model\\qti\\da... | Set the value of an attribute |
56,978 | public function addClass ( $ className ) { $ oldClassName = $ this -> getAttributeValue ( 'class' ) ; $ oldClassNameArr = $ oldClassName ? explode ( ' ' , $ oldClassName ) : array ( ) ; $ classNameArr = array_merge ( $ oldClassNameArr , explode ( ' ' , $ className ) ) ; $ classNameArr = array_unique ( array_filter ( ar... | Add a CSS class to the item body |
56,979 | public function removeClass ( $ className ) { $ oldClassName = $ this -> getAttributeValue ( 'class' ) ; $ oldClassNameArr = $ oldClassName ? explode ( ' ' , $ oldClassName ) : array ( ) ; unset ( $ oldClassNameArr [ array_search ( $ className , $ oldClassNameArr ) ] ) ; $ this -> setAttribute ( 'class' , implode ( ' '... | Add a CSS class from the item body |
56,980 | public function getAttributeValues ( $ filterNull = true ) { $ returnValue = array ( ) ; foreach ( $ this -> attributes as $ name => $ attribute ) { if ( ! $ filterNull || ! $ attribute -> isNull ( ) ) { $ returnValue [ $ name ] = $ attribute -> getValue ( ) ; } } return $ returnValue ; } | Get all attributes values |
56,981 | public static function getTemplateQti ( ) { if ( empty ( static :: $ qtiTagName ) ) { throw new QtiModelException ( 'The element has no tag name defined : ' . get_called_class ( ) ) ; } $ template = static :: getTemplatePath ( ) . '/qti.' . static :: $ qtiTagName . '.tpl.php' ; if ( ! file_exists ( $ template ) ) { $ t... | Get the absolute path of the template of the qti . xml |
56,982 | protected function getTemplateQtiVariables ( ) { $ variables = array ( ) ; $ variables [ 'tag' ] = static :: $ qtiTagName ; $ variables [ 'attributes' ] = $ this -> getAttributeValues ( ) ; if ( $ this instanceof FlowContainer ) { $ variables [ 'body' ] = $ this -> getBody ( ) -> toQTI ( ) ; } return $ variables ; } | Get the variables to be used in the qti . xml template |
56,983 | public function toQTI ( ) { $ template = static :: getTemplateQti ( ) ; $ variables = $ this -> getTemplateQtiVariables ( ) ; if ( isset ( $ variables [ 'attributes' ] ) ) { $ variables [ 'attributes' ] = $ this -> xmlizeOptions ( $ variables [ 'attributes' ] , true ) ; } $ tplRenderer = new taoItems_models_classes_Tem... | Export the data to the QTI XML format |
56,984 | public static function getTemplatePath ( ) { if ( empty ( self :: $ templatesPath ) ) { $ dir = \ common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'taoQtiItem' ) -> getDir ( ) ; self :: $ templatesPath = $ dir . 'model/qti/templates/' ; } $ returnValue = self :: $ templatesPath ; return ( string ) $ ... | Get the main template directory |
56,985 | public function getComposingElements ( $ className = '' ) { $ returnValue = array ( ) ; if ( $ className === '' ) { $ className = 'oat\taoQtiItem\model\qti\Element' ; } $ reflection = new ReflectionClass ( $ this ) ; foreach ( $ reflection -> getProperties ( ) as $ property ) { if ( ! $ property -> isStatic ( ) && ! $ ... | Recursively get all Qti Elements contained within the current Qti Element |
56,986 | protected function xmlizeOptions ( $ formalOpts = array ( ) , $ recursive = false ) { $ returnValue = ( string ) '' ; if ( ! is_array ( $ formalOpts ) ) { throw new InvalidArgumentException ( 'formalOpts must be an array, ' . gettype ( $ formalOpts ) . ' given' ) ; } $ options = ( ! $ recursive ) ? $ this -> getAttribu... | This method enables you to build a string of attributes for an xml node from the Qti Element attributes according to their types . |
56,987 | public function getSerial ( ) { if ( empty ( $ this -> serial ) ) { $ this -> serial = $ this -> buildSerial ( ) ; } $ returnValue = $ this -> serial ; return ( string ) $ returnValue ; } | Obtain a serial for the instance of the class that implements the |
56,988 | protected function buildSerial ( ) { if ( DEBUG_MODE ) { $ clazz = strtolower ( get_class ( $ this ) ) ; $ prefix = substr ( $ clazz , strpos ( $ clazz , 'taoqtiitem\\model\\qti\\' ) + 21 ) . '_' ; $ serial = str_replace ( '.' , '' , uniqid ( $ prefix , true ) ) ; $ serial = str_replace ( '\\' , '_' , $ serial ) ; } el... | create a unique serial number |
56,989 | protected function containsItem ( ) { $ found = false ; if ( $ this -> hasManifest ( ) ) { foreach ( $ this -> getManifest ( ) -> getElementsByTagName ( 'resource' ) as $ resourceNode ) { if ( $ resourceNode -> getAttribute ( 'identifier' ) == $ this -> buildIdentifier ( ) ) { $ found = true ; break ; } } } return $ fo... | Whenever the item is already in the manifest |
56,990 | public static function getCustomInteractions ( ) { $ taoQtiItem = common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'taoQtiItem' ) ; $ map = $ taoQtiItem -> getConfig ( self :: CONFIG_ID ) ; return is_array ( $ map ) ? $ map : array ( ) ; } | Returns a list of registered custom interactions . |
56,991 | public static function getCustomInteractionByName ( $ name ) { $ all = self :: getCustomInteractions ( ) ; if ( isset ( $ all [ $ name ] ) ) { return $ all [ $ name ] ; } return '' ; } | Get the php class that represents a custom interaction from its class attribute |
56,992 | public function importPortableElementFile ( $ absolutePath , $ relativePath ) { if ( $ this -> isPortableElementAsset ( $ relativePath ) ) { $ this -> importingFiles [ ] = $ relativePath ; return $ this -> getFileInfo ( $ absolutePath , $ relativePath ) ; } else { throw new \ common_Exception ( 'trying to import an ass... | Handle pci import process for a file |
56,993 | public function getFileInfo ( $ path , $ relPath ) { if ( file_exists ( $ path ) ) { return array ( 'name' => basename ( $ path ) , 'uri' => $ relPath , 'mime' => \ tao_helpers_File :: getMimeType ( $ path ) , 'filePath' => $ path , 'size' => filesize ( $ path ) , ) ; } throw new \ tao_models_classes_FileNotFoundExcept... | Get details about file |
56,994 | protected function feedRequiredFiles ( Item $ item ) { $ this -> requiredFiles = [ ] ; $ this -> portableObjects = [ ] ; $ this -> picModels = [ ] ; $ models = $ this -> getPortableFactory ( ) -> getModels ( ) ; foreach ( $ models as $ model ) { $ className = $ model -> getQtiElementClassName ( ) ; $ portableElementsXm... | Feed the instance with portable related data extracted from the item |
56,995 | public function importPortableElements ( ) { if ( count ( $ this -> importingFiles ) != count ( $ this -> requiredFiles ) ) { throw new \ common_Exception ( 'Needed files are missing during Portable Element asset files ' . print_r ( $ this -> requiredFiles , true ) . ' ' . print_r ( $ this -> importingFiles , true ) ) ... | Do the import of portable elements |
56,996 | private function replaceLibAliases ( PortableElementObject $ object ) { $ id = $ object -> getTypeIdentifier ( ) ; $ object -> setRuntimeKey ( 'libraries' , array_map ( function ( $ lib ) use ( $ id ) { if ( preg_match ( '/^' . $ id . '/' , $ lib ) ) { return $ lib . '.js' ; } return $ lib ; } , $ object -> getRuntimeK... | Replace the libs aliases with their relative url before saving into the registry This format is consistent with the format of TAO portable package manifest |
56,997 | public static function catchItemRdfUpdatedEvent ( ItemRdfUpdatedEvent $ event ) { $ rdfItem = new core_kernel_classes_Resource ( $ event -> getItemUri ( ) ) ; $ type = $ rdfItem -> getProperty ( taoItems_models_classes_ItemsService :: PROPERTY_ITEM_MODEL ) ; $ directory = taoItems_models_classes_ItemsService :: singlet... | synchronise item label |
56,998 | public function setNamespace ( $ namespace ) { if ( is_string ( $ namespace ) === false ) { $ msg = "The namespace argument must be a string." ; throw new InvalidArgumentException ( $ msg ) ; } elseif ( $ namespace === '' ) { $ msg = "The namespace argument must be a non-empty string." ; throw new InvalidArgumentExcept... | Set the XML namespace of the mapping . |
56,999 | public function setPrefix ( $ prefix ) { if ( is_string ( $ prefix ) === false ) { $ msg = "The prefix argument must be a string." ; throw new InvalidArgumentException ( $ msg ) ; } elseif ( $ prefix === '' ) { $ msg = "The prefix argument must be a non-empty string." ; throw new InvalidArgumentException ( $ msg ) ; } ... | Set the XML prefix of the mapping . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.