private function create_small_files() {
        $count = self::$paramsmallfilecount[$this->size];
        $this->log('createsmallfiles', $count, true);

        // Create resource with default textfile only.
        $resourcegenerator = $this->generator->get_plugin_generator('mod_resource');
        $record = array('course' => $this->course,
                'name' => get_string('smallfiles', 'tool_generator'));
        $options = array('section' => 0);
        $resource = $resourcegenerator->create_instance($record, $options);

        // Add files.
        $fs = get_file_storage();
        $context = context_module::instance($resource->cmid);
        $filerecord = array('component' => 'mod_resource', 'filearea' => 'content',
                'contextid' => $context->id, 'itemid' => 0, 'filepath' => '/');
        for ($i = 0; $i < $count; $i++) {
            $filerecord['filename'] = 'smallfile' . $i . '.dat';

            // Generate random binary data (different for each file so it
            // doesn't compress unrealistically).
            $data = random_bytes_emulate($this->limit_filesize(self::$paramsmallfilesize[$this->size]));

            $fs->create_file_from_string($filerecord, $data);
            $this->dot($i, $count);
        }

        $this->end_log();
    }
private function create_small_files() {
        $count = self::$paramsmallfilecount[$this->size];
        $this->log('createsmallfiles', $count, true);

        // Create resource with default textfile only.
        $resourcegenerator = $this->generator->get_plugin_generator('mod_resource');
        $record = array('course' => $this->course,
                'name' => get_string('smallfiles', 'tool_generator'));
        $options = array('section' => 0);
        $resource = $resourcegenerator->create_instance($record, $options);

        // Add files.
        $fs = get_file_storage();
        $context = context_module::instance($resource->cmid);
        $filerecord = array('component' => 'mod_resource', 'filearea' => 'content',
                'contextid' => $context->id, 'itemid' => 0, 'filepath' => '/');
        for ($i = 0; $i < $count; $i++) {
            $filerecord['filename'] = 'smallfile' . $i . '.dat';

            // Generate random binary data (different for each file so it
            // doesn't compress unrealistically).
            $data = random_bytes_emulate($this->limit_filesize(self::$paramsmallfilesize[$this->size]));

            $fs->create_file_from_string($filerecord, $data);
            $this->dot($i, $count);
        }

        $this->end_log();
    }
private function create_small_files ( ) { $ count = self :: $ paramsmallfilecount [ $ this -> size ] ; $ this -> log ( 'createsmallfiles' , $ count , true ) ; // Create resource with default textfile only. $ resourcegenerator = $ this -> generator -> get_plugin_generator ( 'mod_resource' ) ; $ record = array ( 'course' => $ this -> course , 'name' => get_string ( 'smallfiles' , 'tool_generator' ) ) ; $ options = array ( 'section' => 0 ) ; $ resource = $ resourcegenerator -> create_instance ( $ record , $ options ) ; // Add files. $ fs = get_file_storage ( ) ; $ context = context_module :: instance ( $ resource -> cmid ) ; $ filerecord = array ( 'component' => 'mod_resource' , 'filearea' => 'content' , 'contextid' => $ context -> id , 'itemid' => 0 , 'filepath' => '/' ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ filerecord [ 'filename' ] = 'smallfile' . $ i . '.dat' ; // Generate random binary data (different for each file so it // doesn't compress unrealistically). $ data = random_bytes_emulate ( $ this -> limit_filesize ( self :: $ paramsmallfilesize [ $ this -> size ] ) ) ; $ fs -> create_file_from_string ( $ filerecord , $ data ) ; $ this -> dot ( $ i , $ count ) ; } $ this -> end_log ( ) ; }
Creates one resource activity with a lot of small files.
Creates one resource activity with a lot of small files .