56 private ?
string $tag =
null;
80 $lineItem = new \stdClass();
82 $lineItem->{
'@type'} =
'LineItem';
84 $lineItem->reportingMethod =
'http://purl.imsglobal.org/ctx/lis/v2p1/Result#normalScore';
85 if (!empty($this->resourceId)) {
86 $lineItem->assignedActivity = new \stdClass();
89 $lineItem->scoreConstraints = new \stdClass();
90 $lineItem->scoreConstraints->{
'@type'} =
'NumericLimits';
91 $lineItem->scoreConstraints->normalMaximum = $this->scoreMaximum;
103 $lineItem = new \stdClass();
105 $lineItem->label = $this->label;
106 $lineItem->scoreMaximum = $this->scoreMaximum;
107 if (!empty($this->resourceId)) {
108 $lineItem->resourceId = $this->resourceId;
110 if (!empty($this->tag)) {
111 $lineItem->tag = $this->tag;
126 $reportingMethod =
null;
127 $scoreMaximum =
null;
132 foreach (get_object_vars($item) as
$name => $value) {
135 $label = $item->label;
137 case 'reportingMethod':
138 $reportingMethod = $item->reportingMethod;
140 case 'scoreConstraints':
141 $scoreConstraints = $item->scoreConstraints;
144 $scoreMaximum = $item->scoreMaximum;
146 case 'assignedActivity':
147 if (isset($item->assignedActivity->activityId)) {
148 $activityId = $item->assignedActivity->activityId;
152 $activityId = $item->resourceId;
159 if (is_null($scoreMaximum) && $label && $reportingMethod && $scoreConstraints) {
160 foreach (get_object_vars($scoreConstraints) as
$name => $value) {
161 $method = str_replace(
'Maximum',
'Score',
$name);
162 if (substr($reportingMethod, -strlen($method)) === $method) {
163 $scoreMaximum = $value;
168 if (!is_null($scoreMaximum)) {
169 $obj =
new LineItem($label, $scoreMaximum, $activityId, $tag);
Class to represent a line-item object.
string $resourceId
Resource ID associated with line-item.
static fromJsonObject(object $item)
Generate a LineItem object from its JSON or JSON-LD representation.
int $scoreMaximum
Maximum score of line-item.
toJsonObject()
Generate the JSON object representation of the line-item.
__construct(string $label, int $scoreMaximum, string $resourceId=null, string $tag=null)
Class constructor.
string $tag
Tag of line-item.
toJsonldObject()
Generate the JSON-LD object representation of the line-item.
string $label
Label of line-item.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...