381 : void {
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);
392
393 }
394 if ($this->run_manager->hasStarted() &&
395 !$this->run_manager->hasFinished()) {
396 $this->launch_target = $ctrl->getLinkTargetByClass(
397 self::class,
398 "resume"
399 );
400 $this->launch_title =
$lng->txt(
"resume_survey");
401 } elseif (!$this->run_manager->hasStarted()) {
402 $this->launch_target = $ctrl->getLinkTargetByClass(
403 self::class,
404 "start"
405 );
406 $this->launch_title =
$lng->txt(
"start_survey");
407 }
408 } else {
409
410 $appr_ids = array();
411
412
413 if ($anonymous_code) {
414 $anonymous_id = $survey->getAnonymousIdByCode($anonymous_code);
415 if ($anonymous_id) {
416 $appr_ids = $survey->getAppraiseesToRate(0, $anonymous_id);
417 }
418 }
419
420
421
423 $appr_ids = $survey->getAppraiseesToRate($this->user_id);
424 }
425
426 if (count($appr_ids)) {
427
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();
432 }
433
434 $list = array();
435 $appraisee_options = [];
436 $closed = 0;
437 $open = 0;
438 $finished = 0;
439 foreach ($appr_ids as $appr_id) {
440 if ($survey->isAppraiseeClosed($appr_id)) {
441
442 $list[$appr_id] =
$lng->txt(
"survey_360_appraisee_is_closed");
443 $closed++;
444 if ($active_appraisees[$appr_id] ?? false) {
445 $finished++;
446 }
447 } elseif (array_key_exists($appr_id, $active_appraisees)) {
448
449 if ($active_appraisees[$appr_id]) {
450 $list[$appr_id] =
$lng->txt(
"already_completed_survey");
451 $finished++;
452 }
453
454 else {
455 $list[$appr_id] = array(
"resume",
$lng->txt(
"resume_survey"));
456 $open++;
457 }
458 } else {
459
460 $list[$appr_id] = array(
"start",
$lng->txt(
"start_survey"));
461 $open++;
462 }
463 }
464
465 foreach ($list as $appr_id => $item) {
467 if (is_array($item)) {
468 $appraisee_options[$appr_id] = $appr_name;
469 }
470 }
471 if (count($appraisee_options) > 0) {
472 $this->launch_inputs[
"appraisee_id"] =
$f->input()->field()->select(
473 $lng->txt(
"survey_360_appraisee"),
474 $appraisee_options
475 )->withRequired(true)->withValue(key($appraisee_options));
476 $this->launch_target = $ctrl->getLinkTargetByClass(
477 self::class,
478 "start"
479 );
480 $this->launch_title =
$lng->txt(
"survey_360_rate_other_appraisee");
481 }
482
483 $status_txt = ($open === 0)
484 ?
$lng->txt(
"svy_0_open_appraisees")
485 : sprintf(
$lng->txt(
"svy_x_open_appraisees"), $open);
486 if ($finished > 0) {
487 $status_txt .=
" " . sprintf(
$lng->txt(
"svy_finished_x_appraisees"), $finished);
488 }
489 if ($closed > 0) {
490 $status_txt .=
" " . sprintf(
$lng->txt(
"svy_x_appraisees_closed_for_raters"), $closed);
491 }
492 $this->launch_information[
$lng->txt(
"svy_your_appraisees")] = $status_txt;
493
495 $this->launch_messages[] =
$lng->txt(
"survey_360_no_appraisees");
496
497 }
498 }
499 }
500 }
StatusManager $status_manager
mustEnterCode(string $code="")
Check if user must enter code to start (and currently is able to start)
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=null)
Default behaviour is: