ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Properties.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\Refinery\Factory as Refinery;
26use ILIAS\UI\Factory as UIFactory;
30
31class Properties implements Property
32{
33 private ?PropertySequence $sequence = null;
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
69 {
70 $clone = clone $this;
71 $clone->sequence = $sequence;
72 return $clone;
73 }
74
76 {
78 }
79
81 {
82 $clone = clone $this;
83 $clone->aggregated_results = $aggregated_results;
84 return $clone;
85 }
86
87 public function getAsQuestionsTableRow(
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}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
__construct(private readonly int $question_id, private readonly GeneralQuestionProperties $question_properties,)
Definition: Properties.php:36
PropertyAggregatedResults $aggregated_results
Definition: Properties.php:34
withSequenceInformation(PropertySequence $sequence)
Definition: Properties.php:68
getAsQuestionsTableRow(Language $lng, UIFactory $ui_factory, Refinery $refinery, \Closure $question_target_link_builder, OrderingRowBuilder $row_builder, TitleColumnsBuilder $title_builder)
Definition: Properties.php:87
withAggregatedResults(PropertyAggregatedResults $aggregated_results)
Definition: Properties.php:80
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
link(string $caption, string $href, bool $new_viewport=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31