ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
exObjQuestionPoolGUI Class Reference

When a component consumes the assessment question service for purposes of authoring and managing questions like the current question pool object, it is neccessary to handle the following use cases. More...

+ Collaboration diagram for exObjQuestionPoolGUI:

Public Member Functions

 executeCommand ()
 The question creation and editing is handled by the the ilAsqQuestionAuthoring interface. More...
 
 showQuestions ()
 For question listings the ilAsqQuestionFactory provides a factory method to retrieve an array of associative question data arrays. More...
 
 importQuestions ()
 When a component provides import functionality for assessment questions, it needs to make use of the ILIAS QTI service to get any qti xml parsed to an QTI object graph provided by the QTI service. More...
 
 exportQuestions ()
 When a component provides export functionality for assessment questions, it needs the ilAsqQuestion interface method toQtiXML to retrieve an qti item xml string. More...
 
 deleteQuestion ()
 For the deletion of questions ilAsqQuestion provides the interface method deleteQuestion. More...
 

Detailed Description

When a component consumes the assessment question service for purposes of authoring and managing questions like the current question pool object, it is neccessary to handle the following use cases.

Definition at line 8 of file class.exObjQuestionPoolGUI.php.

Member Function Documentation

◆ deleteQuestion()

exObjQuestionPoolGUI::deleteQuestion ( )

For the deletion of questions ilAsqQuestion provides the interface method deleteQuestion.

The ilAsqFactory is to be used to get the ilAsqQuestion instance for any given questionId. A simple call to deleteQuestion deletes the question and all its data.

use the ilAsqFactory to get an ilAsqQuestion instance that supports the deletion process

Definition at line 138 of file class.exObjQuestionPoolGUI.php.

References $DIC.

139  {
140  global $DIC; /* @var ILIAS\DI\Container $DIC */
141 
142  $questionId = 0; // init from GET parameters
143 
149  $questionInstance = $DIC->question()->getQuestionInstance($questionId);
150  $questionInstance->delete();
151  }
$DIC
Definition: xapitoken.php:46

◆ executeCommand()

exObjQuestionPoolGUI::executeCommand ( )

The question creation and editing is handled by the the ilAsqQuestionAuthoring interface.

It is relevant for the request flow using the ILIAS control structure. This interface will be implemented from the current question GUI classes in the future and provides the executeCommand method that internally performs the different commands.

To integrate the workflow of authoring questions to a consumer, the consumer's GUI class must implement a suitable forward case in its own executeCommand method.

Since the consumer MUST not know about any concrete question type's ilAsqQuestionAuthoring implementation a dynamic switch-case expression is neccessary. The ilAsqService class provides such an expression with a corresponding method. It returns the lowercase class name for the corresponding question type authoring class or the interface name when the current next class in the control flow does not relate to any question type authoring class. An instance of the service class can be requested using $DIC->question()->service().

Definition at line 26 of file class.exObjQuestionPoolGUI.php.

References $DIC.

27  {
28  global $DIC; /* @var ILIAS\DI\Container $DIC */
29 
30  switch ($DIC->ctrl()->getNextClass($this)) {
31  case $DIC->question()->service()->fetchNextAuthoringCommandClass($DIC->ctrl()->getNextClass()):
32 
33  $questionId = 0; // Fetch questionId from Request Parameters
34  $backLink = ''; // Initialise with Back Link to Consumers Back-Landing Page
35 
36  $questionInstance = $DIC->question()->getQuestionInstance($questionId);
37  $questionAuthoringGUI = $DIC->question()->getAuthoringCommandInstance($questionInstance);
38 
39  $questionAuthoringGUI->setBackLink($backLink);
40 
41  $DIC->ctrl()->forwardCommand($questionAuthoringGUI);
42  }
43  }
$DIC
Definition: xapitoken.php:46

◆ exportQuestions()

exObjQuestionPoolGUI::exportQuestions ( )

When a component provides export functionality for assessment questions, it needs the ilAsqQuestion interface method toQtiXML to retrieve an qti item xml string.

Since the QTI service does not support to fetch an QTI xml string based on an QTI object graph, the current implementation of returning the xml string itself will be kept within the toQtiXML interface method.

To export one or more assessment questions the ilAsqFactory provides factory methods to get single or multiple ilAsqQuestion instances.

get questions managed by this parent object

build QTI xml string that will be used for any kind of export

Definition at line 111 of file class.exObjQuestionPoolGUI.php.

References $DIC.

112  {
113  global $DIC; /* @var ILIAS\DI\Container $DIC */
114 
115  $parentObjectId = 0; // init with question pool object id
116 
120  $questions = $DIC->question()->getQuestionInstances($parentObjectId);
121 
126  $qtiXML = '';
127 
128  foreach ($questions as $questionInstance) {
129  $qtiXML .= $questionInstance->toQtiXML();
130  }
131  }
$DIC
Definition: xapitoken.php:46

◆ importQuestions()

exObjQuestionPoolGUI::importQuestions ( )

When a component provides import functionality for assessment questions, it needs to make use of the ILIAS QTI service to get any qti xml parsed to an QTI object graph provided by the QTI service.

To actually import the question as an assessment question the ilAsqQuestion interface method fromQtiItem can be used. To retrieve an empty ilAsqQuestion instance, the question type of the QtiItem needs to be determined.

For the question type determination the ilAsqService class provides a corresponding method. An instance of the service class can be requested using $DIC->question()->service().

parse any qti import xml using the QTI Service and retrieve an array containing ilQTIItem instances

Definition at line 80 of file class.exObjQuestionPoolGUI.php.

References $DIC.

81  {
82  global $DIC; /* @var ILIAS\DI\Container $DIC */
83 
84  $parentObjectId = 0; // init with question pool object id
85 
90  $qtiItems = array(); /* @var ilQTIItem[] $qtiItems */
91 
92  foreach ($qtiItems as $qtiItem) {
93  $questionType = $DIC->question()->service()->determineQuestionTypeByQtiItem($qtiItem);
94  $questionInstance = $DIC->question()->getEmptyQuestionInstance($questionType);
95 
96  $questionInstance->fromQtiItem($qtiItem);
97  $questionInstance->setParentId($parentObjectId);
98  $questionInstance->save();
99  }
100  }
$DIC
Definition: xapitoken.php:46

◆ showQuestions()

exObjQuestionPoolGUI::showQuestions ( )

For question listings the ilAsqQuestionFactory provides a factory method to retrieve an array of associative question data arrays.

This structure can be simply used as data structure for any ilTable2 implementation.

initialise any ilTable2GUI with this data array render initialised ilTable2GUI

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

References $DIC.

51  {
52  global $DIC; /* @var ILIAS\DI\Container $DIC */
53 
54  $parentObjectId = 0; // init with question pool object id
55 
56  $questionDataArray = $DIC->question()->getQuestionDataArray($parentObjectId);
57 
63  $tableGUI = new exQuestionsTableGUI($this, 'showQuestions', '');
64  $tableGUI->setData($questionDataArray);
65 
66  $tableHTML = $tableGUI->getHTML(); // render table
67  }
For that questions that are actually shown in the rows limit of the table corresponding question link...
$DIC
Definition: xapitoken.php:46

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