19declare(strict_types=1);
25use Psr\Http\Message\ServerRequestInterface;
47 protected UIFactory $ui_factory,
48 protected UIRenderer $ui_renderer,
50 protected ServerRequestInterface $request,
52 protected int $qpl_obj_id,
60 $cmd = $this->
ctrl->getCmd();
61 $this->
ctrl->saveParameter($this, self::PARAM_IDS);
67 if ($this->question_ids === []) {
68 $out[] = $this->ui_factory->messageBox()->failure(
69 $this->
lng->txt(
'qpl_bulkedit_no_ids')
104 throw new \Exception(
"'$cmd'" .
" not implemented");
108 $this->tpl->setContent($this->ui_renderer->render(
$out));
113 if (!$this->request_wrapper->has(self::PARAM_IDS)) {
116 $trafo = $this->
refinery->custom()->transformation(
117 fn($v) => array_map(
'intval', explode(
',', $v))
119 return $this->request_wrapper->retrieve(self::PARAM_IDS, $trafo);
125 $form = $form->withRequest($this->request);
126 $data = $form->getData();
128 if (
$data !==
null && $update($questions,
$data)) {
129 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_bulkedit_success'),
true);
139 foreach ($this->question_ids as $qid) {
147 return $this->
refinery->custom()->transformation(
148 fn(array $v) => array_shift($v)
154 return $this->ui_factory->input()->container()->form()->standard(
155 $this->
ctrl->getFormAction($this, self::CMD_SAVEAUTHOR),
157 $this->ui_factory->input()->field()
158 ->text($this->lng->txt(
'author'))
167 return function (array $questions,
string $author) {
168 foreach ($questions as
$q) {
169 $q->setAuthor($author);
170 $q->saveQuestionDataToDb();
180 return $this->ui_factory->input()->container()->form()->standard(
181 $this->
ctrl->getFormAction($this, self::CMD_SAVELIFECYCLE),
183 $this->ui_factory->input()->field()
184 ->select($this->lng->txt(
'qst_lifecycle'),
$options)
193 return function (array $questions,
string $lifecycle) {
195 foreach ($questions as
$q) {
196 $q->setLifecycle($lc);
206 $form->setFormAction($this->
ctrl->getFormAction($this, self::CMD_SAVETAXONOMIES));
210 foreach ($taxonomy_ids as $taxonomy_id) {
212 $label = sprintf($this->
lng->txt(
'qpl_qst_edit_form_taxonomy'), $taxonomy->getTitle());
213 $postvar =
"tax_node_assign_$taxonomy_id";
217 $taxSelect->setTitle($label);
218 $form->addItem($taxSelect);
220 $form->addCommandButton(self::CMD_SAVETAXONOMIES, $this->
lng->txt(
"qpl_bulk_save_overwrite"));
221 $form->addCommandButton(self::CMD_SAVETAXONOMIESADD, $this->
lng->txt(
"qpl_bulk_save_add"));
228 $post = $this->request->getParsedBody();
229 $form_cmd = array_shift(
$post[
'cmd']);
230 $overwrite = ($form_cmd === $this->
lng->txt(
'qpl_bulk_save_overwrite'));
233 foreach ($taxonomy_ids as $taxonomy_id) {
234 $postvar =
"tax_node_assign_$taxonomy_id";
235 foreach ($questions as
$q) {
237 $assigned_nodes = $assignments->getAssignmentsOfItem(
$q->getId());
240 foreach ($assigned_nodes as $existing) {
241 if ($overwrite && !in_array($existing[
"node_id"],
$post[$postvar])
243 $assignments->deleteAssignment((
int) $existing[
"node_id"],
$q->getId());
245 $skip[] = (
int) $existing[
"node_id"];
249 $values =
$post[$postvar];
250 foreach ($values as $value) {
251 if (!in_array((
int) $value, $skip)) {
252 $assignments->addAssignment((
int) $value,
$q->getId());
257 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_bulkedit_success'),
true);
Builds a Color from either hex- or rgb values.
static instantiateQuestion(int $question_id)
static getDraftInstance()
static getInstance($identifier)
@ilCtrl_Calls ilBulkEditQuestionsGUI: ilFormPropertyDispatchGUI
store(Form\Standard $form, Closure $update)
const CMD_SAVETAXONOMIESADD
__construct(protected ilGlobalTemplateInterface $tpl, protected ilCtrl $ctrl, protected ilLanguage $lng, protected UIFactory $ui_factory, protected UIRenderer $ui_renderer, protected Refinery $refinery, protected ServerRequestInterface $request, protected RequestWrapper $request_wrapper, protected int $qpl_obj_id,)
storeTaxonomies(ilPropertyFormGUI $form)
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface RequestWrapper.
An entity that renders components to a string output.