Skip to content

Commit

Permalink
Fix coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
aydevworks committed Nov 3, 2023
1 parent 82dd384 commit 0422b28
Show file tree
Hide file tree
Showing 22 changed files with 76 additions and 62 deletions.
4 changes: 2 additions & 2 deletions apiclients/easikit/classes/requests/getcomponentgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class getcomponentgrade extends request {
'mod_code' => 'MOD_CODE',
'mod_occ_year_code' => 'AYR_CODE',
'mod_occ_psl_code' => 'PSL_CODE',
'mod_occ_mav' => 'MAV_OCCUR'
'mod_occ_mav' => 'MAV_OCCUR',
];

/** @var string request method */
Expand Down Expand Up @@ -85,7 +85,7 @@ public function process_response($response): array {
'MAB_PERC' => $matches[1],
'MAB_NAME' => $value['name'],
'MKS_CODE' => $value['mark_scheme']['code'],
'APA_ROMC' => $value['schedule']['location']['room']['identifier']
'APA_ROMC' => $value['schedule']['location']['room']['identifier'],
];
}
}
Expand Down
3 changes: 2 additions & 1 deletion apiclients/easikit/classes/requests/getmarkingschemes.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @author Alex Yeung <[email protected]>
*/
class getmarkingschemes extends request {

/** @var string request method */
const METHOD = 'GET';

Expand Down Expand Up @@ -66,7 +67,7 @@ public function process_response($response): array {
'MKS_CODE' => $markingscheme['identifier'],
'MKS_MARKS' => $markingscheme['usage_indicator']['code'],
'MKS_TYPE' => $markingscheme['type']['code'],
'MKS_IUSE' => $markingscheme['in_use_indicator']
'MKS_IUSE' => $markingscheme['in_use_indicator'],
];
}
}
Expand Down
3 changes: 2 additions & 1 deletion apiclients/easikit/classes/requests/getstudent.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
*/
class getstudent extends request {


/** @var string[] Fields mapping - Local data fields to SITS' fields */
const FIELDS_MAPPING = [
'idnumber' => 'STU_CODE',
'mapcode' => 'MAP_CODE',
'mabseq' => 'MAB_SEQ'
'mabseq' => 'MAB_SEQ',
];

/** @var string request method */
Expand Down
2 changes: 2 additions & 0 deletions apiclients/easikit/classes/requests/getstudents.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
class getstudents extends request {



/** @var string[] Fields mapping - Local data fields to SITS' fields */
const FIELDS_MAPPING = [
'mapcode' => 'MAP_CODE',
Expand Down
3 changes: 2 additions & 1 deletion apiclients/easikit/tests/privacy_provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* @author Alex Yeung <[email protected]>
*/
class privacy_provider_test extends \advanced_testcase {

protected function setUp(): void {
parent::setUp();
$this->resetAfterTest();
Expand All @@ -39,7 +40,7 @@ protected function setUp(): void {
* @return void
* @throws \coding_exception
*/
public function test_get_reason() {
public function test_get_reason(): void {
$reason = get_string(provider::get_reason(), 'sitsapiclient_easikit');
$this->assertEquals('This plugin does not store any personal data.', $reason);
}
Expand Down
6 changes: 3 additions & 3 deletions apiclients/easikit/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
$plugin->version = 2023051900;
$plugin->requires = 2021051708;
$plugin->maturity = MATURITY_ALPHA;
$plugin->dependencies = array(
'local_sitsgradepush' => 2022020101
);
$plugin->dependencies = [
'local_sitsgradepush' => 2022020101,
];
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class getcomponentgrade extends request {
'mod_code' => 'MOD_CODE',
'mod_occ_year_code' => 'AYR_CODE',
'mod_occ_psl_code' => 'PSL_CODE',
'mod_occ_mav' => 'MAV_OCCUR'
'mod_occ_mav' => 'MAV_OCCUR',
];

/** @var string[] Endpoint params */
Expand Down Expand Up @@ -60,7 +60,7 @@ public function __construct(\stdClass $data) {
}

// Set the fields mapping, params fields and data.
parent::__construct(self::FIELDS_MAPPING, $endpointurl, self::ENDPOINT_PARAMS, $data);
parent::__construct(self::FIELDS_MAPPING, $endpointurl, self::ENDPOINT_PARAMS, $data);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions apiclients/stutalkdirect/classes/requests/getstudent.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class getstudent extends request {
const FIELDS_MAPPING = [
'idnumber' => 'STU_CODE',
'mapcode' => 'MAP_CODE',
'mabseq' => 'MAB_SEQ'
'mabseq' => 'MAB_SEQ',
];

/** @var string[] Endpoint params */
Expand Down Expand Up @@ -59,7 +59,7 @@ public function __construct(\stdClass $data) {
}

// Set the fields mapping, params fields and data.
parent::__construct(self::FIELDS_MAPPING, $endpointurl, self::ENDPOINT_PARAMS, $data);
parent::__construct(self::FIELDS_MAPPING, $endpointurl, self::ENDPOINT_PARAMS, $data);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apiclients/stutalkdirect/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function send_request(irequest $request) {
curl_setopt(
$curlclient,
CURLOPT_HTTPHEADER,
array('Content-Type: application/json')
['Content-Type: application/json']
);
}

Expand Down
4 changes: 3 additions & 1 deletion apiclients/stutalkdirect/tests/privacy_provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
* @author Alex Yeung <[email protected]>
*/
class privacy_provider_test extends \advanced_testcase {


protected function setUp(): void {
parent::setUp();
$this->resetAfterTest();
Expand All @@ -39,7 +41,7 @@ protected function setUp(): void {
* @return void
* @throws \coding_exception
*/
public function test_get_reason() {
public function test_get_reason(): void {
$reason = get_string(provider::get_reason(), 'sitsapiclient_stutalkdirect');
$this->assertEquals('This plugin does not store any personal data.', $reason);
}
Expand Down
6 changes: 3 additions & 3 deletions apiclients/stutalkdirect/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
$plugin->version = 2023051700;
$plugin->requires = 2021051708;
$plugin->maturity = MATURITY_ALPHA;
$plugin->dependencies = array(
'local_sitsgradepush' => 2022020101
);
$plugin->dependencies = [
'local_sitsgradepush' => 2022020101,
];
9 changes: 5 additions & 4 deletions classes/errormanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @author Alex Yeung <[email protected]>
*/
class errormanager {

/** @var int error type cannot be determined */
const ERROR_UNKNOWN = -99;

Expand Down Expand Up @@ -66,7 +67,7 @@ class errormanager {
self::ERROR_ATTEMPT_NUMBER_BLANK => 'Attempt number blank',
self::ERROR_OVERWRITE_EXISTING_RECORD => 'Overwrite not allowed',
self::ERROR_INVALID_MARKS => 'Invalid marks',
self::ERROR_INVALID_HAND_IN_STATUS => 'Invalid hand in status'
self::ERROR_INVALID_HAND_IN_STATUS => 'Invalid hand in status',
];

/** @var array error types and their match error strings */
Expand All @@ -82,7 +83,7 @@ class errormanager {
'no further update allowed',
],
self::ERROR_INVALID_MARKS => ['Mark and/or Grade not valid'],
self::ERROR_INVALID_HAND_IN_STATUS => ['handin_status provided is not in SUS table']
self::ERROR_INVALID_HAND_IN_STATUS => ['handin_status provided is not in SUS table'],
];

/**
Expand All @@ -91,7 +92,7 @@ class errormanager {
* @param int|null $errorcode error code
* @return string error label
*/
public static function get_error_label(int $errorcode = null) : string {
public static function get_error_label(int $errorcode = null): string {
// If no error code provided, return unknown error.
if (!isset($errorcode)) {
return self::ERROR_TYPES_LABEL[self::ERROR_UNKNOWN];
Expand All @@ -106,7 +107,7 @@ public static function get_error_label(int $errorcode = null) : string {
* @param string|null $errorstring
* @return int
*/
public static function identify_error(string $errorstring = null) : int {
public static function identify_error(string $errorstring = null): int {
// If no error string provided, return unknown error.
if (!isset($errorstring)) {
return self::ERROR_UNKNOWN;
Expand Down
3 changes: 2 additions & 1 deletion classes/output/pushrecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ public function __construct(\stdClass $student, int $coursemoduleid, \stdClass $

/**
* Set grade.
* @param int $studentid
*
* @param int $coursemoduleid
* @param int $studentid
* @return void
* @throws \moodle_exception
*/
Expand Down
16 changes: 8 additions & 8 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@

defined('MOODLE_INTERNAL') || die;

$capabilities = array(
'local/sitsgradepush:mapassessment' => array(
$capabilities = [
'local/sitsgradepush:mapassessment' => [
'riskbitmask' => RISK_CONFIG,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(),
),
'local/sitsgradepush:pushgrade' => array(
'archetypes' => [],
],
'local/sitsgradepush:pushgrade' => [
'riskbitmask' => RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(),
),
);
'archetypes' => [],
],
];
20 changes: 10 additions & 10 deletions db/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@
*/
defined('MOODLE_INTERNAL') || die();

$observers = array(
array(
$observers = [
[
'eventname' => '\mod_assign\event\submission_graded',
'callback' => 'local_sitsgradepush_observer::submission_graded',
'priority' => 200,
),
array(
],
[
'eventname' => '\mod_quiz\event\attempt_submitted',
'callback' => 'local_sitsgradepush_observer::quiz_attempt_submitted',
'priority' => 200,
),
array(
],
[
'eventname' => '\core\event\user_graded',
'callback' => 'local_sitsgradepush_observer::user_graded',
'priority' => 200,
),
array(
],
[
'eventname' => '\mod_quiz\event\attempt_regraded',
'callback' => 'local_sitsgradepush_observer::quiz_attempt_regraded',
'priority' => 200,
),
);
],
];
6 changes: 3 additions & 3 deletions db/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@

// We defined the web service functions to install.
$functions = [
'local_sitsgradepush_schedule_push_task' => array(
'local_sitsgradepush_schedule_push_task' => [
'classname' => 'local_sitsgradepush\external\schedule_push_task',
'description' => 'Schedule a push task',
'ajax' => true,
'type' => 'write',
'loginrequired' => true
),
'loginrequired' => true,
],
];


10 changes: 5 additions & 5 deletions db/tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

defined('MOODLE_INTERNAL') || die;

$tasks = array(
array(
$tasks = [
[
'classname' => 'local_sitsgradepush\task\pushtask',
'blocking' => 0,
'minute' => '*',
'hour' => '*',
'day' => '*',
'month' => '*',
'dayofweek' => '*'
)
);
'dayofweek' => '*',
],
];
5 changes: 3 additions & 2 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,9 @@ function xmldb_local_sitsgradepush_upgrade($oldversion) {

// Patch transfer log.
$DB->execute('
UPDATE {local_sitsgradepush_tfr_log} t
SET t.assessmentmappingid = (SELECT m.id FROM {local_sitsgradepush_mapping} m WHERE m.coursemoduleid = t.coursemoduleid)');
UPDATE {local_sitsgradepush_tfr_log} t
SET t.assessmentmappingid =
(SELECT m.id FROM {local_sitsgradepush_mapping} m WHERE m.coursemoduleid = t.coursemoduleid)');

// Launch change of nullability for field assessmentmappingid.
$dbman->change_field_notnull($table, $field);
Expand Down
7 changes: 5 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ function local_sitsgradepush_coursemodule_standard_elements($formwrapper, $mform
*/
function local_sitsgradepush_coursemodule_edit_post_actions($data, $course) {
$manager = manager::get_manager();
$manager->save_assessment_mappings($data);
// Save assessment mapping.
if (!empty($data->gradepushassessmentselect)) {
$manager->save_assessment_mappings($data);
}

return $data;
}
Expand Down Expand Up @@ -170,7 +173,7 @@ function local_sitsgradepush_coursemodule_validation($fromform, $fields) {
}

// For Turnitin assignment, check if the number of parts is greater than 1.
if ($activitytype[1] === 'turnitintooltwo') {
if ($activitytype[1] === 'turnitintooltwo' && !empty($componentgrades)) {
if ($fields['numparts'] > 1) {
return ['numparts' => get_string('error:turnitin_numparts', 'local_sitsgradepush')];
}
Expand Down
12 changes: 6 additions & 6 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
));

// Set the user profile field for export staff's source.
$options = array();
$options = [];
$manager = manager::get_manager();
$fields = $manager->get_user_profile_fields();
if (!empty($fields)) {
Expand All @@ -117,11 +117,11 @@
}
}
$settings->add(new admin_setting_configselect(
'local_sitsgradepush/user_profile_field',
get_string('settings:userprofilefield', 'local_sitsgradepush'),
get_string('settings:userprofilefield:desc', 'local_sitsgradepush'),
'',
$options)
'local_sitsgradepush/user_profile_field',
get_string('settings:userprofilefield', 'local_sitsgradepush'),
get_string('settings:userprofilefield:desc', 'local_sitsgradepush'),
'',
$options)
);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/privacy_provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* @author Alex Yeung <[email protected]>
*/
class privacy_provider_test extends \advanced_testcase {

protected function setUp(): void {
parent::setUp();
$this->resetAfterTest();
Expand All @@ -39,7 +40,7 @@ protected function setUp(): void {
* @return void
* @throws \coding_exception
*/
public function test_get_reason() {
public function test_get_reason(): void {
$reason = get_string(provider::get_reason(), 'local_sitsgradepush');
$this->assertEquals('This plugin does not store any personal data.', $reason);
}
Expand Down
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$plugin->version = 2023103100;
$plugin->requires = 2021051708;
$plugin->maturity = MATURITY_ALPHA;
$plugin->dependencies = array(
$plugin->dependencies = [
'block_portico_enrolments' => 2023012400,
'block_lifecycle' => 2022120800
);
'block_lifecycle' => 2022120800,
];

0 comments on commit 0422b28

Please sign in to comment.