Data generator class for mod_data.  
 More...
|  | 
|  | create_content ($instance, $record=array()) | 
|  | Generates a piece of content for the module. 
 | 
|  | 
|  | create_entry ($data, array $contents, $groupid=0, $tags=[], array $options=null, int $userid=0) | 
|  | Creates a field for a mod_data instance. 
 | 
|  | 
|  | create_field (stdClass $record=null, $data=null) | 
|  | Creates a field for a mod_data instance. 
 | 
|  | 
|  | create_instance ($record=null, array $options=null) | 
|  | Creates a mod_data instance. 
 | 
|  | 
|  | create_preset (stdClass $instance, stdClass $record=null) | 
|  | Creates a preset from a mod_data instance. 
 | 
|  | 
|  | get_modulename () | 
|  | Returns module name. 
 | 
|  | 
|  | reset () | 
|  | To be called from data reset code only, do not use in tests. 
 | 
|  | 
|  | 
|  | insert_files (stdClass $instance, stdClass $record, string $table, context $context, string $component, string $filearea, int $targetitemid) | 
|  | Update the instance record, inserting any files that are referenced. 
 | 
|  | 
|  | post_add_instance ($id, $cmid) | 
|  | Called after *_add_instance() 
 | 
|  | 
|  | precreate_course_module ($courseid, array $options) | 
|  | Create course module and link it to course. 
 | 
|  | 
|  | prepare_moduleinfo_record ($record, $options) | 
|  | Merges together arguments $record and $options and fills default module fields that are shared by all module types. 
 | 
|  | 
|  | set_user (?stdClass $user=null) | 
|  | Set the current user during data generation. 
 | 
|  | 
|  | 
| int | $databasefieldcount = 0 | 
|  | keep track of how many database fields have been created. 
 | 
|  | 
| int | $databaserecordcount = 0 | 
|  | keep track of how many database records have been created. 
 | 
|  | 
| testing_data_generator | $datagenerator | 
|  | 
| int | $instancecount = 0 | 
|  | number of created instances 
 | 
|  | 
Data generator class for mod_data. 
- Copyright
- 2012 Petr Skoda  
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 
◆ create_content()
  
  | 
        
          | testing_module_generator::create_content | ( |  | $instance, |  
          |  |  |  | $record = array() ) |  | inherited | 
 
 
◆ create_entry()
      
        
          | mod_data_generator::create_entry | ( |  | $data, | 
        
          |  |  | array | $contents, | 
        
          |  |  |  | $groupid = 0, | 
        
          |  |  |  | $tags = [], | 
        
          |  |  | array | $options = null, | 
        
          |  |  | int | $userid = 0 ) | 
      
 
Creates a field for a mod_data instance. 
Keep in mind the default data field params created in create_field() function! ...if you haven't provided your own custom data field parameters there. The developers using the generator must adhere to the following format :
Syntax : $contents[ fieldid ] = fieldvalue $contents['checkbox'] = array('val1', 'val2', 'val3' .....) $contents['data'] = 'dd-mm-yyyy' $contents['menu'] = 'value'; $contents['multimenu'] = array('val1', 'val2', 'val3' .....) $contents['number'] = 'numeric value' $contents['radiobuton'] = 'value' $contents['text'] = 'text' $contents['textarea'] = 'text' $contents['url'] = 'example.url' or array('example.url', 'urlname') $contents['latlong'] = array('value for lattitude', 'value for longitude') $contents['file'] = 'filename or draftitemid' $contents['picture'] = array('filename or draftitemid', 'alternative text')
- Parameters
- 
  
    | stdClass | $data | record from table {data} |  | array | $contents |  |  | int | $groupid |  |  | array | $tags |  |  | array | $options |  |  | int | $userid | if defined, it will be the author of the entry |  
 
- Return values
- 
  
    | int | id of the generated record in table {data_records} |  
 
 
 
◆ create_field()
      
        
          | mod_data_generator::create_field | ( | stdClass | $record = null, | 
        
          |  |  |  | $data = null ) | 
      
 
Creates a field for a mod_data instance. 
- Parameters
- 
  
  
- Return values
- 
  
  
 
 
◆ create_instance()
      
        
          | mod_data_generator::create_instance | ( |  | $record = null, | 
        
          |  |  | array | $options = null ) | 
      
 
 
◆ create_preset()
      
        
          | mod_data_generator::create_preset | ( | stdClass | $instance, | 
        
          |  |  | stdClass | $record = null ) | 
      
 
Creates a preset from a mod_data instance. 
- Parameters
- 
  
    | stdClass | $instance | The mod_data instance. |  | stdClass | null | $record | The preset information, like 'name'. |  
 
- Return values
- 
  
    | preset | The preset that has been created. |  
 
 
 
◆ get_modulename()
  
  | 
        
          | testing_module_generator::get_modulename | ( |  | ) |  |  | inherited | 
 
Returns module name. 
- Return values
- 
  
    | string | name of module that this class describes |  
 
- Exceptions
- 
  
  
 
 
◆ insert_files()
  
  | 
        
          | component_generator_base::insert_files | ( | stdClass | $instance, |  
          |  |  | stdClass | $record, |  
          |  |  | string | $table, |  
          |  |  | context | $context, |  
          |  |  | string | $component, |  
          |  |  | string | $filearea, |  
          |  |  | int | $targetitemid ) |  | protectedinherited | 
 
Update the instance record, inserting any files that are referenced. 
- Parameters
- 
  
    | stdClass | $instance | The instance record of the already-created record |  | stdClass | $record | The data passed in to create the instance |  | string | $table | The table that the data exists in |  | context | $context | The context of the instance |  | string | $component | The component of the owning plugin |  | string | $filearea | The name of the file area |  | int | $targetitemid | The itemid to use when saving the files |  
 
- Return values
- 
  
    | stdClass | The updated instance record |  
 
 
 
◆ post_add_instance()
  
  | 
        
          | testing_module_generator::post_add_instance | ( |  | $id, |  
          |  |  |  | $cmid ) |  | protectedinherited | 
 
 
◆ precreate_course_module()
  
  | 
        
          | testing_module_generator::precreate_course_module | ( |  | $courseid, |  
          |  |  | array | $options ) |  | protectedinherited | 
 
 
◆ prepare_moduleinfo_record()
  
  | 
        
          | testing_module_generator::prepare_moduleinfo_record | ( |  | $record, |  
          |  |  |  | $options ) |  | protectedinherited | 
 
Merges together arguments $record and $options and fills default module fields that are shared by all module types. 
- Parameters
- 
  
    | object | array | $record | fields (different from defaults) for this module |  | null | array | $options | for backward-compatibility this may include fields from course_modules table. They are merged into $record |  
 
- Exceptions
- 
  
  
 
 
◆ reset()
      
        
          | mod_data_generator::reset | ( |  | ) |  | 
      
 
 
◆ set_user()
  
  | 
        
          | component_generator_base::set_user | ( | ?stdClass | $user = null | ) |  |  | protectedinherited | 
 
Set the current user during data generation. 
This should be avoided wherever possible, but in some situations underlying code will insert data as the current user.
- Parameters
- 
  
  
 
 
The documentation for this class was generated from the following file: