From 85da7b661f4c81f70228faa5c0a9d66dc7c25b46 Mon Sep 17 00:00:00 2001 From: AL Rachels Date: Mon, 1 Jul 2024 13:16:31 -0500 Subject: [PATCH] codechecker fixes --- classes/completion/custom_completion.php | 1 - classes/local/results.php | 4 +- classes/privacy/provider.php | 4 +- db/access.php | 1 - lang/en/hotquestion.php | 83 ++++++++++++------------ lib.php | 7 +- locallib.php | 5 +- mod_form.php | 1 - renderer.php | 2 +- version.php | 1 - 10 files changed, 50 insertions(+), 59 deletions(-) diff --git a/classes/completion/custom_completion.php b/classes/completion/custom_completion.php index 1abf4e8..8068458 100644 --- a/classes/completion/custom_completion.php +++ b/classes/completion/custom_completion.php @@ -88,7 +88,6 @@ public function get_state(string $rule): int { } else if ($rule == 'completionpass') { if ($status = $hotquestion->completionpass <= $DB->get_field_sql($questioncountsql. - //' AND hqg.userid = $userid AND hqg.rawrating >= hqqcompletionpass', ' AND hqg.userid = $userid AND hqg.rawrating >= hqgrade', $questioncountparams)) { $status = $hotquestion->completionpass = 1; diff --git a/classes/local/results.php b/classes/local/results.php index 7ad0863..2c3e845 100644 --- a/classes/local/results.php +++ b/classes/local/results.php @@ -354,8 +354,8 @@ public static function hotquestion_comment_permissions($commentparam) { * @param stdClass $entry Entry object. */ public static function hotquestion_get_editor_and_attachment_options($course, $context, $entry) { - $maxfiles = 99; // TODO: add some setting. - $maxbytes = $course->maxbytes; // TODO: add some setting. + $maxfiles = 99; + $maxbytes = $course->maxbytes; $editoroptions = [ 'trusttext' => true, diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index f662a84..c8d31aa 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -58,7 +58,7 @@ class provider implements \core_privacy\local\metadata\provider, * @param collection $collection The initialised collection to add items to. * @return collection The updated collection of metadata items. */ - public static function get_metadata(collection $collection) : collection { + public static function get_metadata(collection $collection): collection { $collection->add_database_table( 'hotquestion_questions', [ @@ -107,7 +107,7 @@ private static function get_modid() { * @param int $userid The user to search. * @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin. */ - public static function get_contexts_for_userid(int $userid) : contextlist { + public static function get_contexts_for_userid(int $userid): contextlist { $contextlist = new contextlist(); $modid = self::get_modid(); if (!$modid) { diff --git a/db/access.php b/db/access.php index da6ceb3..d6eb7af 100644 --- a/db/access.php +++ b/db/access.php @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - /** * Capability definitions for the hotquestion module * diff --git a/lang/en/hotquestion.php b/lang/en/hotquestion.php index 67cf32d..8e43e6c 100644 --- a/lang/en/hotquestion.php +++ b/lang/en/hotquestion.php @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - /** * English strings for hotquestion. * @@ -28,11 +27,11 @@ $string['ago'] = '{$a} ago'; $string['allowanonymouspost'] = 'Allow post question as anonymous'; -$string['allowanonymouspost_help'] = 'If enabled, questions can be posted anonomously, and if approved for viewing heat votes can be made by everyone.'; $string['allowanonymouspost_descr'] = 'If enabled, questions can be posted anonomously, and if approved for viewing heat votes can be made by everyone.'; +$string['allowanonymouspost_help'] = 'If enabled, questions can be posted anonomously, and if approved for viewing heat votes can be made by everyone.'; $string['allowauthorinfohide'] = 'Allow authors name to be hidden'; -$string['allowauthorinfohide_help'] = 'If enabled, the name of the questions author can be visible to teachers but hidden from students.'; $string['allowauthorinfohide_descr'] = 'If enabled, the name of the questions author can be visible to teachers but hidden from students.'; +$string['allowauthorinfohide_help'] = 'If enabled, the name of the questions author can be visible to teachers but hidden from students.'; $string['allowcomments'] = 'Allow comments on entries'; $string['allowcomments_help'] = 'If enabled, all participants with permission to create comments will be able to add comments to hot question entries.'; $string['alwaysshowdescription'] = 'Always show description'; @@ -40,25 +39,25 @@ $string['anonymous'] = 'Anonymous'; $string['approvallabel'] = 'Approval required column label'; $string['approvallabel_descr'] = 'Enter a default label for the Approved column.'; -$string['approvedyes'] = 'Approved'; $string['approvedno'] = 'Not approved'; +$string['approvedyes'] = 'Approved'; $string['authorinfo'] = 'Posted by {$a->user} at {$a->time}'; $string['authorinfohide'] = 'Posted {$a->time}'; $string['calendarend'] = '{$a} closes'; $string['calendarstart'] = '{$a} opens'; $string['cnfallowcomments'] = 'Define if a hot question will accept comments on entries by default'; +$string['completiondetail:pass'] = 'Passing grade: {$a}'; $string['completiondetail:post'] = 'Post questions: {$a}'; $string['completiondetail:vote'] = 'Give heat: {$a}'; -$string['completiondetail:pass'] = 'Passing grade: {$a}'; -$string['completionpostdesc'] = 'Student must create at least {$a} questions(s)'; -$string['completionvotedesc'] = 'Student must vote/give heat to {$a} question(s) or post(s)'; +$string['completionpass'] = 'Student must pass:'; $string['completionpassdesc'] = 'Student must receive passing grade of {$a}'; -$string['completionpostgroup'] = 'Require questions'; -$string['completionvotegroup'] = 'Require heat:'; $string['completionpassgroup'] = 'Require pass:'; $string['completionpost'] = 'Student must add questions:'; +$string['completionpostdesc'] = 'Student must create at least {$a} questions(s)'; +$string['completionpostgroup'] = 'Require questions'; $string['completionvote'] = 'Student must add heat:'; -$string['completionpass'] = 'Student must pass:'; +$string['completionvotedesc'] = 'Student must vote/give heat to {$a} question(s) or post(s)'; +$string['completionvotegroup'] = 'Require heat:'; $string['connectionerror'] = 'Connection error'; $string['content'] = 'Content'; $string['csvexport'] = 'Export to .csv'; @@ -115,15 +114,9 @@ $string['heatlimit_help'] = 'Enter a default for the number of times you can apply heat/vote, per round. Zero hides the heat column.'; $string['heatreceived'] = 'Heat received'; $string['heatvisibility'] = 'Heat column visibility'; -$string['heatvisibility_help'] = 'If enabled, the Heat column is visible.'; $string['heatvisibility_descr'] = 'If enabled, the Heat column is visible, otherwise it is hidden.'; +$string['heatvisibility_help'] = 'If enabled, the Heat column is visible.'; $string['hotquestion'] = 'Hotquestion'; -$string['hotquestionclosed'] = 'This activity closed on {$a}.'; -$string['hotquestionclosetime'] = 'Close time'; -$string['hotquestionintro'] = 'Topic'; -$string['hotquestionname'] = 'Activity Name'; -$string['hotquestionopentime'] = 'Open time'; -$string['hotquestionopen'] = 'This activity will be open on {$a}.'; $string['hotquestion:addinstance'] = 'Can add new Hot Question'; $string['hotquestion:ask'] = 'Ask questions'; $string['hotquestion:comment'] = 'Write comments'; @@ -132,88 +125,94 @@ $string['hotquestion:rate'] = 'Rate questions'; $string['hotquestion:view'] = 'View questions'; $string['hotquestion:vote'] = 'Vote on questions'; +$string['hotquestionclosed'] = 'This activity closed on {$a}.'; +$string['hotquestionclosetime'] = 'Close time'; +$string['hotquestionintro'] = 'Topic'; +$string['hotquestionname'] = 'Activity Name'; +$string['hotquestionopen'] = 'This activity will be open on {$a}.'; +$string['hotquestionopentime'] = 'Open time'; +$string['id'] = 'ID'; $string['improperuseviewgradesclass'] = 'Improper use of the viewgrades class. Cannot load the grade item.'; $string['incorrectmodule'] = 'Course Module ID was incorrect'; -$string['id'] = 'ID'; +$string['inputapprovallabel'] = 'Approved'; +$string['inputapprovallabel_descr'] = 'Change the Approved column name to what you want it to be.'; +$string['inputapprovallabel_help'] = 'Change the Approved column name to better fit the use of this activity.'; +$string['inputheatlabel'] = 'Heat'; +$string['inputheatlabel_descr'] = 'Change the Heat column name to what you want it to be.'; +$string['inputheatlabel_help'] = 'Change the Heat column name to better fit the use of this activity.'; $string['inputquestion'] = 'Submit your question here:'; $string['inputquestion_descr'] = 'Change submit directions to what you want them to be.'; $string['inputquestion_help'] = 'Change the submit directions to what you want them to be.'; $string['inputquestionlabel'] = 'Questions'; $string['inputquestionlabel_descr'] = 'Change the Questions column name to what you want it to be.'; $string['inputquestionlabel_help'] = 'Change the Questions column name to better fit the use of this activity.'; -$string['inputteacherprioritylabel'] = 'Priority'; -$string['inputteacherprioritylabel_descr'] = 'Change the Priority column name to what you want it to be.'; -$string['inputteacherprioritylabel_help'] = 'Change the Priority column name to better fit the use of this activity.'; -$string['inputheatlabel'] = 'Heat'; -$string['inputheatlabel_descr'] = 'Change the Heat column name to what you want it to be.'; -$string['inputheatlabel_help'] = 'Change the Heat column name to better fit the use of this activity.'; $string['inputremovelabel'] = 'Remove'; $string['inputremovelabel_descr'] = 'Change the Remove column name to what you want it to be.'; $string['inputremovelabel_help'] = 'Change the remove column name to better fit the use of this activity.'; -$string['inputapprovallabel'] = 'Approved'; -$string['inputapprovallabel_descr'] = 'Change the Approved column name to what you want it to be.'; -$string['inputapprovallabel_help'] = 'Change the Approved column name to better fit the use of this activity.'; +$string['inputteacherprioritylabel'] = 'Priority'; +$string['inputteacherprioritylabel_descr'] = 'Change the Priority column name to what you want it to be.'; +$string['inputteacherprioritylabel_help'] = 'Change the Priority column name to better fit the use of this activity.'; $string['invalidquestion'] = 'Empty questions are ignored.'; $string['modulename'] = 'Hot Question'; $string['modulename_help'] = 'A Hot Question activity enables students to post and vote on posts, in response to questions asked by course teachers.'; $string['modulename_link'] = 'mod/hotquestion/view'; $string['modulenameplural'] = 'Hot Questions'; $string['newround'] = 'Open a new round'; -$string['newroundsuccess'] = 'You have successfully opened a new round.'; $string['newroundconfirm'] = 'Confirm you want to start a new round? (Existing questions and votes will be archived and can not be added to!)'; +$string['newroundsuccess'] = 'You have successfully opened a new round.'; $string['nextround'] = 'Next round'; $string['noquestions'] = 'No entries yet.'; -$string['notavailable'] = 'Not currently available!
'; $string['notapproved'] = 'This entry is not currently approved for viewing.
'; +$string['notavailable'] = 'Not currently available!
'; $string['pluginadministration'] = 'Hot question administration'; $string['pluginname'] = 'Hot Question'; -$string['previousround'] = 'Previous round'; $string['postbutton'] = 'Click to post'; $string['postmaxgrade'] = 'Questions for max grading'; $string['postmaxgrade_help'] = 'The number of questions required to obtain the maximum score. This is nominally a count of questions, but the value attained by a user may be improved by heat factor (questions with greater heat count more) and by voting on other questions (a user may improve the grade by participating in voting for questions by other students).'; +$string['previousround'] = 'Previous round'; $string['privacy:metadata:hotquestion_questions'] = "Information about the user's entries for a given Hot Question activity. "; -$string['privacy:metadata:hotquestion_questions:userid'] = 'The ID of the user that posted this entry.'; -$string['privacy:metadata:hotquestion_questions:hotquestion'] = 'The ID of the Hot Question activity in which the content was posted.'; -$string['privacy:metadata:hotquestion_questions:content'] = 'The content of the question.'; -$string['privacy:metadata:hotquestion_questions:time'] = 'Time the question was posted.'; -$string['privacy:metadata:hotquestion_questions:id'] = 'ID of the entry.'; $string['privacy:metadata:hotquestion_questions:anonymous'] = 'Is the entry posted as anonymous?'; $string['privacy:metadata:hotquestion_questions:approved'] = 'Is the question approved for general viewing?'; +$string['privacy:metadata:hotquestion_questions:content'] = 'The content of the question.'; +$string['privacy:metadata:hotquestion_questions:hotquestion'] = 'The ID of the Hot Question activity in which the content was posted.'; +$string['privacy:metadata:hotquestion_questions:id'] = 'ID of the entry.'; +$string['privacy:metadata:hotquestion_questions:time'] = 'Time the question was posted.'; $string['privacy:metadata:hotquestion_questions:tpriority'] = 'Has the teacher given a priority for this entry?'; +$string['privacy:metadata:hotquestion_questions:userid'] = 'The ID of the user that posted this entry.'; $string['privacy:metadata:hotquestion_votes'] = 'Information about votes on questions.'; $string['privacy:metadata:hotquestion_votes:id'] = 'ID of the entry.'; $string['privacy:metadata:hotquestion_votes:question'] = 'The ID of the entry for this vote'; $string['privacy:metadata:hotquestion_votes:voter'] = 'User ID who voted.'; -$string['teacherprioritylabel'] = 'Priority column label'; -$string['teacherprioritylabel_descr'] = 'Enter a default label for the Priority column.'; $string['question'] = 'Question'; -$string['questions'] = 'Questions'; $string['questionlabel'] = 'Questions column label'; $string['questionlabel_descr'] = 'Enter a default label for the Questions column.'; -$string['questionsubmitted'] = 'Your post has been submitted successfully.'; $string['questionremove'] = 'Remove'; $string['questionremovesuccess'] = 'You have successfully removed that question.'; +$string['questions'] = 'Questions'; +$string['questionsubmitted'] = 'Your post has been submitted successfully.'; $string['rawgrade'] = 'Raw grade {$a->rawgrade} / {$a->max}'; +$string['removedround'] = 'You have successfully removed this round.'; $string['removelabel'] = 'Remove column label'; $string['removelabel_descr'] = 'Enter a default label for the Remove column.'; $string['removeround'] = 'Remove this round'; -$string['removedround'] = 'You have successfully removed this round.'; $string['removevote'] = 'Remove my vote'; $string['requireapproval'] = 'Approval required'; -$string['requireapproval_help'] = 'If enabled, questions require approval by a teacher before they are viewable by everyone.'; $string['requireapproval_descr'] = 'If enabled, questions require approval by a teacher before they are viewable by everyone.'; +$string['requireapproval_help'] = 'If enabled, questions require approval by a teacher before they are viewable by everyone.'; $string['resethotquestion'] = 'Delete all questions and votes'; $string['returnto'] = 'Return to {$a}'; $string['round'] = 'Round {$a}'; $string['showrecentactivity'] = 'Show recent activity'; $string['showrecentactivityconfig'] = 'Everyone can see notifications in recent activity reports.'; $string['teacherpriority'] = 'Priority'; +$string['teacherprioritylabel'] = 'Priority column label'; +$string['teacherprioritylabel_descr'] = 'Enter a default label for the Priority column.'; $string['teacherpriorityvisibility'] = 'Teacher priority column visibility'; -$string['teacherpriorityvisibility_help'] = 'If enabled, the Teacher priority column is visible.'; $string['teacherpriorityvisibility_descr'] = 'If enabled, the Teacher priority column is visible, otherwise it is hidden.'; +$string['teacherpriorityvisibility_help'] = 'If enabled, the Teacher priority column is visible.'; $string['time'] = 'Time'; $string['totalcomments'] = 'Total comments'; $string['unapprovedquestionhide'] = 'Hide unapproved questions'; diff --git a/lib.php b/lib.php index 96a48a2..399ed40 100644 --- a/lib.php +++ b/lib.php @@ -217,7 +217,6 @@ function get_question_list($hotquestionid) { * $return->time = the time they did it * $return->info = a short text description * @return null - * @todo Finish documenting this function */ function hotquestion_user_outline($course, $user, $mod, $hotquestion) { $return = new stdClass; @@ -234,7 +233,6 @@ function hotquestion_user_outline($course, $user, $mod, $hotquestion) { * @param int $mod * @param int $hotquestion * @return boolean - * @todo Finish documenting this function */ function hotquestion_user_complete($course, $user, $mod, $hotquestion) { return true; @@ -361,7 +359,6 @@ function hotquestion_print_recent_activity($course, $viewfullnames, $timestart) * as sending out mail, toggling flags etc ... * * @return boolean - * @todo Finish documenting this function **/ function hotquestion_cron () { return true; @@ -586,7 +583,7 @@ function hotquestion_get_completion_state($course, $cm, $userid, $type) { // Get hotquestion details. $hotquestion = $DB->get_record('hotquestion', ['id' => $cm->instance], '*', MUST_EXIST); - // If completion option is enabled, evaluate it and return true/false + // If completion option is enabled, evaluate it and return true/false. if (!$hotquestion->completionpost && !$hotquestion->completionvote && !$hotquestion->completionpass) { return $type; } @@ -914,7 +911,7 @@ function hotquestion_rescale_activity_grades(stdClass $course, stdClass $cm, flo * * @param stdClass $hotquestion stdClass. */ -function hotquestion_check_ratings_recalculation(stdClass $hotquestion) : bool { +function hotquestion_check_ratings_recalculation(stdClass $hotquestion): bool { global $CFG, $DB; require_once($CFG->dirroot.'/mod/hotquestion/locallib.php'); diff --git a/locallib.php b/locallib.php index 73359ef..57c0e4c 100644 --- a/locallib.php +++ b/locallib.php @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - /** * Internal library of functions for module hotquestion. * @@ -828,7 +827,7 @@ public function tpriority_change($u, $question) { * @param int $userid The single user to calculate the rating for. * @return float $rating number */ - public function calculate_user_ratings($userid = null) : float { + public function calculate_user_ratings($userid = null): float { global $DB, $USER; if (!$userid) { @@ -876,7 +875,7 @@ public function calculate_user_ratings($userid = null) : float { * @param int $questionid The question id. * @return array Array of int userids or empty if none. */ - public function get_question_voters(int $questionid) : array { + public function get_question_voters(int $questionid): array { global $DB; $voters = $DB->get_records_menu('hotquestion_votes', ['question' => $questionid], '', 'id, voter'); diff --git a/mod_form.php b/mod_form.php index 25482cb..d057a07 100644 --- a/mod_form.php +++ b/mod_form.php @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - /** * The main hotquestion configuration form. * diff --git a/renderer.php b/renderer.php index d973eb6..501f66f 100644 --- a/renderer.php +++ b/renderer.php @@ -609,7 +609,7 @@ public function hotquestion_get_question_comment_count($question, $cm) { * @param bool $showrating * @return string */ - public function current_user_rating(bool $showrating) : string { + public function current_user_rating(bool $showrating): string { global $USER; $output = ''; diff --git a/version.php b/version.php index 0efb463..2ed4b1e 100644 --- a/version.php +++ b/version.php @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - /** * Defines the version of hotquestion. *