public function getVariableFile($variableUri) {
        //distinguish QTI file from other "file" base type
        $baseType = $this->getVariableBaseType($variableUri);

        // https://bugs.php.net/bug.php?id=52623 ;
        // if the constant for max buffering, mysqlnd or similar driver
        // is being used without need to adapt buffer size as it is atutomatically adapted for all the data.
        if (core_kernel_classes_DbWrapper::singleton()->getPlatForm()->getName() == 'mysql') {
            if (defined("PDO::MYSQL_ATTR_MAX_BUFFER_SIZE")) {
                $maxBuffer = (is_int(ini_get('upload_max_filesize'))) ? (ini_get('upload_max_filesize')* 1.5) : 10485760 ;
                core_kernel_classes_DbWrapper::singleton()->getSchemaManager()->setAttribute(\PDO::MYSQL_ATTR_MAX_BUFFER_SIZE,$maxBuffer);
            }
        }

        switch ($baseType) {
            case "file": {
                    $value = $this->getVariableCandidateResponse($variableUri);
                    common_Logger::i(var_export(strlen($value), true));
                    $decodedFile = Datatypes::decodeFile($value);
                    common_Logger::i("FileName:");
                    common_Logger::i(var_export($decodedFile["name"], true));
                    common_Logger::i("Mime Type:");
                    common_Logger::i(var_export($decodedFile["mime"], true));
                    $file = array(
                        "data" => $decodedFile["data"],
                        "mimetype" => "Content-type: " . $decodedFile["mime"],
                        "filename" => $decodedFile["name"]);
                    break;
                }
            default: { //legacy files
                    $file = array(
                        "data" => $this->getVariableCandidateResponse($variableUri),
                        "mimetype" => "Content-type: text/xml",
                        "filename" => "trace.xml");
                }
        }
        return $file;
    }
public function getVariableFile($variableUri) {
        //distinguish QTI file from other "file" base type
        $baseType = $this->getVariableBaseType($variableUri);

        // https://bugs.php.net/bug.php?id=52623 ;
        // if the constant for max buffering, mysqlnd or similar driver
        // is being used without need to adapt buffer size as it is atutomatically adapted for all the data.
        if (core_kernel_classes_DbWrapper::singleton()->getPlatForm()->getName() == 'mysql') {
            if (defined("PDO::MYSQL_ATTR_MAX_BUFFER_SIZE")) {
                $maxBuffer = (is_int(ini_get('upload_max_filesize'))) ? (ini_get('upload_max_filesize')* 1.5) : 10485760 ;
                core_kernel_classes_DbWrapper::singleton()->getSchemaManager()->setAttribute(\PDO::MYSQL_ATTR_MAX_BUFFER_SIZE,$maxBuffer);
            }
        }

        switch ($baseType) {
            case "file": {
                    $value = $this->getVariableCandidateResponse($variableUri);
                    common_Logger::i(var_export(strlen($value), true));
                    $decodedFile = Datatypes::decodeFile($value);
                    common_Logger::i("FileName:");
                    common_Logger::i(var_export($decodedFile["name"], true));
                    common_Logger::i("Mime Type:");
                    common_Logger::i(var_export($decodedFile["mime"], true));
                    $file = array(
                        "data" => $decodedFile["data"],
                        "mimetype" => "Content-type: " . $decodedFile["mime"],
                        "filename" => $decodedFile["name"]);
                    break;
                }
            default: { //legacy files
                    $file = array(
                        "data" => $this->getVariableCandidateResponse($variableUri),
                        "mimetype" => "Content-type: text/xml",
                        "filename" => "trace.xml");
                }
        }
        return $file;
    }
public function getVariableFile ( $ variableUri ) { //distinguish QTI file from other "file" base type $ baseType = $ this -> getVariableBaseType ( $ variableUri ) ; // https://bugs.php.net/bug.php?id=52623 ; // if the constant for max buffering, mysqlnd or similar driver // is being used without need to adapt buffer size as it is atutomatically adapted for all the data. if ( core_kernel_classes_DbWrapper :: singleton ( ) -> getPlatForm ( ) -> getName ( ) == 'mysql' ) { if ( defined ( "PDO::MYSQL_ATTR_MAX_BUFFER_SIZE" ) ) { $ maxBuffer = ( is_int ( ini_get ( 'upload_max_filesize' ) ) ) ? ( ini_get ( 'upload_max_filesize' ) * 1.5 ) : 10485760 ; core_kernel_classes_DbWrapper :: singleton ( ) -> getSchemaManager ( ) -> setAttribute ( \ PDO :: MYSQL_ATTR_MAX_BUFFER_SIZE , $ maxBuffer ) ; } } switch ( $ baseType ) { case "file" : { $ value = $ this -> getVariableCandidateResponse ( $ variableUri ) ; common_Logger :: i ( var_export ( strlen ( $ value ) , true ) ) ; $ decodedFile = Datatypes :: decodeFile ( $ value ) ; common_Logger :: i ( "FileName:" ) ; common_Logger :: i ( var_export ( $ decodedFile [ "name" ] , true ) ) ; common_Logger :: i ( "Mime Type:" ) ; common_Logger :: i ( var_export ( $ decodedFile [ "mime" ] , true ) ) ; $ file = array ( "data" => $ decodedFile [ "data" ] , "mimetype" => "Content-type: " . $ decodedFile [ "mime" ] , "filename" => $ decodedFile [ "name" ] ) ; break ; } default : { //legacy files $ file = array ( "data" => $ this -> getVariableCandidateResponse ( $ variableUri ) , "mimetype" => "Content-type: text/xml" , "filename" => "trace.xml" ) ; } } return $ file ; }
Return the file data associate to a variable
@param $variableUri
@return array file data
@throws \core_kernel_persistence_Exception
Return the file data associate to a variable