public function writePendingResponses(AssessmentTestSeeker $seeker, PendingResponses $pendingResponses)
    {
        try {
            $state = $pendingResponses->getState();
            $itemRef = $pendingResponses->getAssessmentItemRef();
            $occurence = $pendingResponses->getOccurence();

            // Write the state.
            $responseDeclarations = $itemRef->getResponseDeclarations();
            $varCount = count($state);
            $this->writeTinyInt($varCount);

            foreach ($state as $responseVariable) {
                $respId = $responseVariable->getIdentifier();
                if (isset($responseDeclarations[$respId]) === true) {
                    $this->writeShort($seeker->seekPosition($responseDeclarations[$respId]));
                    $this->writeVariableValue($responseVariable);
                } else {
                    $msg = "No response variable with identifier '${respId}' found in related assessmentItemRef.";
                    throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::PENDING_RESPONSES);
                }
            }

            // Write the assessmentItemRef.
            $this->writeShort($seeker->seekPosition($itemRef));

            // Write the occurence number.
            $this->writeTinyInt($occurence);
        } catch (BinaryStreamAccessException $e) {
            $msg = "An error occured while reading some pending responses.";
            throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::PENDING_RESPONSES, $e);
        } catch (OutOfBoundsException $e) {
            $msg = "A QTI component position could not be found in the assessmentTest tree structure.";
            throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::PENDING_RESPONSES, $e);
        }
    }
public function writePendingResponses(AssessmentTestSeeker $seeker, PendingResponses $pendingResponses)
    {
        try {
            $state = $pendingResponses->getState();
            $itemRef = $pendingResponses->getAssessmentItemRef();
            $occurence = $pendingResponses->getOccurence();

            // Write the state.
            $responseDeclarations = $itemRef->getResponseDeclarations();
            $varCount = count($state);
            $this->writeTinyInt($varCount);

            foreach ($state as $responseVariable) {
                $respId = $responseVariable->getIdentifier();
                if (isset($responseDeclarations[$respId]) === true) {
                    $this->writeShort($seeker->seekPosition($responseDeclarations[$respId]));
                    $this->writeVariableValue($responseVariable);
                } else {
                    $msg = "No response variable with identifier '${respId}' found in related assessmentItemRef.";
                    throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::PENDING_RESPONSES);
                }
            }

            // Write the assessmentItemRef.
            $this->writeShort($seeker->seekPosition($itemRef));

            // Write the occurence number.
            $this->writeTinyInt($occurence);
        } catch (BinaryStreamAccessException $e) {
            $msg = "An error occured while reading some pending responses.";
            throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::PENDING_RESPONSES, $e);
        } catch (OutOfBoundsException $e) {
            $msg = "A QTI component position could not be found in the assessmentTest tree structure.";
            throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::PENDING_RESPONSES, $e);
        }
    }
public function writePendingResponses ( AssessmentTestSeeker $ seeker , PendingResponses $ pendingResponses ) { try { $ state = $ pendingResponses -> getState ( ) ; $ itemRef = $ pendingResponses -> getAssessmentItemRef ( ) ; $ occurence = $ pendingResponses -> getOccurence ( ) ; // Write the state. $ responseDeclarations = $ itemRef -> getResponseDeclarations ( ) ; $ varCount = count ( $ state ) ; $ this -> writeTinyInt ( $ varCount ) ; foreach ( $ state as $ responseVariable ) { $ respId = $ responseVariable -> getIdentifier ( ) ; if ( isset ( $ responseDeclarations [ $ respId ] ) === true ) { $ this -> writeShort ( $ seeker -> seekPosition ( $ responseDeclarations [ $ respId ] ) ) ; $ this -> writeVariableValue ( $ responseVariable ) ; } else { $ msg = "No response variable with identifier '${respId}' found in related assessmentItemRef." ; throw new QtiBinaryStreamAccessException ( $ msg , $ this , QtiBinaryStreamAccessException :: PENDING_RESPONSES ) ; } } // Write the assessmentItemRef. $ this -> writeShort ( $ seeker -> seekPosition ( $ itemRef ) ) ; // Write the occurence number. $ this -> writeTinyInt ( $ occurence ) ; } catch ( BinaryStreamAccessException $ e ) { $ msg = "An error occured while reading some pending responses." ; throw new QtiBinaryStreamAccessException ( $ msg , $ this , QtiBinaryStreamAccessException :: PENDING_RESPONSES , $ e ) ; } catch ( OutOfBoundsException $ e ) { $ msg = "A QTI component position could not be found in the assessmentTest tree structure." ; throw new QtiBinaryStreamAccessException ( $ msg , $ this , QtiBinaryStreamAccessException :: PENDING_RESPONSES , $ e ) ; } }
Write a PendingResponses object in the current binary stream.

@param \qtism\runtime\storage\common\AssessmentTestSeeker $seeker An AssessmentTestSeeker object from where positions in the assessmentTest tree will be pulled out.
@param \qtism\runtime\tests\PendingResponses $pendingResponses The read PendingResponses object.
@throws \qtism\runtime\storage\binary\QtiBinaryStreamAccessException
Write a PendingResponses object in the current binary stream .