Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions lbplanner/classes/helpers/config_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static function add_customfield(): void {
if (array_key_exists('modcustomfields', core_component::get_plugin_list('local'))) {

$handler = mod_handler::create();
$categoryid = $handler->create_category('LB Planner');
$categoryid = $handler->create_category('LB Planer');

set_config('categoryid', $categoryid, 'local_lbplanner');
$categorycontroller = category_controller::create($categoryid, null, $handler);
Expand All @@ -64,7 +64,7 @@ public static function add_customfield(): void {
'{"required":"0","uniquevalues":"0","options":"GK\r\nEK\r\nTEST\r\nM",
"defaultvalue":"","locked":"0","visibility":"2"}'
);
$fieldcontroller->set('shortname', 'lb_planner_gk_ek');
$fieldcontroller->set('shortname', 'lb_planer_gk_ek');
$fieldcontroller->save();
}
}
Expand Down
22 changes: 11 additions & 11 deletions lbplanner/classes/helpers/course_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class course_helper {
/**
* The course table used by the LP
*/
const LBPLANNER_COURSE_TABLE = 'local_lbplanner_courses';
const EDUPLANNER_COURSE_TABLE = 'local_lbplanner_courses';

/**
* A list of nice colors to choose from :)
Expand All @@ -61,23 +61,23 @@ class course_helper {
/**
* Get course from lbpanner DB
*
* @param int $courseid id of the course in lbplanner
* @param int $courseid id of the course in Eduplanner
* @param int $userid id of the user
*
* @return course course from lbplanner
* @return course course from Eduplanner
* @throws dml_exception
*/
public static function get_lbplanner_course(int $courseid, int $userid): course {
public static function get_eduplanner_course(int $courseid, int $userid): course {
global $DB;
return course::from_db($DB->get_record(self::LBPLANNER_COURSE_TABLE, ['courseid' => $courseid, 'userid' => $userid]));
return course::from_db($DB->get_record(self::EDUPLANNER_COURSE_TABLE, ['courseid' => $courseid, 'userid' => $userid]));
}

/**
* Get all current courses.
* @param bool $onlyenrolled whether to include only courses in which the current user is enrolled in
* @return course[] all courses of the current year
*/
public static function get_all_lbplanner_courses(bool $onlyenrolled=true): array {
public static function get_all_eduplanner_courses(bool $onlyenrolled=true): array {
global $DB, $USER;
$userid = $USER->id;

Expand All @@ -96,11 +96,11 @@ public static function get_all_lbplanner_courses(bool $onlyenrolled=true): array
if (!course::check_year($mdlcourse)) {
continue;
}
// Check if the course is already in the LB Planner database.
if ($DB->record_exists(self::LBPLANNER_COURSE_TABLE, ['courseid' => $courseid, 'userid' => $userid])) {
$fetchedcourse = self::get_lbplanner_course($courseid, $userid);
// Check if the course is already in the Eduplanner database.
if ($DB->record_exists(self::EDUPLANNER_COURSE_TABLE, ['courseid' => $courseid, 'userid' => $userid])) {
$fetchedcourse = self::get_eduplanner_course($courseid, $userid);
} else {
// IF not create an Object to be put into the LB Planner database.
// IF not create an Object to be put into the Eduplanner database.
$fetchedcourse = new course(
0, $courseid, $userid,
course::prepare_shortname($mdlcourse->shortname),
Expand All @@ -110,7 +110,7 @@ public static function get_all_lbplanner_courses(bool $onlyenrolled=true): array
try {
$fetchedcourse->set_fresh(
$DB->insert_record(
self::LBPLANNER_COURSE_TABLE,
self::EDUPLANNER_COURSE_TABLE,
$fetchedcourse->prepare_for_db()
)
);
Expand Down
4 changes: 2 additions & 2 deletions lbplanner/classes/helpers/notifications_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class notifications_helper {
/**
* Name of the notifications table.
*/
const LBPLANNER_NOTIFICATION_TABLE = 'local_lbplanner_notification';
const EDUPLANNER_NOTIFICATION_TABLE = 'local_lbplanner_notification';

/**
* Returns the data structure of a notification
Expand Down Expand Up @@ -75,7 +75,7 @@ public static function notify_user(int $userid, int $info, int $type): int {
$notification->timestamp = time();
$notification->timestamp_read = null;

$id = $DB->insert_record(self::LBPLANNER_NOTIFICATION_TABLE, $notification);
$id = $DB->insert_record(self::EDUPLANNER_NOTIFICATION_TABLE, $notification);

return $id;
}
Expand Down
4 changes: 1 addition & 3 deletions lbplanner/classes/helpers/slot_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

use core\context\system as context_system;

use DateInterval;
use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use DateTimeZone;
Expand Down Expand Up @@ -280,7 +278,7 @@ public static function get_filters_for_slot(int $slotid): array {
* @return slot[] the filtered slot array
*/
public static function filter_slots_for_user(array $allslots, \stdClass $user): array {
$mycourses = course_helper::get_all_lbplanner_courses();
$mycourses = course_helper::get_all_eduplanner_courses();
$mycourseids = [];
foreach ($mycourses as $course) {
array_push($mycourseids, $course->courseid);
Expand Down
20 changes: 10 additions & 10 deletions lbplanner/classes/helpers/user_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class user_helper {
/**
* Name of the user database
*/
const LB_PLANNER_USER_TABLE = 'local_lbplanner_users';
const EDUPLANNER_USER_TABLE = 'local_lbplanner_users';

/**
* Name of the moodle's database
Expand All @@ -46,7 +46,7 @@ class user_helper {
const MOODLE_USER_TABLE = 'user';

/**
* Checks if the given user exists in the LB_PLANNER_USER database.
* Checks if the given user exists in the EDUPLANNER_USER database.
*
* @param int $userid The id of the user to check.
*
Expand All @@ -55,7 +55,7 @@ class user_helper {
*/
public static function check_user_exists(int $userid): bool {
global $DB;
return $DB->record_exists(self::LB_PLANNER_USER_TABLE, ['userid' => $userid]);
return $DB->record_exists(self::EDUPLANNER_USER_TABLE, ['userid' => $userid]);
}

/**
Expand All @@ -69,22 +69,22 @@ public static function check_user_exists(int $userid): bool {
*/
public static function get_user(int $userid): user {
global $DB;
$dbuser = $DB->get_record(self::LB_PLANNER_USER_TABLE, ['userid' => $userid]);
$dbuser = $DB->get_record(self::EDUPLANNER_USER_TABLE, ['userid' => $userid]);

if ($dbuser !== false) {
return user::from_db($dbuser);
}

// Register user if not found.
$lbplanneruser = new user(0, $userid, 'default', 'none', 1, false);
$lbpid = $DB->insert_record(self::LB_PLANNER_USER_TABLE, $lbplanneruser->prepare_for_db());
$lbplanneruser->set_fresh($lbpid);
$eduplanneruser = new user(0, $userid, 'default', 'none', 1, false);
$epid = $DB->insert_record(self::EDUPLANNER_USER_TABLE, $eduplanneruser->prepare_for_db());
$eduplanneruser->set_fresh($epid);

// Create empty plan for newly registered user.
$plan = new \stdClass();
$plan->name = 'Plan for ' . ($lbplanneruser->get_mdluser()->username);
$plan->name = 'Plan for ' . ($eduplanneruser->get_mdluser()->username);
$planid = $DB->insert_record(plan_helper::TABLE, $plan);
$lbplanneruser->set_planid($planid);
$eduplanneruser->set_planid($planid);

// Set user as owner of new plan.
$planaccess = new \stdClass();
Expand All @@ -96,7 +96,7 @@ public static function get_user(int $userid): user {
// Notify the FE that this user likely hasn't used LBP before.
notifications_helper::notify_user($userid, -1, NOTIF_TRIGGER::USER_REGISTERED);

return $lbplanneruser;
return $eduplanneruser;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lbplanner/classes/model/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class user {

/**
* Constructs a new course
* @param int $lbpid ID of the lb planner user
* @param int $lbpid ID of the Eduplanner user
* @param int $mdlid ID of the moodle user
* @param string $theme user-chosen theme
* @param string $colorblindness user's colorblindness
Expand Down
4 changes: 2 additions & 2 deletions lbplanner/db/services.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// This file is part of the LB Planner plugin.
// This file is part of the local_lbplanner.
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -398,7 +398,7 @@
];

$services = [
'LB Planner API' => [
'LB Planer API' => [
'functions' => [
'local_lbplanner_user_get_user',
'local_lbplanner_user_get_all_users',
Expand Down
2 changes: 1 addition & 1 deletion lbplanner/lang/en/local_lbplanner.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// This file is part of the LB Planner plugin.
// This file is part of the local_lbplanner.
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion lbplanner/services/config/get_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function get_version(): array {
public static function get_version_returns(): external_single_structure {
return new external_single_structure(
[
'release' => new external_value(PARAM_TEXT, 'the current LBPlanner version'),
'release' => new external_value(PARAM_TEXT, 'the current Eduplanner version'),
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion lbplanner/services/courses/get_all_courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function get_all_courses(): array {
throw new \moodle_exception('access denied: must be slotmaster');
}

$courses = course_helper::get_all_lbplanner_courses(false);
$courses = course_helper::get_all_eduplanner_courses(false);
$results = [];
foreach ($courses as $course) {
array_push($results, $course->prepare_for_api());
Expand Down
2 changes: 1 addition & 1 deletion lbplanner/services/courses/get_my_courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function get_my_courses_parameters(): external_function_parameters
* Get all the courses of the current year.
*/
public static function get_my_courses(): array {
$courses = course_helper::get_all_lbplanner_courses(true);
$courses = course_helper::get_all_eduplanner_courses(true);
$results = [];
foreach ($courses as $course) {
array_push($results, $course->prepare_for_api());
Expand Down
4 changes: 2 additions & 2 deletions lbplanner/services/courses/update_course.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static function update_course(int $courseid, string $color, string $short
throw new moodle_exception('Shortname is too long');
}

$course = course_helper::get_lbplanner_course($courseid, $USER->id);
$course = course_helper::get_eduplanner_course($courseid, $USER->id);

if ($color !== null) {
$course->set_color($color);
Expand All @@ -85,7 +85,7 @@ public static function update_course(int $courseid, string $color, string $short
$course->set_enabled((bool) $enabled);
}

$DB->update_record(course_helper::LBPLANNER_COURSE_TABLE, $course->prepare_for_db());
$DB->update_record(course_helper::EDUPLANNER_COURSE_TABLE, $course->prepare_for_db());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lbplanner/services/modules/get_all_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function get_all_modules(bool $ekenabled): array {

$modules = [];

$courses = course_helper::get_all_lbplanner_courses();
$courses = course_helper::get_all_eduplanner_courses();
$planid = plan_helper::get_plan_id($USER->id);

foreach ($courses as $course) {
Expand Down
2 changes: 1 addition & 1 deletion lbplanner/services/notifications/get_all_notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function get_all_notifications_parameters(): external_function_par
public static function get_all_notifications(): array {
global $DB, $USER;

$dbnotifications = $DB->get_records(notifications_helper::LBPLANNER_NOTIFICATION_TABLE, ['userid' => $USER->id]);
$dbnotifications = $DB->get_records(notifications_helper::EDUPLANNER_NOTIFICATION_TABLE, ['userid' => $USER->id]);

$notifications = [];

Expand Down
6 changes: 3 additions & 3 deletions lbplanner/services/notifications/update_notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ public static function update_notification(int $status, int $notificationid) {
['status' => $status, 'notificationid' => $notificationid]
);

if (!$DB->record_exists(notifications_helper::LBPLANNER_NOTIFICATION_TABLE, ['id' => $notificationid])) {
if (!$DB->record_exists(notifications_helper::EDUPLANNER_NOTIFICATION_TABLE, ['id' => $notificationid])) {
throw new \moodle_exception('Notification does not exist');
}

$notification = $DB->get_record(
notifications_helper::LBPLANNER_NOTIFICATION_TABLE,
notifications_helper::EDUPLANNER_NOTIFICATION_TABLE,
['id' => $notificationid],
'*',
MUST_EXIST
);
$notification->status = $status;
$notification->timestamp_read = time();

$DB->update_record(notifications_helper::LBPLANNER_NOTIFICATION_TABLE, $notification);
$DB->update_record(notifications_helper::EDUPLANNER_NOTIFICATION_TABLE, $notification);
}

/**
Expand Down
14 changes: 7 additions & 7 deletions lbplanner/services/user/delete_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace local_lbplanner_services;

use dml_exception;
use core_external\{external_api, external_function_parameters, external_value};
use core_external\{external_api, external_function_parameters};
use local_lbplanner\helpers\{user_helper, plan_helper, course_helper, notifications_helper};
use local_lbplanner\enums\{PLAN_INVITE_STATE, PLAN_ACCESS_TYPE};
use moodle_exception;
Expand Down Expand Up @@ -51,8 +51,8 @@ public static function delete_user() {
$userid = $USER->id;

// Check if User is in user table.
if (!$DB->record_exists(user_helper::LB_PLANNER_USER_TABLE, ['userid' => $userid])) {
throw new moodle_exception('User is not registered in LB Planner');
if (!$DB->record_exists(user_helper::EDUPLANNER_USER_TABLE, ['userid' => $userid])) {
throw new moodle_exception('User is not registered in Eduplanner');
}

$planid = plan_helper::get_plan_id($userid);
Expand All @@ -68,8 +68,8 @@ public static function delete_user() {
$DB->delete_records(plan_helper::TABLE, ['id' => $planid]);

// Delete all Notifications.
if ($DB->record_exists(notifications_helper::LBPLANNER_NOTIFICATION_TABLE, ['userid' => $userid])) {
$DB->delete_records(notifications_helper::LBPLANNER_NOTIFICATION_TABLE, ['userid' => $userid]);
if ($DB->record_exists(notifications_helper::EDUPLANNER_NOTIFICATION_TABLE, ['userid' => $userid])) {
$DB->delete_records(notifications_helper::EDUPLANNER_NOTIFICATION_TABLE, ['userid' => $userid]);
}

$invites = plan_helper::get_invites_send($userid);
Expand All @@ -83,9 +83,9 @@ public static function delete_user() {
$DB->delete_records(plan_helper::ACCESS_TABLE, ['userid' => $userid]);

// Deleting all Courses associated with the User.
$DB->delete_records(course_helper::LBPLANNER_COURSE_TABLE, ['userid' => $userid]);
$DB->delete_records(course_helper::EDUPLANNER_COURSE_TABLE, ['userid' => $userid]);
// Deleting User from User table.
$DB->delete_records(user_helper::LB_PLANNER_USER_TABLE, ['userid' => $userid]);
$DB->delete_records(user_helper::EDUPLANNER_USER_TABLE, ['userid' => $userid]);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lbplanner/services/user/update_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use invalid_parameter_exception;
use moodle_exception;

use local_lbplanner\helpers\{plan_helper, user_helper};
use local_lbplanner\helpers\user_helper;
use local_lbplanner\model\user;

/**
Expand Down Expand Up @@ -59,7 +59,7 @@ public static function update_user_parameters(): external_function_parameters {
}

/**
* Updates the given user in the lbplanner DB
* Updates the given user in the eduplanner DB
* @param ?string $theme The theme the user has selected
* @param ?string $colorblindness The colorblindness the user has selected
* @param ?bool $displaytaskcount The displaytaskcount the user has selected
Expand Down Expand Up @@ -100,7 +100,7 @@ public static function update_user(?string $theme, ?string $colorblindness, ?boo
$user->ekenabled = $ekenabled;
}

$DB->update_record(user_helper::LB_PLANNER_USER_TABLE, $user->prepare_for_db());
$DB->update_record(user_helper::EDUPLANNER_USER_TABLE, $user->prepare_for_db());

return $user->prepare_for_api();
}
Expand Down
2 changes: 1 addition & 1 deletion lbplanner/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die;

if ($hassiteconfig) {
$settings = new admin_settingpage('local_lbplanner', 'LB Planner');
$settings = new admin_settingpage('local_lbplanner', 'LB Planer');
$ADMIN->add('localplugins', $settings);

$settings->add(new admin_setting_configtext('local_lbplanner/activeyear',
Expand Down
Loading