idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
2,900
public static function file ( $ input ) { if ( Symphony :: Log ( ) ) { Symphony :: Log ( ) -> pushDeprecateWarningToLog ( 'SHA1::file()' , 'PBKDF2::hash()' , array ( 'message-format' => __ ( 'The use of `%s` is strongly discouraged due to severe security flaws.' ) , ) ) ; } return sha1_file ( $ input ) ; }
Uses SHA1 to create a hash from the contents of a file
2,901
public function getHttpStatusCode ( ) { if ( $ this -> _status != null ) { $ this -> setHttpStatus ( $ this -> _status ) ; } if ( isset ( $ this -> _headers [ 'status' ] ) ) { return $ this -> _headers [ 'status' ] [ 'response_code' ] ; } return self :: HTTP_STATUS_OK ; }
Gets the current HTTP Status . If none is set it assumes HTTP_STATUS_OK
2,902
public function isRequestValid ( ) { $ max_size = @ ini_get ( 'post_max_size' ) ; if ( ! $ max_size ) { return true ; } if ( server_safe ( 'REQUEST_METHOD' ) === 'POST' && ( int ) server_safe ( 'CONTENT_LENGTH' ) > General :: convertHumanFileSizeToBytes ( $ max_size ) ) { return false ; } return true ; }
This function will check to ensure that this post request is not larger than what the server is set to handle . If it is a notice is shown .
2,903
public function getSortingOrder ( ) { $ result = Symphony :: Configuration ( ) -> get ( 'section_' . $ this -> get ( 'handle' ) . '_order' , 'sorting' ) ; return ( is_null ( $ result ) ? 'asc' : $ result ) ; }
Returns the sort order for this Section . Defaults to asc .
2,904
public function setSortingField ( $ sort , $ write = true ) { Symphony :: Configuration ( ) -> set ( 'section_' . $ this -> get ( 'handle' ) . '_sortby' , $ sort , 'sorting' ) ; if ( $ write ) { Symphony :: Configuration ( ) -> write ( ) ; } }
Saves the new field this Section will be sorted by .
2,905
public function setSortingOrder ( $ order , $ write = true ) { Symphony :: Configuration ( ) -> set ( 'section_' . $ this -> get ( 'handle' ) . '_order' , $ order , 'sorting' ) ; if ( $ write ) { Symphony :: Configuration ( ) -> write ( ) ; } }
Saves the new sort order for this Section .
2,906
public function fetchFields ( $ type = null , $ location = null ) { return FieldManager :: fetch ( null , $ this -> get ( 'id' ) , 'ASC' , 'sortorder' , $ type , $ location ) ; }
Returns an array of all the fields in this section optionally filtered by the field type or it s location within the section .
2,907
public function fetchFilterableFields ( $ location = null ) { return FieldManager :: fetch ( null , $ this -> get ( 'id' ) , 'ASC' , 'sortorder' , null , $ location , null , Field :: __FILTERABLE_ONLY__ ) ; }
Returns an array of all the fields that can be filtered .
2,908
public function fetchToggleableFields ( $ location = null ) { return FieldManager :: fetch ( null , $ this -> get ( 'id' ) , 'ASC' , 'sortorder' , null , $ location , null , Field :: __TOGGLEABLE_ONLY__ ) ; }
Returns an array of all the fields that can be toggled . This function is used to help build the With Selected drop downs on the Publish Index pages
2,909
public function commit ( ) { $ settings = $ this -> _data ; if ( isset ( $ settings [ 'id' ] ) ) { $ id = $ settings [ 'id' ] ; unset ( $ settings [ 'id' ] ) ; $ section_id = SectionManager :: edit ( $ id , $ settings ) ; if ( $ section_id ) { $ section_id = $ id ; } } else { $ section_id = SectionManager :: add ( $ se...
Commit the settings of this section from the section editor to create an instance of this section in tbl_sections . This function loops of each of the fields in this section and calls their commit function .
2,910
public function display ( $ page ) { self :: $ _page = new FrontendPage ; Symphony :: ExtensionManager ( ) -> notifyMembers ( 'FrontendInitialised' , '/frontend/' ) ; $ output = self :: $ _page -> generate ( $ page ) ; return $ output ; }
Called by index . php this function is responsible for rendering the current page on the Frontend . One delegate is fired FrontendInitialised
2,911
public static function render ( $ e ) { $ page = PageManager :: fetchPageByType ( '404' ) ; $ previous_exception = Frontend :: instance ( ) -> getException ( ) ; if ( is_null ( $ page [ 'id' ] ) ) { parent :: render ( new SymphonyErrorPage ( $ e -> getMessage ( ) , __ ( 'Page Not Found' ) , 'generic' , array ( ) , Page...
The render function will take a FrontendPageNotFoundException Exception and output a HTML page . This function first checks to see if their is a page in Symphony that has been given the 404 page type otherwise it will just use the default Symphony error page template to output the exception
2,912
public static function initialiseLang ( ) { $ lang = ! empty ( $ _REQUEST [ 'lang' ] ) ? preg_replace ( '/[^a-zA-Z\-]/' , null , $ _REQUEST [ 'lang' ] ) : 'en' ; Lang :: initialize ( ) ; Lang :: set ( $ lang , false ) ; }
Initialises the language by looking at the lang key passed via GET or POST
2,913
public static function buildFilterElement ( $ name , $ status , $ message = null , array $ attributes = null ) { $ filter = new XMLElement ( 'filter' , ( ! $ message || is_object ( $ message ) ? null : $ message ) , array ( 'name' => $ name , 'status' => $ status ) ) ; if ( $ message instanceof XMLElement ) { $ filter ...
This method will construct XML that represents the result of an Event filter .
2,914
public static function appendErrors ( XMLElement $ result , array $ fields , $ errors , $ post_values ) { $ result -> setAttribute ( 'result' , 'error' ) ; $ result -> appendChild ( new XMLElement ( 'message' , __ ( 'Entry encountered errors when saving.' ) , array ( 'message-id' => EventMessages :: ENTRY_ERRORS ) ) ) ...
Appends errors generated from fields during the execution of an Event
2,915
public static function createError ( Field $ field , $ type , $ message = null ) { $ error = new XMLElement ( $ field -> get ( 'element_name' ) , null , array ( 'label' => General :: sanitize ( $ field -> get ( 'label' ) ) , 'type' => $ type , 'message-id' => ( $ type === 'missing' ) ? EventMessages :: FIELD_MISSING : ...
Given a Field instance the type of error and the message this function creates an XMLElement node so that it can be added to the ?debug for the Event
2,916
public static function __reduceType ( $ a , $ b ) { if ( is_array ( $ b ) ) { return array_reduce ( $ b , array ( 'SectionEvent' , '__reduceType' ) ) ; } return ( strlen ( trim ( $ b ) ) === 0 ) ? 'missing' : 'invalid' ; }
Helper method to determine if a field is missing or if the data provided was invalid . Used in conjunction with array_reduce .
2,917
protected function processPreSaveFilters ( XMLElement $ result , array & $ fields , XMLElement & $ post_values , $ entry_id = null ) { $ can_proceed = true ; Symphony :: ExtensionManager ( ) -> notifyMembers ( 'EventPreSaveFilter' , '/frontend/' , array ( 'fields' => & $ fields , 'event' => & $ this , 'messages' => & $...
Processes all extensions attached to the EventPreSaveFilter delegate
2,918
protected function processPostSaveFilters ( XMLElement $ result , array $ fields , Entry $ entry = null ) { Symphony :: ExtensionManager ( ) -> notifyMembers ( 'EventPostSaveFilter' , '/frontend/' , array ( 'entry_id' => $ entry -> get ( 'id' ) , 'fields' => $ fields , 'entry' => $ entry , 'event' => & $ this , 'messag...
Processes all extensions attached to the EventPostSaveFilter delegate
2,919
public static function parseDate ( $ string , $ direction = null , $ equal_to = false ) { $ parts = array ( 'start' => null , 'end' => null ) ; if ( preg_match ( '/^\d{1,4}$/' , $ string , $ matches ) ) { $ year = current ( $ matches ) ; $ parts [ 'start' ] = "$year-01-01 00:00:00" ; $ parts [ 'end' ] = "$year-12-31 23...
Given a string this function builds the range of dates that match it . The strings should be in ISO8601 style format or a natural date such as last week etc .
2,920
public static function isEqualTo ( array $ parts , $ direction , $ equal_to = false ) { if ( ! $ equal_to ) { return $ parts ; } if ( $ direction == 'later' ) { $ parts [ 'end' ] = $ parts [ 'start' ] ; } else { $ parts [ 'start' ] = $ parts [ 'end' ] ; } return $ parts ; }
Builds the correct date array depending if the filter should include the filter as well ie . later than 2011 is effectively the same as equal to or later than 2012 .
2,921
public function insertBreadcrumbs ( array $ values ) { if ( empty ( $ values ) ) { return ; } if ( $ this -> Breadcrumbs instanceof XMLElement && count ( $ this -> Breadcrumbs -> getChildrenByName ( 'nav' ) ) === 1 ) { $ nav = $ this -> Breadcrumbs -> getChildrenByName ( 'nav' ) ; $ nav = $ nav [ 0 ] ; $ p = $ nav -> g...
Allows developers to specify a list of nav items that build the path to the current page or in jargon breadcrumbs .
2,922
public function insertDrawer ( XMLElement $ drawer , $ position = 'horizontal' , $ button = 'append' ) { $ drawer -> addClass ( $ position ) ; $ drawer -> setAttribute ( 'data-position' , $ position ) ; $ drawer -> setAttribute ( 'role' , 'complementary' ) ; $ this -> Drawer [ $ position ] [ ] = $ drawer ; if ( in_arra...
Allows a Drawer element to added to the backend page in one of three positions horizontal vertical - left or vertical - right . The button to trigger the visibility of the drawer will be added after existing actions by default .
2,923
public function doesAuthorHaveAccess ( $ item_limit = null ) { $ can_access = false ; if ( ! isset ( $ item_limit ) || $ item_limit === 'author' ) { $ can_access = true ; } elseif ( $ item_limit === 'developer' && Symphony :: Author ( ) -> isDeveloper ( ) ) { $ can_access = true ; } elseif ( $ item_limit === 'manager' ...
Given the limit of the current navigation item or page this function returns if the current Author can access that item or not .
2,924
private function __appendBodyClass ( array $ context = array ( ) ) { $ body_class = '' ; foreach ( $ context as $ key => $ value ) { if ( is_numeric ( $ value ) ) { $ value = 'id-' . $ value ; } elseif ( ! is_numeric ( $ key ) && isset ( $ value ) ) { if ( is_array ( $ value ) ) { $ value = null ; } else { $ value = st...
Given the context of the current page which is an associative array this function will append the values to the page s body as classes . If an context value is numeric it will be prepended by id - otherwise all classes will be prefixed by the context key .
2,925
public function sortAlerts ( $ a , $ b ) { if ( $ a -> { 'type' } === $ b -> { 'type' } ) { return 0 ; } if ( ( $ a -> { 'type' } === Alert :: ERROR && $ a -> { 'type' } !== $ b -> { 'type' } ) || ( $ a -> { 'type' } === Alert :: SUCCESS && $ b -> { 'type' } === Alert :: NOTICE ) ) { return - 1 ; } return 1 ; }
Errors first success next then notices .
2,926
private static function createChildNavItem ( $ item , $ extension_handle ) { if ( ! isset ( $ item [ 'relative' ] ) || $ item [ 'relative' ] === true ) { $ link = '/extension/' . $ extension_handle . '/' . ltrim ( $ item [ 'link' ] , '/' ) ; } else { $ link = '/' . ltrim ( $ item [ 'link' ] , '/' ) ; } $ nav_item = arr...
This function builds out a navigation menu item for children . Children live under a parent navigation item and are shown on hover .
2,927
private static function __navigationFindGroupIndex ( array $ nav , $ group ) { foreach ( $ nav as $ index => $ item ) { if ( $ item [ 'name' ] === $ group ) { return $ index ; } } return false ; }
Given an associative array representing the navigation and a group this function will attempt to return the index of the group in the navigation array . If it is found it will return the index otherwise it will return false .
2,928
public function addTimestampValidationPageAlert ( $ errorMessage , $ existingObject , $ action ) { $ authorId = $ existingObject -> get ( 'modification_author_id' ) ; if ( ! $ authorId ) { $ authorId = $ existingObject -> get ( 'author_id' ) ; } $ author = AuthorManager :: fetchByID ( $ authorId ) ; $ formatteAuthorNam...
Adds a localized Alert message for failed timestamp validations . It also adds meta information about the last author and timestamp .
2,929
public static function initialize ( ) { self :: $ _dictionary = array ( ) ; if ( empty ( self :: $ _datetime_dictionary ) ) { self :: $ _datetime_dictionary = include LANG . '/datetime.php' ; } if ( empty ( self :: $ _transliterations ) ) { self :: $ _transliterations = include LANG . '/transliterations.php' ; } if ( e...
Initialize transliterations datetime dictionary and languages array .
2,930
private static function createLanguage ( $ code , $ name , $ handle = null , array $ extensions = array ( ) ) { return array ( $ code => array ( 'name' => $ name , 'handle' => $ handle , 'extensions' => $ extensions ) ) ; }
Create an array of Language information for internal use .
2,931
public static function set ( $ code , $ checkStatus = true ) { if ( ! $ code || $ code == self :: get ( ) ) { return ; } if ( $ code !== 'en' && ( self :: isLanguageEnabled ( $ code ) || $ checkStatus === false ) ) { self :: $ _lang = $ code ; self :: $ _dictionary = array ( ) ; self :: load ( vsprintf ( '%s/lang_%s/la...
Set system language load translations for core and extensions . If the specified language cannot be found Symphony will default to English .
2,932
public static function isLanguageEnabled ( $ code ) { if ( $ code == 'en' ) { return true ; } $ handle = ( isset ( self :: $ _languages [ $ code ] ) ) ? self :: $ _languages [ $ code ] [ 'handle' ] : '' ; $ enabled_extensions = array ( ) ; if ( class_exists ( 'Symphony' , false ) && ( ! is_null ( Symphony :: ExtensionM...
Given a valid language code this function checks if the language is enabled .
2,933
public static function getAvailableLanguages ( $ checkStatus = true ) { $ languages = array ( ) ; foreach ( self :: $ _languages as $ key => $ language ) { if ( self :: isLanguageEnabled ( $ key ) || ( $ checkStatus === false && isset ( $ language [ 'handle' ] ) ) ) { $ languages [ $ key ] = $ language [ 'name' ] ; } }...
Get an array of the codes and names of all languages that are available system wide .
2,934
public static function localizeDate ( $ string ) { if ( self :: isLocalized ( ) ) { foreach ( self :: $ _datetime_dictionary as $ value ) { $ string = preg_replace ( '/\b' . $ value . '\b/i' , self :: translate ( $ value ) , $ string ) ; } } return $ string ; }
Localize dates .
2,935
public static function standardizeDate ( $ string ) { if ( self :: isLocalized ( ) ) { foreach ( self :: $ _datetime_dictionary as $ values ) { $ string = preg_replace ( '/\b' . self :: translate ( $ values ) . '\b/i' . ( self :: isUnicodeCompiled ( ) === true ? 'u' : null ) , $ values , $ string ) ; } $ separator = Sy...
Standardize dates .
2,936
protected function unmarshallChildrenKnown ( DOMElement $ element , QtiComponentCollection $ children ) { if ( ( $ caseSensitive = $ this -> getDOMElementAttributeAs ( $ element , 'caseSensitive' , 'boolean' ) ) !== null ) { $ object = new StringMatch ( $ children , $ caseSensitive ) ; if ( ( $ substring = $ this -> ge...
Unmarshall a QTI stringMatch operator element into an StringMatch object .
2,937
public function load ( $ uri , $ validate = false ) { $ this -> loadImplementation ( $ uri , $ validate , false ) ; $ this -> setUrl ( $ uri ) ; }
Load a QTI - XML assessment file . The file will be loaded and represented in an AssessmentTest object .
2,938
protected function saveImplementation ( $ uri = '' , $ formatOutput = true ) { $ qtiComponent = $ this -> getDocumentComponent ( ) ; if ( ! empty ( $ qtiComponent ) ) { $ this -> setDomDocument ( new DOMDocument ( '1.0' , 'UTF-8' ) ) ; if ( $ formatOutput == true ) { $ this -> getDomDocument ( ) -> formatOutput = true ...
Implementation of save .
2,939
public function schemaValidate ( $ filename = '' ) { if ( empty ( $ filename ) ) { $ filename = XmlUtils :: getSchemaLocation ( $ this -> getVersion ( ) ) ; } if ( is_readable ( $ filename ) ) { $ oldErrorConfig = libxml_use_internal_errors ( true ) ; $ doc = $ this -> getDomDocument ( ) ; if ( @ $ doc -> schemaValidat...
Validate the document against a schema .
2,940
public function xInclude ( $ validate = false ) { if ( ( $ root = $ this -> getDocumentComponent ( ) ) !== null ) { $ baseUri = str_replace ( '\\' , '/' , $ this -> getDomDocument ( ) -> documentElement -> baseURI ) ; $ pathinfo = pathinfo ( $ baseUri ) ; $ basePath = $ pathinfo [ 'dirname' ] ; $ iterator = new QtiComp...
Resolve include components .
2,941
public function resolveTemplateLocation ( $ validate = false ) { if ( ( $ root = $ this -> getDocumentComponent ( ) ) !== null ) { if ( $ root instanceof AssessmentItem && ( $ responseProcessing = $ root -> getResponseProcessing ( ) ) !== null && ( $ templateLocation = $ responseProcessing -> getTemplateLocation ( ) ) ...
Resolve responseProcessing elements with template location .
2,942
public function includeAssessmentSectionRefs ( $ validate = false ) { if ( ( $ root = $ this -> getDocumentComponent ( ) ) !== null ) { $ baseUri = str_replace ( '\\' , '/' , $ this -> getDomDocument ( ) -> documentElement -> baseURI ) ; $ pathinfo = pathinfo ( $ baseUri ) ; $ basePath = $ pathinfo [ 'dirname' ] ; $ co...
Include assessmentSectionRefs component in the current document .
2,943
protected function decorateRootElement ( DOMElement $ rootElement ) { $ xsdLocation = 'http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1.xsd' ; $ xmlns = "http://www.imsglobal.org/xsd/imsqti_v2p1" ; switch ( trim ( $ this -> getVersion ( ) ) ) { case '2.0.0' : $ xsdLocation = 'http://www.imsglobal.org/xsd/imsqti_v2p...
Decorate the root element of the XmlAssessmentDocument with the appropriate namespaces and schema definition .
2,944
public function process ( ) { $ operands = $ this -> getOperands ( ) ; if ( $ operands -> containsNull ( ) === true ) { return null ; } if ( $ operands -> exclusivelySingle ( ) === false ) { $ msg = "The PatternMatch operator only accepts operands with a single cardinality." ; throw new OperatorProcessingException ( $ ...
Process the PatternMatch .
2,945
public function process ( ) { $ expr = $ this -> getExpression ( ) ; $ state = $ this -> getState ( ) ; $ identifier = $ expr -> getIdentifier ( ) ; $ var = $ state -> getVariable ( $ identifier ) ; if ( is_null ( $ var ) ) { return null ; } elseif ( $ var instanceof ResponseVariable ) { return $ var -> getCorrectRespo...
Returns the related correstResponse as a QTI Runtime compliant value .
2,946
public function setTemplateIdentifier ( $ templateIdentifier ) { if ( is_string ( $ templateIdentifier ) === true && ( empty ( $ templateIdentifier ) === true ) || Format :: isIdentifier ( $ templateIdentifier , false ) === true ) { $ this -> templateIdentifier = $ templateIdentifier ; } else { $ msg = "The 'templateId...
Set the template identifier of the choice .
2,947
public function setShowHide ( $ showHide ) { if ( in_array ( $ showHide , ShowHide :: asArray ( ) ) === true ) { $ this -> showHide = $ showHide ; } else { $ msg = "The 'showHide' argument must be a value from the ShowHide enumeration." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the visibility of the choice .
2,948
public function setMinOperands ( $ minOperands ) { if ( is_int ( $ minOperands ) && $ minOperands >= 0 ) { $ this -> minOperands = $ minOperands ; } else { $ msg = "The minOperands argument must be an integer >= 0, '" . $ minOperands . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the minimum operands count for this Operator .
2,949
public function setMaxOperands ( $ maxOperands ) { if ( is_int ( $ maxOperands ) ) { $ this -> maxOperands = $ maxOperands ; } else { $ msg = "The maxOperands argument must be an integer, '" . gettype ( $ maxOperands ) . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the maxmimum operands count for this Operator . The value is - 1 if unlimited .
2,950
public function setAcceptedCardinalities ( array $ acceptedCardinalities ) { foreach ( $ acceptedCardinalities as $ cardinality ) { if ( ! in_array ( $ cardinality , OperatorCardinality :: asArray ( ) , true ) ) { $ msg = "Accepted cardinalities must be values from the Cardinality enumeration, '" . $ cardinality . "' g...
Set the accepted operand cardinalities .
2,951
public function setAcceptedBaseTypes ( array $ acceptedBaseTypes ) { foreach ( $ acceptedBaseTypes as $ baseType ) { if ( ! in_array ( $ baseType , OperatorBaseType :: asArray ( ) , true ) ) { $ msg = "Accepted baseTypes must be values from the OperatorBaseType enumeration, '" . $ baseType . "' given." ; throw new Inva...
Set the accepted operand accepted baseTypes .
2,952
public function process ( ) { $ operands = $ this -> getOperands ( ) ; if ( $ operands -> containsNull ( ) === true ) { return null ; } if ( $ operands -> exclusivelySingle ( ) === false ) { $ msg = "The StringMatch operator only accepts operands with a single cardinality." ; throw new OperatorProcessingException ( $ m...
Process the StringMatch operator .
2,953
protected function marshall ( QtiComponent $ component ) { $ element = parent :: marshall ( $ component ) ; $ this -> setDOMElementAttribute ( $ element , 'href' , $ component -> getHref ( ) ) ; $ categories = $ component -> getCategories ( ) ; if ( count ( $ categories ) > 0 ) { $ this -> setDOMElementAttribute ( $ el...
Marshall an AssessmentItemRef object into a DOMElement object .
2,954
protected function unmarshall ( DOMElement $ element ) { $ baseComponent = parent :: unmarshall ( $ element ) ; if ( ( $ href = $ this -> getDOMElementAttributeAs ( $ element , 'href' ) ) !== null ) { $ object = new AssessmentItemRef ( $ baseComponent -> getIdentifier ( ) , $ href ) ; $ object -> setRequired ( $ baseCo...
Unmarshall a DOMElement object corresponding to a QTI assessmentItemRef element .
2,955
public function setMin ( $ min ) { if ( is_int ( $ min ) || Format :: isVariableRef ( $ max ) ) { $ this -> min = $ min ; } else { $ msg = "'Min' must be an integer, '" . gettype ( $ min ) . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the value of the min attribute .
2,956
public function setStep ( $ step ) { if ( is_int ( $ step ) ) { $ this -> step = $ step ; } else { $ msg = "'Step' must be an integer, '" . gettype ( $ step ) . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the value of the step attribute .
2,957
public function setName ( $ name ) { if ( is_string ( $ name ) === true ) { $ this -> name = $ name ; } else { $ msg = "The 'name' argument must be a string, '" . gettype ( $ name ) . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the name of the parameter as interpreted by the object .
2,958
public function setValue ( $ value ) { if ( is_string ( $ value ) === true ) { $ this -> value = $ value ; } else { $ msg = "The 'value' argument must be a string, '" . gettype ( $ value ) . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the value to pass to the object for the named parameter .
2,959
public function setValueType ( $ valueType ) { if ( in_array ( $ valueType , ParamType :: asArray ( ) , true ) === true ) { $ this -> valueType = $ valueType ; } else { $ msg = "The 'valueType' argument must be a value from the ParamType enumeration, '" . gettype ( $ valueType ) . "' given." ; throw new InvalidArgument...
Set the valueType attribute .
2,960
protected function marshall ( QtiComponent $ component ) { $ element = static :: getDOMCradle ( ) -> createElement ( $ component -> getQtiClassName ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'select' , $ component -> getSelect ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'withReplacement' , $ comp...
Marshall a Selection object into a DOMElement object .
2,961
protected function unmarshall ( DOMElement $ element ) { $ frag = $ element -> ownerDocument -> createDocumentFragment ( ) ; $ element = $ element -> cloneNode ( true ) ; $ frag -> appendChild ( $ element ) ; $ xmlString = $ frag -> ownerDocument -> saveXML ( $ frag ) ; if ( ( $ value = $ this -> getDOMElementAttribute...
Unmarshall a DOMElement object corresponding to a QTI Selection object .
2,962
protected function unmarshall ( DOMElement $ element ) { if ( ( $ sourceValue = $ this -> getDOMElementAttributeAs ( $ element , 'sourceValue' , 'float' ) ) !== null ) { if ( ( $ targetValue = $ this -> getDOMElementAttributeAs ( $ element , 'targetValue' , 'string' ) ) !== null ) { $ object = new InterpolationTableEnt...
Unmarshall a DOMElement object corresponding to a QTI InterpolationEntry element .
2,963
public function setVariable ( Variable $ variable ) { $ this -> checkType ( $ variable ) ; $ data = & $ this -> getDataPlaceHolder ( ) ; $ data [ $ variable -> getIdentifier ( ) ] = $ variable ; }
Set a variable to the state . It will be accessible by it s variable name .
2,964
public function unsetVariable ( $ variable ) { $ data = & $ this -> getDataPlaceHolder ( ) ; if ( gettype ( $ variable ) === 'string' ) { $ variableIdentifier = $ variable ; } elseif ( $ variable instanceof Variable ) { $ variableIdentifier = $ variable -> getIdentifier ( ) ; } else { $ msg = "The variable argument mus...
Unset a variable from the current state . In other words the relevant Variable object is removed from the state .
2,965
public function resetOutcomeVariables ( $ preserveBuiltIn = true ) { $ data = & $ this -> getDataPlaceHolder ( ) ; foreach ( array_keys ( $ data ) as $ k ) { if ( $ data [ $ k ] instanceof OutcomeVariable ) { if ( $ preserveBuiltIn === true && $ k === 'completionStatus' ) { continue ; } else { $ data [ $ k ] -> applyDe...
Reset all outcome variables to their defaults .
2,966
public function resetTemplateVariables ( ) { $ data = & $ this -> getDataPlaceHolder ( ) ; foreach ( array_keys ( $ data ) as $ k ) { if ( $ data [ $ k ] instanceof TemplateVariable ) { $ data [ $ k ] -> applyDefaultValue ( ) ; } } }
Reset all template variables to their defaults .
2,967
public function containsNullOnly ( ) { $ data = $ this -> getDataPlaceHolder ( ) ; foreach ( $ data as $ variable ) { $ value = $ variable -> getValue ( ) ; if ( $ variable -> isNull ( ) === false ) { return false ; } } return true ; }
Whether or not the State contains NULL only values .
2,968
public function containsValuesEqualToVariableDefaultOnly ( ) { $ data = $ this -> getDataPlaceHolder ( ) ; foreach ( $ data as $ variable ) { $ value = $ variable -> getValue ( ) ; $ default = $ variable -> getDefaultValue ( ) ; if ( Utils :: isNull ( $ value ) === true ) { if ( Utils :: isNull ( $ default ) === false ...
Whether or not the State contains only values that are equals to their variable default value only .
2,969
public function setComponent ( QtiComponent $ templateProcessing ) { if ( $ templateProcessing instanceof TemplateProcessing ) { parent :: setComponent ( $ templateProcessing ) ; } else { $ msg = "The TemplateProcessing class only accepts TemplateProcessing objects to be executed." ; throw new InvalidArgumentException ...
Set the TemplateProcessing object to be executed by the engine depending on the current context .
2,970
public function process ( ) { $ context = $ this -> getContext ( ) ; $ templateProcessing = $ this -> getComponent ( ) ; $ trialCount = 0 ; $ impactedVariables = Utils :: templateProcessingImpactedVariables ( $ templateProcessing ) ; $ tplVarCopies = array ( ) ; foreach ( $ impactedVariables as $ varIdentifier ) { $ tp...
Process the template processing .
2,971
protected function unmarshall ( DOMElement $ element ) { if ( ( $ max = $ this -> getDOMElementAttributeAs ( $ element , 'max' ) ) !== null ) { $ max = ( Format :: isVariableRef ( $ max ) ) ? $ max : floatval ( $ max ) ; $ object = new RandomFloat ( 0.0 , $ max ) ; if ( ( $ min = $ this -> getDOMElementAttributeAs ( $ ...
Unmarshall a DOMElement object corresponding to a QTI randomFloat element .
2,972
public function process ( ) { $ expr = $ this -> getExpression ( ) ; if ( $ expr -> getName ( ) === MathEnumeration :: E ) { return new QtiFloat ( M_E ) ; } else { return new QtiFloat ( M_PI ) ; } }
Process the MathConstant Expression .
2,973
public function process ( ) { $ operands = $ this -> getOperands ( ) ; if ( ( $ c = count ( $ operands ) ) < 2 ) { $ msg = "The 'qtism.runtime.expressions.operators.custom.Explode' custom operator takes 2 sub-expressions as parameters, ${c} given." ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProc...
Process the expression by implementing PHP core s explode function .
2,974
public function setOutcomeIdentifier ( $ outcomeIdentifier ) { if ( Format :: isIdentifier ( $ outcomeIdentifier , false ) === true ) { $ this -> outcomeIdentifier = $ outcomeIdentifier ; } else { $ msg = "The 'outcomeIdentifier' argument must be a valid QTI identifier, '" . $ outcomeIdentifier . "' given." ; throw new...
The identifier of an outcome variable ruling the visibility of the feedbackBlock .
2,975
public function process ( ) { $ operands = $ this -> getOperands ( ) ; if ( $ operands -> containsNull ( ) === true ) { return null ; } if ( $ operands -> exclusivelySingle ( ) === false ) { $ msg = "The Round operator only accepts operands with a single cardinality." ; throw new OperatorProcessingException ( $ msg , $...
Process the Round operator .
2,976
public function marshall ( QtiComponent $ component ) { $ element = self :: getDOMCradle ( ) -> createElement ( $ component -> getQtiClassName ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'identifier' , $ component -> getIdentifier ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'minConstraint' , $ com...
Marshall an AssociationValidityConstraint object to its XML counterpart .
2,977
public function unmarshall ( DOMElement $ element ) { if ( ( $ identifier = $ this -> getDOMElementAttributeAs ( $ element , 'identifier' ) ) !== null ) { if ( ( $ minConstraint = $ this -> getDOMElementAttributeAs ( $ element , 'minConstraint' , 'integer' ) ) !== null ) { if ( ( $ maxConstraint = $ this -> getDOMEleme...
Unmarshall a DOMElement to its AssociationValidityConstraint data model representation .
2,978
public function marshall ( ) { $ collection = $ this -> getToMarshall ( ) ; $ ctx = $ this -> getContext ( ) ; $ access = $ ctx -> getStreamAccess ( ) ; $ valueArray = $ collection -> getArrayCopy ( ) ; $ valueArrayVarName = $ ctx -> generateVariableName ( $ valueArray ) ; $ arrayArgs = new PhpArgumentCollection ( ) ; ...
Marshall AbstractCollection objects into PHP source code .
2,979
protected function marshall ( QtiComponent $ component ) { $ element = static :: getDOMCradle ( ) -> createElement ( $ component -> getQtiClassName ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'identifier' , $ component -> getIdentifier ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'required' , $ com...
Marshall a SectionPart object into a DOMElement object .
2,980
protected function unmarshall ( DOMElement $ element ) { if ( ( $ identifier = $ this -> getDOMElementAttributeAs ( $ element , 'identifier' ) ) !== null ) { $ object = new SectionPart ( $ identifier ) ; if ( ( $ required = $ this -> getDOMElementAttributeAs ( $ element , 'required' , 'boolean' ) ) !== null ) { $ objec...
Unmarshall a DOMElement object corresponding to a QTI sectionPart element .
2,981
public function process ( ) { $ expr = $ this -> getExpression ( ) ; $ state = $ this -> getState ( ) ; $ var = $ state -> getVariable ( $ expr -> getIdentifier ( ) ) ; return ( $ var === null ) ? null : $ var -> getDefaultValue ( ) ; }
Returns the defaultValue of the current Expression to be processed . If no Variable with the given identifier is found null is returned . If the Variable has no defaultValue null is returned .
2,982
protected function marshall ( QtiComponent $ component ) { return self :: getDOMCradle ( ) -> importNode ( $ component -> getXml ( ) -> documentElement , true ) ; }
Marshall an SSML sub object into a DOMElement object .
2,983
protected function unmarshall ( DOMElement $ element ) { $ node = $ element -> cloneNode ( true ) ; return new Sub ( $ element -> ownerDocument -> saveXML ( $ node ) ) ; }
Unmarshall a DOMElement object corresponding to an SSML sub element .
2,984
protected function marshall ( QtiComponent $ component ) { $ element = parent :: marshall ( $ component ) ; $ this -> setDOMElementAttribute ( $ element , 'outcomeIdentifier' , $ component -> getOutcomeIdentifier ( ) ) ; $ weightIdentifier = $ component -> getWeightIdentifier ( ) ; if ( ! empty ( $ weightIdentifier ) )...
Marshall an outcomeMaximum object in its DOMElement equivalent .
2,985
public function setHotspotChoices ( HotspotChoiceCollection $ hotspotChoices ) { if ( count ( $ hotspotChoices ) > 0 ) { $ this -> hotspotChoices = $ hotspotChoices ; } else { $ msg = "A GraphicOrderInteraction must contain at least 1 hotspotChoice object. None given." ; throw new InvalidArgumentException ( $ msg ) ; }...
Set the hotspots that define the choices that are to be ordered by the candidate .
2,986
public function setMinChoices ( $ minChoices ) { if ( is_int ( $ minChoices ) && $ minChoices !== 0 ) { if ( $ minChoices > count ( $ this -> getHotspotChoices ( ) ) ) { $ msg = "The 'minChoices' argument must not exceed the number of choices available." ; throw new InvalidArgumentException ( $ msg ) ; } $ this -> minC...
Set the minimum number of choices that the candidate must select and order to form a valid response . A negative value indicates that no minChoice is indicated .
2,987
public function setMaxChoices ( $ maxChoices ) { if ( is_int ( $ maxChoices ) && $ maxChoices !== 0 ) { if ( $ this -> getMinChoices ( ) > 0 && $ maxChoices < $ this -> getMinChoices ( ) ) { $ msg = "The 'maxChoices' argument must be greater than or equal to the 'minChoices' attribute." ; throw new InvalidArgumentExcep...
Set the maximum number of choices that the candidate must select and order to form a valid response . A negative value indicates that no maxChoice is indicated .
2,988
protected function marshall ( QtiComponent $ component ) { $ element = static :: getDOMCradle ( ) -> createElement ( $ component -> getQtiClassName ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'templateIdentifier' , $ component -> getTemplateIdentifier ( ) ) ; $ expr = $ component -> getExpression ( ) ; $ exp...
Marshall a TemplateDefault object into a DOMElement object .
2,989
protected function unmarshall ( DOMElement $ element ) { if ( ( $ tplIdentifier = $ this -> getDOMElementAttributeAs ( $ element , 'templateIdentifier' ) ) !== null ) { $ expressionElt = self :: getFirstChildElement ( $ element ) ; if ( $ expressionElt !== false ) { $ exprMarshaller = $ this -> getMarshallerFactory ( )...
Unmarshall a DOMElement object corresponding to a QTI templateDefault element .
2,990
public function setMatchMax ( $ matchMax ) { if ( is_int ( $ matchMax ) === true && $ matchMax >= 0 ) { $ this -> matchMax = $ matchMax ; } else { $ msg = "The 'matchMax' argument must be a positive integer, '" . gettype ( $ matchMax ) . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the matchMax of the associableHotspot .
2,991
public function setMatchMin ( $ matchMin ) { if ( is_int ( $ matchMin ) === true && $ matchMin >= 0 ) { $ this -> matchMin = $ matchMin ; } else { $ msg = "The 'matchMin' argument must be a positive integer, '" . gettype ( $ matchMin ) . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the matchMin of the associableHotspot .
2,992
public function setHotspotLabel ( $ hotspotLabel ) { if ( Format :: isString256 ( $ hotspotLabel ) === true ) { $ this -> hotspotLabel = $ hotspotLabel ; } else { $ msg = "The 'hotspotLabel' argument must be a string value with at most 256 characters." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the hotspotLabel of the associableHotspot .
2,993
protected function marshall ( QtiComponent $ component ) { $ element = $ this -> createElement ( $ component ) ; $ this -> fillElement ( $ element , $ component ) ; $ this -> setDOMElementAttribute ( $ element , 'responseIdentifier' , $ component -> getResponseIdentifier ( ) ) ; if ( $ component -> hasXmlBase ( ) === t...
Marshall a CustomInteraction object into a DOMElement object .
2,994
protected function unmarshall ( DOMElement $ element ) { if ( ( $ responseIdentifier = $ this -> getDOMElementAttributeAs ( $ element , 'responseIdentifier' ) ) !== null ) { $ frag = $ element -> ownerDocument -> createDocumentFragment ( ) ; $ element = $ element -> cloneNode ( true ) ; $ frag -> appendChild ( $ elemen...
Unmarshall a DOMElement object corresponding to a QTI customInteraction element .
2,995
public function setCite ( $ cite ) { if ( Format :: isUri ( $ cite ) === true ) { $ this -> cite = $ cite ; } else { $ msg = "The 'cite' argument must be a valid URI, '" . $ cite . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the cite attribute s value .
2,996
public static function createFromDataModel ( ValueCollection $ valueCollection ) { $ container = new static ( ) ; foreach ( $ valueCollection as $ value ) { $ container [ ] = RuntimeUtils :: valueToRuntime ( $ value -> getValue ( ) , $ value -> getBaseType ( ) ) ; } return $ container ; }
Create a Container object from a Data Model ValueCollection object .
2,997
public function distinct ( ) { $ container = clone $ this ; $ newDataPlaceHolder = [ ] ; foreach ( $ this -> getDataPlaceHolder ( ) as $ key => $ value ) { $ found = false ; foreach ( $ newDataPlaceHolder as $ newValue ) { if ( gettype ( $ value ) === 'object' && $ value instanceof Comparable && $ value -> equals ( $ n...
Get Distinct Container Copy .
2,998
public function process ( ) { $ operands = $ this -> getOperands ( ) ; $ expression = $ this -> getExpression ( ) ; $ numberRepeats = $ expression -> getNumberRepeats ( ) ; if ( gettype ( $ numberRepeats ) === 'string' ) { $ state = $ this -> getState ( ) ; $ varName = ExprUtils :: sanitizeVariableRef ( $ numberRepeats...
Process the Repeat operator .
2,999
public function process ( ) { $ testSession = $ this -> getState ( ) ; $ itemSubset = $ this -> getItemSubset ( ) ; $ numberIncorrect = 0 ; foreach ( $ itemSubset as $ item ) { $ itemSessions = $ testSession -> getAssessmentItemSessions ( $ item -> getIdentifier ( ) ) ; if ( $ itemSessions !== false ) { foreach ( $ ite...
Process the related NumberIncorrect expression .