Initial xentral_oss_20.3.c9ffacf

This commit is contained in:
Alex
2021-05-21 08:49:41 +02:00
parent 5406e4a551
commit 34e5ac43d9
18884 changed files with 2109867 additions and 0 deletions
@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace Xentral\Modules\LearningDashboard\Data;
final class Lesson implements \JsonSerializable
{
/** @var string */
private $name;
/** @var array|Task[] */
private $tasks;
/**
* Lesson constructor.
*
* @param string $name
*/
public function __construct(string $name)
{
$this->name = $name;
}
/** @param Task $task */
public function addTask(Task $task)
{
$this->tasks[] = $task;
}
public function getProgress()
{
$totalSteps = 0;
$completedSteps = 0;
foreach ($this->tasks as $task) {
$taskProgress = $task->getProgress();
$totalSteps += $taskProgress['total'];
$completedSteps += $taskProgress['complete'];
}
return [
'total' => $totalSteps,
'completed' => $completedSteps,
];
}
/** @return array */
public function jsonSerialize()
{
return [
'name' => $this->name,
'progress' => $this->getProgress(),
'tasks' => $this->tasks,
];
}
}
@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace Xentral\Modules\LearningDashboard\Data;
final class Tab implements \JsonSerializable
{
/** @var string */
private $name;
/** @var Lesson[] */
private $lessons;
/**
* Tab constructor.
*
* @param string $name
*/
public function __construct(string $name)
{
$this->name = $name;
}
/** @param Lesson $lesson */
public function addLesson(Lesson $lesson)
{
$this->lessons[] = $lesson;
}
/** @return array */
public function jsonSerialize()
{
$totalSteps = 0;
$completedSteps = 0;
foreach ($this->lessons as $lesson) {
$lessonProgress = $lesson->getProgress();
$totalSteps += $lessonProgress['total'];
$completedSteps += $lessonProgress['completed'];
}
return [
'name' => $this->name,
'progress' => [
'total' => $totalSteps,
'completed' => $completedSteps,
],
'lessons' => $this->lessons,
];
}
}
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace Xentral\Modules\LearningDashboard\Data;
final class Task implements \JsonSerializable
{
/** @var array */
private $data;
/**
* Task constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
$this->data = $data;
}
/**
* @return array
*/
public function getData(): array
{
return $this->data;
}
/** @return array */
public function getProgress(): array
{
$stepCount = 0;
$completedStepCount = 0;
foreach ($this->data['step_groups'] as $stepGroupName => $stepGroupContent) {
$stepCount++;
if (isset($stepGroupContent['completed']) && $stepGroupContent['completed'] === true) {
$completedStepCount++;
}
}
return [
'complete' => $completedStepCount,
'total' => $stepCount,
];
}
/** @return array */
public function jsonSerialize()
{
return [
'key' => $this->data['key'],
'title' => $this->data['title'],
'category' => $this->data['category'],
'sub_title' => $this->data['sub_title'],
'description' => $this->data['description'],
'missing_modules' => $this->data['missing_modules'],
'missing_permissions' => $this->data['missing_permissions'],
'link' => "index.php?module=wizard&action=ajax&cmd=set_active_wizard&key={$this->data['key']}",
'progress' => $this->getProgress(),
];
}
}