Skip to content

Commit

Permalink
codechecker fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
drachels committed Jul 1, 2024
1 parent a83ec91 commit 85da7b6
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 59 deletions.
1 change: 0 additions & 1 deletion classes/completion/custom_completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions classes/local/results.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
[
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.


/**
* Capability definitions for the hotquestion module
*
Expand Down
83 changes: 41 additions & 42 deletions lang/en/hotquestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.


/**
* English strings for hotquestion.
*
Expand All @@ -28,37 +27,37 @@

$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';
$string['alwaysshowdescription_help'] = 'If disabled, the Hot Question Description will not be visible to students.';
$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';
Expand Down Expand Up @@ -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';
Expand All @@ -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'] = '<b>Not currently available!<br></b>';
$string['notapproved'] = '<b>This entry is not currently approved for viewing.<br></b>';
$string['notavailable'] = '<b>Not currently available!<br></b>';
$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';
Expand Down
7 changes: 2 additions & 5 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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');
Expand Down
5 changes: 2 additions & 3 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.


/**
* Internal library of functions for module hotquestion.
*
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
Expand Down
1 change: 0 additions & 1 deletion mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.


/**
* The main hotquestion configuration form.
*
Expand Down
2 changes: 1 addition & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down
1 change: 0 additions & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.


/**
* Defines the version of hotquestion.
*
Expand Down

0 comments on commit 85da7b6

Please sign in to comment.