3 declare(strict_types=1);
18 $ui_factory = $DIC[
'ui.factory'];
19 $renderer = $DIC[
'ui.renderer'];
20 $data_factory = new \ILIAS\Data\Factory();
21 $request = $DIC->http()->request();
22 $ctrl = $DIC[
'ilCtrl'];
23 $spacer = $ui_factory->divider()->horizontal();
25 $url = $data_factory->uri($DIC->http()->request()->getUri()->__toString());
26 $url =
$url->withParameter(
'launcher_redirect',
'');
29 $description =
'<p>Before you can join this group, you will have to accept the terms and conditions</p>';
30 $instruction = $ui_factory->messageBox()->info(
'Accept the conditions.');
31 $group = $ui_factory->input()->field()->group([
32 $ui_factory->input()->field()->checkbox(
'Understood',
'ok')
34 $evaluation =
function (
Result $result,
Launcher &$launcher) use ($ctrl, $ui_factory) {
35 if ($result->
isOK() && $result->
value()[0]) {
37 (
string)$launcher->getTarget()->getURL()->withParameter(
'launcher_redirect',
'terms accepted (' . $launcher->getButtonLabel() .
')')
40 $launcher = $launcher->withStatusMessageBox($ui_factory->messageBox()->failure(
'You must accept the conditions.'));
43 $target = $data_factory->link(
'Join Group',
$url->withParameter(
'launcher_id',
'l1'));
45 $launcher = $ui_factory->launcher()
47 ->withDescription($description)
48 ->withInputs($group, $evaluation, $instruction);
50 if (array_key_exists(
'launcher_id', $request->getQueryParams()) && $request->getQueryParams()[
'launcher_id'] ===
'l1') {
51 $launcher = $launcher->withRequest($request);
55 $icon = $ui_factory->symbol()->icon()->standard(
'auth',
'authentification needed',
'large');
56 $description =
'<p>Before you can take the survey, you have to agree to our terms and conditions.</p>';
57 $target = $data_factory->link(
'Take Survey',
$url->withParameter(
'launcher_id',
'l2'));
58 $launcher2 = $ui_factory->launcher()
60 ->withStatusIcon($icon)
61 ->withButtonLabel(
'Take Survey')
62 ->withDescription($description)
63 ->withInputs($group, $evaluation);
65 if (array_key_exists(
'launcher_id', $request->getQueryParams()) && $request->getQueryParams()[
'launcher_id'] ===
'l2') {
66 $launcher2 = $launcher2->withRequest($request);
71 $icon = $ui_factory->symbol()->icon()->standard(
'ps',
'authentification needed',
'large');
72 $status_message = $ui_factory->messageBox()->info(
"You will be asked for your personal passcode when you start the test.");
73 $instruction = $ui_factory->messageBox()->info(
'Fill the form; use password "ilias" to pass');
74 $group = $ui_factory->input()->field()->group([
75 $ui_factory->input()->field()->password(
'pwd',
'Password')
77 $evaluation =
function (
Result $result,
Launcher &$launcher) use ($ctrl, $ui_factory) {
78 if ($result->
isOK() && $result->
value()[0]->toString() ===
'ilias') {
80 (
string)$launcher->getTarget()->getURL()->withParameter(
'launcher_redirect',
'password protected')
83 $launcher = $launcher->withStatusMessageBox($ui_factory->messageBox()->failure(
'nope. wrong pass.'));
86 $target = $data_factory->link(
'Begin Exam',
$url->withParameter(
'launcher_id',
'l3'));
87 $launcher3 = $ui_factory->launcher()
90 ->withInputs($group, $evaluation, $instruction)
91 ->withStatusIcon($icon)
92 ->withStatusMessageBox($status_message)
93 ->withModalSubmitLabel(
'Begin Exam')
94 ->withModalCancelLabel(
'Cancel')
97 if (array_key_exists(
'launcher_id', $request->getQueryParams()) && $request->getQueryParams()[
'launcher_id'] ===
'l3') {
98 $launcher3 = $launcher3->withRequest($request);
102 $result =
"not submitted or wrong pass";
104 if (array_key_exists(
'launcher_redirect', $request->getQueryParams())
105 && $v = $request->getQueryParams()[
'launcher_redirect']
107 $result =
"<b>sucessfully redirected ($v)</b>";
110 return $result .
"<hr/>" . $renderer->render([
isOK()
Get to know if the result is ok.
value()
Get the encapsulated value.
A result encapsulates a value or an error and simplifies the handling of those.
with_fields()
In this example, the Launcher is configured with inputs; a Modal containing a Form will open upon cli...