ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilAssQuestionHint Class Reference
+ Collaboration diagram for ilAssQuestionHint:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getId ()
 returns the hint id More...
 
 setId ($id)
 sets the passed hint id More...
 
 getQuestionId ()
 returns the question id the hint currently relates to More...
 
 setQuestionId ($questionId)
 sets the passed question id so hint relates to it More...
 
 getIndex ()
 returns the ordering index of hint More...
 
 setIndex ($index)
 sets the passed hint ordering index More...
 
 getPoints ()
 returns the points to ground-off for this hint More...
 
 setPoints ($points)
 sets the passed points to ground-off for this hint More...
 
 getText ()
 returns the hint text More...
 
 setText ($text)
 sets the passed hint text More...
 
 load ($id)
 loads the hint dataset with passed id from database and assigns it the to this hint object instance More...
 
 save ()
 saves the current hint object state to database. More...
 
 delete ()
 deletes the persisted hint object in database by deleting the hint dataset identified by hint id More...
 
 getPageObjectType ()
 

Static Public Member Functions

static assignDbRow (self $questionHint, $hintDbRow)
 assigns the field elements of passed hint db row array to the corresponding hint object properties of passed hint object instance More...
 
static deleteById ($hintId)
 deletes the persisted hint object in database by deleting the hint dataset identified by hint id More...
 
static getInstanceById ($hintId)
 creates a hint object instance, loads the persisted hint dataset identified by passed hint id from database and assigns it as object state More...
 
static getHintIndexLabel (ilLanguage $lng, $hintIndex)
 

Data Fields

const PAGE_OBJECT_TYPE = 'qht'
 

Private Member Functions

 update ()
 persists the current object state to database by updating an existing dataset identified by hint id More...
 
 insert ()
 persists the current object state to database by inserting a new dataset with a new hint id fetched from primary key sequence More...
 

Private Attributes

 $id = null
 
 $questionId = null
 
 $index = null
 
 $points = null
 
 $text = null
 

Detailed Description

Definition at line 14 of file class.ilAssQuestionHint.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionHint::__construct ( )

Constructor.

@access public

Definition at line 65 of file class.ilAssQuestionHint.php.

66 {
67
68 }

Member Function Documentation

◆ assignDbRow()

static ilAssQuestionHint::assignDbRow ( self  $questionHint,
  $hintDbRow 
)
static

assigns the field elements of passed hint db row array to the corresponding hint object properties of passed hint object instance

@access public

Parameters
self$questionHint
array$hintDbRow

Definition at line 303 of file class.ilAssQuestionHint.php.

304 {
305 foreach($hintDbRow as $field => $value)
306 {
307 switch($field)
308 {
309 case 'qht_hint_id': $questionHint->setId($value); break;
310 case 'qht_question_fi': $questionHint->setQuestionId($value); break;
311 case 'qht_hint_index': $questionHint->setIndex($value); break;
312 case 'qht_hint_points': $questionHint->setPoints($value); break;
313 case 'qht_hint_text': $questionHint->setText($value); break;
314
315 default: throw new ilTestQuestionPoolException("invalid db field identifier ($field) given!");
316 }
317 }
318 }

Referenced by ilAssQuestionHintList\getListByHintIds(), ilAssQuestionHintList\getListByQuestionId(), and load().

+ Here is the caller graph for this function:

◆ delete()

ilAssQuestionHint::delete ( )

deletes the persisted hint object in database by deleting the hint dataset identified by hint id

Returns
integer $affectedRows

Definition at line 289 of file class.ilAssQuestionHint.php.

290 {
291 return self::deleteById($this->getId());
292 }
static deleteById($hintId)
deletes the persisted hint object in database by deleting the hint dataset identified by hint id
getId()
returns the hint id

References deleteById(), and getId().

+ Here is the call graph for this function:

◆ deleteById()

static ilAssQuestionHint::deleteById (   $hintId)
static

deletes the persisted hint object in database by deleting the hint dataset identified by hint id

@access public

@global ilDB $ilDB

Parameters
integer$hintId
Returns
integer $affectedRows

Definition at line 330 of file class.ilAssQuestionHint.php.

331 {
332 global $ilDB;
333
334 $query = "
335 DELETE FROM qpl_hints
336 WHERE qht_hint_id = %s
337 ";
338
339 return $ilDB->manipulateF(
340 $query, array('integer'), array($hintId)
341 );
342 }
global $ilDB

References $ilDB, and $query.

Referenced by delete().

+ Here is the caller graph for this function:

◆ getHintIndexLabel()

static ilAssQuestionHint::getHintIndexLabel ( ilLanguage  $lng,
  $hintIndex 
)
static

Definition at line 365 of file class.ilAssQuestionHint.php.

366 {
367 return sprintf($lng->txt('tst_question_hints_index_column_label'), $hintIndex);
368 }
global $lng
Definition: privfeed.php:40

References $lng.

Referenced by ilAssQuestionHintPageObjectCommandForwarder\buildRequestPresentationPageObjectGUI(), and ilAssQuestionHintsTableGUI\fillRow().

+ Here is the caller graph for this function:

◆ getId()

ilAssQuestionHint::getId ( )

returns the hint id

@access public

Returns
integer $id

Definition at line 76 of file class.ilAssQuestionHint.php.

References $id.

Referenced by delete(), insert(), save(), ilAssQuestionHintTracking\storeRequest(), ilAssQuestionPreviewHintTracking\storeRequest(), and update().

+ Here is the caller graph for this function:

◆ getIndex()

ilAssQuestionHint::getIndex ( )

returns the ordering index of hint

@access public

Returns
integer $index

Definition at line 120 of file class.ilAssQuestionHint.php.

121 {
122 return $this->index;
123 }

References $index.

Referenced by insert(), and update().

+ Here is the caller graph for this function:

◆ getInstanceById()

static ilAssQuestionHint::getInstanceById (   $hintId)
static

creates a hint object instance, loads the persisted hint dataset identified by passed hint id from database and assigns it as object state

@access public

Parameters
integer$hintId
Returns
self $hintInstance

Definition at line 353 of file class.ilAssQuestionHint.php.

354 {
355 $questionHint = new self();
356 $questionHint->load($hintId);
357 return $questionHint;
358 }

Referenced by ilAssQuestionHintTracking\getNextRequestableHint(), ilAssQuestionPreviewHintTracking\getNextRequestableHint(), ilAssQuestionHintsGUI\initHintOrderingClipboardNotification(), ilAssQuestionHintsGUI\pasteFromOrderingClipboardAfterCmd(), ilAssQuestionHintsGUI\pasteFromOrderingClipboardBeforeCmd(), and ilAssQuestionHintRequestGUI\showHintCmd().

+ Here is the caller graph for this function:

◆ getPageObjectType()

ilAssQuestionHint::getPageObjectType ( )

Definition at line 360 of file class.ilAssQuestionHint.php.

361 {
363 }

References PAGE_OBJECT_TYPE.

◆ getPoints()

ilAssQuestionHint::getPoints ( )

returns the points to ground-off for this hint

@access public

Returns
integer $points

Definition at line 142 of file class.ilAssQuestionHint.php.

143 {
144 return $this->points;
145 }

References $points.

Referenced by insert(), and update().

+ Here is the caller graph for this function:

◆ getQuestionId()

ilAssQuestionHint::getQuestionId ( )

returns the question id the hint currently relates to

@access public

Returns
integer $questionId

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

References $questionId.

Referenced by insert(), and update().

+ Here is the caller graph for this function:

◆ getText()

ilAssQuestionHint::getText ( )

returns the hint text

@access public

Returns
string $text

Definition at line 164 of file class.ilAssQuestionHint.php.

165 {
166 return $this->text;
167 }

References $text.

Referenced by insert(), and update().

+ Here is the caller graph for this function:

◆ insert()

ilAssQuestionHint::insert ( )
private

persists the current object state to database by inserting a new dataset with a new hint id fetched from primary key sequence

@access private @global ilDB $ilDB

Returns
boolean $success

Definition at line 268 of file class.ilAssQuestionHint.php.

269 {
270 global $ilDB;
271
272 $this->setId($ilDB->nextId('qpl_hints'));
273
274 return $ilDB->insert('qpl_hints', array(
275 'qht_hint_id' => array('integer', $this->getId()),
276 'qht_question_fi' => array('integer', $this->getQuestionId()),
277 'qht_hint_index' => array('integer', $this->getIndex()),
278 'qht_hint_points' => array('float', $this->getPoints()),
279 'qht_hint_text' => array('clob', $this->getText())
280 ));
281 }
getPoints()
returns the points to ground-off for this hint
getText()
returns the hint text
getQuestionId()
returns the question id the hint currently relates to
setId($id)
sets the passed hint id
getIndex()
returns the ordering index of hint

References $ilDB, getId(), getIndex(), getPoints(), getQuestionId(), getText(), and setId().

Referenced by save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

ilAssQuestionHint::load (   $id)

loads the hint dataset with passed id from database and assigns it the to this hint object instance

@access public @global ilDB $ilDB

Parameters
integer$id
Returns
boolean $success

Definition at line 189 of file class.ilAssQuestionHint.php.

190 {
191 global $ilDB;
192
193 $query = "
194 SELECT qht_hint_id,
195 qht_question_fi,
196 qht_hint_index,
197 qht_hint_points,
198 qht_hint_text
199
200 FROM qpl_hints
201
202 WHERE qht_hint_id = %s
203 ";
204
205 $res = $ilDB->queryF(
206 $query, array('integer'), array((int)$id)
207 );
208
209 while( $row = $ilDB->fetchAssoc($res) )
210 {
211 self::assignDbRow($this, $row);
212
213 return true;
214 }
215
216 return false;
217 }
static assignDbRow(self $questionHint, $hintDbRow)
assigns the field elements of passed hint db row array to the corresponding hint object properties of...

References $id, $ilDB, $query, $res, $row, and assignDbRow().

+ Here is the call graph for this function:

◆ save()

ilAssQuestionHint::save ( )

saves the current hint object state to database.

it performs an insert or update, depending on the current initialisation of the hint id property

a valid initialised id leads to an update, a non or invalid initialised id leads to an insert

@access public

Returns
boolean $success

Definition at line 228 of file class.ilAssQuestionHint.php.

229 {
230 if( $this->getId() ) return $this->update();
231 else return $this->insert();
232 }
update()
persists the current object state to database by updating an existing dataset identified by hint id
insert()
persists the current object state to database by inserting a new dataset with a new hint id fetched f...

References getId(), insert(), and update().

+ Here is the call graph for this function:

◆ setId()

ilAssQuestionHint::setId (   $id)

sets the passed hint id

@access public

Parameters
integer$id

Definition at line 87 of file class.ilAssQuestionHint.php.

88 {
89 $this->id = (int)$id;
90 }

References $id.

Referenced by insert().

+ Here is the caller graph for this function:

◆ setIndex()

ilAssQuestionHint::setIndex (   $index)

sets the passed hint ordering index

@access public

Parameters
integer$index

Definition at line 131 of file class.ilAssQuestionHint.php.

132 {
133 $this->index = (int)$index;
134 }

References $index.

◆ setPoints()

ilAssQuestionHint::setPoints (   $points)

sets the passed points to ground-off for this hint

@access public

Parameters
integer$points

Definition at line 153 of file class.ilAssQuestionHint.php.

154 {
155 $this->points = (float)$points;
156 }

References $points.

◆ setQuestionId()

ilAssQuestionHint::setQuestionId (   $questionId)

sets the passed question id so hint relates to it

@access public

Parameters
integer$questionId

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

110 {
111 $this->questionId = (int)$questionId;
112 }

References $questionId.

◆ setText()

ilAssQuestionHint::setText (   $text)

sets the passed hint text

@access public

Parameters
string$text

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

176 {
177 $this->text = $text;
178 }

References $text.

◆ update()

ilAssQuestionHint::update ( )
private

persists the current object state to database by updating an existing dataset identified by hint id

@access private @global ilDB $ilDB

Returns
boolean $success

Definition at line 242 of file class.ilAssQuestionHint.php.

243 {
244 global $ilDB;
245
246 return $ilDB->update(
247 'qpl_hints',
248 array(
249 'qht_question_fi' => array('integer', $this->getQuestionId()),
250 'qht_hint_index' => array('integer', $this->getIndex()),
251 'qht_hint_points' => array('float', $this->getPoints()),
252 'qht_hint_text' => array('clob', $this->getText())
253 ),
254 array(
255 'qht_hint_id' => array('integer', $this->getId())
256 )
257 );
258 }

References $ilDB, getId(), getIndex(), getPoints(), getQuestionId(), and getText().

Referenced by save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $id

ilAssQuestionHint::$id = null
private

Definition at line 24 of file class.ilAssQuestionHint.php.

Referenced by getId(), load(), and setId().

◆ $index

ilAssQuestionHint::$index = null
private

Definition at line 41 of file class.ilAssQuestionHint.php.

Referenced by getIndex(), and setIndex().

◆ $points

ilAssQuestionHint::$points = null
private

Definition at line 50 of file class.ilAssQuestionHint.php.

Referenced by getPoints(), and setPoints().

◆ $questionId

ilAssQuestionHint::$questionId = null
private

Definition at line 32 of file class.ilAssQuestionHint.php.

Referenced by getQuestionId(), and setQuestionId().

◆ $text

ilAssQuestionHint::$text = null
private

Definition at line 58 of file class.ilAssQuestionHint.php.

Referenced by getText(), and setText().

◆ PAGE_OBJECT_TYPE

const ilAssQuestionHint::PAGE_OBJECT_TYPE = 'qht'

Definition at line 16 of file class.ilAssQuestionHint.php.

Referenced by getPageObjectType().


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