Skip to content

Commit

Permalink
little cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaroWalter committed Sep 9, 2024
1 parent 80d87f7 commit 30aa635
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 42 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
fail-fast: false
matrix:
php: [ '8.0', '8.1', '8.2', '8.3' ]
moodle-branch: [ 'MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE' ]
moodle-branch: [ 'MOODLE_401_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE' ]
database: [ 'mariadb', 'pgsql' ]
exclude:
- php: '8.0'
Expand All @@ -135,9 +135,7 @@ jobs:
moodle-branch: 'MOODLE_401_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_401_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_402_STABLE'
- php: '8.3'
- php: 8.3'
moodle-branch: 'MOODLE_403_STABLE'
include:
- php: '7.4'
Expand Down
4 changes: 2 additions & 2 deletions amd/src/postletter.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async function changeButtonString(index, toshowmore) {
}

/**
* Removes in a text all &nbsp; and surrounding <p> tags excluding the first occurrence.
* Removes in a text all &nbsp and surrounding <p> tags excluding the first occurrence.
*
* Helper function to make post look better.
* @param {object} element
Expand All @@ -145,4 +145,4 @@ async function replaceParagraghTags(element) {
message.substring(firstPTag + 3, lastPTag).replace(/<p>/g, '<br>').replace(/<\/p>/g, '') +
message.substring(lastPTag);
element.innerHTML = message;
}
}
12 changes: 6 additions & 6 deletions amd/src/usersettings_save.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ function collecttimefiltersettings() {
// Get the relevant time spans of the time filter.
// Check if the alltimebutton is set.
alltimebutton.forEach(function(button) {
if (button.parentNode.classList.contains('active')) {
// Get the timespan.
settings['timepast'] = convertidtotime(button.id);
settings['timefuture'] = convertidtotime(button.id);
settingsset = true;
}
if (button.parentNode.classList.contains('active')) {
// Get the timespan.
settings['timepast'] = convertidtotime(button.id);
settings['timefuture'] = convertidtotime(button.id);
settingsset = true;
}
});

if (settingsset) {
Expand Down
2 changes: 1 addition & 1 deletion classes/contentcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public function build_content(): array {
foreach ($this->events as $event) {
// Display a orientation marker on the current date between the other events.
if (!$orientationmarkerset && (($event->timestart <= $time))) {

$orientationmarkerset = true;
$tempcontent = new orientation_marker($index, $time);
$this->content[$index] = $tempcontent->export_data();
Expand All @@ -87,6 +86,7 @@ public function build_content(): array {
$templetter = new letter\letter($index, $event->courseid, $event->modulename, $event->instancename,
$event->content, $event->timestart, $event->coursemoduleid);
}

$this->content[$index] = $templetter->export_letter();

// Collect the courses shown in the townsquare to be able to filter them afterwards.
Expand Down
2 changes: 1 addition & 1 deletion classes/letter/letter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* Class that represents an unspecific type of content.
*
* This class is used for the basic letter type and is the top-class for more specific letters..
* This class is used for the basic letter type and is the top-class for more specific letters.
*
* @package block_townsquare
* @copyright 2023 Tamaro Walter
Expand Down
3 changes: 0 additions & 3 deletions classes/letter/post_letter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@

defined('MOODLE_INTERNAL') || die;

global $CFG;
require_once($CFG->libdir . '/portfoliolib.php');

/**
* Class that represents a post from the forum or moodleoverflow module.
*
Expand Down
1 change: 1 addition & 0 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ class renderer extends plugin_renderer_base {
public function render_main($data): string {
return $this->render_from_template('block_townsquare/blockcontent', $data);
}

}
15 changes: 8 additions & 7 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
namespace block_townsquare\privacy;

use core_privacy\local\request\approved_userlist;
use core_privacy\local\request\core_userlist_provider;
use core_privacy\local\request\userlist;
use core_privacy\local\metadata\collection;
use core_privacy\local\request\approved_contextlist;
Expand All @@ -40,7 +41,7 @@
class provider implements
\core_privacy\local\metadata\provider,
\core_privacy\local\request\plugin\provider,
\core_privacy\local\request\core_userlist_provider {
core_userlist_provider {

/**
* Function that describes the type of data that is stored.
Expand All @@ -50,11 +51,11 @@ class provider implements
public static function get_metadata(collection $collection): collection {
$collection->add_database_table('block_townsquare', [
'userid' => 'privacy:metadata:block_townsquare_preferences:userid',
'timefilterpast' => 'privacy:metadata:block_townsquare_preferences:timefilterpast',
'timefilterfuture' => 'privacy:metadata:block_townsquare_preferences:timefilterfuture',
'basicletter' => 'privacy:metadata:block_townsquare_preferences:basicletter',
'completionletter' => 'privacy:metadata:block_townsquare_preferences:completionletter',
'postletter' => 'privacy:metadata:block_townsquare_preferences:postletter',
'timefilterpast' => 'privacy:metadata:block_townsquare_preferences:timefilterpast',
'timefilterfuture' => 'privacy:metadata:block_townsquare_preferences:timefilterfuture',
'basicletter' => 'privacy:metadata:block_townsquare_preferences:basicletter',
'completionletter' => 'privacy:metadata:block_townsquare_preferences:completionletter',
'postletter' => 'privacy:metadata:block_townsquare_preferences:postletter',
], 'privacy:metadata:block_townsquare_preferences');
return $collection;
}
Expand Down Expand Up @@ -154,7 +155,6 @@ public static function delete_data_for_all_users_in_context(\context $context) {
}
}


/**
* Delete all user data for the specified user, in the specified contexts.
* @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
Expand All @@ -169,4 +169,5 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {
}
}
}

}
14 changes: 3 additions & 11 deletions classes/townsquareevents.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function get_all_events_sorted(): array {
public function get_coreevents(): array {
global $DB;

// Get all events from the last six months and the next six months.
// Get all events from the database.
$coreevents = $this->get_events_from_db($this->timestart, $this->timeend, $this->courses);

// Filter the events and add the instancename.
Expand All @@ -123,19 +123,13 @@ public function get_coreevents(): array {
}

/**
* Function to get the newest posts from modules like the forum or moodleoverflow.
* Function to get the newest posts from the forum.
*
* The events are sorted in descending order by time created (newest event first)
* @return array;
*/
public function get_postevents(): array {
global $DB;

// If forum is not installed or not activated, return empty array.
if (!$DB->get_record('modules', ['name' => 'forum', 'visible' => 1])) {
return [];
}

// Get all post from the database.
$forumposts = $this->get_forumposts_from_db($this->courses, $this->timestart);

foreach ($forumposts as $post) {
Expand Down Expand Up @@ -304,8 +298,6 @@ private function filter_forum_privatepost(&$forumpost): bool {
$forumpost->privatereplyfrom = $isprivatemessage && $isauthor;
$forumpost->privatereplyto = $isprivatemessage && $isreceiver;

// Add attributes as the posts is further processed.

return false;
}

Expand Down
1 change: 0 additions & 1 deletion db/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@
* Custom code to be run on installing the plugin.
*/
function xmldb_block_townsquare_install() {

return true;
}
2 changes: 1 addition & 1 deletion db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
2 changes: 1 addition & 1 deletion templates/activitycompletionletter.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
</b>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion templates/basicletter.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@
</div>

</div>
</div>
</div>
2 changes: 1 addition & 1 deletion templates/blockcontent.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@
</div>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion templates/orientationmarker.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
style="border-color: {{orientationmarkercolor}}; background-color: {{orientationmarkercolor}};">
<div class="orientationmarker_body card-body">
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion tests/behat/block_townsquare_timefilter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ Feature: Extra feature file to test the time filter
And I should see "Test assign 6" in the "Town Square" "block"
And I should see "Test assign 7" in the "Town Square" "block"
And I should see "Test assign 4" in the "Town Square" "block"
And I should see "Test choice 1" in the "Town Square" "block"
And I should see "Test choice 1" in the "Town Square" "block"

0 comments on commit 30aa635

Please sign in to comment.