ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Properties.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
30 
31 class Properties implements Property
32 {
35 
36  public function __construct(
37  private readonly int $question_id,
38  private readonly GeneralQuestionProperties $question_properties,
39  ) {
40  if ($question_id !== $question_properties->getQuestionId()) {
41  throw new \Exception(
42  sprintf(
43  'The question ids do not match. Id local: %s. Id properties: %s.',
44  $question_id,
45  $question_properties->getQuestionId()
46  )
47  );
48  }
49 
50  $this->aggregated_results = new PropertyAggregatedResults($question_id);
51  }
52 
53  public function getQuestionId(): int
54  {
55  return $this->question_id;
56  }
57 
59  {
60  return $this->question_properties;
61  }
62 
64  {
65  return $this->sequence;
66  }
67 
68  public function withSequenceInformation(PropertySequence $sequence): self
69  {
70  $clone = clone $this;
71  $clone->sequence = $sequence;
72  return $clone;
73  }
74 
76  {
78  }
79 
80  public function withAggregatedResults(PropertyAggregatedResults $aggregated_results): self
81  {
82  $clone = clone $this;
83  $clone->aggregated_results = $aggregated_results;
84  return $clone;
85  }
86 
87  public function getAsQuestionsTableRow(
88  Language $lng,
89  UIFactory $ui_factory,
91  \Closure $question_target_link_builder,
92  OrderingRowBuilder $row_builder,
93  TitleColumnsBuilder $title_builder
94  ): OrderingRow {
95  return $row_builder->buildOrderingRow(
96  (string) $this->question_id,
97  [
98  'question_id' => $this->question_id,
99  'title' => $ui_factory->link()->standard(
100  $refinery->encode()->htmlSpecialCharsAsEntities()->transform(
101  $this->question_properties->getTitle()
102  ),
103  $question_target_link_builder($this->question_id)
104  ),
105  'description' => $this->question_properties->getDescription(),
106  'type_tag' => $this->question_properties->getTypeName($lng),
107  'points' => $this->question_properties->getAvailablePoints(),
108  'author' => $this->question_properties->getAuthor(),
109  'complete' => $this->question_properties->isRequiredInformationComplete(),
110  'lifecycle' => \ilAssQuestionLifecycle::getInstance($this->question_properties->getLifecycle())->getTranslation($lng) ?? '',
111  'qpl' => $title_builder->buildAccessCheckedQuestionpoolTitleAsLink($this->question_properties->getOriginObjectId()),
112  'nr_of_answers' => $this->getAggregatedResults()->getNumberOfAnswers(),
113  'average_points' => $this->getAggregatedResults()->getAveragePoints(),
114  'percentage_points_achieved' => "{$this->getAggregatedResults()->getPercentageOfPointsAchieved()}%"
115  ]
116  );
117  }
118 }
__construct(private readonly int $question_id, private readonly GeneralQuestionProperties $question_properties,)
Definition: Properties.php:36
getAsQuestionsTableRow(Language $lng, UIFactory $ui_factory, Refinery $refinery, \Closure $question_target_link_builder, OrderingRowBuilder $row_builder, TitleColumnsBuilder $title_builder)
Definition: Properties.php:87
buildAccessCheckedQuestionpoolTitleAsLink(?int $qpl_id, ?string $title=null, bool $reference=false)
withAggregatedResults(PropertyAggregatedResults $aggregated_results)
Definition: Properties.php:80
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
PropertyAggregatedResults $aggregated_results
Definition: Properties.php:34
global $lng
Definition: privfeed.php:31
buildOrderingRow(string $id, array $record)
withSequenceInformation(PropertySequence $sequence)
Definition: Properties.php:68