Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tool_monitor_generator Class Reference
Inheritance diagram for tool_monitor_generator:
testing_module_generator component_generator_base

Public Member Functions

 create_content ($instance, $record=array())
 Generates a piece of content for the module. More...
 
 create_event_entries ($record=null)
 Function to generate event entries. More...
 
 create_history ($record=null)
 Function to generate history data. More...
 
 create_instance ($record=null, array $options=null)
 Creates an instance of the module for testing purposes. More...
 
 create_rule ($record=null)
 Function to generate rule data. More...
 
 create_subscription ($record=null)
 Function to generate subscription data. More...
 
 get_modulename ()
 Returns module name. More...
 
 reset ()
 To be called from data reset code only, do not use in tests. More...
 

Protected Member Functions

 post_add_instance ($id, $cmid)
 Called after *_add_instance() More...
 
 precreate_course_module ($courseid, array $options)
 Create course module and link it to course. More...
 
 prepare_moduleinfo_record ($record, $options)
 Merges together arguments $record and $options and fills default module fields that are shared by all module types. More...
 

Protected Attributes

testing_data_generator $datagenerator
 
number $instancecount = 0
 of created instances
 
int $rulecount
 keep track of how many rules have been created.
 

Member Function Documentation

◆ create_content()

testing_module_generator::create_content (   $instance,
  $record = array() 
)
inherited

Generates a piece of content for the module.

User is usually taken from global $USER variable.

Parameters
stdClass$instanceobject returned from create_instance() call
stdClass | array$record
Return values
stdClassgenerated object
Exceptions
coding_exceptionif function is not implemented by module

Reimplemented in mod_wiki_generator, mod_lesson_generator, mod_forum_generator, and mod_book_generator.

◆ create_event_entries()

tool_monitor_generator::create_event_entries (   $record = null)

Function to generate event entries.

Parameters
stdClass | array$recorddata to insert as event entry.
Return values
stdClass::$recordAn object representing the newly created event entry.

◆ create_history()

tool_monitor_generator::create_history (   $record = null)

Function to generate history data.

Exceptions
coding_exceptionif $record->sid or $record->userid not present.
Parameters
stdClass | array$recorddata to insert as history entry.
Return values
stdClass::$recordAn object representing the newly created history entry.

◆ create_instance()

testing_module_generator::create_instance (   $record = null,
array  $options = null 
)
inherited

Creates an instance of the module for testing purposes.

Module type will be taken from the class name. Each module type may overwrite this function to add other default values used by it.

Parameters
array | stdClass$recorddata for module being generated. Requires 'course' key (an id or the full object). Also can have any fields from add module form.
null | array$optionsgeneral options for course module. Since 2.6 it is possible to omit this argument by merging options into $record
Return values
stdClassrecord from module-defined table with additional field cmid (corresponding id in course_modules table)

Reimplemented in mod_workshop_generator, mod_wiki_generator, mod_url_generator, mod_survey_generator, mod_scorm_generator, mod_resource_generator, mod_quiz_generator, mod_page_generator, mod_lti_generator, mod_lesson_generator, mod_label_generator, mod_imscp_generator, mod_glossary_generator, mod_forum_generator, mod_folder_generator, mod_feedback_generator, mod_data_generator, mod_choice_generator, mod_chat_generator, mod_book_generator, mod_assignment_generator, and mod_assign_generator.

◆ create_rule()

tool_monitor_generator::create_rule (   $record = null)

Function to generate rule data.

Parameters
stdClass | array$recorddata to insert as rule entry.
Return values
tool_monitor

◆ create_subscription()

tool_monitor_generator::create_subscription (   $record = null)

Function to generate subscription data.

Exceptions
coding_exceptionif $record->ruleid or $record->userid not present.
Parameters
stdClass | array$recorddata to insert as subscription entry.
Return values
tool_monitor

◆ get_modulename()

testing_module_generator::get_modulename ( )
inherited

Returns module name.

Return values
stringname of module that this class describes
Exceptions
coding_exceptionif class invalid

◆ post_add_instance()

testing_module_generator::post_add_instance (   $id,
  $cmid 
)
protectedinherited

Called after *_add_instance()

Since 2.6 it is recommended to use function add_moduleinfo() to create a module.

Deprecated:
since 2.6
See also
testing_module_generator::create_instance()
Parameters
int$id
int$cmid
Return values
stdClassmodule instance

◆ precreate_course_module()

testing_module_generator::precreate_course_module (   $courseid,
array  $options 
)
protectedinherited

Create course module and link it to course.

Since 2.6 it is recommended to use function add_moduleinfo() to create a module.

Deprecated:
since 2.6
See also
testing_module_generator::create_instance()
Parameters
integer$courseid
array$optionssection, visible
Return values
integer::$cminstance id

◆ 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$recordfields (different from defaults) for this module
null | array$optionsfor backward-compatibility this may include fields from course_modules table. They are merged into $record
Exceptions
coding_exceptionif $record->course is not specified

◆ reset()

testing_module_generator::reset ( )
inherited

To be called from data reset code only, do not use in tests.

Return values
void

Reimplemented from component_generator_base.

Reimplemented in mod_wiki_generator, mod_survey_generator, mod_lesson_generator, mod_glossary_generator, mod_forum_generator, mod_data_generator, mod_chat_generator, and mod_book_generator.


The documentation for this class was generated from the following file: