From 64d4a9a7428b1d6fb82b3177a73f5550d63be3ef Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Tue, 27 Jul 2021 04:38:41 +0200 Subject: [PATCH 1/3] Remove useless and inconsistent grade db fields --- db/upgrade.php | 21 +++++++++++++++++++-- locallib.php | 2 -- version.php | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/db/upgrade.php b/db/upgrade.php index a7b54be125..3d79f76ead 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -94,8 +94,6 @@ function xmldb_moodleoverflow_upgrade($oldversion) { $table->add_field('moodleoverflowid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); $table->add_field('grade', XMLDB_TYPE_FLOAT, '10', null, XMLDB_NOTNULL, null, '0'); - $table->add_field('late', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '0'); - $table->add_field('completed', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); // Adding keys to table moodleoverflow_grades. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); @@ -155,5 +153,24 @@ function xmldb_moodleoverflow_upgrade($oldversion) { upgrade_mod_savepoint(true, 2021060800, 'moodleoverflow'); } + if ($oldversion < 2021072700) { + // Define fields late and completed to be dropped from moodleoverflow_grades. + $table = new xmldb_table('moodleoverflow_grades'); + + $field = new xmldb_field('late'); + // Conditionally launch drop field late. + if ($dbman->field_exists($table, $field)) { + $dbman->drop_field($table, $field); + } + + $field = new xmldb_field('completed'); + // Conditionally launch drop field completed. + if ($dbman->field_exists($table, $field)) { + $dbman->drop_field($table, $field); + } + + upgrade_mod_savepoint(true, 2021072700, 'moodleoverflow'); + } + return true; } \ No newline at end of file diff --git a/locallib.php b/locallib.php index 8a5671b21c..33bb760f31 100644 --- a/locallib.php +++ b/locallib.php @@ -1901,8 +1901,6 @@ function moodleoverflow_update_user_grade_on_db($moodleoverflow, $postuserrating $gradedataobject->moodleoverflowid = $moodleoverflow->id; $gradedataobject->userid = $userid; $gradedataobject->grade = $grade; - $gradedataobject->late = 0; - $gradedataobject->completed = 0; $DB->insert_record('moodleoverflow_grades', $gradedataobject, false); } diff --git a/version.php b/version.php index b180510332..7dde56bd8a 100644 --- a/version.php +++ b/version.php @@ -28,7 +28,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_moodleoverflow'; -$plugin->version = 2021060800; +$plugin->version = 2021072700; $plugin->release = 'v3.11-r1'; $plugin->requires = 2018051703; $plugin->maturity = MATURITY_STABLE; From 74c3fc7670d78c111bdd350cf9fbe14646aa2c63 Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Tue, 27 Jul 2021 05:22:11 +0200 Subject: [PATCH 2/3] Fix new codechecker errors requiring newline at end of file --- classes/event/rating_created.php | 2 +- classes/event/rating_deleted.php | 2 +- classes/event/rating_updated.php | 2 +- classes/observer.php | 2 +- classes/privacy/data_export_helper.php | 2 +- classes/readtracking.php | 2 +- classes/subscriptions.php | 2 +- db/events.php | 2 +- db/messages.php | 2 +- db/services.php | 2 +- db/upgrade.php | 2 +- discussion.php | 2 +- index.php | 2 +- markposts.php | 2 +- post.php | 2 +- renderer.php | 2 +- settings.php | 2 +- subscribe.php | 2 +- tests/privacy_provider_test.php | 2 +- tests/readtracking_test.php | 2 +- tests/subscriptions_test.php | 2 +- tracking.php | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/classes/event/rating_created.php b/classes/event/rating_created.php index 4e918e9aee..d96a91321a 100644 --- a/classes/event/rating_created.php +++ b/classes/event/rating_created.php @@ -63,4 +63,4 @@ public function get_description() { public static function get_name() { return get_string('eventratingcreated', 'mod_moodleoverflow'); } -} \ No newline at end of file +} diff --git a/classes/event/rating_deleted.php b/classes/event/rating_deleted.php index 209cf35b10..1d1fa070e6 100644 --- a/classes/event/rating_deleted.php +++ b/classes/event/rating_deleted.php @@ -63,4 +63,4 @@ public function get_description() { public static function get_name() { return get_string('eventratingdeleted', 'mod_moodleoverflow'); } -} \ No newline at end of file +} diff --git a/classes/event/rating_updated.php b/classes/event/rating_updated.php index 6b3901ee47..bf0673f79f 100644 --- a/classes/event/rating_updated.php +++ b/classes/event/rating_updated.php @@ -63,4 +63,4 @@ public function get_description() { public static function get_name() { return get_string('eventratingupdated', 'mod_moodleoverflow'); } -} \ No newline at end of file +} diff --git a/classes/observer.php b/classes/observer.php index 199cf027f2..26948f67c3 100644 --- a/classes/observer.php +++ b/classes/observer.php @@ -141,4 +141,4 @@ public static function course_module_created(\core\event\course_module_created $ moodleoverflow_instance_created($event->get_context(), $moodleoverflow); } } -} \ No newline at end of file +} diff --git a/classes/privacy/data_export_helper.php b/classes/privacy/data_export_helper.php index 271496a059..d6314a30bd 100644 --- a/classes/privacy/data_export_helper.php +++ b/classes/privacy/data_export_helper.php @@ -498,4 +498,4 @@ public static function get_subcontext($discussion = null, $post = null) { } return $subcontext; } -} \ No newline at end of file +} diff --git a/classes/readtracking.php b/classes/readtracking.php index 8bedfe8946..8b67e39be1 100644 --- a/classes/readtracking.php +++ b/classes/readtracking.php @@ -565,4 +565,4 @@ public static function moodleoverflow_count_unread_posts_course($userid, $course // Else return nothing. return array(); } -} \ No newline at end of file +} diff --git a/classes/subscriptions.php b/classes/subscriptions.php index 349cec5d3d..4231c4ed4a 100644 --- a/classes/subscriptions.php +++ b/classes/subscriptions.php @@ -1081,4 +1081,4 @@ public static function get_discussion_subscription_icon($moodleoverflow, $discus return \html_writer::link($subscriptionlink, $output, $array); } -} \ No newline at end of file +} diff --git a/db/events.php b/db/events.php index fb23de721e..a5d05d3463 100644 --- a/db/events.php +++ b/db/events.php @@ -44,4 +44,4 @@ 'callback' => 'mod_moodleoverflow_observer::course_module_created', ), -); \ No newline at end of file +); diff --git a/db/messages.php b/db/messages.php index adb9f3a540..c03df6a673 100644 --- a/db/messages.php +++ b/db/messages.php @@ -28,4 +28,4 @@ // Ordinary single moodleoverflow posts. 'posts' => array(), -); \ No newline at end of file +); diff --git a/db/services.php b/db/services.php index 2061917cbf..7bcba3e5eb 100644 --- a/db/services.php +++ b/db/services.php @@ -34,4 +34,4 @@ 'ajax' => true, 'capabilities' => 'mod/moodleoverflow:ratepost' ) -); \ No newline at end of file +); diff --git a/db/upgrade.php b/db/upgrade.php index 3d79f76ead..e33cb2fe2a 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -173,4 +173,4 @@ function xmldb_moodleoverflow_upgrade($oldversion) { } return true; -} \ No newline at end of file +} diff --git a/discussion.php b/discussion.php index 1c814d7511..fbb22b423a 100644 --- a/discussion.php +++ b/discussion.php @@ -159,4 +159,4 @@ moodleoverflow_print_discussion($course, $cm, $moodleoverflow, $discussion, $post, $canreply); -echo $OUTPUT->footer(); \ No newline at end of file +echo $OUTPUT->footer(); diff --git a/index.php b/index.php index 445d34d7ea..ad494c22ab 100644 --- a/index.php +++ b/index.php @@ -390,4 +390,4 @@ } // Print the pages footer. -echo $OUTPUT->footer(); \ No newline at end of file +echo $OUTPUT->footer(); diff --git a/markposts.php b/markposts.php index 376645cff9..e56ce3bb62 100644 --- a/markposts.php +++ b/markposts.php @@ -142,4 +142,4 @@ // Redirect the user back to the view.php. redirect(moodleoverflow_go_back_to($returnto), $message, null, $status); exit; -} \ No newline at end of file +} diff --git a/post.php b/post.php index bd22209343..08804cfc12 100644 --- a/post.php +++ b/post.php @@ -763,4 +763,4 @@ $mformpost->display(); // Display the footer. -echo $OUTPUT->footer(); \ No newline at end of file +echo $OUTPUT->footer(); diff --git a/renderer.php b/renderer.php index 6a953be58b..b05569a3d1 100644 --- a/renderer.php +++ b/renderer.php @@ -102,4 +102,4 @@ public function render_moodleoverflow_email(\mod_moodleoverflow\output\moodleove public function moodleoverflow_email_template() { return null; } -} \ No newline at end of file +} diff --git a/settings.php b/settings.php index 0c0710c3e2..f51f296c03 100644 --- a/settings.php +++ b/settings.php @@ -112,4 +112,4 @@ $setting->set_updatedcallback('moodleoverflow_update_all_grades'); } -} \ No newline at end of file +} diff --git a/subscribe.php b/subscribe.php index 4772dad12e..cc1617dd45 100644 --- a/subscribe.php +++ b/subscribe.php @@ -333,4 +333,4 @@ redirect($returnto, get_string('discussionnowsubscribed', 'moodleoverflow', $info), null, $notify['success']); exit; } -} \ No newline at end of file +} diff --git a/tests/privacy_provider_test.php b/tests/privacy_provider_test.php index 6907576df7..2b8bf36977 100644 --- a/tests/privacy_provider_test.php +++ b/tests/privacy_provider_test.php @@ -1459,4 +1459,4 @@ public function test_grades() { 'userid, grade'); self::assertEmpty($grades); } -} \ No newline at end of file +} diff --git a/tests/readtracking_test.php b/tests/readtracking_test.php index 5da8937c18..ea979137cf 100644 --- a/tests/readtracking_test.php +++ b/tests/readtracking_test.php @@ -159,4 +159,4 @@ public function test_moodleoverflow_is_tracked() { $result = \mod_moodleoverflow\readtracking::moodleoverflow_is_tracked($mooptional); $this->assertEquals(false, $result); } -} \ No newline at end of file +} diff --git a/tests/subscriptions_test.php b/tests/subscriptions_test.php index 82325c7f9c..341e96635f 100644 --- a/tests/subscriptions_test.php +++ b/tests/subscriptions_test.php @@ -1458,4 +1458,4 @@ public function test_is_subscribable_loggedin($options, $expect) { $this->assertEquals($expect, \mod_moodleoverflow\subscriptions::is_subscribable($moodleoverflow)); } -} \ No newline at end of file +} diff --git a/tracking.php b/tracking.php index f56fe1dd6e..64dcb17f9c 100644 --- a/tracking.php +++ b/tracking.php @@ -121,4 +121,4 @@ // Print an error message. print_error('cannottrack', 'moodleoverflow', get_local_referer(false)); } -} \ No newline at end of file +} From 1df01bd419546d205f5790f4f79ba064c984d254 Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Tue, 27 Jul 2021 05:36:27 +0200 Subject: [PATCH 3/3] Use Mariadb 10.5 as 10.6 does not currently work with moodle (MDL-72131) --- .github/workflows/moodle-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index 1ffa225b21..ff58505766 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -114,7 +114,7 @@ jobs: steps: - name: Start MariaDB if: matrix.database == 'mariadb' - run: docker run -p 3306:3306 -e MYSQL_USER=root -e MYSQL_ALLOW_EMPTY_PASSWORD=true -d mariadb:10 + run: docker run -p 3306:3306 -e MYSQL_USER=root -e MYSQL_ALLOW_EMPTY_PASSWORD=true -d mariadb:10.5 - name: Start PostgreSQL if: matrix.database == 'pgsql'