ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilLTIConsumerResult Class Reference
+ Collaboration diagram for ilLTIConsumerResult:

Public Member Functions

 save ()
 Save a result object. More...
 
 getId ()
 
 getObjId ()
 
 getUsrId ()
 
 getResult ()
 

Static Public Member Functions

static getById (int $a_id)
 Get a result by id. More...
 
static getByKeys (int $a_obj_id, int $a_usr_id, ?bool $a_create=false)
 Get a result by object and user key. More...
 
static getResultsForObject (int $objId)
 

Data Fields

int $id
 
int $obj_id
 
int $usr_id
 
float $result = null
 

Protected Member Functions

 fillData (array $data)
 Fill the properties with data from an array. More...
 

Detailed Description

Definition at line 29 of file class.ilLTIConsumerResult.php.

Member Function Documentation

◆ fillData()

ilLTIConsumerResult::fillData ( array  $data)
protected

Fill the properties with data from an array.

Parameters
arrayassoc data

Definition at line 107 of file class.ilLTIConsumerResult.php.

References ILIAS\Repository\int().

107  : void
108  {
109  $this->id = (int) $data['id'];
110  $this->obj_id = (int) $data['obj_id'];
111  $this->usr_id = (int) $data['usr_id'];
112  $this->result = $data['result'] == null ? null : (float) $data['result'];
113  }
+ Here is the call graph for this function:

◆ getById()

static ilLTIConsumerResult::getById ( int  $a_id)
static

Get a result by id.

Definition at line 54 of file class.ilLTIConsumerResult.php.

References $DIC, and $res.

55  {
56  global $DIC;
57 
58  $query = 'SELECT * FROM lti_consumer_results'
59  . ' WHERE id = ' . $DIC->database()->quote($a_id, 'integer');
60 
61  $res = $DIC->database()->query($query);
62  if ($row = $DIC->database()->fetchAssoc($res)) {
63  $resObj = new ilLTIConsumerResult();
64  $resObj->fillData($row);
65  return $resObj;
66  } else {
67  return null;
68  }
69  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:25

◆ getByKeys()

static ilLTIConsumerResult::getByKeys ( int  $a_obj_id,
int  $a_usr_id,
?bool  $a_create = false 
)
static

Get a result by object and user key.

Returns
ilLTIConsumerResult

Definition at line 75 of file class.ilLTIConsumerResult.php.

References $DIC, and $res.

Referenced by ilObjLTIConsumer\buildLaunchParameters(), ilObjLTIConsumer\buildLaunchParametersLTI13(), ilLTIConsumerGradeServiceScores\checkScore(), ilLPStatusLtiOutcome\getLtiUserResult(), ilLTIConsumerPlaceholderValues\getReachedScore(), and ilLTIConsumerResultService\handleRequest().

76  {
77  global $DIC;
78 
79  $logger = $DIC->logger()->root();
80  $logger->info('getByKeys: ' . $a_obj_id . ' ' . $a_usr_id);
81 
82  $query = 'SELECT * FROM lti_consumer_results'
83  . ' WHERE obj_id = ' . $DIC->database()->quote($a_obj_id, 'integer')
84  . ' AND usr_id = ' . $DIC->database()->quote($a_usr_id, 'integer');
85 
86  $res = $DIC->database()->query($query);
87  if ($row = $DIC->database()->fetchAssoc($res)) {
88  $resObj = new ilLTIConsumerResult();
89  $resObj->fillData($row);
90  return $resObj;
91  } elseif ($a_create) {
92  $resObj = new ilLTIConsumerResult();
93  $resObj->obj_id = $a_obj_id;
94  $resObj->usr_id = $a_usr_id;
95  $resObj->result = null;
96  $resObj->save();
97  return $resObj;
98  } else {
99  return null;
100  }
101  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

◆ getId()

ilLTIConsumerResult::getId ( )

Definition at line 151 of file class.ilLTIConsumerResult.php.

References $id.

151  : int
152  {
153  return $this->id;
154  }

◆ getObjId()

ilLTIConsumerResult::getObjId ( )

Definition at line 156 of file class.ilLTIConsumerResult.php.

References $obj_id.

156  : int
157  {
158  return $this->obj_id;
159  }

◆ getResult()

ilLTIConsumerResult::getResult ( )

Definition at line 166 of file class.ilLTIConsumerResult.php.

References $result.

166  : ?float
167  {
168  return $this->result;
169  }

◆ getResultsForObject()

static ilLTIConsumerResult::getResultsForObject ( int  $objId)
static
Parameters
$objId
Returns
ilLTIConsumerResult[]

Definition at line 175 of file class.ilLTIConsumerResult.php.

References $DIC, $res, and $results.

175  : array
176  {
177  global $DIC; /* @var \ILIAS\DI\Container $DIC */
178 
179  $query = 'SELECT * FROM lti_consumer_results'
180  . ' WHERE obj_id = ' . $DIC->database()->quote($objId, 'integer');
181 
182  $res = $DIC->database()->query($query);
183 
184  $results = [];
185 
186  if ($row = $DIC->database()->fetchAssoc($res)) {
187  $resObj = new ilLTIConsumerResult();
188  $resObj->fillData($row);
189 
190  $results[$resObj->getUsrId()] = $resObj;
191  }
192 
193  return $results;
194  }
$res
Definition: ltiservices.php:69
$objId
Definition: xapitoken.php:55
global $DIC
Definition: shib_login.php:25
$results

◆ getUsrId()

ilLTIConsumerResult::getUsrId ( )

Definition at line 161 of file class.ilLTIConsumerResult.php.

References $usr_id.

161  : int
162  {
163  return $this->usr_id;
164  }

◆ save()

ilLTIConsumerResult::save ( )

Save a result object.

Definition at line 118 of file class.ilLTIConsumerResult.php.

References $DIC.

Referenced by ilLTIConsumerResultService\replaceResult().

118  : bool
119  {
120  global $DIC; /* @var \ILIAS\DI\Container $DIC */
121 
122  $logger = $DIC->logger()->root();
123 
124  $logger->info('save: ' . $this->obj_id . ' ' . $this->usr_id);
125 
126  if (!isset($this->usr_id) || !isset($this->obj_id)) {
127  return false;
128  }
129  if (!isset($this->id)) {
130  $this->id = $DIC->database()->nextId('lti_consumer_results');
131  }
132 
133  $logger = $DIC->logger()->root();
134 
135  $logger->info('save 2: ' . $this->obj_id . ' ' . $this->usr_id);
136 
137  $DIC->database()->replace(
138  'lti_consumer_results',
139  array(
140  'id' => array('integer', $this->id)
141  ),
142  array(
143  'obj_id' => array('integer', $this->obj_id),
144  'usr_id' => array('integer', $this->usr_id),
145  'result' => array('float', $this->result)
146  )
147  );
148  return true;
149  }
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

Field Documentation

◆ $id

int ilLTIConsumerResult::$id

Definition at line 34 of file class.ilLTIConsumerResult.php.

Referenced by getId().

◆ $obj_id

int ilLTIConsumerResult::$obj_id

Definition at line 39 of file class.ilLTIConsumerResult.php.

Referenced by getObjId().

◆ $result

float ilLTIConsumerResult::$result = null

Definition at line 49 of file class.ilLTIConsumerResult.php.

Referenced by getResult().

◆ $usr_id

int ilLTIConsumerResult::$usr_id

Definition at line 44 of file class.ilLTIConsumerResult.php.

Referenced by getUsrId().


The documentation for this class was generated from the following file: