Skip to content

Commit

Permalink
code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaroWalter committed Jul 4, 2024
1 parent ebfeec2 commit 2166e9b
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 46 deletions.
6 changes: 3 additions & 3 deletions block_townsquare.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class block_townsquare extends block_base {
*
* @return void
*/
public function init():void {
public function init(): void {
$this->title = get_string('pluginname', 'block_townsquare');
}

Expand All @@ -40,7 +40,7 @@ public function init():void {
*
* @return object|null The block HTML.
*/
public function get_content():object {
public function get_content(): object {
global $OUTPUT;

if ($this->content !== null) {
Expand All @@ -62,7 +62,7 @@ public function get_content():object {
*
* @return array of the pages where the block can be added.
*/
public function applicable_formats():array {
public function applicable_formats(): array {
return [
'admin' => false,
'site-index' => false,
Expand Down
6 changes: 3 additions & 3 deletions classes/contentcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct() {
* Builds the content from events.
* @return array
*/
public function build_content():array {
public function build_content(): array {
$this->events = $this->townsquareevents->get_all_events_sorted();

$orientationmarkerset = false;
Expand Down Expand Up @@ -95,15 +95,15 @@ public function build_content():array {
* Getter for the content
* @return array
*/
public function get_content():array {
public function get_content(): array {
return $this->content;
}

/**
* Getter for the events
* @return array
*/
public function get_events():array {
public function get_events(): array {
return $this->events;
}
}
2 changes: 1 addition & 1 deletion classes/letter/activitycompletion_letter.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct($contentid, $calendarevent) {
* Export function for the mustache template.
* return array
*/
public function export_letter():array {
public function export_letter(): array {
// Change the timestamp to a date.
$date = date('d.m.Y', $this->created);

Expand Down
2 changes: 1 addition & 1 deletion classes/letter/post_letter.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function __construct($contentid, $postevent) {
* Export Function for the mustache template.
* @return array
*/
public function export_letter():array {
public function export_letter(): array {
return [
'contentid' => $this->contentid,
'lettertype' => $this->lettertype,
Expand Down
2 changes: 1 addition & 1 deletion classes/orientation_marker.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct($contentid, $time) {
* Export function for the mustache template.
* @return array
*/
public function export_data():array {
public function export_data(): array {
// Change the timestamp to a date.
$date = date('d.m.Y', $this->today);

Expand Down
2 changes: 1 addition & 1 deletion classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class renderer extends plugin_renderer_base {
* @param array $data Data to render the townsquare templates
* @return string HTML string
*/
public function render_main($data):string {
public function render_main($data): string {
return $this->render_from_template('block_townsquare/blockcontent', $data);
}
}
46 changes: 21 additions & 25 deletions lang/en/block_townsquare.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,35 @@

defined('MOODLE_INTERNAL') || die();

// Core strings for the installation.
$string['pluginname'] = 'Townsquare block';
$string['pluginname'] = 'Town Square';
$string['pluginname:addinstance'] = 'Add the Town Square block';
$string['pluginname:myaddinstance'] = 'Add the Town Square block to the dashboard';

// Mustache templates strings.
$string['completionletterorigin'] = '{$a->modulename} should be completed until today';
$string['basicletterorigin'] = 'A notification from {$a->instancename}:';
$string['postletterorigin'] = '{$a->authorname} posted in {$a->instancename} -> {$a->discussionname}:';
$string['orientationmarkercontent'] = 'Hi {$a->username}, welcome to townsquare! Today is the {$a->date}';

// Letter strings.
$string['invalidmodulename'] = 'Module name is unknown or not supported';

// Event strings.
$string['assignduemessage'] = 'Assignment is due until {$a->time}';
$string['assigngradingduemessage'] = 'Assignment is due to be graded until {$a->time}';
$string['basicletterorigin'] = 'A notification from {$a->instancename}:';
$string['chattimemessage'] = 'The next chat time is today at {$a->time}';
$string['choiceopenmessage'] = 'Voting is possible from {$a->time} onwards';
$string['choiceclosemessage'] = 'Please vote until {$a->time}. Afterwards the choice is closed';
$string['dataopenmessage'] = 'The database opens today';
$string['choiceopenmessage'] = 'Voting is possible from {$a->time} onwards';
$string['completionletterorigin'] = '{$a->modulename} should be completed until today';
$string['dataclosemessage'] = 'Please submit your entries until {$a->time}. The database closes afterwards';
$string['feedbackopenmessage'] = 'Writing feedback is possible from {$a->time} onwards';
$string['dataopenmessage'] = 'The database opens today';
$string['feedbackclosemessage'] = 'Writing feedback is possible until {$a->time}';
$string['feedbackopenmessage'] = 'Writing feedback is possible from {$a->time} onwards';
$string['forumduemessage'] = 'The forum is due until {$a->time}';
$string['lessonopenmessage'] = 'The lesson opens today at {$a->time}';
$string['invalidmodulename'] = 'Module name is unknown or not supported';
$string['lessonclosemessage'] = 'The lesson ends today at {$a->time}';
$string['quizopenmessage'] = 'The Quiz is open from {$a->time} onwards';
$string['lessonopenmessage'] = 'The lesson opens today at {$a->time}';
$string['orientationmarkercontent'] = 'Hi {$a->username}, welcome to townsquare! Today is the {$a->date}';
$string['pluginname'] = 'Town Square';
$string['pluginname:addinstance'] = 'Add the Town Square block';
$string['pluginname:myaddinstance'] = 'Add the Town Square block to the dashboard';
$string['plugintitle'] = 'Townsquare block';

$string['postletterorigin'] = '{$a->authorname} posted in {$a->instancename} -> {$a->discussionname}:';




$string['quizclosemessage'] = 'The Quiz closes today at {$a->time}';
$string['quizopenmessage'] = 'Scorm Activity opens today';
$string['quizclosemessage'] = 'Scorm Activity closes today';
$string['workshopopensubmission'] = 'Submissions for the workshop are possible from {$a->time} onwards';
$string['quizopenmessage'] = 'The Quiz is open from {$a->time} onwards';
$string['workshopcloseassessment'] = 'Assessments for the workshop are due until {$a->time}';
$string['workshopclosesubmission'] = 'Please submit your work until {$a->time}. The workshop closes afterwards';
$string['workshopopenassessment'] = 'The assessment phase starts today at {$a->time}';
$string['workshopcloseassessment'] = 'Assessments for the workshop are due until {$a->time}';
$string['workshopopensubmission'] = 'Submissions for the workshop are possible from {$a->time} onwards';
6 changes: 3 additions & 3 deletions tests/contentcontroller_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*
* @covers \block_townsquare\contentcontroller
*/
class contentcontroller_test extends \advanced_testcase {
final class contentcontroller_test extends \advanced_testcase {

// Attributes.

Expand Down Expand Up @@ -121,7 +121,7 @@ public function test_letters(): void {
* Helper function that sets up the testdata.
* @return void
*/
private function helper_course_set_up():void {
private function helper_course_set_up(): void {
global $DB;
// Declare generators.
$datagenerator = $this->getDataGenerator();
Expand Down Expand Up @@ -160,7 +160,7 @@ private function helper_course_set_up():void {
* @param int $gradingduedate timestamp
* @return object
*/
private function create_assignment($allowsubmissionsdate, $duedate, $gradingduedate):object {
private function create_assignment($allowsubmissionsdate, $duedate, $gradingduedate): object {
// Create an activity completion for the assignment if wanted.
$featurecompletionmanual = [
'completion' => COMPLETION_TRACKING_MANUAL,
Expand Down
8 changes: 4 additions & 4 deletions tests/coreevents_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* @covers \block_townsquare\townsquareevents::get_coreevents()
*/
class coreevents_test extends \advanced_testcase {
final class coreevents_test extends \advanced_testcase {

// Attributes.

Expand Down Expand Up @@ -271,7 +271,7 @@ private function helper_course_set_up(): void {
* @param bool $activitycompletion
* @return object
*/
private function create_assignment($courseid, $allowsubmissionsdate, $duedate, $gradingduedate, $activitycompletion):object {
private function create_assignment($courseid, $allowsubmissionsdate, $duedate, $gradingduedate, $activitycompletion): object {
// Create an activity completion for the assignment if wanted.
$featurecompletionmanual = [];
if ($activitycompletion) {
Expand All @@ -295,7 +295,7 @@ private function create_assignment($courseid, $allowsubmissionsdate, $duedate, $
* @param object $user The user for whom the events should be collected (townsquareevents.php uses $USER).
* @return array
*/
private function get_calendarevents_from_user($user):array {
private function get_calendarevents_from_user($user): array {
$this->setUser($user);
$townsquareevents = new townsquareevents();
return $townsquareevents->get_coreevents();
Expand All @@ -308,7 +308,7 @@ private function get_calendarevents_from_user($user):array {
* @param array $enrolledcourses
* @return bool
*/
private function check_eventcourses($events, $enrolledcourses):bool {
private function check_eventcourses($events, $enrolledcourses): bool {
foreach ($events as $event) {
$eventcourseid = $event->courseid;

Expand Down
8 changes: 4 additions & 4 deletions tests/postevents_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
* @covers \block_townsquare\townsquareevents::get_postevents()
*/
class postevents_test extends \advanced_testcase {
final class postevents_test extends \advanced_testcase {

// Attributes.

Expand Down Expand Up @@ -378,7 +378,7 @@ private function helper_course_set_up(): void {
* @param object $moodleoverflow The moodleoverflow that should be made anonymous.
* @param int $anonymoussetting The type of anonymous moodleoverflow.
*/
private function make_anonymous($moodleoverflow, $anonymoussetting):void {
private function make_anonymous($moodleoverflow, $anonymoussetting): void {
global $DB;
if ($anonymoussetting == 1 || $anonymoussetting == 2) {
$moodleoverflow->anonymous = $anonymoussetting;
Expand All @@ -393,7 +393,7 @@ private function make_anonymous($moodleoverflow, $anonymoussetting):void {
* @param object $user The user for whom the events should be collected (townsquareevents.php uses $USER).
* @return array
*/
private function get_postevents_from_user($user):array {
private function get_postevents_from_user($user): array {
$this->setUser($user);
$townsquareevents = new townsquareevents();
return $townsquareevents->get_postevents();
Expand All @@ -405,7 +405,7 @@ private function get_postevents_from_user($user):array {
* @param array $enrolledcourses
* @return bool
*/
private function check_postcourses($posts, $enrolledcourses):bool {
private function check_postcourses($posts, $enrolledcourses): bool {
foreach ($posts as $post) {
$postcourseid = $post->courseid;

Expand Down

0 comments on commit 2166e9b

Please sign in to comment.