ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSurveySkillAssignmentTableGUI.php
Go to the documentation of this file.
1<?php
2
20
26{
32
33 public function __construct(
34 object $a_parent_obj,
35 string $a_parent_cmd,
36 ilObjSurvey $a_survey
37 ) {
38 global $DIC;
39
40 $this->ctrl = $DIC->ctrl();
41 $this->lng = $DIC->language();
42 $this->access = $DIC->access();
43 $ilCtrl = $DIC->ctrl();
44
45 $this->object = $a_survey;
46 $this->skill_survey = new ilSurveySkill($a_survey);
47
48 $this->skill_tree_service = $DIC->skills()->tree();
49 $this->skill_tree = $this->skill_tree_service->getGlobalSkillTree();
50
51 parent::__construct($a_parent_obj, $a_parent_cmd);
52 $this->getQuestions();
53
54 $this->addColumn($this->lng->txt("question"));
55 $this->addColumn($this->lng->txt("survey_skill"));
56 $this->addColumn($this->lng->txt("actions"));
57
58 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
59 $this->setRowTemplate("tpl.svy_skill_ass_row.html", "components/ILIAS/Survey");
60 }
61
62 public function getQuestions(): void
63 {
64 $survey_questions = $this->object->getSurveyQuestions();
65
66 $table_data = [];
67
68 if (count($survey_questions) > 0) {
69 $table_data = array();
70 $last_questionblock_id = $position = $block_position = 0;
71 foreach ($survey_questions as $question_id => $data) {
72 // it is only possible to assign to a subset
73 // of question types: single choice(2)
74 $supported = false;
75 if ((int) $data["questiontype_fi"] === 2) {
76 $supported = true;
77 }
78
79 $id = $data["question_id"];
80
81 $table_data[$id] = array("id" => $id,
82 "type" => "question",
83 "supported" => $supported,
84 "heading" => $data["heading"],
85 "title" => $data["title"],
86 "description" => $data["description"],
87 "author" => $data["author"],
88 "obligatory" => (bool) $data["obligatory"]);
89 }
90 }
91 $this->setData($table_data);
92 }
93
94 protected function fillRow(array $a_set): void
95 {
97 $ilCtrl = $this->ctrl;
98
99 $ilCtrl->setParameter($this->parent_obj, "q_id", $a_set["id"]);
100
101 if ($a_set["supported"]) {
102 $this->tpl->setCurrentBlock("cmd");
103 $this->tpl->setVariable(
104 "HREF_CMD",
105 $ilCtrl->getLinkTarget(
106 $this->parent_obj,
107 "assignSkillToQuestion"
108 )
109 );
110 $this->tpl->setVariable("TXT_CMD", $lng->txt("survey_assign_competence"));
111 $this->tpl->parseCurrentBlock();
112
113 if ($s = $this->skill_survey->getSkillForQuestion($a_set["id"])) {
114 $this->tpl->setCurrentBlock("cmd");
115 $this->tpl->setVariable(
116 "HREF_CMD",
117 $ilCtrl->getLinkTarget(
118 $this->parent_obj,
119 "removeSkillFromQuestion"
120 )
121 );
122 $this->tpl->setVariable("TXT_CMD", $lng->txt("survey_remove_competence"));
123 $this->tpl->parseCurrentBlock();
124
125 $this->tpl->setVariable(
126 "COMPETENCE",
127 ilBasicSkill::_lookupTitle($s["base_skill_id"], $s["tref_id"])
128 );
129
130 //var_dump($a_set);
131 $path = $this->skill_tree->getSkillTreePath($s["base_skill_id"], $s["tref_id"]);
132 $path_nodes = array();
133 foreach ($path as $p) {
134 if ($p["child"] > 1 && $p["skill_id"] != $s["base_skill_id"]) {
135 $path_nodes[] = ilBasicSkill::_lookupTitle($p["skill_id"], $p["tref_id"]);
136 }
137 }
138 $this->tpl->setVariable("PATH", implode(" > ", $path_nodes));
139 $this->tpl->setVariable("COMP_ID", "comp_" . $a_set["id"]);
140 }
141 } else {
142 $this->tpl->setVariable("NOT_SUPPORTED", $lng->txt("svy_skl_comp_assignm_not_supported"));
143 }
144
145 $this->tpl->setVariable("QUESTION_TITLE", $a_set["title"]);
146
147 $ilCtrl->setParameter($this->parent_obj, "q_id", "");
148 }
149}
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
TableGUI class for survey questions to skill assignment.
__construct(object $a_parent_obj, string $a_parent_cmd, ilObjSurvey $a_survey)
fillRow(array $a_set)
Standard Version of Fill Row.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
ilLanguage $lng
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26