Skip to content

Commit

Permalink
Merge pull request #22 from ucl-isd/CTP-3796-sonarqube-fixes-2
Browse files Browse the repository at this point in the history
Ctp 3796 sonarqube fixes 2
  • Loading branch information
aspark21 authored Sep 30, 2024
2 parents 70ebdb7 + d02e1e0 commit fa59c08
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 30 deletions.
2 changes: 1 addition & 1 deletion actions/feedbacks/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$feedbackid = required_param('feedbackid', PARAM_INT);
$finalised = (bool)optional_param('submitbutton', 0, PARAM_TEXT);
$ajax = optional_param('ajax', 0, PARAM_INT);
$remove = !!optional_param('removefeedbackbutton', 0, PARAM_TEXT);
$remove = (bool)optional_param('removefeedbackbutton', 0, PARAM_TEXT);
$confirm = optional_param('confirm', 0, PARAM_INT);

$params = [
Expand Down
9 changes: 0 additions & 9 deletions backup/moodle2/restore_coursework_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@

class restore_coursework_activity_structure_step extends restore_activity_structure_step {

// Just a handy way to spit out debugging info while in the bowels of restore
static function cheaplog($thing, $append = true) {
if ($append) {
$append = FILE_APPEND;
}

file_put_contents('/tmp/cheap.log', print_r($thing, true)."\n---------------\n", $append);
}

/**
* Define the structure of the restore workflow.
*
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/controller_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function model_name() {
* @throws \coding_exception
*/
protected function cancel_button_was_pressed() {
return !!optional_param('cancel', false, PARAM_ALPHA);
return (bool)optional_param('cancel', false, PARAM_ALPHA);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/submissions_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ protected function prepare_environment() {
* @throws \coding_exception
*/
private function terms_were_agreed_to() {
return !!optional_param('termsagreed', false, PARAM_INT);
return (bool)optional_param('termsagreed', 0, PARAM_INT);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions classes/export/csv/cells/agreedgrade_cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ public function get_header($stage) {
return $strings;
}

public function validate_cell($value, $submissionid, $stageidentifier='', $uploadedgradecells = []) {
public function validate_cell($value, $submissionid, $stageidentifier = '', $uploadedgradecells = []) {

global $DB, $PAGE, $USER;

$stageidentifier = 'final_agreed_1';
$stageident = 'final_agreed_1';
$agreedgradecap = ['mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade',
'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade'];
'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade'];

if (empty($value)) {
return true;
Expand Down Expand Up @@ -172,7 +172,7 @@ public function validate_cell($value, $submissionid, $stageidentifier='', $uploa
// Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled).
$feedbackparams = [
'submissionid' => $submission->id,
'stage_identifier' => $stageidentifier,
'stage_identifier' => $stageident,
];

$feedback = feedback::find($feedbackparams);
Expand All @@ -185,7 +185,7 @@ public function validate_cell($value, $submissionid, $stageidentifier='', $uploa
$feedbackparams = [
'submissionid' => $submissionid,
'assessorid' => $USER->id,
'stage_identifier' => $stageidentifier,
'stage_identifier' => $stageident,
];
$newfeedback = feedback::build($feedbackparams);

Expand Down
6 changes: 3 additions & 3 deletions classes/export/csv/cells/stages_cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public function get_cell($submission, $student, $stageidentifier) {
$gradedata = [];
// go through each stage and get a grade, if grade not present then put a placeholder
for ($i = 1; $i <= $this->stages; $i++) {
$stageidentifier = 'assessor_'.$i;
$grade = $submission->get_assessor_feedback_by_stage($stageidentifier);
$stageident = 'assessor_'.$i;
$grade = $submission->get_assessor_feedback_by_stage($stageident);

if ($this->coursework->allocation_enabled()) {
$allocation = $submission->get_assessor_allocation_by_stage($stageidentifier);
$allocation = $submission->get_assessor_allocation_by_stage($stageident);
if ($allocation) {
$gradedata[] = $this->get_assessor_name($allocation->assessorid);
$gradedata[] = $this->get_assessor_username($allocation->assessorid);
Expand Down
2 changes: 1 addition & 1 deletion classes/framework/table_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public function reload($complainifnotfound = true) {
* @param bool $sneakily If true, do not update the timemodified stamp. Useful for cron.
* @return void
*/
public function update_attribute($name, $value, $sneakily = false) {
public function update_attribute($name, $value, $sneakily = false): void {
$this->apply_column_value_to_self($name, $value);
$this->save($sneakily);
}
Expand Down
6 changes: 4 additions & 2 deletions classes/models/coursework.php
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,8 @@ public function validate_and_set_allocation_strategy($allocationstrategy) {
public function set_assessor_allocation_strategy($strategyname) {

if ($this->allocation_strategy_is_valid($strategyname)) {
return $this->update_attribute('assessorallocationstrategy', $strategyname);
$this->update_attribute('assessorallocationstrategy', $strategyname);
return;
}
return false;
}
Expand All @@ -1053,7 +1054,8 @@ public function set_assessor_allocation_strategy($strategyname) {
public function set_moderator_allocation_strategy($strategyname) {

if ($this->allocation_strategy_is_valid($strategyname)) {
return $this->update_attribute('moderatorallocationstrategy', $strategyname);
$this->update_attribute('moderatorallocationstrategy', $strategyname);
return;
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion classes/sample_set_rule/total_sample_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function save_form_data($assessornumber = 0, &$order = 0) {

}

static function compare_key($a, $b) {
private static function compare_key($a, $b) {
if ($a === $b) {
return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions renderers/page_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ protected function marking_preview_html($ownsubmission) {
* @return string
* @throws coding_exception
*/
function csv_upload($uploadform, $csvtype) {
public function csv_upload($uploadform, $csvtype) {

$html = '';

Expand Down Expand Up @@ -1212,7 +1212,7 @@ function csv_upload($uploadform, $csvtype) {
* @return string
* @throws coding_exception
*/
function process_csv_upload($processingresults, $csvcontent, $csvtype) {
public function process_csv_upload($processingresults, $csvcontent, $csvtype) {

$html = '';

Expand Down Expand Up @@ -1254,7 +1254,7 @@ function process_csv_upload($processingresults, $csvcontent, $csvtype) {

}

function feedback_upload($form) {
public function feedback_upload($form) {

$html = '';

Expand All @@ -1273,7 +1273,7 @@ function feedback_upload($form) {

}

function process_feedback_upload($processingresults) {
public function process_feedback_upload($processingresults) {
$title = get_string('feedbackuploadresults', 'mod_coursework');

$this->page->set_pagelayout('standard');
Expand Down Expand Up @@ -1316,7 +1316,7 @@ function process_feedback_upload($processingresults) {
*
* @return string
*/
function view_course_index($courseid) {
public function view_course_index($courseid) {
global $CFG, $DB, $USER;
$o = '';
$course = $DB->get_record('course', ['id' => $courseid]);
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/behat_mod_coursework.php
Original file line number Diff line number Diff line change
Expand Up @@ -2496,7 +2496,7 @@ public function visit_page($pathname) {
* @param bool $ignoreparams
*/
public function i_should_be_on_the_page($pagename, $ignoreparams = false) {
$ignoreparams = !!$ignoreparams;
$ignoreparams = (bool)$ignoreparams;

if ($this->running_javascript()) {
$this->wait_for_seconds(10);
Expand Down

0 comments on commit fa59c08

Please sign in to comment.