Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6aeff86
add procession functins
TamaroWalter Mar 11, 2024
acc1fcc
delete function that causes error
TamaroWalter Mar 11, 2024
140bef2
add deprecated comments
TamaroWalter Mar 11, 2024
bb98d33
bootstrap adjustments for Moodle 4.4.
TamaroWalter Mar 11, 2024
b39a422
WIP: trying to add mform data in import
TamaroWalter Mar 12, 2024
a705aa0
Completed updates for moodle 404
TamaroWalter Mar 12, 2024
397d407
user old format_string functions for compatibility
TamaroWalter Mar 12, 2024
586cf03
fix fails
TamaroWalter Mar 12, 2024
cc3e169
delete workflows for unsupported versions
TamaroWalter Mar 12, 2024
411d8de
include new moodle versions
TamaroWalter Mar 13, 2024
5c96fd6
test against master
TamaroWalter Mar 13, 2024
cf17932
syntax fix in workflows
TamaroWalter Mar 13, 2024
afa5c9e
fix in backup function
TamaroWalter Mar 13, 2024
bc38222
codechecker fixes
TamaroWalter Mar 13, 2024
f39560d
remove unused code
TamaroWalter Mar 15, 2024
7e13b11
Merge branch 'bugfix/settingsreset' of github.com:learnweb/moodle-mod…
TamaroWalter Mar 15, 2024
cb9311f
little update in backup stepslib
TamaroWalter Mar 15, 2024
fb8ec84
adapt CI to moodle 4.4
TamaroWalter Apr 23, 2024
318ac17
Merge branch 'master' into update/M4.4
TamaroWalter Apr 23, 2024
b6ecbf5
Shell escape the release notes in the release workflow
TamaroWalter May 2, 2024
677b368
add reviewed attributes in backup stepslib
TamaroWalter May 2, 2024
5d74f5a
improve backup stepslib
TamaroWalter May 2, 2024
1938d43
save firstpost as in mod_forum
TamaroWalter May 2, 2024
7e81760
adapt workflow matrix to Moodle 404
TamaroWalter May 8, 2024
d2413a3
fixes for M4.4
TamaroWalter May 23, 2024
07ec785
more fixes for M4.4
TamaroWalter May 23, 2024
6e882c6
use deprecated behat funtion directly
TamaroWalter May 23, 2024
9605eba
refactor deprecated phpunit function
TamaroWalter May 23, 2024
7ea9f0e
add condition to use deprecated function in older Moodle versions
TamaroWalter May 23, 2024
1af92d1
Merge branch 'master' into update/M4.4
TamaroWalter May 23, 2024
e2f8e2c
codechecker fixes
TamaroWalter May 23, 2024
f7cdb4a
Merge branch 'master' into bugfix/settingsreset
TamaroWalter May 23, 2024
d215afa
add delay for pgsql
TamaroWalter May 24, 2024
f207468
rollback
TamaroWalter May 24, 2024
730b256
WIP: try to fix phpunit test for postgresql
TamaroWalter May 28, 2024
334f619
codecleaning
TamaroWalter May 28, 2024
9bb30d1
enable transaction rollback
TamaroWalter May 28, 2024
91eb439
pull from update branch
TamaroWalter May 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:

strategy:
matrix:
php: ['8.2']
moodle-branch: ['MOODLE_403_STABLE']
php: ['8.3']
moodle-branch: ['MOODLE_404_STABLE']
database: ['pgsql']

steps:
Expand Down Expand Up @@ -110,22 +110,27 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.1']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE']
php: ['8.0', '8.1', '8.2', '8.3']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE']
database: ['mariadb', 'pgsql']
include:
- php: '8.2'
moodle-branch: 'MOODLE_402_STABLE'
database: 'mariadb'
exclude:
- php: '8.0'
moodle-branch: 'MOODLE_404_STABLE'
- php: '8.2'
moodle-branch: 'MOODLE_401_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_401_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_402_STABLE'
database: 'pgsql'
- php: '8.2'
moodle-branch: 'MOODLE_403_STABLE'
database: 'mariadb'
- php: '8.2'
- php: '8.3'
moodle-branch: 'MOODLE_403_STABLE'
include:
- php: '7.4'
moodle-branch: 'MOODLE_401_STABLE'
database: 'pgsql'
- php: '7.4'
moodle-branch: 'MOODLE_401_STABLE'
database: 'mariadb'

steps:
- name: Start MariaDB
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/moodle-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
--data-urlencode "vcstag=${TAGNAME}" \
--data-urlencode "changelogurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commits/${TAGNAME}" \
--data-urlencode "altdownloadurl=${ZIPURL}" \
--data-urlencode "releasenotes=${BODY}" \
--data-urlencode "releasenotes=${BODY@Q}" \
--data-urlencode "releasenotesformat=4")
echo "response=${RESPONSE}" >> $GITHUB_OUTPUT
- name: Evaluate the response
Expand Down
35 changes: 14 additions & 21 deletions backup/moodle2/backup_moodleoverflow_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,48 +45,41 @@ protected function define_structure() {

// Define the root element describing the moodleoverflow instance.
$moodleoverflow = new backup_nested_element('moodleoverflow', ['id'], [
'name', 'intro', 'introformat', 'maxbytes', 'maxattachments',
'forcesubscribe', 'trackingtype', 'timecreated', 'timemodified',
'ratingpreference', 'coursewidereputation', 'allownegativereputation']);
'name', 'intro', 'introformat', 'maxbytes', 'maxattachments', 'timecreated', 'timemodified',
'forcesubscribe', 'trackingtype', 'ratingpreference', 'coursewidereputation', 'allowrating',
'allowreputation', 'allownegativereputation', 'grademaxgrade', 'gradescalefactor', 'gradecat',
'anonymous', 'allowmultiplemarks', ]);

// Define each element separated.
$discussions = new backup_nested_element('discussions');
$discussion = new backup_nested_element('discussion', ['id'], [
'name', 'firstpost', 'userid', 'timemodified', 'usermodified', 'timestart']);
'name', 'firstpost', 'userid', 'timestart', 'timemodified', 'usermodified', ]);

$posts = new backup_nested_element('posts');

$post = new backup_nested_element('post', ['id'], [
'parent', 'userid', 'created', 'modified',
'mailed', 'message', 'messageformat', 'attachment']);
'message', 'messageformat', 'attachment', 'mailed', 'reviewed', 'timereviewed', ]);

$ratings = new backup_nested_element('ratings');

$rating = new backup_nested_element('rating', ['id'], [
'userid', 'rating', 'firstrated', 'lastchanged']);
'userid', 'rating', 'firstrated', 'lastchanged', ]);

$discussionsubs = new backup_nested_element('discuss_subs');

$discussionsub = new backup_nested_element('discuss_sub', ['id'], [
'userid',
'preference',
]);
'userid', 'preference', ]);

$subscriptions = new backup_nested_element('subscriptions');

$subscription = new backup_nested_element('subscription', ['id'], [
'userid']);
$subscription = new backup_nested_element('subscription', ['id'], ['userid']);

$readposts = new backup_nested_element('readposts');

$read = new backup_nested_element('read', ['id'], [
'userid', 'discussionid', 'postid', 'firstread',
'lastread']);
'userid', 'discussionid', 'postid', 'firstread', 'lastread', ]);

$tracking = new backup_nested_element('tracking');
$grades = new backup_nested_element('grades');
$grade = new backup_nested_element('grade', ['id'], ['userid', 'grade']);

$track = new backup_nested_element('track', ['id'], [
'userid']);
$tracking = new backup_nested_element('tracking');
$track = new backup_nested_element('track', ['id'], ['userid']);

// Build the tree.
$moodleoverflow->add_child($discussions);
Expand Down
6 changes: 3 additions & 3 deletions classes/manager/mail_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use context_course;
use context_module;
use core\context\course;
use core_php_time_limit;
use mod_moodleoverflow\anonymous;
use mod_moodleoverflow\output\moodleoverflow_email;
Expand Down Expand Up @@ -406,7 +407,7 @@ private static function send_post($userto, $post, array &$coursemodules, array &
['userid' => $dataobject->userid,
'courseid' => $dataobject->courseid,
'forumid' => $dataobject->forumid,
'forumdiscussionid' => $dataobject->forumdiscussionid],
'forumdiscussionid' => $dataobject->forumdiscussionid, ],
'numberofposts, id');
if (is_object($record)) {
$dataset = $record;
Expand Down Expand Up @@ -496,8 +497,7 @@ private static function send_post($userto, $post, array &$coursemodules, array &

// Preapare to actually send the post now. Build up the content.
$cleanname = str_replace('"', "'", strip_tags(format_string($moodleoverflow->name)));
$coursecontext = context_course::instance($course->id);
$shortname = format_string($course->shortname, true, ['context' => $coursecontext]);
$shortname = format_string($course->shortname, true, ['context' => context_course::instance($course->id)]);

// Define a header to make mails easier to track.
$emailmessageid = generate_email_messageid('moodlemoodleoverflow' . $moodleoverflow->id);
Expand Down
2 changes: 1 addition & 1 deletion classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static function role_assigned(\core\event\role_assigned $event) {
WHERE m.course = :courseid AND m.forcesubscribe = :initial AND mo.name = 'moodleoverflow' AND ms.id IS NULL";
$params = ['courseid' => $context->instanceid,
'userid' => $userid,
'initial' => MOODLEOVERFLOW_INITIALSUBSCRIBE];
'initial' => MOODLEOVERFLOW_INITIALSUBSCRIBE, ];
$moodleoverflows = $DB->get_records_sql($sql, $params);

// Loop through all moodleoverflows.
Expand Down
4 changes: 2 additions & 2 deletions classes/privacy/data_export_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function export_discussion_data($userid, array $mappings) {
FROM {moodleoverflow} mof
INNER JOIN {moodleoverflow_discussions} d ON d.moodleoverflow = mof.id
LEFT JOIN {moodleoverflow_discuss_subs} dsub ON dsub.discussion = d.id
WHERE mof.id ${foruminsql}
WHERE mof.id {$foruminsql}
AND (
d.userid = :discussionuserid OR
d.usermodified = :dmuserid OR
Expand Down Expand Up @@ -113,7 +113,7 @@ public static function export_all_posts($userid, array $mappings) {
INNER JOIN {moodleoverflow_posts} p ON p.discussion = d.id
LEFT JOIN {moodleoverflow_read} fr ON fr.postid = p.id
LEFT JOIN {moodleoverflow_ratings} rat ON rat.postid = p.id
WHERE mof.id ${foruminsql} AND
WHERE mof.id {$foruminsql} AND
(
p.userid = :postuserid OR
fr.userid = :readuserid OR
Expand Down
10 changes: 5 additions & 5 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,22 +324,22 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {

$DB->delete_records('moodleoverflow_read', [
'moodleoverflowid' => $forum->id,
'userid' => $userid]);
'userid' => $userid, ]);

$DB->delete_records('moodleoverflow_subscriptions', [
'moodleoverflow' => $forum->id,
'userid' => $userid]);
'userid' => $userid, ]);

$DB->delete_records('moodleoverflow_discuss_subs', [
'moodleoverflow' => $forum->id,
'userid' => $userid]);
'userid' => $userid, ]);

$DB->delete_records('moodleoverflow_tracking', [
'moodleoverflowid' => $forum->id,
'userid' => $userid]);
'userid' => $userid, ]);
$DB->delete_records('moodleoverflow_grades', [
'moodleoverflowid' => $forum->id,
'userid' => $userid]);
'userid' => $userid, ]);

// Do not delete ratings but reset userid.
$ratingsql = "userid = :userid AND discussionid IN
Expand Down
2 changes: 1 addition & 1 deletion classes/ratings.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function moodleoverflow_add_rating($moodleoverflow, $postid, $rati
// Is the submitted rating valid?
$possibleratings = [RATING_NEUTRAL, RATING_DOWNVOTE, RATING_UPVOTE, RATING_SOLVED,
RATING_HELPFUL, RATING_REMOVE_DOWNVOTE, RATING_REMOVE_UPVOTE,
RATING_REMOVE_SOLVED, RATING_REMOVE_HELPFUL];
RATING_REMOVE_SOLVED, RATING_REMOVE_HELPFUL, ];
if (!in_array($rating, $possibleratings)) {
throw new moodle_exception('invalidratingid', 'moodleoverflow');
}
Expand Down
4 changes: 2 additions & 2 deletions classes/subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public static function get_unsubscribable_moodleoverflows() {
WHERE m.forcesubscribe <> :forcesubscribe AND ms.id IS NOT NULL AND cm.course $coursesql";
$params = ['modulename' => 'moodleoverflow',
'userid' => $USER->id,
'forcesubscribe' => MOODLEOVERFLOW_FORCESUBSCRIBE];
'forcesubscribe' => MOODLEOVERFLOW_FORCESUBSCRIBE, ];
$mergedparams = array_merge($courseparams, $params);
$moodleoverflows = $DB->get_recordset_sql($sql, $mergedparams);

Expand Down Expand Up @@ -670,7 +670,7 @@ public static function subscribe_user($userid, $moodleoverflow, $context, $userr
$params = [
'userid' => $userid,
'moodleoverflowid' => $moodleoverflow->id,
'preference' => self::MOODLEOVERFLOW_DISCUSSION_UNSUBSCRIBED];
'preference' => self::MOODLEOVERFLOW_DISCUSSION_UNSUBSCRIBED, ];
$where = 'userid = :userid AND moodleoverflow = :moodleoverflowid AND preference <> :preference';
$DB->delete_records_select('moodleoverflow_discuss_subs', $where, $params);

Expand Down
10 changes: 5 additions & 5 deletions classes/tables/userstats_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ public function __construct($uniqueid, $courseid, $moodleoverflow, $url) {
'forumactivity',
'courseactivity',
'forumreputation',
'coursereputation']);
'coursereputation', ]);
$this->define_baseurl($url);
$this->define_headers([get_string('fullnameuser'),
get_string('userstatsupvotes', 'moodleoverflow'),
get_string('userstatsdownvotes', 'moodleoverflow'),
(get_string('userstatsforumactivity', 'moodleoverflow') . $this->helpactivity->object),
(get_string('userstatscourseactivity', 'moodleoverflow') . $this->helpactivity->object),
get_string('userstatsforumreputation', 'moodleoverflow'),
get_string('userstatscoursereputation', 'moodleoverflow')]);
get_string('userstatscoursereputation', 'moodleoverflow'), ]);
$this->get_table_data();
$this->sortable(true, 'coursereputation', SORT_DESC);
$this->no_sorting('username');
Expand Down Expand Up @@ -277,7 +277,7 @@ public function set_helpactivity() {
'tabindex' => '0',
'data-content' => '<div class=&quot;no-overflow&quot;><p>' .
get_string('helpamountofactivity', 'moodleoverflow') .
'</p> </div>'];
'</p> </div>', ];

$this->helpactivity->object = \html_writer::span($this->helpactivity->icon,
$this->helpactivity->class,
Expand Down Expand Up @@ -356,10 +356,10 @@ public function col_coursereputation($row) {
*/
private function badge_render($number) {
if ($number > 0) {
return \html_writer::tag('h5', \html_writer::start_span('badge badge-success') .
return \html_writer::tag('h5', \html_writer::start_span('badge bg-success') .
$number . \html_writer::end_span());
} else {
return \html_writer::tag('h5', \html_writer::start_span('badge badge-warning') .
return \html_writer::tag('h5', \html_writer::start_span('badge bg-warning') .
$number . \html_writer::end_span());
}
}
Expand Down
4 changes: 2 additions & 2 deletions classes/task/send_daily_mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public function execute() {
$mail = [];
// Fill the $mail array.
foreach ($userdata as $row) {
$currentcourse = $DB->get_record('course', array('id' => $row->courseid), 'fullname, id');
$currentcourse = $DB->get_record('course', ['id' => $row->courseid], 'fullname, id');
// Check if the user is enrolled in the course, if not, go to the next row.
if (!is_enrolled(\context_course::instance($row->courseid), $user->userid, '', true)) {
continue;
}

$currentforum = $DB->get_record('moodleoverflow', array('id' => $row->forumid), 'name, id');
$currentforum = $DB->get_record('moodleoverflow', ['id' => $row->forumid], 'name, id');
$coursemoduleid = get_coursemodule_from_instance('moodleoverflow', $row->forumid);
$discussion = $DB->get_record('moodleoverflow_discussions', ['id' => $row->forumdiscussionid], 'name, id');
$unreadposts = $row->numberofposts;
Expand Down
1 change: 0 additions & 1 deletion discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
echo '<div id="moodleoverflow-posts"><div id="moodleoverflow-root">';

moodleoverflow_print_discussion($course, $cm, $moodleoverflow, $discussion, $post, $multiplemarks);

echo '</div></div>';

echo $OUTPUT->footer();
2 changes: 2 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/

// Require needed files.
use core\context\course;

require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once(dirname(__FILE__) . '/locallib.php');
require_once($CFG->dirroot . '/course/lib.php');
Expand Down
5 changes: 3 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

use core\context\course;

defined('MOODLE_INTERNAL') || die();
require_once(dirname(__FILE__) . '/locallib.php');

Expand Down Expand Up @@ -135,7 +137,6 @@ function moodleoverflow_add_instance(stdClass $moodleoverflow, mod_moodleoverflo
$moodleoverflow->timecreated = time();

// You may have to add extra stuff in here.

$moodleoverflow->id = $DB->insert_record('moodleoverflow', $moodleoverflow);

return $moodleoverflow->id;
Expand Down Expand Up @@ -788,7 +789,7 @@ function moodleoverflow_send_mails() {
['userid' => $dataobject->userid,
'courseid' => $dataobject->courseid,
'forumid' => $dataobject->forumid,
'forumdiscussionid' => $dataobject->forumdiscussionid],
'forumdiscussionid' => $dataobject->forumdiscussionid, ],
'numberofposts, id');
if (is_object($record)) {
$dataset = $record;
Expand Down
Loading