forked from ILIAS-eLearning/ILIAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
831 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
$info = <<<INFO | ||
Hello there. | ||
This calls an arbitrary entrypoint of ILIAS for testing purpose. For more informations | ||
about entrypoints, have a look into `components/ILIAS/Component/src/EntryPoint.php`. | ||
INFO; | ||
|
||
if (count($argv) !== 3) { | ||
echo $info; | ||
die("php cli/entry_point.php \$bootstrap \$name\n"); | ||
} | ||
|
||
$bootstrap = $argv[1]; | ||
$entry_point = $argv[2]; | ||
|
||
require_once(__DIR__ . "/../artifacts/bootstrap_$bootstrap.php"); | ||
|
||
exit(entry_point($entry_point)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ILIAS\Component\Activities; | ||
|
||
use ILIAS\Component\Dependencies\Name; | ||
use ILIAS\UI\Component\Input\Control\Form\FormInput; | ||
use ILIAS\Data\Result; | ||
|
||
/** | ||
* An Activity is an action on the domain layer action of a component. | ||
* | ||
* This defines the interface to any activity. When implementing Activities, | ||
* you should use one of these base classes: | ||
* | ||
* | ||
* | ||
*/ | ||
interface Activity | ||
{ | ||
/** | ||
* Shall return classname of the Activity, wrapped in Name. | ||
*/ | ||
public function getName(): Name; | ||
|
||
public function getType(): ActivityType; | ||
|
||
public function getDescription(): string; // shall be TextHandling/Markdown some day | ||
|
||
public function getInputDescription(): FormInput; // might better be ILIAS/UI/Input/Input, but we would need to promote many properties there before. | ||
|
||
/** | ||
* This shall check if the given user is allowed to perform the activity based | ||
* on business rules of this component. This shall, for example, check if the | ||
* given user may add this other user to a course based on RBAC and position | ||
* permissions, but this shall not check overall business rules such as: root | ||
* may do everything. This shall not cause any observable side effects. | ||
* | ||
* @param mixed $parameters whatever the `FormInput` from `getInputDescription` produces. | ||
*/ | ||
public function isAllowedToPerform(int $usr_id, mixed $parameters): bool; | ||
|
||
/** | ||
* This shall perform the activity. This shall not check if a user is allowed to perform the activity. | ||
* | ||
* @throws any SPL Exception (https://www.php.net/manual/en/spl.exceptions.php) | ||
* @param mixed $parameters whatever the `FormInput` from `getInputDescription` produces. | ||
*/ | ||
public function perform(mixed $parameters): mixed; | ||
|
||
/** | ||
* Grinds the $raw_parameters through the input description, checks if the users | ||
* is allowed to perform the action as requested and, if so, then attempts to | ||
* performs it. Wraps the result and possible errors in the `Result` type. | ||
*/ | ||
public function maybePerformAs(int $usr_id, array $raw_parameters): Result; | ||
} |
33 changes: 33 additions & 0 deletions
33
components/ILIAS/Component/src/Activities/ActivityImpl.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ILIAS\Component\Activities; | ||
|
||
/** | ||
* Basic Implementation for Activities. Use Command or Query for more speficism | ||
* instead. | ||
*/ | ||
abstract class ActivityImpl implements Activity | ||
{ | ||
public function getName(): \ILIAS\Component\Dependencies\Name | ||
{ | ||
return new \ILIAS\Component\Dependencies\Name(static::class); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
components/ILIAS/Component/src/Activities/ActivityType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ILIAS\Component\Activities; | ||
|
||
enum ActivityType: string | ||
{ | ||
case Command = "command"; | ||
case Query = "query"; | ||
} |
44 changes: 44 additions & 0 deletions
44
components/ILIAS/Component/src/Activities/ListActivitiesEntryPoint.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ILIAS\Component\Activities; | ||
|
||
use ILIAS\Component\EntryPoint; | ||
use ILIAS\Component\Component; | ||
|
||
/** | ||
* A simple entrypoint that just says hello, for testing and documentation | ||
* purpose. | ||
*/ | ||
class ListActivitiesEntryPoint extends EntryPoint\Base | ||
{ | ||
public function __construct( | ||
protected Repository $repository | ||
) { | ||
parent::__construct(self::class); | ||
} | ||
|
||
public function enter(): int | ||
{ | ||
echo join("\n", array_keys(iterator_to_array($this->repository->getActivitiesByName("/.*/")))); | ||
echo "\n"; | ||
return 0; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
components/ILIAS/Component/src/Activities/ObjectActivity.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ILIAS\Component\Activities; | ||
|
||
use ILIAS\UI\Component\Input\Control\Form\FormInput; | ||
|
||
/** | ||
* An Activity that refers to a certain object in the system. This also is a | ||
* generic interface but a subset of inputs is fixed. | ||
* | ||
* This does not necessarily need to refer to an ilObject, but can also be used | ||
* to refer to any objects internal to a given component, such as questions, | ||
* memberships or certain results. | ||
*/ | ||
interface ObjectActivity extends Activity | ||
{ | ||
/** | ||
* @inheritdocs | ||
* | ||
* For an ObjectActivity, this needs to return an input with one field named | ||
* "id" that can accept a string value. | ||
*/ | ||
public function getInputDescription(): FormInput; | ||
|
||
/** | ||
* Works just like `getInputDescription` but checks if that description | ||
* matches the spec. | ||
* | ||
* @throws \LogicException if there is no "id" field in the Input. | ||
*/ | ||
public function getCheckedInputDescription(): FormInput; | ||
|
||
/** | ||
* To allow consumers to build an understanding of internal object structure of | ||
* a component, an ObjectActivity needs to tell a "type" of object it touches. | ||
* | ||
* The type should be a short alphanumeric string. | ||
*/ | ||
public function getTargetType(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ILIAS\Component\Activities; | ||
|
||
/** | ||
* Basic class for Queries. | ||
*/ | ||
abstract class Query extends ActivityImpl | ||
{ | ||
public function getType(): \ILIAS\Component\Activities\ActivityType | ||
{ | ||
return ActivityType::Query; | ||
} | ||
} |
Oops, something went wrong.