Skip to content

Commit

Permalink
Cleanup + Docs based on Moodle Code Checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Laur0r committed Jun 7, 2024
1 parent 6828664 commit 9cf176b
Show file tree
Hide file tree
Showing 35 changed files with 888 additions and 59 deletions.
9 changes: 8 additions & 1 deletion backup/moodle2/backup_ratingallocate_activity_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@
use mod_ratingallocate\db as this_db;

/**
* Define the complete ratingallocate structure for backup, with [file and] id annotations
* Class to define the complete ratingallocate structure for backup, with [file and] id annotations
*
* @package mod_ratingallocate
* @copyright 2014 C. Usener
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_ratingallocate_activity_structure_step extends backup_activity_structure_step {

/**
* Define the complete ratingallocate structure for backup.
* @return backup_nested_element
* @throws ReflectionException
* @throws base_element_struct_exception
* @throws base_step_exception
*/
protected function define_structure() {

// To know if we are including userinfo.
Expand Down
55 changes: 52 additions & 3 deletions backup/moodle2/restore_ratingallocate_activity_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@
*/
class restore_ratingallocate_activity_structure_step extends restore_activity_structure_step {

/**
* Define the complete ratingallocate structure for restore.
* @return mixed
* @throws base_step_exception
*/
protected function define_structure() {
$paths = array();
$paths = [];
$userinfo = $this->get_setting_value('userinfo');

$ratingallocatepath = '/activity/' . this_db\ratingallocate::TABLE;
Expand All @@ -52,6 +57,12 @@ protected function define_structure() {
return $this->prepare_activity_structure($paths);
}

/**
* @param $data
* @return void
* @throws base_step_exception
* @throws dml_exception
*/
protected function process_ratingallocate($data) {
global $DB;
$data = (object) $data;
Expand All @@ -74,6 +85,13 @@ protected function process_ratingallocate($data) {
$this->apply_activity_instance($newitemid);
}

/**
* Restore data for ratingallocate choices.
* @param $data
* @return void
* @throws dml_exception
* @throws restore_step_exception
*/
protected function process_ratingallocate_choices($data) {
global $DB;
$data = (object) $data;
Expand All @@ -86,6 +104,13 @@ protected function process_ratingallocate_choices($data) {
$this->set_mapping(this_db\ratingallocate_choices::TABLE, $oldid, $newitemid);
}

/**
* Restore data for the ratingallocate ratings of users.
* @param $data
* @return void
* @throws dml_exception
* @throws restore_step_exception
*/
protected function process_ratingallocate_ratings($data) {
global $DB;
$data = (object) $data;
Expand All @@ -99,6 +124,13 @@ protected function process_ratingallocate_ratings($data) {
$this->set_mapping(this_db\ratingallocate_ratings::TABLE, $oldid, $newitemid);
}

/**
* Restore data of allocations of users to choices.
* @param $data
* @return void
* @throws dml_exception
* @throws restore_step_exception
*/
protected function process_ratingallocate_allocations($data) {
global $DB;
$data = (object) $data;
Expand All @@ -114,7 +146,7 @@ protected function process_ratingallocate_allocations($data) {
}

/**
* Process group choices restore data.
* Restore data of group restrictions of choices.
*
* @param array $data
* @return void
Expand All @@ -132,6 +164,13 @@ protected function process_ratingallocate_group_choices($data) {
$this->set_mapping(this_db\ratingallocate_group_choices::TABLE, $oldid, $newitemid);
}

/**
* Restore data for generated groups based on allocations.
* @param $data
* @return void
* @throws dml_exception
* @throws restore_step_exception
*/
protected function process_ratingallocate_ch_gengroups($data) {
global $DB;
$data = (object) $data;
Expand All @@ -145,6 +184,13 @@ protected function process_ratingallocate_ch_gengroups($data) {
$this->set_mapping(this_db\ratingallocate_ch_gengroups::TABLE, $oldid, $newitemid);
}

/**
* Restore data for generated groupings based on allocations.
* @param $data
* @return void
* @throws dml_exception
* @throws restore_step_exception
*/
protected function process_ratingallocate_groupings($data) {
global $DB;
$data = (object) $data;
Expand All @@ -158,8 +204,11 @@ protected function process_ratingallocate_groupings($data) {
$this->set_mapping(this_db\ratingallocate_groupings::TABLE, $oldid, $newitemid);
}

/**
* Add ratingallocate related files.
* @return void
*/
protected function after_execute() {
// Add ratingallocate related files.
$this->add_related_files('mod_' . RATINGALLOCATE_MOD_NAME, 'intro', null);
}
}
35 changes: 35 additions & 0 deletions classes/event/all_ratings_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,67 @@
**/
class all_ratings_deleted extends \core\event\base {

/**
* Create simple all_ratings_deleted event.
* @param $modulecontext
* @param $ratingallocateid
* @return \core\event\base
* @throws \coding_exception
*/
public static function create_simple($modulecontext, $ratingallocateid) {
return self::create(['context' => $modulecontext, 'objectid' => $ratingallocateid]);
}

/**
* Initialize data.
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'ratingallocate_ratings';
}

/**
* Get event name.
* @return \lang_string|string
* @throws \coding_exception
*/
public static function get_name() {
return get_string('log_all_ratings_deleted', 'mod_ratingallocate');
}

/**
* Get event description.
* @return \lang_string|string|null
* @throws \coding_exception
*/
public function get_description() {
return get_string('log_all_ratings_deleted_description', 'mod_ratingallocate',
['userid' => $this->userid, 'ratingallocateid' => $this->objectid]);
}

/**
* Get event url.
* @return \moodle_url
* @throws \moodle_exception
*/
public function get_url() {
return new \moodle_url('/mod/ratingallocate/view.php', ['m' => $this->objectid]);
}

/**
* Get event mapping.
* @return string[]
*/
public static function get_objectid_mapping() {
return ['db' => 'ratingallocate', 'restore' => 'ratingallocate'];
}

/**
* No other mappings available.
* @return false
*/
public static function get_other_mapping() {
return false;
}
Expand Down
34 changes: 34 additions & 0 deletions classes/event/allocation_published.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,67 @@
**/
class allocation_published extends \core\event\base {

/**
* Create simple allocation_published event.
* @param $modulecontext
* @param $ratingallocateid
* @return \core\event\base
* @throws \coding_exception
*/
public static function create_simple($modulecontext, $ratingallocateid) {
return self::create(['context' => $modulecontext, 'objectid' => $ratingallocateid]);
}

/**
* Initialize data.
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'ratingallocate';
}

/**
* Get event name.
* @return \lang_string|string
* @throws \coding_exception
*/
public static function get_name() {
return get_string('log_allocation_published', 'mod_ratingallocate');
}

/**
* Get event description.
* @return \lang_string|string|null
* @throws \coding_exception
*/
public function get_description() {
return get_string('log_allocation_published_description', 'mod_ratingallocate',
['userid' => $this->userid, 'ratingallocateid' => $this->objectid]);
}

/**
* Get event url.
* @return \moodle_url
* @throws \moodle_exception
*/
public function get_url() {
return new \moodle_url('/mod/ratingallocate/view.php', ['m' => $this->objectid]);
}

/**
* Get event mapping.
* @return string[]
*/
public static function get_objectid_mapping() {
return ['db' => 'ratingallocate', 'restore' => 'ratingallocate'];
}

/**
* No other mappings available.
* @return false
*/
public static function get_other_mapping() {
return false;
}
Expand Down
34 changes: 34 additions & 0 deletions classes/event/allocation_statistics_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,67 @@
**/
class allocation_statistics_viewed extends \core\event\base {

/**
* Create simple allocation_statistics_viewed event.
* @param $modulecontext
* @param $ratingallocateid
* @return \core\event\base
* @throws \coding_exception
*/
public static function create_simple($modulecontext, $ratingallocateid) {
return self::create(['context' => $modulecontext, 'objectid' => $ratingallocateid]);
}

/**
* Initialize data.
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'ratingallocate';
}

/**
* Get event name.
* @return \lang_string|string
* @throws \coding_exception
*/
public static function get_name() {
return get_string('log_allocation_statistics_viewed', 'mod_ratingallocate');
}

/**
* Get event description.
* @return \lang_string|string|null
* @throws \coding_exception
*/
public function get_description() {
return get_string('log_allocation_statistics_viewed_description', 'mod_ratingallocate',
['userid' => $this->userid, 'ratingallocateid' => $this->objectid]);
}

/**
* Get event url.
* @return \moodle_url
* @throws \moodle_exception
*/
public function get_url() {
return new \moodle_url('/mod/ratingallocate/view.php', ['m' => $this->objectid]);
}

/**
* Get event mapping.
* @return string[]
*/
public static function get_objectid_mapping() {
return ['db' => 'ratingallocate', 'restore' => 'ratingallocate'];
}

/**
* No other mappings available.
* @return false
*/
public static function get_other_mapping() {
return false;
}
Expand Down
Loading

0 comments on commit 9cf176b

Please sign in to comment.