ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ($a_id)
 Get a result by id. More...
 
static getByKeys ($a_obj_id, $a_usr_id, $a_create=false)
 Get a result by object and user key. More...
 
static getResultsForObject ($objId)
 

Data Fields

 $id
 
 $obj_id
 
 $usr_id
 
 $result
 

Protected Member Functions

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

Detailed Description

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

Member Function Documentation

◆ fillData()

ilLTIConsumerResult::fillData (   $data)
protected

Fill the properties with data from an array.

Parameters
arrayassoc data

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

References $data.

Referenced by getById(), getByKeys(), and getResultsForObject().

99  {
100  $this->id = $data['id'];
101  $this->obj_id = $data['obj_id'];
102  $this->usr_id = $data['usr_id'];
103  $this->result = $data['result'];
104  }
$data
Definition: storeScorm.php:23
+ Here is the caller graph for this function:

◆ getById()

static ilLTIConsumerResult::getById (   $a_id)
static

Get a result by id.

Parameters
integerid
Returns
LTIConsumerResult of null if not exists

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

References $DIC, $query, $res, and fillData().

44  {
45  global $DIC;
46 
47  $query = 'SELECT * FROM lti_consumer_results'
48  . ' WHERE id = ' . $DIC->database()->quote($a_id, 'integer');
49 
50  $res = $DIC->database()->query($query);
51  if ($row = $DIC->database()->fetchAssoc($res)) {
52  $resObj = new ilLTIConsumerResult;
53  $resObj->fillData($row);
54  return $resObj;
55  } else {
56  return null;
57  }
58  }
fillData($data)
Fill the properties with data from an array.
foreach($_POST as $key=> $value) $res
$query
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ getByKeys()

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

Get a result by object and user key.

Parameters
integerobject id
integeruser id
booleansave a new result object result if not exists
Returns
ilLTIConsumerResult

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

References $DIC, $query, $res, fillData(), and save().

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

70  {
71  global $DIC;
72 
73  $query = 'SELECT * FROM lti_consumer_results'
74  . ' WHERE obj_id = ' . $DIC->database()->quote($a_obj_id, 'integer')
75  . ' AND usr_id = ' . $DIC->database()->quote($a_usr_id, 'integer');
76 
77  $res = $DIC->database()->query($query);
78  if ($row = $DIC->database()->fetchAssoc($res)) {
79  $resObj = new ilLTIConsumerResult;
80  $resObj->fillData($row);
81  return $resObj;
82  } elseif ($a_create) {
83  $resObj = new ilLTIConsumerResult;
84  $resObj->obj_id = $a_obj_id;
85  $resObj->usr_id = $a_usr_id;
86  $resObj->result = null;
87  $resObj->save();
88  return $resObj;
89  } else {
90  return null;
91  }
92  }
save()
Save a result object.
fillData($data)
Fill the properties with data from an array.
foreach($_POST as $key=> $value) $res
$query
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilLTIConsumerResult::getId ( )
Returns
int

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

References $id.

137  {
138  return $this->id;
139  }

◆ getObjId()

ilLTIConsumerResult::getObjId ( )
Returns
int

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

References $obj_id.

145  {
146  return $this->obj_id;
147  }

◆ getResult()

ilLTIConsumerResult::getResult ( )
Returns
float

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

References $result.

161  {
162  return $this->result;
163  }

◆ getResultsForObject()

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

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

References $DIC, $objId, $query, $res, $results, and fillData().

170  {
171  global $DIC; /* @var \ILIAS\DI\Container $DIC */
172 
173  $query = 'SELECT * FROM lti_consumer_results'
174  . ' WHERE obj_id = ' . $DIC->database()->quote($objId, 'integer');
175 
176  $res = $DIC->database()->query($query);
177 
178  $results = [];
179 
180  if ($row = $DIC->database()->fetchAssoc($res)) {
181  $resObj = new ilLTIConsumerResult;
182  $resObj->fillData($row);
183 
184  $results[$resObj->getUsrId()] = $resObj;
185  }
186 
187  return $results;
188  }
$objId
Definition: xapitoken.php:41
fillData($data)
Fill the properties with data from an array.
foreach($_POST as $key=> $value) $res
$query
$results
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ getUsrId()

ilLTIConsumerResult::getUsrId ( )
Returns
int

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

References $usr_id.

153  {
154  return $this->usr_id;
155  }

◆ save()

ilLTIConsumerResult::save ( )

Save a result object.

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

References $DIC.

Referenced by getByKeys().

110  {
111  global $DIC; /* @var \ILIAS\DI\Container $DIC */
112 
113  if (!isset($this->usr_id) or !isset($this->obj_id)) {
114  return false;
115  }
116  if (!isset($this->id)) {
117  $this->id = $DIC->database()->nextId('lti_consumer_results');
118  }
119  $DIC->database()->replace(
120  'lti_consumer_results',
121  array(
122  'id' => array('integer', $this->id)
123  ),
124  array(
125  'obj_id' => array('integer', $this->obj_id),
126  'usr_id' => array('integer', $this->usr_id),
127  'result' => array('float', $this->result)
128  )
129  );
130  return true;
131  }
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

Field Documentation

◆ $id

ilLTIConsumerResult::$id

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

Referenced by getId().

◆ $obj_id

ilLTIConsumerResult::$obj_id

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

Referenced by getObjId().

◆ $result

ilLTIConsumerResult::$result

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

Referenced by getResult().

◆ $usr_id

ilLTIConsumerResult::$usr_id

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

Referenced by getUsrId().


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