ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilCopySelfAssQuestionTableGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
26 {
27  private QuestionInterface $questioninfo;
29  protected int $pool_ref_id;
30  protected int $pool_obj_id;
31 
32  public function __construct(
33  object $a_parent_obj,
34  string $a_parent_cmd,
35  int $a_pool_ref_id
36  ) {
37  global $DIC;
38 
39  $this->ctrl = $DIC->ctrl();
40  $this->access = $DIC->access();
41  $this->questioninfo = $DIC->testQuestion();
42 
43  $this->setId("cont_qpl");
44  $this->pool_ref_id = $a_pool_ref_id;
45  $this->pool_obj_id = ilObject::_lookupObjId($a_pool_ref_id);
46 
47  parent::__construct($a_parent_obj, $a_parent_cmd);
48 
49  $this->setTitle(ilObject::_lookupTitle($this->pool_obj_id));
50 
51  $this->setFormName('sa_quest_browser');
52 
53  $this->addColumn($this->lng->txt("title"), 'title', '');
54  $this->addColumn($this->lng->txt("cont_question_type"), 'ttype', '');
55  $this->addColumn($this->lng->txt("actions"), '', '');
56 
57 
58  $this->setRowTemplate("tpl.copy_sa_quest_row.html", "components/ILIAS/COPage");
59 
60  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
61  $this->setDefaultOrderField("title");
62  $this->setDefaultOrderDirection("asc");
63 
64  $this->initFilter();
65 
66  $this->getQuestions();
67  }
68 
69  public function getQuestions(): void
70  {
71  global $DIC;
72 
73  $access = $this->access;
74 
76  $all_ids = array();
77  foreach ($all_types as $k => $v) {
78  $all_ids[] = $v["question_type_id"];
79  }
80 
81  $questions = array();
82  if ($access->checkAccess("read", "", $this->pool_ref_id)) {
83  $questionList = new ilAssQuestionList(
84  $DIC->database(),
85  $DIC->language(),
86  $DIC['refinery'],
87  $DIC["component.repository"]
88  );
89  $questionList->setParentObjId($this->pool_obj_id);
90  $questionList->load();
91 
92  $data = $questionList->getQuestionDataArray();
93 
94  $questions = array();
95  foreach ($data as $d) {
96  // list only self assessment question types
97  if (in_array($d["question_type_fi"], $all_ids)) {
98  $questions[] = $d;
99  }
100  }
101  }
102  $this->setData($questions);
103  }
104 
105  protected function fillRow(array $a_set): void
106  {
107  $lng = $this->lng;
108  $ctrl = $this->ctrl;
109 
110  // action: copy
111  $ctrl->setParameter($this->parent_obj, "q_id", $a_set["question_id"]);
112  $ctrl->setParameter($this->parent_obj, "subCmd", "copyQuestion");
113  $this->tpl->setCurrentBlock("cmd");
114  $this->tpl->setVariable(
115  "HREF_CMD",
116  $ctrl->getLinkTarget($this->parent_obj, $this->parent_cmd)
117  );
118  $this->tpl->setVariable(
119  "TXT_CMD",
120  $lng->txt("cont_copy_question_into_page")
121  );
122  $this->tpl->parseCurrentBlock();
123  $ctrl->setParameter($this->parent_obj, "subCmd", "listPoolQuestions");
124 
125  // properties
126  $this->tpl->setVariable("TITLE", $a_set["title"]);
127  $this->tpl->setVariable(
128  "TYPE",
129  $this->questioninfo->getGeneralQuestionProperties($a_set["question_id"])->getTypeName($lng)
130  );
131  }
132 }
setData(array $a_data)
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance) ...
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
setFormName(string $a_name="")
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_pool_ref_id)
ilLanguage $lng
setId(string $a_val)
static _lookupObjId(int $ref_id)
static & _getSelfAssessmentQuestionTypes($all_tags=false)
static _lookupTitle(int $obj_id)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
global $DIC
Definition: shib_login.php:26
setDefaultOrderDirection(string $a_defaultorderdirection)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setParentObjId(?int $parentObjId)
__construct(Container $dic, ilPlugin $plugin)
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)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)