19 declare(strict_types=1);
32 protected \ILIAS\Notes\Service
$notes;
39 $this->notes = $DIC->notes();
44 return array(
"4.3.0",
"5.0.0");
47 protected function getXmlNamespace(
string $a_entity,
string $a_schema_version): string
49 return "http://www.ilias.de/xml/Modules/Poll/" . $a_entity;
55 protected function getTypes(
string $a_entity,
string $a_version): array
57 if ($a_entity ===
"poll") {
63 "Description" =>
"text",
66 "ViewResults" =>
"integer",
74 "Description" =>
"text",
77 "ViewResults" =>
"integer",
79 "ShowResultsAs" =>
"integer",
80 "ShowComments" =>
"integer",
81 "MaxAnswers" =>
"integer",
82 "ResultSort" =>
"integer",
83 "NonAnon" =>
"integer",
84 "Period" =>
"integer",
85 "PeriodBegin" =>
"integer",
86 "PeriodEnd" =>
"integer" 93 if ($a_entity ===
"poll_answer") {
99 "PollId" =>
"integer",
110 public function readData(
string $a_entity,
string $a_version, array $a_ids): void
114 if ($a_entity ===
"poll") {
115 switch ($a_version) {
118 "pl.question,pl.image,pl.view_results" .
120 " JOIN object_data od ON (od.obj_id = pl.id)" .
121 " WHERE " .
$ilDB->in(
"pl.id", $a_ids,
false,
"integer") .
122 " AND od.type = " .
$ilDB->quote(
"poll",
"text"));
126 ",pl.question,pl.image,pl.view_results,pl.show_results_as" .
127 ",pl.max_answers,pl.result_sort,pl.non_anon,pl.period,pl.period_begin,pl.period_end" .
129 " JOIN object_data od ON (od.obj_id = pl.id)" .
130 " WHERE " .
$ilDB->in(
"pl.id", $a_ids,
false,
"integer") .
131 " AND od.type = " .
$ilDB->quote(
"poll",
"text"));
137 if ($a_entity ===
"poll_answer") {
138 switch ($a_version) {
142 " FROM il_poll_answer WHERE " .
143 $ilDB->in(
"poll_id", $a_ids,
false,
"integer"));
152 ?array $a_rec = null,
158 "poll_answer" => array(
"ids" => $a_rec[
"Id"] ?? null)
164 public function getXmlRecord(
string $a_entity,
string $a_version, array $a_set): array
166 if ($a_entity ===
"poll") {
168 $a_set[
"Dir"] = $dir;
170 $a_set[
"ShowComments"] = $this->notes->domain()->commentsActive((
int) $a_set[
"Id"]);
181 string $a_schema_version
204 if ($new_id = $a_mapping->
getMapping(
"Services/Container",
"objs", (
string) ($a_rec[
"Id"] ??
"0"))) {
212 $newObj->setTitle((
string) ($a_rec[
"Title"] ??
''));
213 $newObj->setDescription((
string) ($a_rec[
"Description"]));
214 if ((
int) $a_rec[
"MaxAnswers"]) {
215 $newObj->setMaxNumberOfAnswers((
int) $a_rec[
"MaxAnswers"]);
217 $newObj->setSortResultByVotes((
bool) ($a_rec[
"ResultSort"] ??
false));
218 $newObj->setNonAnonymous((
bool) ($a_rec[
"NonAnon"] ??
false));
219 if ((
int) $a_rec[
"ShowResultsAs"]) {
220 $newObj->setShowResultsAs((
int) $a_rec[
"ShowResultsAs"]);
222 $newObj->setShowComments((
bool) ($a_rec[
"ShowComments"] ??
false));
223 $newObj->setQuestion((
string) ($a_rec[
"Question"] ??
''));
224 $newObj->setImage((
string) ($a_rec[
"Image"] ??
''));
226 $newObj->setVotingPeriod((
bool) ($a_rec[
"Period"] ?? 0));
227 $newObj->setVotingPeriodBegin((
int) ($a_rec[
"PeriodBegin"] ?? 0));
228 $newObj->setVotingPeriodEnd((
int) ($a_rec[
"PeriodEnd"] ?? 0));
232 if ($a_rec[
"Image"]) {
233 $dir = str_replace(
"..",
"", (
string) ($a_rec[
"Dir"] ??
''));
241 $a_mapping->
addMapping(
"Modules/Poll",
"poll", (
string) ($a_rec[
"Id"] ??
"0"), (
string) $newObj->getId());
245 $poll_id = (
int) $a_mapping->
getMapping(
"Modules/Poll",
"poll", (
string) ($a_rec[
"PollId"] ??
"0"));
248 $poll->saveAnswer((
string) ($a_rec[
"Answer"] ??
''), (
int) ($a_rec[
"pos"] ?? 10));
const VIEW_RESULTS_AFTER_VOTE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getTypes(string $a_entity, string $a_version)
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
ILIAS Notes Service $notes
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
Needs to be overwritten for import use case.
getXmlRecord(string $a_entity, string $a_version, array $a_set)
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static initStorage(int $a_id, ?string $a_subdir=null)
__construct(Container $dic, ilPlugin $plugin)
readData(string $a_entity, string $a_version, array $a_ids)
stripTags(array $rec, array $omit_keys=[])
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getXmlNamespace(string $a_entity, string $a_schema_version)