diff --git a/.github/workflows/gha.dist.yml b/.github/workflows/gha.dist.yml
index 3666c370..4befb3ed 100644
--- a/.github/workflows/gha.dist.yml
+++ b/.github/workflows/gha.dist.yml
@@ -36,8 +36,8 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: ['7.4']
- moodle-branch: ['MOODLE_401_STABLE']
+ php: ['8.1']
+ moodle-branch: ['MOODLE_404_STABLE']
database: [mariadb]
steps:
diff --git a/lbplanner/classes/helpers/plan_helper.php b/lbplanner/classes/helpers/plan_helper.php
index 976cf7bf..3fb991f4 100644
--- a/lbplanner/classes/helpers/plan_helper.php
+++ b/lbplanner/classes/helpers/plan_helper.php
@@ -184,7 +184,6 @@ public static function get_plan(int $planid): array {
return [
'name' => $plan->name,
'planid' => $planid,
- 'enableek' => $plan->enableek,
'deadlines' => self::get_deadlines($planid),
'members' => $members,
];
@@ -200,7 +199,6 @@ public static function plan_structure(): external_single_structure {
[
'name' => new external_value(PARAM_TEXT, 'Name of the plan'),
'planid' => new external_value(PARAM_INT, 'ID of the plan'),
- 'enableek' => new external_value(PARAM_BOOL, 'Whether EK is enabled'),
'deadlines' => new external_multiple_structure(
new external_single_structure(
[
diff --git a/lbplanner/classes/model/user.php b/lbplanner/classes/model/user.php
index 5903e195..f2be664d 100644
--- a/lbplanner/classes/model/user.php
+++ b/lbplanner/classes/model/user.php
@@ -25,7 +25,6 @@
namespace local_lbplanner\model;
-use coding_exception;
use core\context\system as context_system;
use core_external\{external_single_structure, external_value};
use user_picture;
@@ -60,9 +59,14 @@ class user {
public string $colorblindness;
/**
- * @var int $displaytaskcount The display task count the user has selected in the app.
+ * @var bool $displaytaskcount The display task count the user has selected in the app.
*/
- public int $displaytaskcount;
+ public bool $displaytaskcount;
+
+ /**
+ * @var bool $ekenabled Whether the user wants to see EK or not.
+ */
+ public bool $ekenabled;
/**
* @var ?\stdClass $mdluser the cached moodle user
@@ -90,21 +94,24 @@ class user {
* @param int $mdlid ID of the moodle user
* @param string $theme user-chosen theme
* @param string $colorblindness user's colorblindness
- * @param int $displaytaskcount user's display task count
+ * @param bool $displaytaskcount user's display task count
+ * @param bool $ekenabled whether the user wants to see EK modules
*/
public function __construct(
int $lbpid,
int $mdlid,
string $theme,
string $colorblindness,
- int $displaytaskcount
+ bool $displaytaskcount,
+ bool $ekenabled = false
) {
global $USER;
$this->lbpid = $lbpid;
$this->mdlid = $mdlid;
$this->set_theme($theme);
$this->set_colorblindness($colorblindness);
- $this->set_displaytaskcount($displaytaskcount);
+ $this->displaytaskcount = $displaytaskcount;
+ $this->ekenabled = $ekenabled;
$this->planid = null;
$this->pfp = null;
$this->capabilitybitmask = null;
@@ -123,7 +130,7 @@ public function __construct(
* @return user a representation of this user and its data
*/
public static function from_db(object $obj): self {
- return new self($obj->id, $obj->userid, $obj->theme, $obj->colorblindness, $obj->displaytaskcount);
+ return new self($obj->id, $obj->userid, $obj->theme, $obj->colorblindness, $obj->displaytaskcount, $obj->ekenabled);
}
/**
@@ -137,18 +144,6 @@ public function set_fresh(int $lbpid): void {
$this->lbpid = $lbpid;
}
- /**
- * Sets display task count
- * @param int $count display task count
- * @throws \coding_exception if $count <= 0
- */
- public function set_displaytaskcount(int $count): void {
- if ($count <= 0) {
- throw new \coding_exception('User\'s Display Task Count cannot be <= 0');
- }
- $this->displaytaskcount = $count;
- }
-
/**
* Sets colorblindness
* @param string $cbn colorblindness
@@ -323,6 +318,7 @@ public function prepare_for_api(): array {
$this->prepare_for_api_short(),
[
'theme' => $this->theme,
+ 'ekenabled' => $this->ekenabled,
'planid' => $this->get_planid(),
'colorblindness' => $this->colorblindness,
'displaytaskcount' => $this->displaytaskcount,
@@ -344,10 +340,11 @@ public static function api_structure(): external_single_structure {
'firstname' => new external_value(PARAM_TEXT, 'The firstname of the user'),
'lastname' => new external_value(PARAM_TEXT, 'The lastname of the user'),
'theme' => new external_value(PARAM_TEXT, 'The theme the user has selected'),
+ 'ekenabled' => new external_value(PARAM_BOOL, 'Whether the user wants to see EK modules'),
'profileimageurl' => new external_value(PARAM_URL, 'The url of the profile image'),
'planid' => new external_value(PARAM_INT, 'The id of the plan the user is assigned to'),
'colorblindness' => new external_value(PARAM_TEXT, 'The colorblindness of the user'),
- 'displaytaskcount' => new external_value(PARAM_INT, 'If the user has the taskcount-enabled 1-yes 0-no'),
+ 'displaytaskcount' => new external_value(PARAM_BOOL, 'Whether the user has the taskcount enabled'),
'capabilities' => new external_value(PARAM_INT, 'The capabilities of the user represented as a bitmask value'),
'vintage' => new external_value(PARAM_TEXT, 'The vintage of the user', VALUE_DEFAULT),
'email' => new external_value(PARAM_TEXT, 'The email address of the user'),
diff --git a/lbplanner/db/install.xml b/lbplanner/db/install.xml
index 4064f4cd..6585b39f 100644
--- a/lbplanner/db/install.xml
+++ b/lbplanner/db/install.xml
@@ -7,6 +7,7 @@
+
@@ -62,7 +63,6 @@
-
@@ -101,7 +101,7 @@
-
+
diff --git a/lbplanner/db/upgrade.php b/lbplanner/db/upgrade.php
index 5102d297..93de6f16 100644
--- a/lbplanner/db/upgrade.php
+++ b/lbplanner/db/upgrade.php
@@ -33,12 +33,31 @@
* @return bool true
*/
function xmldb_local_lbplanner_upgrade($oldversion): bool {
+ global $DB;
+ $dbman = $DB->get_manager();
+
if ($oldversion < 2024022700) {
config_helper::add_customfield();
}
if ($oldversion < 20250117) {
unset_config('defaultactiveyear', 'local_lbplanner');
}
+ if ($oldversion < 2025012201) {
+ $usertable = new xmldb_table('local_lbplanner_users');
+ $plantable = new xmldb_table('local_lbplanner_plans');
+ $fieldlanguage = new xmldb_field('language');
+ $fieldenableek = new xmldb_field('enableek');
+ $dbman->drop_field($usertable, $fieldlanguage);
+ $dbman->drop_field($plantable, $fieldenableek);
+ $fieldekenabled = new xmldb_field(
+ name: 'ekenabled',
+ type: XMLDB_TYPE_INTEGER,
+ precision: '1',
+ notnull: XMLDB_NOTNULL,
+ default: 0,
+ );
+ $dbman->add_field($usertable, $fieldekenabled);
+ }
return true;
}
diff --git a/lbplanner/lang/en/local_lbplanner.php b/lbplanner/lang/en/local_lbplanner.php
index 473aa669..eeae8888 100644
--- a/lbplanner/lang/en/local_lbplanner.php
+++ b/lbplanner/lang/en/local_lbplanner.php
@@ -24,8 +24,8 @@
defined('MOODLE_INTERNAL') || die();
-$string['pluginname'] = 'LB Planner';
-$string['lb_planner:student'] = 'LB Planner Student';
-$string['lb_planner:teacher'] = 'LB Planner Teacher';
$string['lb_planner:admin'] = 'LB Planner Admin';
$string['lb_planner:manager'] = 'LB Planner Manager';
+$string['lb_planner:student'] = 'LB Planner Student';
+$string['lb_planner:teacher'] = 'LB Planner Teacher';
+$string['pluginname'] = 'LB Planner';
diff --git a/lbplanner/services/plan/get_plan.php b/lbplanner/services/plan/get_plan.php
index 5b405f71..3ad725af 100644
--- a/lbplanner/services/plan/get_plan.php
+++ b/lbplanner/services/plan/get_plan.php
@@ -42,7 +42,7 @@ public static function get_plan_parameters(): external_function_parameters {
* @return array
*/
public static function get_plan(): array {
- global $DB, $USER;
+ global $USER;
$planid = plan_helper::get_plan_id($USER->id);
diff --git a/lbplanner/services/plan/update_plan.php b/lbplanner/services/plan/update_plan.php
index 40b41f7f..bc269827 100644
--- a/lbplanner/services/plan/update_plan.php
+++ b/lbplanner/services/plan/update_plan.php
@@ -41,13 +41,6 @@ public static function update_plan_parameters(): external_function_parameters {
null,
NULL_NOT_ALLOWED
),
- 'enableek' => new external_value(
- PARAM_BOOL,
- 'Whether EK is enabled for the plan',
- VALUE_REQUIRED,
- null,
- NULL_NOT_ALLOWED
- ),
]);
}
@@ -55,16 +48,15 @@ public static function update_plan_parameters(): external_function_parameters {
* Update the plan details.
*
* @param string $planname Name of the Plan
- * @param bool $enableek Whether EK is enabled for the plan
* @return void
* @throws Exception when access denied
*/
- public static function update_plan(string $planname, bool $enableek) {
+ public static function update_plan(string $planname) {
global $DB, $USER;
self::validate_parameters(
self::update_plan_parameters(),
- ['planname' => $planname, 'enableek' => $enableek]
+ ['planname' => $planname]
);
$planid = plan_helper::get_plan_id($USER->id);
@@ -75,7 +67,6 @@ public static function update_plan(string $planname, bool $enableek) {
$plan = $DB->get_record(plan_helper::TABLE, ['id' => $planid], '*', MUST_EXIST);
$plan->name = $planname;
- $plan->enableek = $enableek;
$DB->update_record(plan_helper::TABLE, $plan);
}
diff --git a/lbplanner/services/user/get_user.php b/lbplanner/services/user/get_user.php
index f69db0dd..a03120b1 100644
--- a/lbplanner/services/user/get_user.php
+++ b/lbplanner/services/user/get_user.php
@@ -22,7 +22,7 @@
use moodle_exception;
use local_lbplanner\helpers\{user_helper, plan_helper, notifications_helper};
-use local_lbplanner\enums\{PLAN_EK, PLAN_ACCESS_TYPE, NOTIF_TRIGGER};
+use local_lbplanner\enums\{PLAN_ACCESS_TYPE, NOTIF_TRIGGER};
use local_lbplanner\model\user;
/**
@@ -64,7 +64,6 @@ public static function get_user(): array {
// Create empty plan for newly registered user.
$plan = new \stdClass();
$plan->name = 'Plan for ' . $USER->username;
- $plan->enableek = PLAN_EK::ENABLED;
$planid = $DB->insert_record(plan_helper::TABLE, $plan);
$lbplanneruser->set_planid($planid);
diff --git a/lbplanner/services/user/update_user.php b/lbplanner/services/user/update_user.php
index 4170f266..ce0f545c 100644
--- a/lbplanner/services/user/update_user.php
+++ b/lbplanner/services/user/update_user.php
@@ -46,8 +46,13 @@ public static function update_user_parameters(): external_function_parameters {
VALUE_DEFAULT,
null),
'displaytaskcount' => new external_value(
- PARAM_INT,
- 'If the user has the taskcount-enabled 1-yes 0-no',
+ PARAM_BOOL,
+ 'Whether the user has the taskcount enabled',
+ VALUE_DEFAULT,
+ null),
+ 'ekenabled' => new external_value(
+ PARAM_BOOL,
+ 'Whether the user wants to see EK modules',
VALUE_DEFAULT,
null),
]);
@@ -55,15 +60,16 @@ public static function update_user_parameters(): external_function_parameters {
/**
* Updates the given user in the lbplanner DB
- * @param string $theme The theme the user has selected
- * @param string $colorblindness The colorblindness the user has selected
- * @param int $displaytaskcount The displaytaskcount the user has selected
+ * @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
+ * @param ?bool $ekenabled whether the user wants to see EK modules
* @return array The updated user
* @throws moodle_exception
* @throws dml_exception
* @throws invalid_parameter_exception
*/
- public static function update_user($theme, $colorblindness, $displaytaskcount): array {
+ public static function update_user(?string $theme, ?string $colorblindness, ?bool $displaytaskcount, ?bool $ekenabled): array {
global $DB, $USER;
self::validate_parameters(
@@ -72,6 +78,7 @@ public static function update_user($theme, $colorblindness, $displaytaskcount):
'theme' => $theme,
'colorblindness' => $colorblindness,
'displaytaskcount' => $displaytaskcount,
+ 'ekenabled' => $ekenabled,
]
);
@@ -87,7 +94,10 @@ public static function update_user($theme, $colorblindness, $displaytaskcount):
$user->set_theme($theme);
}
if ($displaytaskcount !== null) {
- $user->set_displaytaskcount($displaytaskcount);
+ $user->displaytaskcount = $displaytaskcount;
+ }
+ if ($ekenabled !== null) {
+ $user->ekenabled = $ekenabled;
}
$DB->update_record(user_helper::LB_PLANNER_USER_TABLE, $user->prepare_for_db());
diff --git a/lbplanner/version.php b/lbplanner/version.php
index c7015d60..b8d851c9 100644
--- a/lbplanner/version.php
+++ b/lbplanner/version.php
@@ -28,7 +28,7 @@
$plugin->component = 'local_lbplanner';
$plugin->release = 'Alpha v.'.$release;
-$plugin->version = 2025011800;
+$plugin->version = 2025012201;
$plugin->dependencies = [
// Depend upon version 2023110600 of local_modcustomfields.
'local_modcustomfields' => 2023110600,