Skip to content

Commit

Permalink
Codechecker and PHPDocs recomendations
Browse files Browse the repository at this point in the history
  • Loading branch information
drachels committed Oct 9, 2023
1 parent 0f50f6e commit 32d2ae1
Show file tree
Hide file tree
Showing 36 changed files with 621 additions and 570 deletions.
144 changes: 87 additions & 57 deletions backup/moodle2/backup_hotquestion_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,66 +51,96 @@ protected function define_structure() {
$userinfo = $this->get_setting_value('userinfo');

// Define each element separated.
$hotquestion = new backup_nested_element('hotquestion', array('id'),
array('name',
'intro',
'introformat',
'submitdirections',
'timecreated',
'timemodified',
'timeopen',
'timeclose',
'viewaftertimeclose',
'questionlabel',
'teacherpriorityvisibility',
'teacherprioritylabel',
'heatvisibility',
'heatlabel',
'heatlimit',
'anonymouspost',
'authorhide',
'approval',
'approvallabel',
'removelabel',
'scale',
'assessed',
'assesstimestart',
'assesstimefinish',
'comments',
'grade',
'postmaxgrade',
'factorheat',
'factorpriority',
'factorvote',
'completionpost',
'completionvote',
'completionpass'));
$hotquestion = new backup_nested_element('hotquestion',
[
'id',
],
[
'name',
'intro',
'introformat',
'submitdirections',
'timecreated',
'timemodified',
'timeopen',
'timeclose',
'viewaftertimeclose',
'questionlabel',
'teacherpriorityvisibility',
'teacherprioritylabel',
'heatvisibility',
'heatlabel',
'heatlimit',
'anonymouspost',
'authorhide',
'approval',
'approvallabel',
'removelabel',
'scale',
'assessed',
'assesstimestart',
'assesstimefinish',
'comments',
'grade',
'postmaxgrade',
'factorheat',
'factorpriority',
'factorvote',
'completionpost',
'completionvote',
'completionpass',
]
);

$grades = new backup_nested_element('grades');
$grade = new backup_nested_element('grade', array('id'),
array('userid',
'rawrating',
'timemodified'));
$grade = new backup_nested_element('grade',
[
'id',
],
[
'userid',
'rawrating',
'timemodified',
]
);

$questions = new backup_nested_element('questions');
$question = new backup_nested_element('question', array('id'),
array('content',
'format',
'userid',
'time',
'anonymous',
'approved',
'tpriority'));
$question = new backup_nested_element('question',
[
'id',
],
[
'content',
'format',
'userid',
'time',
'anonymous',
'approved',
'tpriority',
]
);

$rounds = new backup_nested_element('rounds');
$round = new backup_nested_element('round', array('id'),
array('starttime',
'endtime'));
$round = new backup_nested_element('round',
[
'id',
],
[
'starttime',
'endtime',
]
);

$votes = new backup_nested_element('votes');
$vote = new backup_nested_element('vote', array('id'),
array('question',
'voter'));
$vote = new backup_nested_element('vote',
[
'id',
],
[
'question',
'voter',
]
);

// Build the tree.
$hotquestion->add_child($grades);
Expand All @@ -126,14 +156,14 @@ protected function define_structure() {
$votes->add_child($vote);

// Define sources.
$hotquestion->set_source_table('hotquestion', array('id' => backup::VAR_ACTIVITYID));
$hotquestion->set_source_table('hotquestion', ['id' => backup::VAR_ACTIVITYID]);

// All the rest of elements only happen if we are including user info.
if ($userinfo) {
$grade->set_source_table('hotquestion_grades', array('hotquestion' => backup::VAR_PARENTID));
$question->set_source_table('hotquestion_questions', array('hotquestion' => backup::VAR_PARENTID));
$round->set_source_table('hotquestion_rounds', array('hotquestion' => backup::VAR_PARENTID));
$vote->set_source_table('hotquestion_votes', array('question' => backup::VAR_PARENTID));
$grade->set_source_table('hotquestion_grades', ['hotquestion' => backup::VAR_PARENTID]);
$question->set_source_table('hotquestion_questions', ['hotquestion' => backup::VAR_PARENTID]);
$round->set_source_table('hotquestion_rounds', ['hotquestion' => backup::VAR_PARENTID]);
$vote->set_source_table('hotquestion_votes', ['question' => backup::VAR_PARENTID]);
}

// Define id annotations.
Expand Down
10 changes: 5 additions & 5 deletions backup/moodle2/restore_hotquestion_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ protected function define_my_steps() {
* processed by the link decoder.
*/
public static function define_decode_contents() {
$contents = array();
$contents = [];

$contents[] = new restore_decode_content('hotquestion', array('intro'), 'hotquestion');
$contents[] = new restore_decode_content('hotquestion', ['intro'], 'hotquestion');

return $contents;
}
Expand All @@ -67,7 +67,7 @@ public static function define_decode_contents() {
* to the activity to be executed by the link decoder.
*/
public static function define_decode_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_decode_rule('HOTQUESTIONVIEWBYID', '/mod/hotquestion/view.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('HOTQUESTIONINDEX', '/mod/hotquestion/index.php?id=$1', 'course');
Expand All @@ -83,7 +83,7 @@ public static function define_decode_rules() {
* of restore_log_rule objects.
*/
public static function define_restore_log_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_log_rule('hotquestion', 'view', 'view.php?id={course_module}', '{hotquestion}');
$rules[] = new restore_log_rule('hotquestion', 'add question', 'view.php?id={course_module}', '{hotquestion}');
Expand All @@ -104,7 +104,7 @@ public static function define_restore_log_rules() {
* activity level. All them are rules not linked to any module instance cmid = 0).
*/
public static function define_restore_log_rules_for_course() {
$rules = array();
$rules = [];

// Fix old wrong uses (missing extension).
$rules[] = new restore_log_rule('hotquestion', 'view all', 'index?id={course}', null,
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/restore_hotquestion_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class restore_hotquestion_activity_structure_step extends restore_activity_struc
*/
protected function define_structure() {

$paths = array();
$paths = [];
$userinfo = $this->get_setting_value('userinfo');

$paths[] = new restore_path_element('hotquestion', '/activity/hotquestion');
Expand Down
2 changes: 1 addition & 1 deletion classes/completion/custom_completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function get_state(string $rule): int {

} else if ($rule == 'completionvote') {
$status = $hotquestion->completionvote <=
$DB->get_field_sql($questionvotesql , $questionvoteparams);
$DB->get_field_sql($questionvotesql, $questionvoteparams);
} else if ($rule == 'completionpass') {
$status = $hotquestion->completionpass <=
$DB->get_field_sql($questioncountsql.
Expand Down
2 changes: 1 addition & 1 deletion classes/event/add_question.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/hotquestion/edit.php', array('id' => $this->contextinstanceid));
return new \moodle_url('/mod/hotquestion/edit.php', ['id' => $this->contextinstanceid]);
}
}
2 changes: 1 addition & 1 deletion classes/event/add_round.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/hotquestion/view.php', array('id' => $this->contextinstanceid));
return new \moodle_url('/mod/hotquestion/view.php', ['id' => $this->contextinstanceid]);
}
}
2 changes: 1 addition & 1 deletion classes/event/comment_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class comment_created extends \core\event\comment_created {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/hotquestion/view.php', array('id' => $this->contextinstanceid));
return new \moodle_url('/mod/hotquestion/view.php', ['id' => $this->contextinstanceid]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/event/comment_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class comment_deleted extends \core\event\comment_deleted {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/hotquestion/view.php', array('id' => $this->contextinstanceid));
return new \moodle_url('/mod/hotquestion/view.php', ['id' => $this->contextinstanceid]);
}

/**
Expand Down
14 changes: 10 additions & 4 deletions classes/event/comments_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ public function get_description() {
* @return array
*/
protected function get_legacy_logdata() {
return(array($this->courseid, 'hotquestion', 'comments',
'comments.php?pageid=' . $this->objectid, $this->objectid, $this->contextinstanceid));
return(
[
$this->courseid,
'hotquestion',
'comments',
'comments.php?pageid=' . $this->objectid,
$this->objectid, $this->contextinstanceid,
]
);
}

/**
Expand All @@ -71,7 +78,6 @@ protected function get_legacy_logdata() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url("/mod/hotquestion/view.php",
array('eid' => $this->objectid));
return new \moodle_url("/mod/hotquestion/view.php", ['eid' => $this->objectid]);
}
}
2 changes: 1 addition & 1 deletion classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ protected function init() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/hotquestion/view.php', array('f' => $this->objectid));
return new \moodle_url('/mod/hotquestion/view.php', ['f' => $this->objectid]);
}
}
2 changes: 1 addition & 1 deletion classes/event/download_questions.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/hotquestion/view.php', array('id' => $this->contextinstanceid));
return new \moodle_url('/mod/hotquestion/view.php', ['id' => $this->contextinstanceid]);
}
}
2 changes: 1 addition & 1 deletion classes/event/entries_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/hotquestion/report.php', array('id' => $this->contextinstanceid));
return new \moodle_url('/mod/hotquestion/report.php', ['id' => $this->contextinstanceid]);
}
}
2 changes: 1 addition & 1 deletion classes/event/entry_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/hotquestion/edit.php', array('id' => $this->contextinstanceid));
return new \moodle_url('/mod/hotquestion/edit.php', ['id' => $this->contextinstanceid]);
}
}
2 changes: 1 addition & 1 deletion classes/event/remove_question.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/hotquestion/view.php', array('id' => $this->contextinstanceid));
return new \moodle_url('/mod/hotquestion/view.php', ['id' => $this->contextinstanceid]);
}
}
2 changes: 1 addition & 1 deletion classes/event/remove_round.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/hotquestion/view.php', array('id' => $this->contextinstanceid));
return new \moodle_url('/mod/hotquestion/view.php', ['id' => $this->contextinstanceid]);
}
}
2 changes: 1 addition & 1 deletion classes/event/remove_vote.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/hotquestion/view.php', array('id' => $this->contextinstanceid));
return new \moodle_url('/mod/hotquestion/view.php', ['id' => $this->contextinstanceid]);
}
}
2 changes: 1 addition & 1 deletion classes/event/update_vote.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/hotquestion/view.php', array('id' => $this->contextinstanceid));
return new \moodle_url('/mod/hotquestion/view.php', ['id' => $this->contextinstanceid]);
}
}
Loading

0 comments on commit 32d2ae1

Please sign in to comment.