idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
3,000
public function setSimpleAssociableChoices ( SimpleAssociableChoiceCollection $ simpleAssociableChoices ) { if ( count ( $ simpleAssociableChoices ) > 0 ) { $ this -> simpleAssociableChoices = $ simpleAssociableChoices ; } else { $ msg = "An AssociateInteraction object must be composed of at lease one SimpleAssociableC...
Set the choices .
3,001
public function setViews ( ViewCollection $ views ) { if ( count ( $ views ) > 0 ) { $ this -> views = $ views ; } else { $ msg = "A RubricBlock object must contain at least one View." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the views in which the rubric block s content are to be shown .
3,002
public function setComponent ( QtiComponent $ expression ) { if ( $ expression instanceof Expression ) { parent :: setComponent ( $ expression ) ; } else { $ msg = "The ExpressionEngine class only accepts QTI Data Model Expression objects to be processed." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the Expression object to be processed .
3,003
protected function pushTrail ( $ expression ) { if ( $ expression instanceof Expression ) { array_push ( $ this -> trail , $ expression ) ; } else { $ i = count ( $ expression ) ; while ( $ i >= 1 ) { $ i -- ; array_push ( $ this -> trail , $ expression [ $ i ] ) ; } } }
Push an Expression object on the trail stack .
3,004
public function process ( ) { $ expression = $ this -> getComponent ( ) ; $ this -> trail = array ( ) ; $ this -> marker = array ( ) ; $ this -> pushTrail ( $ expression ) ; while ( count ( $ this -> getTrail ( ) ) > 0 ) { $ expression = $ this -> popTrail ( ) ; if ( $ this -> isMarked ( $ expression ) === false && $ e...
Process the current Expression object according to the current execution context .
3,005
public function process ( ) { $ operands = $ this -> getOperands ( ) ; if ( $ operands -> containsNull ( ) === true ) { return null ; } if ( $ operands -> exclusivelySingle ( ) === false ) { $ msg = "The Lte operator only accepts operands with a single cardinality." ; throw new OperatorProcessingException ( $ msg , $ t...
Process the Lte operator .
3,006
public function getData ( ) { $ fp = $ this -> getStream ( ) ; $ data = '' ; while ( feof ( $ fp ) === false ) { $ data .= fread ( $ fp , self :: CHUNK_SIZE ) ; } @ fclose ( $ fp ) ; return $ data ; }
Get the sequence of bytes composing the content of the file .
3,007
public function getStream ( ) { $ fp = @ fopen ( $ this -> getPath ( ) , 'rb' ) ; if ( $ fp === false ) { $ msg = "Cannot retrieve QTI File Stream from '" . $ this -> getPath ( ) . "'." ; throw new RuntimeException ( $ msg ) ; } $ len = current ( unpack ( 'S' , fread ( $ fp , 2 ) ) ) ; fseek ( $ fp , $ len , SEEK_CUR )...
Get a stream resource on the file .
3,008
public static function createFromExistingFile ( $ source , $ destination , $ mimeType , $ withFilename = true ) { if ( is_file ( $ source ) === true ) { if ( is_readable ( $ source ) === true ) { $ pathinfo = pathinfo ( $ destination ) ; if ( is_dir ( $ pathinfo [ 'dirname' ] ) === false ) { if ( ( $ mkdir = @ mkdir ( ...
Create a PersistentFile object from an existing file .
3,009
public static function createFromData ( $ data , $ destination , $ mimeType , $ filename = '' ) { $ tmp = tempnam ( '/tmp' , 'qtism' ) ; file_put_contents ( $ tmp , $ data ) ; $ file = self :: createFromExistingFile ( $ tmp , $ destination , $ mimeType , $ filename ) ; unlink ( $ tmp ) ; return $ file ; }
Create a File from existing data .
3,010
public function equals ( $ obj ) { if ( $ obj instanceof QtiFile ) { if ( $ this -> getFilename ( ) !== $ obj -> getFilename ( ) ) { return false ; } elseif ( $ this -> getMimeType ( ) !== $ obj -> getMimeType ( ) ) { return false ; } else { $ myStream = $ this -> getStream ( ) ; $ objStream = $ obj -> getStream ( ) ; ...
Whether or not two File objects are equals . Two File values are considered to be identical if they have the same file name mime - type and data .
3,011
public function process ( ) { $ operands = $ this -> getOperands ( ) ; if ( $ operands -> containsNull ( ) === true ) { return null ; } if ( $ operands -> exclusivelySingle ( ) === false ) { $ msg = "The Divide operator only accepts operands with a single cardinality." ; throw new OperatorProcessingException ( $ msg , ...
Process the Divide operator .
3,012
protected function unmarshallChildrenKnown ( DOMElement $ element , QtiComponentCollection $ children ) { if ( ( $ name = $ this -> getDOMElementAttributeAs ( $ element , 'name' ) ) !== null ) { $ object = new MathOperator ( $ children , MathFunctions :: getConstantByName ( $ name ) ) ; return $ object ; } else { $ msg...
Unmarshall a QTI mathOperator operator element into a MathsOperator object .
3,013
public function process ( ) { $ expr = $ this -> getExpression ( ) ; $ min = $ expr -> getMin ( ) ; $ max = $ expr -> getMax ( ) ; $ state = $ this -> getState ( ) ; $ min = ( is_float ( $ min ) ) ? $ min : $ state [ Utils :: sanitizeVariableRef ( $ min ) ] -> getValue ( ) ; $ max = ( is_float ( $ max ) ) ? $ max : $ s...
Process the RandomFloat expression .
3,014
public function setComponent ( QtiComponent $ outcomeProcessing ) { if ( $ outcomeProcessing instanceof OutcomeProcessing ) { parent :: setComponent ( $ outcomeProcessing ) ; } else { $ msg = "The OutcomeProcessingEngine class only accepts OutcomeProcessing objects to be executed." ; throw new InvalidArgumentException ...
Set the OutcomeProcessing object to be executed by the engine depending on the current context .
3,015
private static function checkRecursion ( $ component , $ sections ) { $ sectparent = null ; foreach ( $ sections as $ key => $ sect ) { if ( in_array ( $ component , $ sect -> getSectionParts ( ) -> getArrayCopy ( ) ) ) { $ sectparent = $ sect ; } if ( $ sect -> getIdentifier ( ) == $ component -> getIdentifier ( ) ) {...
Checks if the current section has a parent and returns it if any .
3,016
public static function getFirstItem ( $ test , $ component , $ sections ) { $ currentCmp = $ component ; $ visitedNodes = [ ] ; while ( true ) { $ visitedNodes [ ] = $ currentCmp -> getIdentifier ( ) ; switch ( $ currentCmp -> getQtiClassName ( ) ) { case "assessmentItemRef" : return $ currentCmp ; break ; case "assess...
Returns the first AssessmentItem that will be prompted if a branch targets the QtiComponent set as parameter .
3,017
public static function getLastItem ( $ test , $ component , $ sections ) { $ currentCmp = $ component ; while ( true ) { switch ( $ currentCmp -> getQtiClassName ( ) ) { case "assessmentItemRef" : return $ currentCmp ; break ; case "assessmentSection" : $ items = $ currentCmp -> getComponentsByClassName ( "assessmentIt...
Returns the last AssessmentItem that will be prompted before a BranchRule of the QtiComponent set as parameter will be taken .
3,018
public function setUpperBound ( $ upperBound ) { if ( is_float ( $ upperBound ) || ( is_bool ( $ upperBound ) && $ upperBound === false ) ) { $ this -> upperBound = $ upperBound ; } else { $ msg = "The upperBound argument must be a float or false if no upper bound, '" . gettype ( $ upperBound ) . "' given." ; throw new...
Set the upper bound .
3,019
public function setAreaMapEntries ( AreaMapEntryCollection $ areaMapEntries ) { if ( count ( $ areaMapEntries ) >= 1 ) { $ this -> areaMapEntries = $ areaMapEntries ; } else { $ msg = "An AreaMapping object must contain at least one AreaMapEntry object. none given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the collection of AreaMapEntry objects composing the AreaMapping .
3,020
public function initialize ( ) { if ( $ this -> cardinality === Cardinality :: MULTIPLE ) { $ value = new MultipleContainer ( $ this -> baseType ) ; } elseif ( $ this -> cardinality === Cardinality :: ORDERED ) { $ value = new OrderedContainer ( $ this -> baseType ) ; } elseif ( $ this -> cardinality === Cardinality ::...
Initialize the variable with the appropriate default value .
3,021
public function setBaseType ( $ baseType ) { if ( $ baseType === - 1 && $ this -> isRecord ( ) === false ) { $ msg = "You are forced to specify a baseType if cardinality is not RECORD." ; throw new InvalidArgumentException ( $ msg ) ; } $ this -> baseType = $ baseType ; }
Set the baseType of the Variable .
3,022
public function setValue ( QtiDatatype $ value = null ) { if ( Utils :: isBaseTypeCompliant ( $ this -> getBaseType ( ) , $ value ) && Utils :: isCardinalityCompliant ( $ this -> getCardinality ( ) , $ value ) ) { $ this -> value = $ value ; } else { Utils :: throwBaseTypeTypingError ( $ this -> baseType , $ value ) ; ...
Set the value of the Variable .
3,023
public function setDefaultValue ( QtiDatatype $ defaultValue = null ) { if ( Utils :: isBaseTypeCompliant ( $ this -> getBaseType ( ) , $ defaultValue ) && Utils :: isCardinalityCompliant ( $ this -> getCardinality ( ) , $ defaultValue ) ) { $ this -> defaultValue = $ defaultValue ; return ; } else { Utils :: throwBase...
Set the default value of the Variable .
3,024
public static function createFromDataModel ( VariableDeclaration $ variableDeclaration ) { $ identifier = $ variableDeclaration -> getIdentifier ( ) ; $ baseType = $ variableDeclaration -> getBaseType ( ) ; $ cardinality = $ variableDeclaration -> getCardinality ( ) ; $ variable = new static ( $ identifier , $ cardinal...
Create a runtime Variable object from its Data Model representation .
3,025
protected static function dataModelValuesToRuntime ( ValueCollection $ valueCollection , $ baseType , $ cardinality ) { if ( $ cardinality === Cardinality :: SINGLE ) { if ( count ( $ valueCollection ) == 1 ) { $ dataModelValue = RuntimeUtils :: valueToRuntime ( $ valueCollection [ 0 ] -> getValue ( ) , $ baseType ) ; ...
Create a QTI Runtime value from Data Model ValueCollection
3,026
public static function createFromAssessmentSection ( AssessmentSection $ assessmentSection ) { $ extended = new static ( $ assessmentSection -> getIdentifier ( ) , $ assessmentSection -> getTitle ( ) , $ assessmentSection -> isVisible ( ) ) ; $ extended -> setKeepTogether ( $ assessmentSection -> mustKeepTogether ( ) )...
Create a new ExtendedAssessmentSection object from an existing AssessmentSection object .
3,027
protected function marshall ( QtiComponent $ component ) { $ element = self :: getDOMCradle ( ) -> createElement ( 'img' ) ; $ this -> setDOMElementAttribute ( $ element , 'src' , $ component -> getSrc ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'alt' , $ component -> getAlt ( ) ) ; if ( $ component -> hasWi...
Marshall an Img object into a DOMElement object .
3,028
protected function unmarshall ( DOMElement $ element ) { if ( ( $ src = $ this -> getDOMElementAttributeAs ( $ element , 'src' ) ) !== null ) { if ( ( $ alt = $ this -> getDOMElementAttributeAs ( $ element , 'alt' ) ) === null ) { $ alt = '' ; } $ component = new Img ( $ src , $ alt ) ; if ( ( $ longdesc = $ this -> ge...
Unmarshall a DOMElement object corresponding to an XHTML img element .
3,029
public static function asArray ( ) { return array ( 'AUTHOR' => self :: AUTHOR , 'CANDIDATE' => self :: CANDIDATE , 'PROCTOR' => self :: PROCTOR , 'SCORER' => self :: SCORER , 'TEST_CONSTRUCTOR' => self :: TEST_CONSTRUCTOR , 'TUTOR' => self :: TUTOR ) ; }
Get the possible values of the enumaration as an array .
3,030
public static function getNameByConstant ( $ constant ) { switch ( $ constant ) { case self :: AUTHOR : return 'author' ; break ; case self :: CANDIDATE : return 'candidate' ; break ; case self :: PROCTOR : return 'proctor' ; break ; case self :: SCORER : return 'scorer' ; break ; case self :: TEST_CONSTRUCTOR : return...
Get a constant name by its value .
3,031
public static function getConstantByName ( $ name ) { switch ( strtolower ( $ name ) ) { case 'author' : return self :: AUTHOR ; break ; case 'candidate' : return self :: CANDIDATE ; break ; case 'proctor' : return self :: PROCTOR ; break ; case 'scorer' : return self :: SCORER ; break ; case 'testconstructor' : return...
Get the constant value from its name .
3,032
public function setSimpleChoices ( SimpleChoiceCollection $ simpleChoices ) { if ( count ( $ simpleChoices ) > 0 ) { $ this -> simpleChoices = $ simpleChoices ; } else { $ msg = "An OrderInteraction object must be composed of at lease one SimpleChoice object, none given." ; throw new InvalidArgumentException ( $ msg ) ...
Set the ordered list of choices that are displayed to the user .
3,033
public function setMinChoices ( $ minChoices ) { if ( is_int ( $ minChoices ) === true && ( $ minChoices > 0 || $ minChoices === - 1 ) ) { if ( $ minChoices > count ( $ this -> getSimpleChoices ( ) ) ) { $ msg = "The value of 'minChoices' cannot exceed the number of available choices." ; throw new InvalidArgumentExcept...
Set the minimum number of choices that the candidate may select .
3,034
public function setMaxChoices ( $ maxChoices ) { if ( is_int ( $ maxChoices ) === true && $ maxChoices > 0 || $ maxChoices === - 1 ) { if ( $ this -> hasMinChoices ( ) === true && $ maxChoices > count ( $ this -> getSimpleChoices ( ) ) ) { $ msg = "The 'maxChoices' argument cannot exceed the number of available choices...
Set the maximum number of choices that the candidate may select and order when responding to the interaction .
3,035
public function process ( ) { $ testSession = $ this -> getState ( ) ; $ itemSubset = $ this -> getItemSubset ( ) ; $ numberResponded = 0 ; foreach ( $ itemSubset as $ item ) { $ itemSessions = $ testSession -> getAssessmentItemSessions ( $ item -> getIdentifier ( ) ) ; if ( $ itemSessions !== false ) { foreach ( $ ite...
Process the related NumberResponded expression .
3,036
public function setMinTime ( QtiDuration $ minTime = null ) { if ( is_null ( $ minTime ) === false && $ minTime -> getSeconds ( true ) === 0 ) { $ minTime = null ; } $ this -> minTime = $ minTime ; }
Set the minimum time .
3,037
public function setMaxTime ( QtiDuration $ maxTime = null ) { if ( is_null ( $ maxTime ) === false && $ maxTime -> getSeconds ( true ) === 0 ) { $ maxTime = null ; } $ this -> maxTime = $ maxTime ; }
Set the maximum time or null if unlimited .
3,038
public function setAllowLateSubmission ( $ allowLateSubmission ) { if ( is_bool ( $ allowLateSubmission ) ) { $ this -> allowLateSubmission = $ allowLateSubmission ; } else { $ msg = "AllowLateSubmission must be a boolean, '" . gettype ( $ allowLateSubmission ) . "' given." ; throw new InvalidArgumentException ( $ msg ...
Set wether a candidate s response that is beyond the maxTime should be still accepted .
3,039
public function writeScalar ( $ scalar ) { if ( Utils :: isScalar ( $ scalar ) === false ) { $ msg = "A '" . gettype ( $ scalar ) . "' value is not a PHP scalar value nor null." ; throw new InvalidArgumentException ( $ msg ) ; } try { if ( is_int ( $ scalar ) === true ) { $ this -> getStream ( ) -> write ( $ scalar ) ;...
Write a scalar value into the current stream .
3,040
public function writeEquals ( $ spaces = true ) { try { if ( $ spaces === true ) { $ this -> getStream ( ) -> write ( ' = ' ) ; } else { $ this -> getStream ( ) -> write ( '=' ) ; } } catch ( StreamException $ e ) { $ msg = "An error occured while writing the PHP equality symbol (=)." ; throw new StreamAccessException ...
Write the PHP equality symbol into the current stream .
3,041
public function writeNewline ( ) { try { $ this -> getStream ( ) -> write ( "\n" ) ; } catch ( StreamException $ e ) { $ msg = "An error occured while writing a newline escape sequence (\\n)." ; throw new StreamAccessException ( $ msg , $ this , 0 , $ e ) ; } }
Write a newline escape sequence in the current stream .
3,042
public function writeOpeningTag ( $ newline = true ) { try { $ this -> getStream ( ) -> write ( '<?php' ) ; if ( $ newline === true ) { $ this -> writeNewline ( ) ; } } catch ( StreamException $ e ) { $ msg = "An error occured while writing a PHP opening tag (<?php)." ; throw new StreamAccessException ( $ msg , $ this ...
Write a PHP opening tag in the current stream .
3,043
public function writeClosingTag ( $ newline = true ) { try { if ( $ newline === true ) { $ this -> writeNewline ( ) ; } $ this -> getStream ( ) -> write ( '?>' ) ; } catch ( Exception $ e ) { $ msg = "An error occured while writing a PHP closing tag (?>)." ; throw new StreamAccessException ( $ msg , $ this , 0 , $ e ) ...
Write a PHP closing tag in the current string .
3,044
public function writeOpeningParenthesis ( ) { try { $ this -> getStream ( ) -> write ( '(' ) ; } catch ( StreamException $ e ) { $ msg = "An error occured while writing an opening parenthesis (()." ; throw new StreamAccessException ( $ msg , $ this , 0 , $ e ) ; } }
Write an opening parenthesis in the current stream .
3,045
public function writeClosingParenthesis ( ) { try { $ this -> getStream ( ) -> write ( ')' ) ; } catch ( StreamException $ e ) { $ msg = "An error occured while writing a closing parenthesis ())." ; throw new StreamAccessException ( $ msg , $ this , 0 , $ e ) ; } }
Write a closing parenthesis in the current stream .
3,046
public function writeComma ( $ space = true ) { try { $ this -> getStream ( ) -> write ( ',' ) ; if ( $ space === true ) { $ this -> writeSpace ( ) ; } } catch ( StreamException $ e ) { $ msg = "An error occured while writing a comma (,)." ; throw new StreamAccessException ( $ msg , $ this , 0 , $ e ) ; } }
Write a comma in the current stream .
3,047
public function writeSpace ( ) { try { $ this -> getStream ( ) -> write ( ' ' ) ; } catch ( StreamException $ e ) { $ msg = "An error occured while writing a white space ( )." ; throw new StreamAccessException ( $ msg , $ this , 0 , $ e ) ; } }
Write a white space in the current stream .
3,048
public function writeVariable ( $ varname ) { try { $ this -> getStream ( ) -> write ( '$' . $ varname ) ; } catch ( StreamException $ e ) { $ msg = "An error occured while writing a variable reference." ; throw new StreamAccessException ( $ msg , $ this , 0 , $ e ) ; } }
Write a variable reference in the current stream .
3,049
public function writeFunctionCall ( $ funcname , PhpArgumentCollection $ arguments = null ) { try { $ this -> getStream ( ) -> write ( $ funcname ) ; $ this -> writeOpeningParenthesis ( ) ; if ( is_null ( $ arguments ) === false ) { $ this -> writeArguments ( $ arguments ) ; } $ this -> writeClosingParenthesis ( ) ; } ...
Write a function call in the current stream .
3,050
public function writeMethodCall ( $ objectname , $ methodname , PhpArgumentCollection $ arguments = null , $ static = false ) { try { $ this -> writeVariable ( $ objectname ) ; if ( $ static === false ) { $ this -> writeObjectOperator ( ) ; } else { $ this -> writePaamayimNekudotayim ( ) ; } $ this -> getStream ( ) -> ...
Write a method call in the current stream .
3,051
public function writeArguments ( PhpArgumentCollection $ arguments ) { try { $ argsCount = count ( $ arguments ) ; for ( $ i = 0 ; $ i < $ argsCount ; $ i ++ ) { $ this -> writeArgument ( $ arguments [ $ i ] ) ; if ( $ i < $ argsCount - 1 ) { $ this -> writeComma ( ) ; } } } catch ( Exception $ e ) { $ msg = "An error ...
Write a sequence of arguments in the current stream .
3,052
protected function marshall ( QtiComponent $ component ) { $ element = parent :: marshall ( $ component ) ; foreach ( $ component -> getResponseDeclarations ( ) as $ responseDeclaration ) { $ marshaller = $ this -> getMarshallerFactory ( ) -> createMarshaller ( $ responseDeclaration ) ; $ element -> appendChild ( $ mar...
Marshall a ExtendedAssessmentItemRef object into its DOMElement representation .
3,053
protected function marshall ( QtiComponent $ component ) { $ element = self :: getDOMCradle ( ) -> createElement ( 'br' ) ; if ( $ component -> hasXmlBase ( ) === true ) { self :: setXmlBase ( $ element , $ component -> setXmlBase ( ) ) ; } $ this -> fillElement ( $ element , $ component ) ; return $ element ; }
Marshall a Br object into a DOMElement object .
3,054
protected function unmarshall ( DOMElement $ element ) { $ component = new Br ( ) ; if ( ( $ xmlBase = self :: getXmlBase ( $ element ) ) !== false ) { $ component -> setXmlBase ( $ xmlBase ) ; } $ this -> fillBodyElement ( $ component , $ element ) ; return $ component ; }
Unmarshall a DOMElement object corresponding to an XHTML br element .
3,055
public function setPattern ( $ pattern ) { if ( gettype ( $ pattern ) === 'string' ) { $ this -> pattern = $ pattern ; } else { $ msg = "The pattern argument must be a string or a variable reference, '" . $ pattern . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the pattern to match .
3,056
protected function marshall ( QtiComponent $ component ) { $ version = $ this -> getVersion ( ) ; $ element = $ this -> createElement ( $ component ) ; $ element -> appendChild ( $ this -> getMarshallerFactory ( ) -> createMarshaller ( $ component -> getObject ( ) ) -> marshall ( $ component -> getObject ( ) ) ) ; $ th...
Marshall an PositionObjectInteraction object into a DOMElement object .
3,057
protected function unmarshall ( DOMElement $ element ) { $ version = $ this -> getVersion ( ) ; if ( ( $ responseIdentifier = $ this -> getDOMElementAttributeAs ( $ element , 'responseIdentifier' ) ) !== null ) { $ objectElts = $ this -> getChildElementsByTagName ( $ element , 'object' ) ; if ( count ( $ objectElts ) >...
Unmarshall a DOMElement object corresponding to an positionObjectInteraction element .
3,058
protected function unmarshall ( DOMElement $ element ) { $ areaMapEntries = new AreaMapEntryCollection ( ) ; $ areaMapEntryElts = $ this -> getChildElementsByTagName ( $ element , 'areaMapEntry' ) ; foreach ( $ areaMapEntryElts as $ areaMapEntryElt ) { $ marshaller = $ this -> getMarshallerFactory ( ) -> createMarshall...
Unmarshall a DOMElement object corresponding to a QTI areaMapping element .
3,059
protected function marshall ( QtiComponent $ component ) { $ element = $ this -> createElement ( $ component ) ; $ this -> fillElement ( $ element , $ component ) ; $ this -> setDOMElementAttribute ( $ element , 'responseIdentifier' , $ component -> getResponseIdentifier ( ) ) ; $ this -> setDOMElementAttribute ( $ ele...
Marshall an EndAttemptInteraction object into a DOMElement object .
3,060
protected function unmarshall ( DOMElement $ element ) { if ( ( $ responseIdentifier = $ this -> getDOMElementAttributeAs ( $ element , 'responseIdentifier' ) ) !== null ) { if ( ( $ title = $ this -> getDOMElementAttributeAs ( $ element , 'title' ) ) === null ) { $ title = '' ; } $ component = new EndAttemptInteractio...
Unmarshall a DOMElement object corresponding to an endAttemptInteraction element .
3,061
public function getXml ( ) { if ( $ this -> xml === null ) { $ xml = new SerializableDomDocument ( '1.0' , 'UTF-8' ) ; if ( @ $ xml -> loadXML ( $ this -> getXmlString ( ) ) === false ) { $ msg = "The XML content '" . $ this -> getXmlString ( ) . "' of the '" . $ this -> getQtiClassName ( ) . "' external component coul...
Returns the XML representation of the external component as a DOMDocument object .
3,062
public function setShape ( $ shape ) { if ( in_array ( $ shape , QtiShape :: asArray ( ) ) === true ) { $ this -> shape = $ shape ; } else { $ msg = "The 'shape' argument must be a value from the Shape enumeration, '" . $ shape . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the shape of the associableHotspot .
3,063
public function setN ( $ n ) { if ( is_int ( $ n ) || ( gettype ( $ n ) === 'string' && Format :: isVariableRef ( $ n ) ) ) { $ this -> n = $ n ; } else { $ msg = "The n attribute must be an integer or a variable reference, '" . gettype ( $ n ) . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the n attribute .
3,064
public static function variableName ( $ value , $ occurence = 0 ) { if ( is_int ( $ occurence ) === false || $ occurence < 0 ) { $ msg = "The 'occurence' argument must be a positive integer (>= 0)." ; throw new InvalidArgumentException ( $ msg ) ; } if ( is_object ( $ value ) === true ) { $ object = new ReflectionObjec...
Generate a variable name for a given object .
3,065
protected function getAttributeName ( DOMElement $ element , $ attribute ) { if ( $ this -> isWebComponentFriendly ( ) === true && preg_match ( '/^qti-/' , $ element -> localName ) === 1 ) { $ qtiFriendlyClassName = XmlUtils :: qtiFriendlyName ( $ element -> localName ) ; if ( in_array ( $ qtiFriendlyClassName , self :...
Get Attribute Name to Use for Marshalling
3,066
public static function setDOMElementValue ( DOMElement $ element , $ value ) { switch ( gettype ( $ value ) ) { case 'boolean' : $ element -> nodeValue = ( $ value === true ) ? 'true' : 'false' ; break ; default : $ element -> nodeValue = $ value ; break ; } }
Set the node value of a given DOMElement object . Boolean values will be transformed as true | false .
3,067
public static function getFirstChildElement ( $ element ) { $ children = $ element -> childNodes ; for ( $ i = 0 ; $ i < $ children -> length ; $ i ++ ) { $ child = $ children -> item ( $ i ) ; if ( $ child -> nodeType === XML_ELEMENT_NODE ) { return $ child ; } } return false ; }
Get the first child DOM Node with nodeType attribute equals to XML_ELEMENT_NODE . This is very useful to get a sub - node without having to exclude text nodes cdata ... manually .
3,068
protected function unmarshall ( DOMElement $ element ) { $ interpretation = $ this -> getDOMElementAttributeAs ( $ element , 'interpretation' , 'string' ) ; $ interpretation = ( empty ( $ interpretation ) ) ? '' : $ interpretation ; $ values = new ValueCollection ( ) ; $ valueElements = $ element -> getElementsByTagNam...
Unmarshall a DOMElement object corresponding to a QTI defaultValue element .
3,069
public static function timeDiffSeconds ( DateTime $ time1 , DateTime $ time2 ) { $ interval = $ time1 -> diff ( $ time2 ) ; return self :: totalSeconds ( $ interval ) ; }
Get the time difference between two DateTime object in seconds .
3,070
public function push ( $ value ) { $ this -> checkType ( $ value ) ; $ data = & $ this -> getDataPlaceHolder ( ) ; array_push ( $ data , $ value ) ; }
Push a given StackTraceItem object on the StackTrace .
3,071
public function setValue ( $ value ) { if ( $ value instanceof PhpVariable || Utils :: isScalar ( $ value ) ) { $ this -> value = $ value ; } else { $ msg = "The 'value' argument must be a PHP scalar value, a PhpVariable object or null, '" . gettype ( $ value ) . "' given." ; throw new InvalidArgumentException ( $ msg ...
Set the value of the argument . It can be a PhpVariable object or PHP scalar value or null .
3,072
protected function marshall ( QtiComponent $ component ) { $ element = static :: getDOMCradle ( ) -> createElement ( $ component -> getQtiClassName ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'identifier' , $ component -> getIdentifier ( ) ) ; return $ element ; }
Marshall a MapResponsePoint object into a DOMElement object .
3,073
protected function unmarshall ( DOMElement $ element ) { if ( ( $ identifier = $ this -> getDOMElementAttributeAs ( $ element , 'identifier' , 'string' ) ) !== null ) { $ object = new MapResponsePoint ( $ identifier ) ; return $ object ; } else { $ msg = "The mandatory attribute 'identifier' is missing from element '" ...
Unmarshall a DOMElement object corresponding to a QTI mapResponsePoint element .
3,074
protected function marshallChildrenKnown ( QtiComponent $ component , array $ elements ) { $ element = self :: getDOMCradle ( ) -> createElement ( $ component -> getQtiClassName ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'name' , Statistics :: getNameByConstant ( $ component -> getName ( ) ) ) ; foreach ( $...
Unmarshall a StatsOperator object into a QTI statsOperator element .
3,075
protected function unmarshallChildrenKnown ( DOMElement $ element , QtiComponentCollection $ children ) { if ( ( $ name = $ this -> getDOMElementAttributeAs ( $ element , 'name' ) ) !== null ) { $ object = new StatsOperator ( $ children , Statistics :: getConstantByName ( $ name ) ) ; return $ object ; } else { $ msg =...
Unmarshall a QTI statsOperator operator element into a StatsOperator object .
3,076
protected function setIdentifier ( $ identifier ) { if ( Utils :: isValidVariableIdentifier ( $ identifier ) ) { $ this -> identifier = $ identifier ; } else { $ msg = "The identifier '${identifier}' is not a valid QTI Variable Name Identifier." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the identifier string .
3,077
public function getDays ( $ total = false ) { return ( $ total == true ) ? $ this -> getInterval ( ) -> days : $ this -> getInterval ( ) -> d ; }
Get the number of days .
3,078
public function getSeconds ( $ total = false ) { if ( $ total === false ) { return $ this -> getInterval ( ) -> s ; } $ sYears = 31536000 * $ this -> getYears ( ) ; $ sMonths = 30 * 24 * 3600 * $ this -> getMonths ( ) ; $ sDays = 24 * 3600 * $ this -> getDays ( ) ; $ sHours = 3600 * $ this -> getHours ( ) ; $ sMinutes ...
Get the number of seconds .
3,079
public function add ( $ duration ) { $ d1 = $ this -> refDate ; $ d2 = clone $ d1 ; if ( $ duration instanceof QtiDuration ) { $ toAdd = $ duration ; } elseif ( $ duration instanceof DateInterval ) { $ toAdd = self :: createFromDateInterval ( $ duration ) ; } else { return ; } $ d2 -> add ( new DateInterval ( $ this ->...
Add a duration to this one .
3,080
public function process ( ) { $ itemSubset = $ this -> getItemSubset ( ) ; if ( count ( $ itemSubset ) === 0 ) { return null ; } $ testSession = $ this -> getState ( ) ; $ outcomeIdentifier = $ this -> getExpression ( ) -> getOutcomeIdentifier ( ) ; $ weightIdentifier = $ this -> getExpression ( ) -> getWeightIdentifie...
Process the related OutcomeMaximum expression .
3,081
public function setShuffle ( $ shuffle ) { if ( is_bool ( $ shuffle ) ) { $ this -> shuffle = $ shuffle ; } else { $ msg = "Shuffle must be a boolean, '" . gettype ( $ shuffle ) . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set if the child elements must be randomized .
3,082
protected function marshall ( QtiComponent $ component ) { $ element = parent :: marshall ( $ component ) ; $ version = $ this -> getVersion ( ) ; if ( $ component -> isParamVariable ( ) === true ) { $ this -> setDOMElementAttribute ( $ element , 'paramVariable' , true ) ; } elseif ( Version :: compare ( $ version , '2...
Marshall a TemplateDeclaration object into a DOMElement object .
3,083
protected function unmarshall ( DOMElement $ element ) { try { $ baseComponent = parent :: unmarshall ( $ element ) ; $ object = new TemplateDeclaration ( $ baseComponent -> getIdentifier ( ) ) ; $ object -> setBaseType ( $ baseComponent -> getBaseType ( ) ) ; $ object -> setCardinality ( $ baseComponent -> getCardinal...
Unmarshall a DOMElement object corresponding to a QTI templateDeclaration element .
3,084
public function load ( $ url ) { if ( is_readable ( $ url ) === false ) { $ msg = "The PHP document located at '${url}' is not readable or does not exist." ; throw new PhpStorageException ( $ msg , PhpStorageException :: READ ) ; } try { require $ url ; $ this -> setDocumentComponent ( $ rootcomponent ) ; $ this -> set...
Load a PHP QTI document at the specified URL .
3,085
public function setTemplateRules ( TemplateRuleCollection $ templateRules ) { if ( count ( $ templateRules ) > 0 ) { $ this -> templateRules = $ templateRules ; } else { $ msg = "A TemplateProcessing object must be composed of at least one TemplateRule object, none given." ; throw new InvalidArgumentException ( $ msg )...
Set the collection of TemplateRule objects composing the template processing .
3,086
public function setBase ( $ base ) { if ( is_int ( $ base ) === true && $ base >= 0 ) { $ this -> base = $ base ; } else { $ msg = "The 'base' argument must be a positive (>= 0) integer value, '" . gettype ( $ base ) . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
If the interaction is bound to a numeric response variable get the number base in which to interpret the value entered by the candidate .
3,087
public function setFormat ( $ format ) { if ( in_array ( $ format , TextFormat :: asArray ( ) ) === true ) { $ this -> format = $ format ; } else { $ msg = "The 'format' argument must be a value from the TextFormat enumeration, '" . gettype ( $ format ) . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the format of the text entered by the candidate .
3,088
public function setOutcomeRules ( ResponseRuleCollection $ responseRules ) { if ( count ( $ responseRules ) > 0 ) { $ this -> responseRules = $ responseRules ; } else { $ msg = "A ResponseElse object must be bound to at least one ResponseRule object." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the ResponseRule objects to be evaluated .
3,089
public function setGapChoices ( GapChoiceCollection $ gapChoices ) { if ( count ( $ gapChoices ) > 0 ) { $ this -> gapChoices = $ gapChoices ; } else { $ msg = "A GapMatchInteraction object must be composed of at least one GapChoice object, none given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Set the collection of choices for filling the gaps .
3,090
public function pushTrail ( $ components ) { $ trail = & $ this -> getTrail ( ) ; if ( $ components instanceof QtiComponent ) { array_push ( $ trail , $ components ) ; } else { $ i = count ( $ components ) ; while ( $ i >= 1 ) { $ i -- ; array_push ( $ trail , $ components [ $ i ] ) ; } } }
Push some Rule objects on the trail stack .
3,091
protected function marshall ( QtiComponent $ component ) { $ element = static :: getDOMCradle ( ) -> createElement ( $ component -> getQtiClassName ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'baseType' , BaseType :: getNameByConstant ( $ component -> getBaseType ( ) ) ) ; self :: setDOMElementValue ( $ elem...
Marshall a BaseValue object into a DOMElement object .
3,092
protected function unmarshall ( DOMElement $ element ) { if ( ( $ baseType = $ this -> getDOMElementAttributeAs ( $ element , 'baseType' , 'string' ) ) !== null ) { $ value = $ element -> nodeValue ; $ baseTypeCst = BaseType :: getConstantByName ( $ baseType ) ; if ( $ baseTypeCst !== BaseType :: STRING ) { $ value = t...
Unmarshall a DOMElement object corresponding to a QTI baseValue element .
3,093
public function process ( ) { $ operands = $ this -> getOperands ( ) ; $ expression = $ this -> getExpression ( ) ; return new QtiBoolean ( $ operands -> containsNull ( ) ) ; }
Process the IsNullExpression object from the QTI Data Model .
3,094
protected function marshall ( QtiComponent $ component ) { $ element = static :: getDOMCradle ( ) -> createElement ( $ component -> getQtiClassName ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'identifier' , $ component -> getIdentifier ( ) ) ; $ this -> setDOMElementAttribute ( $ element , 'cardinality' , Ca...
Marshall a VariableDeclaration object into a DOMElement object .
3,095
protected function unmarshall ( DOMElement $ element ) { try { if ( ( $ identifier = $ this -> getDOMElementAttributeAs ( $ element , 'identifier' ) ) !== null ) { if ( ( $ cardinality = $ this -> getDOMElementAttributeAs ( $ element , 'cardinality' ) ) !== null ) { $ object = new VariableDeclaration ( $ identifier , -...
Unmarshall a DOMElement object corresponding to a QTI variableDeclaration element .
3,096
public function marshall ( ) { $ toMarshall = $ this -> getToMarshall ( ) ; try { if ( $ toMarshall instanceof QtiCoords ) { $ this -> marshallCoords ( ) ; return ; } elseif ( $ toMarshall instanceof QtiPair ) { $ this -> marshallPair ( ) ; return ; } elseif ( $ toMarshall instanceof QtiDuration ) { $ this -> marshallD...
Marshall a QtiDatatype object into PHP source code .
3,097
protected function marshallCoords ( ) { $ coords = $ this -> getToMarshall ( ) ; $ array = $ coords -> getArrayCopy ( ) ; $ shape = $ coords -> getShape ( ) ; $ ctx = $ this -> getContext ( ) ; $ access = $ ctx -> getStreamAccess ( ) ; $ args = new PhpArgumentCollection ( ) ; foreach ( $ array as $ a ) { $ args [ ] = n...
Marshall a Coords QTI datatype object .
3,098
protected function marshallPair ( ) { $ pair = $ this -> getToMarshall ( ) ; $ ctx = $ this -> getContext ( ) ; $ access = $ ctx -> getStreamAccess ( ) ; try { $ varName = $ ctx -> generateVariableName ( $ pair ) ; $ access -> writeVariable ( $ varName ) ; $ access -> writeEquals ( $ ctx -> mustFormatOutput ( ) ) ; $ a...
Marshall a Pair QTI datatype object .
3,099
protected function marshallDuration ( ) { $ duration = $ this -> getToMarshall ( ) ; $ ctx = $ this -> getContext ( ) ; $ access = $ ctx -> getStreamAccess ( ) ; try { $ varName = $ ctx -> generateVariableName ( $ duration ) ; $ access -> writeVariable ( $ varName ) ; $ access -> writeEquals ( $ ctx -> mustFormatOutput...
Marshall a Duration QTI datatype object .