ILIAS  release_8 Revision v8.24
class.ilPCQuestionOverviewGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 public function __construct(
27 ilPageObject $a_pg_obj,
28 ?ilPageContent $a_content_obj,
29 string $a_hier_id,
30 string $a_pc_id = ""
31 ) {
32 global $DIC;
33
34 $this->ctrl = $DIC->ctrl();
35 $this->tpl = $DIC["tpl"];
36 $this->lng = $DIC->language();
37 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
38 }
39
40 public function executeCommand(): void
41 {
42 // get next class that processes or forwards current command
43 $next_class = $this->ctrl->getNextClass($this);
44
45 // get current command
46 $cmd = $this->ctrl->getCmd();
47
48 switch ($next_class) {
49 default:
50 $this->$cmd();
51 break;
52 }
53 }
54
55 public function insert(): void
56 {
57 $this->edit(true);
58 }
59
60 public function edit(
61 bool $a_insert = false
62 ): void {
63 $ilCtrl = $this->ctrl;
66
68
69 // edit form
70 $form = new ilPropertyFormGUI();
71 $form->setFormAction($ilCtrl->getFormAction($this));
72 if ($a_insert) {
73 $form->setTitle($this->lng->txt("cont_ed_insert_qover"));
74 } else {
75 $form->setTitle($this->lng->txt("cont_edit_qover"));
76 }
77
78 // short message
79 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_qover_short_message"), "short");
80 $cb->setInfo($this->lng->txt("cont_qover_short_message_info"));
81 if (!$a_insert) {
82 $cb->setChecked($this->content_obj->getShortMessage());
83 } else {
84 $cb->setChecked(true);
85 }
86 $form->addItem($cb);
87
88 // list wrong questions
89 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_qover_list_wrong_q"), "wrong_questions");
90 $cb->setInfo($this->lng->txt("cont_qover_list_wrong_q_info"));
91 if (!$a_insert) {
92 $cb->setChecked($this->content_obj->getListWrongQuestions());
93 }
94 $form->addItem($cb);
95
96 // save/cancel buttons
97 if ($a_insert) {
98 $form->addCommandButton("create_qover", $lng->txt("save"));
99 $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
100 } else {
101 $form->addCommandButton("update", $lng->txt("save"));
102 $form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
103 }
104 $html = $form->getHTML();
105 $tpl->setContent($html);
106 }
107
111 public function create(): void
112 {
113 $this->content_obj = new ilPCQuestionOverview($this->getPage());
114 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
115 $this->content_obj->setShortMessage(
116 $this->request->getString("short")
117 );
118 $this->content_obj->setListWrongQuestions(
119 $this->request->getString("wrong_questions")
120 );
121 $this->updated = $this->pg_obj->update();
122 if ($this->updated === true) {
123 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
124 } else {
125 $this->insert();
126 }
127 }
128
132 public function update(): void
133 {
134 $this->content_obj->setShortMessage(
135 $this->request->getString("short")
136 );
137 $this->content_obj->setListWrongQuestions(
138 $this->request->getString("wrong_questions")
139 );
140 $this->updated = $this->pg_obj->update();
141 if ($this->updated === true) {
142 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
143 } else {
144 $this->pg_obj->addHierIDs();
145 $this->edit();
146 }
147 }
148}
This class represents a checkbox property in a property form.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
update()
Update question overview.
create()
Create new question overview.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
This class represents a property form user interface.
global $DIC
Definition: feed.php:28
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc