diff --git a/components/ILIAS/Survey/Evaluation/class.ilSurveyEvaluationGUI.php b/components/ILIAS/Survey/Evaluation/class.ilSurveyEvaluationGUI.php index c0b8e62297b4..f34921b212bb 100755 --- a/components/ILIAS/Survey/Evaluation/class.ilSurveyEvaluationGUI.php +++ b/components/ILIAS/Survey/Evaluation/class.ilSurveyEvaluationGUI.php @@ -25,7 +25,7 @@ * The ilSurveyEvaluationGUI class creates the evaluation output for the ilObjSurveyGUI * class. This saves some heap space because the ilObjSurveyGUI class will be * smaller. - * @author Helmut Schottmüller + * @author Helmut Schottmüller */ class ilSurveyEvaluationGUI { @@ -49,7 +49,6 @@ class ilSurveyEvaluationGUI protected ilObjUser $user; protected ilRbacSystem $rbacsystem; protected ilTree $tree; - protected ilToolbarGUI $toolbar; protected ilObjSurvey $object; protected ilLanguage $lng; protected ilGlobalTemplateInterface $tpl; @@ -69,7 +68,6 @@ public function __construct( $this->user = $DIC->user(); $this->rbacsystem = $DIC->rbac()->system(); $this->tree = $DIC->repositoryTree(); - $this->toolbar = $DIC->toolbar(); $this->ui = $DIC->ui(); $lng = $DIC->language(); $tpl = $DIC["tpl"]; @@ -101,20 +99,20 @@ public function __construct( ); $this->ui_modifier = $DIC->survey() - ->internal() - ->gui() - ->modeUIModifier($this->object->getMode()); + ->internal() + ->gui() + ->modeUIModifier($this->object->getMode()); $this->print = $DIC->survey() - ->internal() - ->gui() - ->print(); + ->internal() + ->gui() + ->print(); $this->access_manager = $DIC->survey() - ->internal() - ->domain() - ->access( - $this->object->getRefId(), - $DIC->user()->getId() - ); + ->internal() + ->domain() + ->access( + $this->object->getRefId(), + $DIC->user()->getId() + ); $this->skill_profile_service = $DIC->skills()->profile(); $this->gui = $DIC->survey()->internal()->gui(); } @@ -188,7 +186,6 @@ public function setEvalSubtabs(): void } } - public function setAppraiseeId( int $a_val ): void { @@ -229,11 +226,22 @@ public function checkAnonymizedEvaluationAccess(): bool // code needed $this->tpl->setVariable("TABS", ""); - $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_evaluation_checkaccess.html", "components/ILIAS/Survey"); + $this->tpl->addBlockFile( + "ADM_CONTENT", + "adm_content", + "tpl.il_svy_svy_evaluation_checkaccess.html", + "components/ILIAS/Survey" + ); $this->tpl->setCurrentBlock("adm_content"); - $this->tpl->setVariable("AUTHENTICATION_NEEDED", $this->lng->txt("svy_check_evaluation_authentication_needed")); + $this->tpl->setVariable( + "AUTHENTICATION_NEEDED", + $this->lng->txt("svy_check_evaluation_authentication_needed") + ); $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "checkEvaluationAccess")); - $this->tpl->setVariable("EVALUATION_CHECKACCESS_INTRODUCTION", $this->lng->txt("svy_check_evaluation_access_introduction")); + $this->tpl->setVariable( + "EVALUATION_CHECKACCESS_INTRODUCTION", + $this->lng->txt("svy_check_evaluation_access_introduction") + ); $this->tpl->setVariable("VALUE_CHECK", $this->lng->txt("ok")); $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel")); $this->tpl->setVariable("TEXT_SURVEY_CODE", $this->lng->txt("survey_code")); @@ -343,7 +351,6 @@ public function exportCumulatedResults( break; } - // parse answer data in evaluation results $ov_row = 2; $question_index = 1; @@ -373,7 +380,14 @@ public function exportCumulatedResults( if ($details) { switch ($this->request->getExportFormat()) { case self::TYPE_XLS: - $this->exportResultsDetailsExcel($excel, $q_eval, $q_res, $do_title, $do_label, $question_index++); + $this->exportResultsDetailsExcel( + $excel, + $q_eval, + $q_res, + $do_title, + $do_label, + $question_index++ + ); break; } } @@ -429,7 +443,6 @@ protected function exportResultsDetailsExcel( $a_excel->addSheet($question_index . "_" . $question->getTitle()); - // question "overview" $kv = array(); @@ -451,7 +464,7 @@ protected function exportResultsDetailsExcel( // answered and skipped users $kv[$this->lng->txt("users_answered")] = $question_res->getUsersAnswered(); - $kv[$this->lng->txt("users_skipped")] = $question_res->getUsersSkipped(); // #0021671 + $kv[$this->lng->txt("users_skipped")] = $question_res->getUsersSkipped(); // #0021671 $excel_row = 1; @@ -597,8 +610,7 @@ protected function parseResultsToExcel( $a_excel->setColors("B" . $a_excel_row . ":C" . $a_excel_row, self::EXCEL_SUBTITLE); $a_excel->setCell($a_excel_row, 1, $this->lng->txt("title")); $a_excel->setCell($a_excel_row++, 2, $this->lng->txt("answer")); - } - // mtx (row), txt + } // mtx (row), txt else { $a_excel->setColors("B" . $a_excel_row . ":B" . $a_excel_row, self::EXCEL_SUBTITLE); $a_excel->setCell($a_excel_row++, 1, $this->lng->txt("answer")); @@ -646,7 +658,7 @@ protected function buildExportButtonAndModal( ): void { $lng = $this->lng; $ctrl = $this->ctrl; - $toolbar = $this->toolbar; + $toolbar = $this->gui->toolbar(); $ui_fac = $this->gui->ui()->factory(); $ctrl->setParameter($this, "export_cmd", $export_cmd); @@ -660,7 +672,7 @@ protected function buildExportButtonAndModal( $toolbar->addComponent($modal); } - protected function getExportModal(): Modal\RoundTrip | Form\Standard + protected function getExportModal(): Modal\RoundTrip|Form\Standard { $lng = $this->lng; $ctrl = $this->ctrl; @@ -675,8 +687,8 @@ protected function getExportModal(): Modal\RoundTrip | Form\Standard \ilSurveyEvaluationGUI::TYPE_SPSS => $lng->txt("exp_type_csv") ] ) - //->withValue(\ilSurveyEvaluationGUI::TYPE_XLS) - ->withRequired(true); + //->withValue(\ilSurveyEvaluationGUI::TYPE_XLS) + ->withRequired(true); $inputs["export_label"] = $ui_fac->input()->field()->select( $lng->txt("title"), @@ -686,8 +698,8 @@ protected function getExportModal(): Modal\RoundTrip | Form\Standard "title_label" => $lng->txt("export_title_label") ] ) - //->withValue("label_only") - ->withRequired(true); + //->withValue("label_only") + ->withRequired(true); $modal = $ui_fac->modal()->roundtrip( $lng->txt("svy_export_format"), @@ -695,7 +707,7 @@ protected function getExportModal(): Modal\RoundTrip | Form\Standard $inputs, $post_url ) - ->withSubmitLabel($lng->txt("export")); + ->withSubmitLabel($lng->txt("export")); return $modal; } @@ -705,7 +717,7 @@ protected function validateAndSubmitExportForm(): void $lng = $this->lng; $ctrl = $this->ctrl; $tabs = $this->tabs; - $toolbar = $this->toolbar; + $toolbar = $this->gui->toolbar(); $request = $this->request; $ui_request = $this->gui->http()->request(); @@ -767,7 +779,6 @@ protected function openEvaluation(): void public function evaluation( int $details = 0 ): void { - $ilToolbar = $this->toolbar; $tree = $this->tree; $ui = $this->ui; @@ -784,7 +795,6 @@ public function evaluation( $this->tabs->activateSubTab("svy_eval_detail"); } - // auth if (!$this->hasResultsAccess()) { if (!$this->access->checkAccess('read', '', $this->object->getRefId())) { @@ -814,32 +824,36 @@ public function evaluation( // setup toolbar $appr_id = $this->evaluation_manager->getCurrentAppraisee(); - $ilToolbar->setFormAction($this->ctrl->getFormAction($this)); $results = array(); $eval_tpl = new ilTemplate("tpl.il_svy_svy_evaluation.html", true, true, "components/ILIAS/Survey"); - if ($details) { - $this->ui_modifier->setResultsDetailToolbar( + $toolbar_components = $this->ui_modifier->setResultsDetailToolbar( $this->object, - $ilToolbar, $this->user->getId(), $eval_tpl ); } else { - $this->ui_modifier->setResultsOverviewToolbar( + $toolbar_components = $this->ui_modifier->setResultsOverviewToolbar( $this->object, - $ilToolbar, $this->user->getId(), $eval_tpl ); } + foreach ($toolbar_components as $component) { + $this->gui->toolbar()->addComponent($component); + } if (!$this->object->get360Mode() || $appr_id) { if ($details) { //templates: results, table of contents - $dtmpl = new ilTemplate("tpl.il_svy_svy_results_details.html", true, true, "components/ILIAS/Survey/Evaluation"); + $dtmpl = new ilTemplate( + "tpl.il_svy_svy_results_details.html", + true, + true, + "components/ILIAS/Survey/Evaluation" + ); $this->lng->loadLanguageModule("content"); } $finished_ids = $this->evaluation_manager->getFilteredFinishedIds(); @@ -890,7 +904,10 @@ public function evaluation( if ($details) { //TABLE OF CONTENTS - $panel_toc = $ui_factory->panel()->standard($this->lng->txt('cont_toc'), $ui_factory->legacy()->content($listing->render())); + $panel_toc = $ui_factory->panel()->standard( + $this->lng->txt('cont_toc'), + $ui_factory->legacy()->content($listing->render()) + ); $render_toc = $ui_renderer->render($panel_toc); $dtmpl->setVariable("PANEL_TOC", $render_toc); @@ -905,7 +922,6 @@ public function evaluation( } } - //$eval_tpl->setVariable('MODAL', $modal); if (!$details) { $table_gui = new ilSurveyResultsCumulatedTableGUI($this, 'evaluation', $results); $eval_tpl->setVariable('CUMULATED', $table_gui->getHTML()); @@ -946,8 +962,8 @@ public function evaluation( /** * Processes an array as a CSV row and converts the array values to correct CSV * values. The "converted" array is returned - * @param array $row The array containing the values for a CSV row - * @param bool $quoteAll Indicates to quote every value (=TRUE) or only values containing quotes and separators (=FALSE, default) + * @param array $row The array containing the values for a CSV row + * @param bool $quoteAll Indicates to quote every value (=TRUE) or only values containing quotes and separators (=FALSE, default) * @param string $separator The value separator in the CSV row (used for quoting) (; = default) * @return array The converted array ready for CSV use */ @@ -1139,23 +1155,20 @@ public function exportEvaluationUser(): void */ public function evaluationuser(): void { - $ilToolbar = $this->toolbar; - if (!$this->hasResultsAccess() && $this->object->getMode() !== ilObjSurvey::MODE_SELF_EVAL) { $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_permission"), true); $this->ctrl->redirectByClass("ilObjSurveyGUI", "infoScreen"); } - $this->ui_modifier->setResultsParticipantToolbar( + $toolbar_components = $this->ui_modifier->setResultsParticipantToolbar( $this->object, - $ilToolbar, $this->user->getId() ); + foreach ($toolbar_components as $component) { + $this->gui->toolbar()->addComponent($component); + } - $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "evaluationuser")); - - $modal = ""; $appr_id = null; $data = []; @@ -1166,7 +1179,7 @@ public function evaluationuser(): void if (!$this->object->get360Mode() || $appr_id) { $this->buildExportButtonAndModal("exportEvaluationUser"); - $ilToolbar->addSeparator(); + $this->gui->toolbar()->addSeparator(); $pv = $this->print->resultsDetails($this->object->getRefId()); $modal_elements = $pv->getModalElements( @@ -1175,8 +1188,9 @@ public function evaluationuser(): void "printResultsPerUserSelection" ) ); - $ilToolbar->addComponent($modal_elements->button); - $ilToolbar->addComponent($modal_elements->modal); + + $this->gui->toolbar()->addComponent($modal_elements->button); + $this->gui->toolbar()->addComponent($modal_elements->modal); $data = $this->evaluation_manager->getUserSpecificResults(); } @@ -1190,7 +1204,6 @@ public function competenceEval(): void { $lng = $this->lng; $ilCtrl = $this->ctrl; - $ilToolbar = $this->toolbar; $tpl = $this->tpl; $ilTabs = $this->tabs; @@ -1199,8 +1212,6 @@ public function competenceEval(): void $ilTabs->activateSubTab("svy_eval_competences"); $ilTabs->activateTab("svy_results"); - $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "competenceEval")); - $appr_id = $this->getAppraiseeId(); if ($appr_id === 0) { @@ -1208,11 +1219,13 @@ public function competenceEval(): void return; } - $this->ui_modifier->setResultsCompetenceToolbar( + $toolbar_components = $this->ui_modifier->setResultsCompetenceToolbar( $this->object, - $ilToolbar, $this->user->getId() ); + foreach ($toolbar_components as $component) { + $this->gui->toolbar()->addComponent($component); + } // evaluation modes $eval_modes = array(); @@ -1223,8 +1236,13 @@ public function competenceEval(): void $skills = array(); foreach ($opts as $id => $o) { $idarr = explode(":", $id); - $skills[$id] = array("id" => $id, "title" => $o, "profiles" => array(), - "base_skill" => $idarr[0], "tref_id" => $idarr[1]); + $skills[$id] = array( + "id" => $id, + "title" => $o, + "profiles" => array(), + "base_skill" => $idarr[0], + "tref_id" => $idarr[1] + ); } // get matching user competence profiles @@ -1261,12 +1279,20 @@ public function competenceEval(): void $ilCtrl->saveParameter($this, "comp_eval_mode"); - $mode_sel = new ilSelectInputGUI($lng->txt("svy_analysis"), "comp_eval_mode"); - $mode_sel->setOptions($eval_modes); - $mode_sel->setValue($comp_eval_mode); - $ilToolbar->addInputItem($mode_sel, true); + $dropdown_items = []; + foreach ($eval_modes as $mode_key => $mode_label) { + $ilCtrl->setParameter($this, "comp_eval_mode", $mode_key); + $dropdown_items[] = $this->ui->factory()->button()->shy( + $mode_label, + $ilCtrl->getLinkTarget($this, "competenceEval") + ); + } + $ilCtrl->setParameter($this, "comp_eval_mode", $comp_eval_mode); - $ilToolbar->addFormButton($lng->txt("select"), "competenceEval"); + $this->gui->toolbar()->addComponent( + $this->ui->factory()->dropdown()->standard($dropdown_items) + ->withLabel($eval_modes[$comp_eval_mode] ?? $lng->txt("svy_analysis")) + ); $pskills_gui = new ilPersonalSkillsGUI(); $rater = $this->evaluation_manager->getCurrentRater( @@ -1310,7 +1336,7 @@ public function competenceEval(): void $sk[] = array( "base_skill_id" => (int) $skill["base_skill"], "tref_id" => (int) $skill["tref_id"] - ); + ); } $html = $pskills_gui->getGapAnalysisHTML($appr_id, $sk); } @@ -1323,7 +1349,11 @@ public function competenceEval(): void */ protected function hasResultsAccess(): bool { - return $this->access->checkRbacOrPositionPermissionAccess('read_results', 'access_results', $this->object->getRefId()); + return $this->access->checkRbacOrPositionPermissionAccess( + 'read_results', + 'access_results', + $this->object->getRefId() + ); } /** @@ -1337,7 +1367,10 @@ public function sumscore(): void $this->ctrl->redirectByClass("ilObjSurveyGUI", "infoScreen"); } - $this->tpl->setOnScreenMessage('info', $this->lng->txt("svy_max_sum_score") . ": " . $this->object->getMaxSumScore()); + $this->tpl->setOnScreenMessage( + 'info', + $this->lng->txt("svy_max_sum_score") . ": " . $this->object->getMaxSumScore() + ); $this->gui->button( $this->lng->txt("print"), diff --git a/components/ILIAS/Survey/Mode/IndividualFeedback/class.UIModifier.php b/components/ILIAS/Survey/Mode/IndividualFeedback/class.UIModifier.php index 7d2e73d421b9..91dd753d730f 100755 --- a/components/ILIAS/Survey/Mode/IndividualFeedback/class.UIModifier.php +++ b/components/ILIAS/Survey/Mode/IndividualFeedback/class.UIModifier.php @@ -75,11 +75,13 @@ public function getSurveySettingsReminderTargets( $cb->setOptionTitle($lng->txt("survey_360_appraisees")); $cb->setInfo($lng->txt("survey_360_appraisees_remind_info")); $cb->setValue("1"); - $cb->setChecked(in_array( - $survey->getReminderTarget(), - array(\ilObjSurvey::NOTIFICATION_APPRAISEES, \ilObjSurvey::NOTIFICATION_APPRAISEES_AND_RATERS), - true - )); + $cb->setChecked( + in_array( + $survey->getReminderTarget(), + array(\ilObjSurvey::NOTIFICATION_APPRAISEES, \ilObjSurvey::NOTIFICATION_APPRAISEES_AND_RATERS), + true + ) + ); $items[] = $cb; // remind raters @@ -87,11 +89,13 @@ public function getSurveySettingsReminderTargets( $cb->setOptionTitle($lng->txt("survey_360_raters")); $cb->setInfo($lng->txt("survey_360_raters_remind_info")); $cb->setValue("1"); - $cb->setChecked(in_array( - $survey->getReminderTarget(), - array(\ilObjSurvey::NOTIFICATION_RATERS, \ilObjSurvey::NOTIFICATION_APPRAISEES_AND_RATERS), - true - )); + $cb->setChecked( + in_array( + $survey->getReminderTarget(), + array(\ilObjSurvey::NOTIFICATION_RATERS, \ilObjSurvey::NOTIFICATION_APPRAISEES_AND_RATERS), + true + ) + ); $items[] = $cb; return $items; @@ -114,22 +118,19 @@ public function setValuesFromForm( $survey->set360Results((int) $form->getInput("ts_res")); } - public function setResultsDetailToolbar( \ilObjSurvey $survey, - \ilToolbarGUI $toolbar, int $user_id, \ilTemplate $eval_tpl - ): void { + ): array { $this->addApprSelectionToToolbar( $survey, - $toolbar, + $this->gui->toolbar(), $user_id ); - $this->addExportAndPrintButton( + return $this->getExportAndPrintComponents( $survey, - $toolbar, true, $eval_tpl ); @@ -137,9 +138,10 @@ public function setResultsDetailToolbar( public function setResultsCompetenceToolbar( \ilObjSurvey $survey, - \ilToolbarGUI $toolbar, int $user_id - ): void { + ): array { + $toolbar = $this->gui->toolbar(); + $this->addApprSelectionToToolbar( $survey, $toolbar, @@ -151,6 +153,8 @@ public function setResultsCompetenceToolbar( $toolbar, $user_id ); + + return []; } /** @@ -172,7 +176,6 @@ public function addRaterSelectionToToolbar( $req->getRaterId() ); - if (!$evaluation_manager->isMultiParticipantsView()) { $raters = $evaluation_manager->getSelectableRaters(); @@ -193,13 +196,11 @@ public function addRaterSelectionToToolbar( $ctrl->getCmd() )->submit()->toToolbar(false, $toolbar); - $toolbar->addSeparator(); } } } - protected function getPanelChart( \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request, \SurveyQuestionEvaluation $a_eval @@ -243,10 +244,14 @@ protected function getPanelTable( //exit; } - \ilDatePresentation::setUseRelativeDates(false); - $a_tpl = new \ilTemplate("tpl.svy_results_details_table.html", true, true, "components/ILIAS/Survey/Evaluation"); + $a_tpl = new \ilTemplate( + "tpl.svy_results_details_table.html", + true, + true, + "components/ILIAS/Survey/Evaluation" + ); // table $ret = ""; @@ -381,7 +386,12 @@ protected function getPanelTable( $a_tpl->setVariable("HEADER", $part_caption); $ret .= $a_tpl->get(); - $a_tpl = new \ilTemplate("tpl.svy_results_details_table.html", true, true, "components/ILIAS/Survey/Evaluation"); + $a_tpl = new \ilTemplate( + "tpl.svy_results_details_table.html", + true, + true, + "components/ILIAS/Survey/Evaluation" + ); } } } diff --git a/components/ILIAS/Survey/Mode/class.AbstractUIModifier.php b/components/ILIAS/Survey/Mode/class.AbstractUIModifier.php index 0e5963493d01..692b8723d25c 100755 --- a/components/ILIAS/Survey/Mode/class.AbstractUIModifier.php +++ b/components/ILIAS/Survey/Mode/class.AbstractUIModifier.php @@ -77,46 +77,44 @@ public function setValuesFromForm( public function setResultsOverviewToolbar( \ilObjSurvey $survey, - \ilToolbarGUI $toolbar, int $user_id, \ilTemplate $eval_tpl - ): void { + ): array { + $components = []; + $config = $this->getInternalService()->domain()->modeFeatureConfig($survey->getMode()); if ($config->usesAppraisees()) { - $this->addApprSelectionToToolbar( - $survey, - $toolbar, - $user_id + $components = array_merge( + $components, + $this->getApprSelectionComponents($survey, $user_id) ); } - $this->addExportAndPrintButton( - $survey, - $toolbar, - false, - $eval_tpl + $components = array_merge( + $components, + $this->getExportAndPrintComponents($survey, false, $eval_tpl) ); + + return $components; } public function setResultsCompetenceToolbar( \ilObjSurvey $survey, - \ilToolbarGUI $toolbar, int $user_id - ): void { - $this->addApprSelectionToToolbar( - $survey, - $toolbar, - $user_id - ); + ): array { + return $this->getApprSelectionComponents($survey, $user_id); } - + /** + * @return \ILIAS\UI\Component\Component[] + */ public function setResultsDetailToolbar( \ilObjSurvey $survey, - \ilToolbarGUI $toolbar, int $user_id, \ilTemplate $eval_tpl - ): void { + ): array { + $components = []; + $request = $this->service ->gui() ->evaluation($survey) @@ -124,73 +122,96 @@ public function setResultsDetailToolbar( $gui = $this->service->gui(); $lng = $gui->lng(); + $ctrl = $gui->ctrl(); + $ui_fac = $gui->ui()->factory(); $config = $this->getInternalService()->domain()->modeFeatureConfig($survey->getMode()); if ($config->usesAppraisees()) { - $this->addApprSelectionToToolbar( - $survey, - $toolbar, - $user_id + $components = array_merge( + $components, + $this->getApprSelectionComponents($survey, $user_id) ); } - $captions = new \ilSelectInputGUI($lng->txt("svy_eval_captions"), "cp"); - $captions->setOptions(array( + $caption_options = [ "ap" => $lng->txt("svy_eval_captions_abs_perc"), "a" => $lng->txt("svy_eval_captions_abs"), - "p" => $lng->txt("svy_eval_captions_perc") - )); - $captions->setValue($request->getCP()); - $toolbar->addInputItem($captions, true); + "p" => $lng->txt("svy_eval_captions_perc"), + ]; + $current_cp = $request->getCP(); + $caption_items = []; + foreach ($caption_options as $key => $label) { + $ctrl->setParameterByClass("ilSurveyEvaluationGUI", "cp", $key); + $ctrl->setParameterByClass("ilSurveyEvaluationGUI", "vw", $request->getVW()); + $caption_items[] = $ui_fac->button()->shy( + $label, + $ctrl->getLinkTargetByClass("ilSurveyEvaluationGUI", "evaluationdetails") + ); + } + // reset parameter + $ctrl->setParameterByClass("ilSurveyEvaluationGUI", "cp", $current_cp); + $components[] = $ui_fac->dropdown()->standard($caption_items) + ->withLabel($caption_options[$current_cp] ?? $lng->txt("svy_eval_captions")); - $view = new \ilSelectInputGUI($lng->txt("svy_eval_view"), "vw"); - $view->setOptions(array( + // View dropdown (replaces ilSelectInputGUI "vw") + $view_options = [ "tc" => $lng->txt("svy_eval_view_tables_charts"), "t" => $lng->txt("svy_eval_view_tables"), - "c" => $lng->txt("svy_eval_view_charts") - )); - $view->setValue($request->getVW()); - $toolbar->addInputItem($view, true); - - $this->gui->button( - $this->gui->lng()->txt("ok"), - "evaluationdetails" - )->submit()->toToolbar(false, $toolbar); - - $toolbar->addSeparator(); - - $this->addExportAndPrintButton( - $survey, - $toolbar, - true, - $eval_tpl + "c" => $lng->txt("svy_eval_view_charts"), + ]; + $current_vw = $request->getVW(); + $view_items = []; + foreach ($view_options as $key => $label) { + $ctrl->setParameterByClass("ilSurveyEvaluationGUI", "vw", $key); + $ctrl->setParameterByClass("ilSurveyEvaluationGUI", "cp", $request->getCP()); + $view_items[] = $ui_fac->button()->shy( + $label, + $ctrl->getLinkTargetByClass("ilSurveyEvaluationGUI", "evaluationdetails") + ); + } + // reset parameter + $ctrl->setParameterByClass("ilSurveyEvaluationGUI", "vw", $current_vw); + $components[] = $ui_fac->dropdown()->standard($view_items) + ->withLabel($view_options[$current_vw] ?? $lng->txt("svy_eval_view")); + + // Separator + export/print + $components = array_merge( + $components, + $this->getExportAndPrintComponents($survey, true, $eval_tpl) ); + + return $components; } + /** + * @return \ILIAS\UI\Component\Component[] + */ public function setResultsParticipantToolbar( \ilObjSurvey $survey, - \ilToolbarGUI $toolbar, int $user_id - ): void { + ): array { + $components = []; + $config = $this->getInternalService()->domain()->modeFeatureConfig($survey->getMode()); if ($config->usesAppraisees()) { - $this->addApprSelectionToToolbar( - $survey, - $toolbar, - $user_id + $components = array_merge( + $components, + $this->getApprSelectionComponents($survey, $user_id) ); } + + return $components; } - protected function addExportAndPrintButton( + protected function getExportAndPrintComponents( \ilObjSurvey $survey, - \ilToolbarGUI $toolbar, bool $details, \ilTemplate $eval_tpl - ): void { - $this->buildExportButtonAndModal($eval_tpl, $details ? "exportDetailData" : "exportData"); + ): array { + $components = []; - $toolbar->addSeparator(); + // Export button + modal + $this->buildExportButtonAndModal($eval_tpl, $details ? "exportDetailData" : "exportData"); if ($details) { $pv = $this->service->gui()->print()->resultsDetails($survey->getRefId()); @@ -220,15 +241,22 @@ protected function addExportAndPrintButton( ); } - $toolbar->addComponent($modal_elements->button); - $toolbar->addComponent($modal_elements->modal); + $components[] = $modal_elements->button; + $components[] = $modal_elements->modal; + + return $components; + } - /* - $button = \ilLinkButton::getInstance(); - $button->setCaption("print"); - $button->setOnClick("if(il.Accordion) { il.Accordion.preparePrint(); } window.print(); return false;"); - $button->setOmitPreventDoubleSubmission(true); - $toolbar->addButtonInstance($button);*/ + protected function getApprSelectionComponents( + \ilObjSurvey $survey, + int $user_id + ): array { + $this->addApprSelectionToToolbar( + $survey, + $this->gui->toolbar(), + $user_id + ); + return []; } protected function buildExportButtonAndModal( @@ -260,7 +288,7 @@ protected function buildExportButtonAndModal( } } - protected function getExportModal(): Modal\RoundTrip | Form\Standard + protected function getExportModal(): Modal\RoundTrip|Form\Standard { $lng = $this->gui->lng(); $ctrl = $this->gui->ctrl(); @@ -275,8 +303,8 @@ protected function getExportModal(): Modal\RoundTrip | Form\Standard \ilSurveyEvaluationGUI::TYPE_SPSS => $lng->txt("exp_type_csv") ] ) - //->withValue(\ilSurveyEvaluationGUI::TYPE_XLS) - ->withRequired(true); + //->withValue(\ilSurveyEvaluationGUI::TYPE_XLS) + ->withRequired(true); $inputs["export_label"] = $ui_fac->input()->field()->select( $lng->txt("title"), @@ -286,8 +314,8 @@ protected function getExportModal(): Modal\RoundTrip | Form\Standard "title_label" => $lng->txt("export_title_label") ] ) - //->withValue("label_only") - ->withRequired(true); + //->withValue("label_only") + ->withRequired(true); $modal = $ui_fac->modal()->roundtrip( $lng->txt("svy_export_format"), @@ -295,7 +323,7 @@ protected function getExportModal(): Modal\RoundTrip | Form\Standard $inputs, $post_url ) - ->withSubmitLabel($lng->txt("export")); + ->withSubmitLabel($lng->txt("export")); return $modal; } @@ -349,7 +377,6 @@ public function addApprSelectionToToolbar( } } - public function getDetailPanels( array $participants, \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request, @@ -359,7 +386,12 @@ public function getDetailPanels( $panels = []; $ui_factory = $this->service->gui()->ui()->factory(); - $a_tpl = new \ilTemplate("tpl.svy_results_details_panel.html", true, true, "components/ILIAS/Survey/Evaluation"); + $a_tpl = new \ilTemplate( + "tpl.svy_results_details_panel.html", + true, + true, + "components/ILIAS/Survey/Evaluation" + ); $question_res = $a_results; $matrix = false; @@ -368,42 +400,47 @@ public function getDetailPanels( $matrix = true; } - // see #28507 (matrix question without a row) if (!is_object($question_res)) { return []; } $question = $question_res->getQuestion(); - // question "overview" $qst_title = $question->getTitle(); $svy_text = nl2br($question->getQuestiontext()); - // Question title anchor $anchor_id = "svyrdq" . $question->getId(); $title = "$qst_title"; $panel_qst_card = $ui_factory->panel()->sub($title, $ui_factory->legacy()->content($svy_text)) - ->withFurtherInformation($this->getPanelCard($question_res)); + ->withFurtherInformation($this->getPanelCard($question_res)); $panels[] = $panel_qst_card; - $a_tpl->setVariable("TABLE", $this->getPanelTable( - $participants, - $request, - $a_eval - )); - - $a_tpl->setVariable("TEXT", $this->getPanelText( - $request, - $a_eval, - $question_res - )); + $a_tpl->setVariable( + "TABLE", + $this->getPanelTable( + $participants, + $request, + $a_eval + ) + ); - $a_tpl->setVariable("CHART", $this->getPanelChart( - $request, - $a_eval - )); + $a_tpl->setVariable( + "TEXT", + $this->getPanelText( + $request, + $a_eval, + $question_res + ) + ); + $a_tpl->setVariable( + "CHART", + $this->getPanelChart( + $request, + $a_eval + ) + ); $panels[] = $ui_factory->panel()->sub("", $ui_factory->legacy()->content($a_tpl->get())); return $panels; @@ -416,9 +453,13 @@ protected function getPanelTable( ): string { $a_results = $a_eval->getResults(); - $a_tpl = new \ilTemplate("tpl.svy_results_details_table.html", true, true, "components/ILIAS/Survey/Evaluation"); + $a_tpl = new \ilTemplate( + "tpl.svy_results_details_table.html", + true, + true, + "components/ILIAS/Survey/Evaluation" + ); - // grid if ($request->getShowTable()) { $grid = $a_eval->getGrid( $a_results, @@ -455,13 +496,16 @@ protected function getPanelChart( ): string { $a_results = $a_eval->getResults(); - $a_tpl = new \ilTemplate("tpl.svy_results_details_chart.html", true, true, "components/ILIAS/Survey/Evaluation"); - // chart + $a_tpl = new \ilTemplate( + "tpl.svy_results_details_chart.html", + true, + true, + "components/ILIAS/Survey/Evaluation" + ); if ($request->getShowChart()) { $chart = $a_eval->getChart($a_results); if ($chart) { if (is_array($chart)) { - // legend if (is_array($chart[1])) { foreach ($chart[1] as $legend_item) { $r = hexdec(substr($legend_item[1], 1, 2)); @@ -497,7 +541,6 @@ protected function getPanelText( $a_tpl = new \ilTemplate("tpl.svy_results_details_text.html", true, true, "components/ILIAS/Survey/Evaluation"); - // text answers $texts = $a_eval->getTextAnswers($a_results); if ($texts) { if (array_key_exists("", $texts)) { @@ -528,8 +571,6 @@ protected function getPanelText( return $a_tpl->get(); } - // in fact we want a \ILIAS\UI\Component\Card\Standard - // see #31743 protected function getPanelCard( \ilSurveyEvaluationResults $question_res ): \ILIAS\UI\Component\Card\Card { diff --git a/components/ILIAS/Survey/Mode/interface.UIModifier.php b/components/ILIAS/Survey/Mode/interface.UIModifier.php index 4e1dba9b879e..76136bf8971e 100755 --- a/components/ILIAS/Survey/Mode/interface.UIModifier.php +++ b/components/ILIAS/Survey/Mode/interface.UIModifier.php @@ -31,6 +31,7 @@ interface UIModifier { public function setInternalService(InternalService $internal_service): void; + public function getInternalService(): InternalService; /** @@ -63,29 +64,25 @@ public function setValuesFromForm( public function setResultsOverviewToolbar( \ilObjSurvey $survey, - \ilToolbarGUI $toolbar, int $user_id, \ilTemplate $eval_tpl - ): void; + ): array; public function setResultsDetailToolbar( \ilObjSurvey $survey, - \ilToolbarGUI $toolbar, int $user_id, \ilTemplate $eval_tpl - ): void; + ): array; public function setResultsParticipantToolbar( \ilObjSurvey $survey, - \ilToolbarGUI $toolbar, int $user_id - ): void; + ): array; public function setResultsCompetenceToolbar( \ilObjSurvey $survey, - \ilToolbarGUI $toolbar, int $user_id - ): void; + ): array; public function getDetailPanels( array $participants,