ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilTestExportPlugin Class Reference

Abstract parent class for all test export plugin classes. More...

+ Inheritance diagram for ilTestExportPlugin:
+ Collaboration diagram for ilTestExportPlugin:

Public Member Functions

 __construct (\ilDBInterface $db, \ilComponentRepositoryWrite $component_repository, string $id)
 
 setTest (ilObjTest $test)
 
 setTimestmap (int $timestmap)
 
 getTimestmap ()
 
 getFormat ()
 
 write ()
 
 getFormatLabel ()
 This method should return a human readable label for your export. More...
 
- Public Member Functions inherited from ilPlugin
 getMessage ()
 
 __construct (\ilDBInterface $db, \ilComponentRepositoryWrite $component_repository, string $id)
 
 getPluginName ()
 
 getId ()
 
 getVersion ()
 Only very little classes seem to care about this: More...
 
 getDirectory ()
 Only very little classes seem to care about this: More...
 
 isActive ()
 Only very little classes seem to care about this: More...
 
 needsUpdate ()
 
 install ()
 
 uninstall ()
 
 activate ()
 This will update (if required) and activate the plugin. More...
 
 deactivate ()
 
 update ()
 
 loadLanguageModule ()
 Load language module for plugin. More...
 
 txt (string $a_var)
 Get Language Variable (prefix will be prepended automatically) More...
 
 getTemplate (string $a_template, bool $a_par1=true, bool $a_par2=true)
 ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 getStyleSheetLocation (string $a_css_file)
 ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 addBlockFile ($a_tpl, $a_var, $a_block, $a_tplname)
 ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 getGlobalScreenProviderCollection ()
 
 exchangeUIRendererAfterInitialization (\ILIAS\DI\Container $dic)
 This methods allows to replace the UI Renderer (see src/UI) of ILIAS after initialization by returning a closure returning a custom renderer. More...
 
 exchangeUIFactoryAfterInitialization (string $dic_key, \ILIAS\DI\Container $dic)
 This methods allows to replace some factory for UI Components (see src/UI) of ILIAS after initialization by returning a closure returning a custom factory. More...
 
- Public Member Functions inherited from ILIAS\Test\ExportImport\Exporter
 deliver ()
 

Protected Member Functions

 getTest ()
 
 buildExportFile (ExportFilename $export_path)
 This method is called if the user wants to export a test of YOUR export type If you throw an exception of type ilException with a respective language variable, ILIAS presents a translated failure message. More...
 
 getFormatIdentifier ()
 A unique identifier which describes your export type, e.g. More...
 
- Protected Member Functions inherited from ilPlugin
 init ()
 Object initialization. More...
 
 getPluginInfo ()
 
 getComponentInfo ()
 
 getPluginSlotInfo ()
 
 afterInstall ()
 If you cannot get rid of the requirement to use this, adjust the install method in your subclass instead. More...
 
 beforeUninstall ()
 If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass instead. More...
 
 afterUninstall ()
 If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass instead. More...
 
 beforeActivation ()
 If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 afterActivation ()
 If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 afterDeactivation ()
 If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 updateDatabase ()
 
 beforeUpdate ()
 If you cannot get rid of the requirement to use this, adjust the update method in your subclass instead. More...
 
 afterUpdate ()
 
 getLanguageHandler ()
 
 buildLanguageHandler ()
 

Protected Attributes

ilObjTest $test = null
 
int $timestmap = -1
 
- Protected Attributes inherited from ilPlugin
ilDBInterface $db
 
ilComponentRepositoryWrite $component_repository
 
string $id
 
ilPluginLanguage $language_handler = null
 
bool $lang_initialised = false
 
ProviderCollection $provider_collection
 
string $message = ''
 

Static Protected Attributes

static $reserved_formats
 

Private Member Functions

 createExportFile (ilGlobalTemplateInterface $main_tpl)
 

Detailed Description

Abstract parent class for all test export plugin classes.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 28 of file class.ilTestExportPlugin.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestExportPlugin::__construct ( \ilDBInterface  $db,
\ilComponentRepositoryWrite  $component_repository,
string  $id 
)

Definition at line 38 of file class.ilTestExportPlugin.php.

References ILIAS\GlobalScreen\Provider\__construct().

42  {
44  }
string $id
ilComponentRepositoryWrite $component_repository
ilDBInterface $db
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ buildExportFile()

ilTestExportPlugin::buildExportFile ( ExportFilename  $export_path)
abstractprotected

This method is called if the user wants to export a test of YOUR export type If you throw an exception of type ilException with a respective language variable, ILIAS presents a translated failure message.

Exceptions
ilException
Parameters
ExportFilename$export_pathThe path to store the export file

Referenced by createExportFile().

+ Here is the caller graph for this function:

◆ createExportFile()

ilTestExportPlugin::createExportFile ( ilGlobalTemplateInterface  $main_tpl)
private

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

References Vendor\Package\$e, buildExportFile(), getFormatIdentifier(), getFormatLabel(), ilPlugin\getId(), getTest(), null, ILIAS\UICore\GlobalTemplate\setOnScreenMessage(), and ilPlugin\txt().

Referenced by getFormat(), and write().

120  : ?string
121  {
122  if ($this->getTest() === null) {
123  throw new ilException('Incomplete object configuration. Please pass an instance of ilObjTest before calling the export!');
124  }
125 
126  try {
127  $export_filename = new ExportFilename($this->getTest()->getId());
128  $this->buildExportFile($export_filename);
129  return $export_filename->getPathname();
130  } catch (ilException $e) {
131  if ($this->txt($e->getMessage()) == '-' . $e->getMessage() . '-') {
132  $main_tpl->setOnScreenMessage('failure', $e->getMessage(), true);
133  } else {
134  $main_tpl->setOnScreenMessage('failure', $this->txt($e->getMessage()), true);
135  }
136  return null;
137  }
138  }
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
txt(string $a_var)
Get Language Variable (prefix will be prepended automatically)
buildExportFile(ExportFilename $export_path)
This method is called if the user wants to export a test of YOUR export type If you throw an exceptio...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFormat()

ilTestExportPlugin::getFormat ( )
final
Exceptions
ilException

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

References $DIC, $file_delivery, createExportFile(), ILIAS\Test\ExportImport\Exporter\deliver(), getFormatIdentifier(), and null.

69  : string
70  {
71  $format_id = $this->getFormatIdentifier();
72 
73  if (!is_string($format_id)) {
74  throw new ilException('The format must be of type string.');
75  }
76 
77  if (!strlen($format_id)) {
78  throw new ilException('The format is empty.');
79  }
80 
81  if (strtolower($format_id) != $format_id) {
82  throw new ilException('Please use a lowercase format.');
83  }
84 
85  if (in_array($format_id, self::$reserved_formats)) {
86  throw new ilException('The format must not be one of: ' . implode(', ', self::$reserved_formats));
87  }
88 
89  return $format_id;
90  }
getFormatIdentifier()
A unique identifier which describes your export type, e.g.
+ Here is the call graph for this function:

◆ getFormatIdentifier()

ilTestExportPlugin::getFormatIdentifier ( )
abstractprotected

A unique identifier which describes your export type, e.g.

imsm There is currently no mapping implemented concerning the filename. Feel free to create csv, xml, zip files ....

Returns
string

Referenced by createExportFile(), and getFormat().

+ Here is the caller graph for this function:

◆ getFormatLabel()

ilTestExportPlugin::getFormatLabel ( )
abstract

This method should return a human readable label for your export.

Returns
string

Referenced by createExportFile().

+ Here is the caller graph for this function:

◆ getTest()

ilTestExportPlugin::getTest ( )
finalprotected

Definition at line 51 of file class.ilTestExportPlugin.php.

References $test.

Referenced by createExportFile().

51  : ?ilObjTest
52  {
53  return $this->test;
54  }
+ Here is the caller graph for this function:

◆ getTimestmap()

ilTestExportPlugin::getTimestmap ( )

Definition at line 61 of file class.ilTestExportPlugin.php.

References $timestmap.

61  : int
62  {
63  return $this->timestmap;
64  }

◆ setTest()

ilTestExportPlugin::setTest ( ilObjTest  $test)
final

Definition at line 46 of file class.ilTestExportPlugin.php.

References $test.

46  : void
47  {
48  $this->test = $test;
49  }

◆ setTimestmap()

ilTestExportPlugin::setTimestmap ( int  $timestmap)

Definition at line 56 of file class.ilTestExportPlugin.php.

References $timestmap.

56  : void
57  {
58  $this->timestmap = $timestmap;
59  }

◆ write()

ilTestExportPlugin::write ( )
final

Implements ILIAS\Test\ExportImport\Exporter.

Definition at line 115 of file class.ilTestExportPlugin.php.

References createExportFile().

115  : ?string
116  {
117  return $this->createExportFile();
118  }
createExportFile(ilGlobalTemplateInterface $main_tpl)
+ Here is the call graph for this function:

Field Documentation

◆ $reserved_formats

ilTestExportPlugin::$reserved_formats
staticprotected
Initial value:
= [
'xml',
'csv'
]

Definition at line 33 of file class.ilTestExportPlugin.php.

◆ $test

ilObjTest ilTestExportPlugin::$test = null
protected

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

Referenced by getTest(), and setTest().

◆ $timestmap

int ilTestExportPlugin::$timestmap = -1
protected

Definition at line 31 of file class.ilTestExportPlugin.php.

Referenced by getTimestmap(), and setTimestmap().


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