Skip to content

Commit

Permalink
CTP-3558 coding standards more spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
watson8 committed Aug 7, 2024
1 parent a1d4d57 commit 2d0e625
Show file tree
Hide file tree
Showing 26 changed files with 60 additions and 63 deletions.
6 changes: 3 additions & 3 deletions classes/allocation/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ public function auto_generate_moderation_set() {
* @return array
*/
public function get_sampling_options() {
return array('0' =>get_string('manual', 'mod_coursework'),
'1' =>get_string('automatic', 'mod_coursework'));
return array('0' => get_string('manual', 'mod_coursework'),
'1' => get_string('automatic', 'mod_coursework'));

}

Expand Down Expand Up @@ -344,7 +344,7 @@ public function auto_generate_sample_set() {

// save sample set
if (!empty($auto_sample_set)) {
foreach ($auto_sample_set as $allocatable) {
foreach ($auto_sample_set as $allocatable) {
$sample = new \stdClass();
$sample->courseworkid = $this->coursework->id;
$sample->allocatableid = $allocatable->id;
Expand Down
4 changes: 2 additions & 2 deletions classes/allocation/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function validate_csv($content, $encoding, $delimeter) {
$s++;
}

return (!empty($errors)) ? $errors : false;
return (!empty($errors)) ? $errors : false;
}

/**
Expand Down Expand Up @@ -262,7 +262,7 @@ public function process_csv($content, $encoding, $delimiter, $processingresults)
$s++;
}

return (!empty($errors)) ? $errors : false;
return (!empty($errors)) ? $errors : false;

}

Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/deadline_extensions_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public function ajax_edit_mitigation($data_params) {
$ability->require_can('edit', $deadline_extension);
$time_content = '';
$time = '';
if ($this->coursework->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()) {
if ($this->coursework->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()) {
$time_content = 'Personal deadline: ' . userdate($personal_deadline->personal_deadline);
$time = date('d-m-Y H:i', $personal_deadline->personal_deadline);
} else if ($this->coursework->deadline) {
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/feedback_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function show_feedback() {

$urlparams = array('feedbackid' => $this->params['feedbackid']);
$PAGE->set_url('/mod/coursework/actions/feedbacks/show.php', $urlparams);
$ajax = (isset($this->params['ajax'])) ? $this->params['ajax'] : 0;
$ajax = (isset($this->params['ajax'])) ? $this->params['ajax'] : 0;

$teacherfeedback = new feedback($this->params['feedbackid']);

Expand Down
4 changes: 2 additions & 2 deletions classes/controllers/personal_deadlines_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function new_personal_deadline() {

$allocatables = unserialize($data->allocatableid);

foreach ($allocatables as $allocatableid) {
foreach ($allocatables as $allocatableid) {
$data->allocatableid = $allocatableid;
$data->id = '';
//$data->id = '';
Expand Down Expand Up @@ -212,7 +212,7 @@ public function insert_update($time) {
} else {
$allocatables = unserialize($data->allocatableid);

foreach ($allocatables as $allocatableid) {
foreach ($allocatables as $allocatableid) {
$data->allocatableid = $allocatableid;
$data->id = '';
//$data->id = '';
Expand Down
2 changes: 1 addition & 1 deletion classes/export/csv/cells/agreedgrade_cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function get_cell($submission, $student, $stage_identifier) {
$gradedata = [];
$this->get_rubric_scores_gradedata($agreedgrade, $gradedata); // multiple parts are handled here
} else {
$gradedata = (!$agreedgrade) ? '': $this->get_actual_grade($agreedgrade->grade);
$gradedata = (!$agreedgrade) ? '' : $this->get_actual_grade($agreedgrade->grade);
}

return $gradedata;
Expand Down
2 changes: 1 addition & 1 deletion classes/export/csv/cells/assessorgrade_cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function get_cell($submission, $student, $stage_identifier) {
$gradedata = [];
$this->get_rubric_scores_gradedata($grade, $gradedata); // multiple parts are handled here
} else {
$gradedata = (!$grade) ? '': $this->get_actual_grade($grade->grade);
$gradedata = (!$grade) ? '' : $this->get_actual_grade($grade->grade);

}

Expand Down
2 changes: 1 addition & 1 deletion classes/export/csv/cells/cell_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function get_stage_identifier_for_assessor($submission, $student) {
$stageidentifier = '';
if ($this->coursework->allocation_enabled()) {
$stageidentifier = $this->coursework->get_assessors_stage_identifier($student->id, $USER->id);
} else if ($this->coursework->get_max_markers()>1) {
} else if ($this->coursework->get_max_markers() > 1) {
// get existing feedback

$sql = "SELECT * FROM {coursework_feedbacks}
Expand Down
2 changes: 1 addition & 1 deletion classes/export/csv/cells/singlegrade_cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function get_cell($submission, $student, $stage_identifier) {
$gradedata = [];
$this->get_rubric_scores_gradedata($grade, $gradedata); // multiple parts are handled here
} else {
$gradedata = (!$grade) ? '': $this->get_actual_grade($grade->grade);
$gradedata = (!$grade) ? '' : $this->get_actual_grade($grade->grade);
}

return $gradedata;
Expand Down
4 changes: 2 additions & 2 deletions classes/export/grading_sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public static function cells_array($coursework) {

// based on capabilities decide what view display - singlegrade or multiplegrade
if ((has_capability('mod/coursework:addagreedgrade', $PAGE->context) || has_capability('mod/coursework:administergrades', $PAGE->context))
&& $coursework->get_max_markers()>1 ) {
&& $coursework->get_max_markers() > 1 ) {
for ($i = 1; $i <= $coursework->get_max_markers(); $i++) {
// extra column with allocated assessor name
if ($coursework->allocation_enabled() && $coursework->get_max_markers() > 1
Expand All @@ -173,7 +173,7 @@ public static function cells_array($coursework) {
$csv_cells[] = 'agreedgrade';
$csv_cells[] = 'agreedfeedback';

} else if (has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && $coursework->get_max_markers() >1) {
} else if (has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && $coursework->get_max_markers() > 1) {
$csv_cells[] = 'singlegrade';
$csv_cells[] = 'feedbackcomments';

Expand Down
19 changes: 8 additions & 11 deletions classes/export/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function validate_csv($content, $encoding, $delimeter, $csv_cells) {
$s++;
}

return (!empty($errors)) ? $errors : false;
return (!empty($errors)) ? $errors : false;
}

function rubric_count_correct($csvheader, $linefromimportedcsv) {
Expand All @@ -174,12 +174,9 @@ function rubric_count_correct($csvheader, $linefromimportedcsv) {
$typepositions = false;
$i = 0;

foreach ($csvheader as $ch) {

foreach ($csvheader as $ch) {
if (strpos($ch, $type) !== false) {

if (empty($typepositions)) $typepositions = [];

$typefound = true;
$typepositions[] = $i;
//break;
Expand Down Expand Up @@ -355,7 +352,7 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces
// defines the start offest to be used when searching for a rubric in a uploaded csv, if the format of upload
// csv is changed this will require changing

$rubricoffset = $rubricoffsetstart = ($coursework->is_configured_to_have_group_submissions()) ? 4 : 5;
$rubricoffset = $rubricoffsetstart = ($coursework->is_configured_to_have_group_submissions()) ? 4 : 5;

$numberofstages = count($stages);

Expand Down Expand Up @@ -519,7 +516,7 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces
$s++;
}

return (!empty($errors)) ? $errors : false;
return (!empty($errors)) ? $errors : false;

}

Expand Down Expand Up @@ -700,7 +697,7 @@ public function get_stage_identifier($submissionid, $cell_identifier) {
$stage_identifier = 'assessor_1';

// double marked - singlegrade - allocated
if ($this->coursework->get_max_markers()>1 && ($cell_identifier == 'singlegrade' || $cell_identifier == 'feedbackcomments')
if ($this->coursework->get_max_markers() > 1 && ($cell_identifier == 'singlegrade' || $cell_identifier == 'feedbackcomments')
&& $this->coursework->allocation_enabled()) {

$dbrecord = $DB->get_record('coursework_allocation_pairs',
Expand All @@ -713,7 +710,7 @@ public function get_stage_identifier($submissionid, $cell_identifier) {
}

// double marked - singlegrade - notallocated
if ($this->coursework->get_max_markers()>1 && ($cell_identifier == 'singlegrade' || $cell_identifier == 'feedbackcomments')
if ($this->coursework->get_max_markers() > 1 && ($cell_identifier == 'singlegrade' || $cell_identifier == 'feedbackcomments')
&& !$this->coursework->allocation_enabled()) {

// if any part of initial submission graded by the user then get stage_identifier from feedback
Expand All @@ -732,7 +729,7 @@ public function get_stage_identifier($submissionid, $cell_identifier) {
AND stage_identifier <> 'final_agreed_1'";
$record = $DB->get_record_sql($sql);

if ($this->coursework->get_max_markers()>$record->graded) {
if ($this->coursework->get_max_markers() > $record->graded) {
$stage = $record->graded+1;
$stage_identifier = 'assessor_' . $stage;
}
Expand Down Expand Up @@ -760,7 +757,7 @@ public function get_stage_identifier($submissionid, $cell_identifier) {
}

// double marked - multiplegrade - allocated/notallocated
if ($this->coursework->get_max_markers()>1 && ($cell_identifier != 'singlegrade' && $cell_identifier != 'feedbackcomments')) {
if ($this->coursework->get_max_markers() > 1 && ($cell_identifier != 'singlegrade' && $cell_identifier != 'feedbackcomments')) {
if (substr($cell_identifier, 0, 8) == 'assessor') {
$stage_identifier = 'assessor_' . (substr($cell_identifier, -1));
//$cells[$i] = substr($cells[$i], 0, -1);
Expand Down
6 changes: 3 additions & 3 deletions classes/forms/assessor_feedback_mform.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function definition() {

$grademenu = make_grades_menu($coursework->grade);

if (($coursework->is_using_advanced_grading() && $coursework->finalstagegrading ==0 ) || ($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 1 && $feedback->stage_identifier != 'final_agreed_1')) {
if (($coursework->is_using_advanced_grading() && $coursework->finalstagegrading ==0 ) || ($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 1 && $feedback->stage_identifier != 'final_agreed_1')) {
$this->_grading_controller = $coursework->get_advanced_grading_active_controller();
$this->_grading_instance = $this->_grading_controller->get_or_create_instance(0, $feedback->assessorid, $feedback->id);
$mform->addElement('grading', 'advancedgrading', get_string('grade', 'mod_coursework'), array('gradinginstance' => $this->_grading_instance));
Expand Down Expand Up @@ -147,7 +147,7 @@ public function add_submit_buttons($draftenabled, $feedbackid) {

$is_published = $feedback->get_submission()->is_published();

if ($feedbackid && !$is_published) {
if ($feedbackid && !$is_published) {
$button_array[] = $this->_form->createElement('submit', 'removefeedbackbutton', get_string('removefeedback', 'coursework'));
}
$button_array[] = $this->_form->createElement('cancel');
Expand Down Expand Up @@ -180,7 +180,7 @@ public function process_data(feedback $feedback) {
$formdata = $this->get_data();
$coursework = $feedback->get_coursework();

if (($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 0 ) || ($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 1 && $feedback->stage_identifier != 'final_agreed_1')) {
if (($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 0 ) || ($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 1 && $feedback->stage_identifier != 'final_agreed_1')) {
$controller = $coursework->get_advanced_grading_active_controller();
$gradinginstance = $controller->get_or_create_instance(0, $feedback->assessorid, $feedback->id);
/**
Expand Down
2 changes: 1 addition & 1 deletion classes/forms/deadline_extension_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function definition() {
$this->_form->addElement('hidden', 'id');
$this->_form->settype('id', PARAM_INT);

if ($this->get_coursework()->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()) {
if ($this->get_coursework()->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()) {
$this->_form->addElement('html', '<div class="alert">Personal deadline: '. userdate($personal_deadline->personal_deadline).'</div>');
} else {
// Current deadline for comparison
Expand Down
2 changes: 1 addition & 1 deletion classes/forms/moderator_agreement_mform.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function definition() {
$mform->setType('courseworkid', PARAM_INT);

// moderator agreement
$options = array('agreed' =>get_string('agreed', 'coursework'), 'disagreed' =>get_string('disagreed', 'coursework'));
$options = array('agreed' => get_string('agreed', 'coursework'), 'disagreed' => get_string('disagreed', 'coursework'));
$mform->addElement('select', 'agreement',
get_string('moderationagreement', 'coursework'),
$options,
Expand Down
2 changes: 1 addition & 1 deletion classes/forms/student_submission_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ protected function add_submit_buttons_to_form() {
// state because the reason for doing submit on behalf of in the first place is that the student cannot use the
// interface themselves, so they are unable to come back later to finalise it themselves.
if (($ability->can('create', $this->get_submission()) || $ability->can('update', $this->get_submission()))
&& $this->get_submission()->get_coursework()->has_deadline() ) {
&& $this->get_submission()->get_coursework()->has_deadline() ) {
$button_array[] = $this->_form->createElement('submit', 'submitbutton', get_string('submit'));
}
if ($ability->can('finalise', $this->get_submission())) {
Expand Down
6 changes: 3 additions & 3 deletions classes/models/submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ public function editable_feedbacks_exist() {
}
}

return (empty($editablefeedbacks)) ? false : $editablefeedbacks;
return (empty($editablefeedbacks)) ? false : $editablefeedbacks;
}

/**
Expand Down Expand Up @@ -1399,7 +1399,7 @@ public function final_draft_feedbacks_exist() {

$editablefeedbacks = $DB->get_records_sql($sql, array('submissionid' => $this->id, 'time' =>time()));

return (empty($editablefeedbacks)) ? false : $editablefeedbacks;
return (empty($editablefeedbacks)) ? false : $editablefeedbacks;
}

/*
Expand Down Expand Up @@ -1461,7 +1461,7 @@ function has_specific_assessor_feedback($assessorid) {
$feedback = $DB->get_record('coursework_feedbacks', array('submissionid' => $this->id,
'assessorid' => $assessorid));

return (empty($feedback)) ? false : $feedback;
return (empty($feedback)) ? false : $feedback;
}

// caching
Expand Down
2 changes: 1 addition & 1 deletion classes/render_helpers/grading_report/cells/user_cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function get_table_header($options = []) {

$viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context());

// a dding this line so that the sortable heading function will make a sortable link unique to the table
// adding this line so that the sortable heading function will make a sortable link unique to the table
// if tablename is set
$tablename = (!empty($options['tablename'])) ? $options['tablename'] : '';

Expand Down
4 changes: 2 additions & 2 deletions classes/sample_set_rule/range_sample_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ public function range_elements($assessor_number, $sequence, $dbrecord = false) {
}

if ($dbrecord) {
$selected_type = array($dbrecord->ruletype=>get_string($dbrecord->ruletype, 'mod_coursework'));
$selected_type = array($dbrecord->ruletype=> get_string($dbrecord->ruletype, 'mod_coursework'));
$selected_to = ($dbrecord->ruletype == 'scale') ? array($dbrecord->upperlimit => $scale[$dbrecord->upperlimit]) : array($dbrecord->upperlimit => $dbrecord->upperlimit);

$selected_from = ($dbrecord->ruletype == 'scale') ? array($dbrecord->lowerlimit => $scale[$dbrecord->lowerlimit]) : array($dbrecord->lowerlimit => $dbrecord->lowerlimit);

$rules_checked = ($dbrecord) ? true : false;

} else {
$selected_type = array('percentage' =>get_string('percentage', 'mod_coursework'));
$selected_type = array('percentage' => get_string('percentage', 'mod_coursework'));
$selected_to = array('100' => '100');
$selected_from = array('0' => '0');;
$rules_checked = false;
Expand Down
4 changes: 2 additions & 2 deletions classes/sample_set_rule/total_sample_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public function add_form_elements($assessor_number=0) {
AND sr.stage_identifier = 'assessor_{$assessor_number}'
AND sp.rulename = 'total_sample_type'";

$selected = ($record = $DB->get_record_sql($sql)) ? array($record->upperlimit => $record->upperlimit) : false;
$checked = ($selected) ? true : false;
$selected = ($record = $DB->get_record_sql($sql)) ? array($record->upperlimit => $record->upperlimit) : false;
$checked = ($selected) ? true : false;

$percentage_options = [];

Expand Down
2 changes: 1 addition & 1 deletion classes/stages/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function make_auto_allocation_if_necessary($allocatable) {
return;
}

if ($this->get_coursework()->assessorallocationstrategy == 'group_assessor' && $this->identifier() == 'assessor_1' ) {
if ($this->get_coursework()->assessorallocationstrategy == 'group_assessor' && $this->identifier() == 'assessor_1' ) {
// get teacher form the group
$teacher = $this->get_assessor_from_moodle_course_group($allocatable);
//$teacher = user::find(12);
Expand Down
2 changes: 1 addition & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2491,7 +2491,7 @@ function xmldb_coursework_upgrade($oldversion) {

$courseworkinstances = $DB->get_records('coursework');

foreach ($courseworkinstances as $cwk) {
foreach ($courseworkinstances as $cwk) {
$courseworkhassubmissions = $DB->record_exists('coursework_submissions', ['courseworkid' => $cwk->id]);
$cwk->renamefiles = ($cwk->blindmarking == 1 || $courseworkhassubmissions) ? 1 : 0;

Expand Down
6 changes: 3 additions & 3 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ function coursework_add_instance($formdata) {
// we have to check to see if this coursework has a deadline ifm it doesn't we need to set the
// deadline to zero

$formdata->deadline = empty($formdata->deadline) ? 0 : $formdata->deadline;
$formdata->deadline = empty($formdata->deadline) ? 0 : $formdata->deadline;
$subnotify = '';
$comma = '';
if (!empty($formdata->submissionnotification)) {
foreach ($formdata->submissionnotification as $uid) {
$subnotify .= $comma . $uid;
$comma = ', ';
$comma = ',';
}
}
$formdata->submissionnotification = $subnotify;
Expand Down Expand Up @@ -442,7 +442,7 @@ function coursework_update_instance($coursework) {
if (!empty($coursework->submissionnotification)) {
foreach ($coursework->submissionnotification as $uid) {
$subnotify .= $comma . $uid;
$comma = ', ';
$comma = ',';
}
}

Expand Down
Loading

0 comments on commit 2d0e625

Please sign in to comment.