19 declare(strict_types=1);
56 $this->user_id = $domain->user()->getId();
57 $this->status_manager = $domain->
participants()->status($this->survey, $this->user_id);
59 $this->run_manager = $domain->
execution()->run($this->survey, $this->user_id);
61 $exec_request = $gui->
execution()->request();
62 $this->requested_code = $exec_request->getAnonymousId();
67 $ctrl = $this->gui->ctrl();
69 $next_class = $ctrl->getNextClass($this);
70 $cmd = $ctrl->getCmd(
"launch");
72 switch ($next_class) {
74 if (in_array($cmd, array(
"launch",
"start",
"resume"))) {
82 $ctrl = $this->gui->ctrl();
83 $main_tpl = $this->gui->ui()->mainTemplate();
85 $this->run_manager->initSession($this->requested_code);
87 $main_tpl->setOnScreenMessage(
"failure", $e->getMessage(),
true);
88 $ctrl->redirectByClass(self::class,
"launch");
94 $f = $this->gui->ui()->factory();
95 $r = $this->gui->ui()->renderer();
96 $ctrl = $this->gui->ctrl();
97 $main_tpl = $this->gui->ui()->mainTemplate();
98 $lng = $this->domain->lng();
104 if ($this->status_manager->cantStartAgain()) {
105 $main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"already_completed_survey"));
135 $items[] = $launcher;
138 $mt = $this->gui->mainTemplate();
139 $mt->setContent(
$r->render($items));
144 $ctrl = $this->gui->ctrl();
145 $request = $this->gui->http()->request();
149 $launcher = $launcher->withRequest($request);
150 $result = $launcher->getResult();
151 if ($result && $result->isOK()) {
152 foreach ($result->value() as $key => $value) {
153 if ($key ===
"appraisee_id") {
154 $ctrl->setParameterByClass(\ilSurveyExecutionGUI::class,
"appr_id", $value);
156 if ($key ===
"anonymous_id") {
157 $this->requested_code = $value;
158 $ctrl->setParameterByClass(\ilSurveyExecutionGUI::class,
"anonymous_id", $value);
167 $ctrl = $this->gui->ctrl();
170 $ctrl->redirectByClass(\ilSurveyExecutionGUI::class,
"start");
175 $ctrl = $this->gui->ctrl();
178 $ctrl->redirectByClass(\ilSurveyExecutionGUI::class,
"resume");
183 $ctrl = $this->gui->ctrl();
184 $lng = $this->domain->lng();
185 $f = $this->gui->ui()->factory();
187 $anonymous_code = $this->run_manager->getCode();
195 if ($this->status_manager->mustEnterCode($anonymous_code)) {
196 $this->launch_information[
$lng->txt(
"svy_code")] =
197 $lng->txt(
"anonymize_anonymous_introduction");
198 $this->launch_inputs[
"anonymous_id"] =
$f->input()->field()->text(
199 $lng->txt(
"enter_anonymous_id")
201 $this->launch_target = $ctrl->getLinkTargetByClass(
205 $this->launch_title =
$lng->txt(
"start_survey");
211 if ($this->status_manager->canAddItselfAsAppraisee() &&
212 $this->access_manager->canStartSurvey()) {
213 $this->launch_message_buttons[] =
$f->button()->standard(
214 $lng->txt(
"survey_360_add_self_appraisee"),
215 $ctrl->getLinkTargetByClass(\ilSurveyParticipantsGUI::class,
"addSelfAppraisee")
220 if ($this->survey->getIntroduction() !==
'') {
221 $introduction = $this->survey->getIntroduction();
222 $this->launch_information[] = $this->survey->prepareTextareaOutput($introduction);
226 if (!$this->feature_config->usesAppraisees()) {
227 $this->launch_information[
$lng->txt(
"survey_results_anonymization")] =
228 !$this->survey->hasAnonymizedResults()
229 ?
$lng->txt(
"survey_results_personalized_info")
230 :
$lng->txt(
"survey_results_anonymized_info");
231 if ($this->access_manager->canAccessEvaluation()) {
232 $this->launch_messages[
$lng->txt(
"evaluation_access")] =
233 $lng->txt(
"evaluation_access_info");
241 $f = $this->gui->ui()->factory();
243 if ($this->launch_target !==
"") {
244 $data_factory = new \ILIAS\Data\Factory();
245 $uri = $data_factory->uri(ILIAS_HTTP_PATH .
'/' . $this->launch_target);
246 $link = $data_factory->link($this->launch_title, $uri);
248 $launcher =
$f->launcher()->inline(
252 if (count($this->launch_inputs) > 0) {
253 $launcher = $launcher->withInputs(
254 $f->input()->field()->group($this->launch_inputs),
258 )->withModalSubmitLabel($this->launch_title);
268 $f = $this->gui->ui()->factory();
269 $lng = $this->domain->lng();
271 if (count($this->launch_information) > 0) {
276 foreach ($this->launch_information as $key => $value) {
277 if (is_numeric($key)) {
278 $items[] =
$f->legacy()->content($value);
280 $key_value[$key] = $value;
284 if (count($key_value) > 0) {
285 if (count($items) > 0) {
286 $items[] =
$f->divider()->horizontal();
288 $items[] =
$f->listing()->descriptive($key_value);
291 $panel =
$f->panel()->standard(
292 $lng->txt(
"svy_information"),
303 $f = $this->gui->ui()->factory();
304 if (count($this->launch_messages) > 0 || count($this->launch_message_buttons) > 0
305 || count($this->launch_message_links) > 0) {
307 foreach ($this->launch_messages as $m) {
308 $mess .=
"<p>$m</p>";
310 $mbox =
$f->messageBox()->info($mess);
311 if (count($this->launch_message_buttons) > 0) {
312 $mbox = $mbox->withButtons($this->launch_message_buttons);
314 if (count($this->launch_message_links) > 0) {
315 $mbox = $mbox->withLinks($this->launch_message_links);
324 $survey = $this->survey;
325 $lng = $this->domain->lng();
327 $privacy_info =
$lng->txt(
"svy_rater_see_app_info");
329 $privacy_info .=
" " .
$lng->txt(
"svy_app_see_rater_info");
332 $this->launch_information[
$lng->txt(
"svy_privacy_info")] = $privacy_info;
337 $survey = $this->survey;
338 $lng = $this->domain->lng();
339 $ctrl = $this->gui->ctrl();
340 $f = $this->gui->ui()->factory();
342 if ($this->status_manager->isAppraisee()) {
345 $appr_data = $survey->getAppraiseesData();
348 $this->launch_information[
$lng->txt(
"svy_your_raters")] =
349 sprintf(
$lng->txt(
"svy_your_raters_finished"), $appr_data[
"finished"]);
351 if ($survey->get360Mode()) {
352 if (!$appr_data[
"closed"]) {
353 $button =
$f->button()->standard(
354 $lng->txt(
"survey_360_appraisee_close_action"),
355 $ctrl->getLinkTargetByClass(
356 \ilSurveyParticipantsGUI::class,
357 "confirmappraiseeclose" 360 $this->launch_message_buttons[] = $button;
362 $txt =
"survey_360_appraisee_close_action_info";
363 if ($survey->getSkillService()) {
366 $this->launch_messages[] =
$lng->txt(
$txt);
369 $dt = new \ilDateTime($appr_data[
"closed"],
IL_CAL_UNIX);
370 $this->launch_information[
$lng->txt(
"status")] = sprintf(
371 $lng->txt(
"survey_360_appraisee_close_action_status"),
380 string $anonymous_code,
382 $ctrl = $this->gui->ctrl();
383 $f = $this->gui->ui()->factory();
384 $lng = $this->domain->lng();
385 $survey = $this->survey;
387 if ($this->access_manager->canStartSurvey() &&
389 if (!$this->feature_config->usesAppraisees()) {
390 if ($anonymous_code) {
391 $ctrl->setParameterByClass(\ilObjSurvey::class,
"anonymous_id", $anonymous_code);
394 if ($this->run_manager->hasStarted() &&
395 !$this->run_manager->hasFinished()) {
396 $this->launch_target = $ctrl->getLinkTargetByClass(
400 $this->launch_title =
$lng->txt(
"resume_survey");
401 } elseif (!$this->run_manager->hasStarted()) {
402 $this->launch_target = $ctrl->getLinkTargetByClass(
406 $this->launch_title =
$lng->txt(
"start_survey");
413 if ($anonymous_code) {
414 $anonymous_id = $survey->getAnonymousIdByCode($anonymous_code);
416 $appr_ids = $survey->getAppraiseesToRate(0, $anonymous_id);
423 $appr_ids = $survey->getAppraiseesToRate($this->user_id);
426 if (count($appr_ids)) {
428 $active_appraisees = array();
429 foreach ($this->run_manager
430 ->getRunsForUser($this->user_id, $anonymous_code) as $item) {
431 $active_appraisees[$item->getAppraiseeId()] = $item->getFinished();
435 $appraisee_options = [];
439 foreach ($appr_ids as $appr_id) {
440 if ($survey->isAppraiseeClosed($appr_id)) {
442 $list[$appr_id] =
$lng->txt(
"survey_360_appraisee_is_closed");
444 if ($active_appraisees[$appr_id] ??
false) {
447 } elseif (array_key_exists($appr_id, $active_appraisees)) {
449 if ($active_appraisees[$appr_id]) {
450 $list[$appr_id] =
$lng->txt(
"already_completed_survey");
455 $list[$appr_id] = array(
"resume",
$lng->txt(
"resume_survey"));
460 $list[$appr_id] = array(
"start",
$lng->txt(
"start_survey"));
465 foreach ($list as $appr_id => $item) {
467 if (is_array($item)) {
468 $appraisee_options[$appr_id] = $appr_name;
471 if (count($appraisee_options) > 0) {
472 $this->launch_inputs[
"appraisee_id"] =
$f->input()->field()->select(
473 $lng->txt(
"survey_360_appraisee"),
475 )->withRequired(
true)->withValue(key($appraisee_options));
476 $this->launch_target = $ctrl->getLinkTargetByClass(
480 $this->launch_title =
$lng->txt(
"survey_360_rate_other_appraisee");
483 $status_txt = ($open === 0)
484 ?
$lng->txt(
"svy_0_open_appraisees")
485 : sprintf(
$lng->txt(
"svy_x_open_appraisees"), $open);
487 $status_txt .=
" " . sprintf(
$lng->txt(
"svy_finished_x_appraisees"), $finished);
490 $status_txt .=
" " . sprintf(
$lng->txt(
"svy_x_appraisees_closed_for_raters"), $closed);
492 $this->launch_information[
$lng->txt(
"svy_your_appraisees")] = $status_txt;
495 $this->launch_messages[] =
$lng->txt(
"survey_360_no_appraisees");
504 $survey = $this->survey;
505 $lng = $this->domain->lng();
506 $ctrl = $this->gui->ctrl();
507 $f = $this->gui->ui()->factory();
509 if (!$this->access_manager->canStartSurvey() &&
510 $this->access_manager->canEditSettings()) {
512 if (!$survey->hasStarted()) {
513 $this->launch_messages[] =
$lng->txt(
'start_date_not_reached') .
' (' .
515 $survey->getStartDate(),
520 if ($survey->hasEnded()) {
521 $this->launch_messages[] =
$lng->txt(
'end_date_reached') .
' (' .
525 if ($survey->getOfflineStatus()) {
526 $this->launch_messages[] =
$lng->txt(
"survey_is_offline");
529 if ($this->access_manager->canEditSettings()) {
530 $this->launch_message_links[] =
$f->link()->standard(
531 $lng->txt(
"survey_edit_settings"),
532 $ctrl->getLinkTargetByClass(\ilObjSurveyGUI::class,
"properties")
__construct(protected InternalDomainService $domain, protected InternalGUIService $gui, protected \ilObjSurvey $survey)
static array static setUseRelativeDates(bool $a_status)
set use relative dates
mustEnterCode(string $code="")
Check if user must enter code to start (and currently is able to start)
StatusManager $status_manager
access(int $ref_id, int $user_id)
Survey internal ui service.
Participant status manager.
forwardInputsToParameters()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
determineMainLink(string $anonymous_code,)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is:
AccessManager $access_manager
array $launch_information
determineNotStartableReasons()
modeFeatureConfig(int $mode)
array $launch_message_buttons
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
Survey Run Note: The manager should get the current user id passed.
FeatureConfig $feature_config
array $launch_message_links
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...