Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
tool_lpimportcsv\framework_importer Class Reference

This file contains the class to import a competency framework. More...

Public Member Functions

 __construct ($text=null, $encoding=null, $delimiter=null, $importid=0, $mappingdata=null, $useprogressbar=false)
 Constructor - parses the raw text for sanity.
 
 add_children (& $node, $parentidnumber)
 Add a competency to the parent with the specified idnumber.
 
 create_competency ($record, $parent, $framework)
 Recursive function to add a competency with all it's children.
 
 fail ($msg)
 Store an error message for display later.
 
 get_error ()
 Get parse errors.
 
 get_importid ()
 Get the CSV import id.
 
 get_scale_configuration ($scaleid, $config)
 Recreate the scale config to point to a new scaleid.
 
 get_scale_id ($scalevalues, $competencyname)
 Search for a global scale that matches this set of scalevalues.
 
 import ()
 Do the job.
 
 list_found_headers ()
 Get the list of headers found in the import.
 

Static Public Member Functions

static list_required_headers ()
 Get the list of headers required for import.
 

Protected Member Functions

 get_column_data ($row, $index)
 Get the a column from the imported data.
 
 read_mapping_data ($data)
 Read the data from the mapping form.
 
 set_related ($record)
 Walk through the idnumbers in the relatedidnumbers col and set the relations.
 
 set_rules ($record)
 Create any completion rule attached to this competency.
 

Protected Attributes

string $error = ''
 $error The errors message from reading the xml
 
array $flat = array()
 $flat The flat competencies tree
 
 $foundheaders = array()
 
array $framework = array()
 $framework The framework info
 
 $importer = null
 
 $importid = 0
 
 $mappings = array()
 
core progress display_if_slow null $progress = null
 $progress The progress bar instance.
 
 $scalecache = array()
 
bool $useprogressbar = false
 $useprogressbar Control whether importing should use progress bars or not.
 

Detailed Description

This file contains the class to import a competency framework.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

tool_lpimportcsv\framework_importer::__construct ( $text = null,
$encoding = null,
$delimiter = null,
$importid = 0,
$mappingdata = null,
$useprogressbar = false )

Constructor - parses the raw text for sanity.

Parameters
string$textThe raw csv text.
string$encodingThe encoding of the csv file.
stringdelimiter The specified delimiter for the file.
stringimportid The id of the csv import.
arraymappingdata The mapping data from the import form.
bool$useprogressbarWhether progress bar should be displayed, to avoid html output on CLI.

Member Function Documentation

◆ add_children()

tool_lpimportcsv\framework_importer::add_children ( & $node,
$parentidnumber )

Add a competency to the parent with the specified idnumber.

Parameters
competency$node(pass by reference)
string$parentidnumberAdd this competency to the parent with this idnumber.

◆ create_competency()

tool_lpimportcsv\framework_importer::create_competency ( $record,
$parent,
$framework )

Recursive function to add a competency with all it's children.

Parameters
stdClass$recordRaw data for the new competency
competency$parent
competency_framework$framework

◆ fail()

tool_lpimportcsv\framework_importer::fail ( $msg)

Store an error message for display later.

Parameters
string$msg

◆ get_column_data()

tool_lpimportcsv\framework_importer::get_column_data ( $row,
$index )
protected

Get the a column from the imported data.

Parameters
arrayThe imported raw row
indexThe column index we want
Return values
stringThe column data.

◆ get_error()

tool_lpimportcsv\framework_importer::get_error ( )

Get parse errors.

Return values
arrayof errors from parsing the xml.

◆ get_importid()

tool_lpimportcsv\framework_importer::get_importid ( )

Get the CSV import id.

Return values
stringThe import id.

◆ get_scale_configuration()

tool_lpimportcsv\framework_importer::get_scale_configuration ( $scaleid,
$config )

Recreate the scale config to point to a new scaleid.

Parameters
int$scaleid
string$configjson encoded scale data.

◆ get_scale_id()

tool_lpimportcsv\framework_importer::get_scale_id ( $scalevalues,
$competencyname )

Search for a global scale that matches this set of scalevalues.

If one is not found it will be created.

Parameters
array$scalevalues
string$competencyname(Used to create a new scale if required)
Return values
intThe id of the scale

◆ import()

tool_lpimportcsv\framework_importer::import ( )

Do the job.

Return values
competency_framework

◆ list_found_headers()

tool_lpimportcsv\framework_importer::list_found_headers ( )

Get the list of headers found in the import.

Return values
arrayThe found headers (names from import)

◆ list_required_headers()

static tool_lpimportcsv\framework_importer::list_required_headers ( )
static

Get the list of headers required for import.

Return values
arrayThe headers (lang strings)

◆ read_mapping_data()

tool_lpimportcsv\framework_importer::read_mapping_data ( $data)
protected

Read the data from the mapping form.

Parameters
arrayThe mapping data.

◆ set_related()

tool_lpimportcsv\framework_importer::set_related ( $record)
protected

Walk through the idnumbers in the relatedidnumbers col and set the relations.

Parameters
stdClass$record

◆ set_rules()

tool_lpimportcsv\framework_importer::set_rules ( $record)
protected

Create any completion rule attached to this competency.

Parameters
stdClass$record

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