Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

This file contains the class to import a competency framework.

Copyright: 2015 Damyon Wiese
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 489 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

framework_importer:: (15 methods):
  fail()
  get_importid()
  list_required_headers()
  list_found_headers()
  read_mapping_data()
  get_column_data()
  __construct()
  add_children()
  get_error()
  create_competency()
  get_scale_configuration()
  get_scale_id()
  set_related()
  set_rules()
  import()


Class: framework_importer  - X-Ref

This file contains the class to import a competency framework.

fail($msg)   X-Ref
Store an error message for display later

param: string $msg

get_importid()   X-Ref
Get the CSV import id

return: string The import id.

list_required_headers()   X-Ref
Get the list of headers required for import.

return: array The headers (lang strings)

list_found_headers()   X-Ref
Get the list of headers found in the import.

return: array The found headers (names from import)

read_mapping_data($data)   X-Ref
Read the data from the mapping form.

param: array The mapping data.

get_column_data($row, $index)   X-Ref
Get the a column from the imported data.

param: array The imported raw row
param: index The column index we want
return: string The column data.

__construct($text = null, $encoding = null, $delimiter = null, $importid = 0, $mappingdata = null,$useprogressbar = false)   X-Ref
Constructor - parses the raw text for sanity.

param: string $text The raw csv text.
param: string $encoding The encoding of the csv file.
param: string delimiter The specified delimiter for the file.
param: string importid The id of the csv import.
param: array mappingdata The mapping data from the import form.
param: bool $useprogressbar Whether progress bar should be displayed, to avoid html output on CLI.

add_children(& $node, $parentidnumber)   X-Ref
Add a competency to the parent with the specified idnumber.

param: competency $node (pass by reference)
param: string $parentidnumber Add this competency to the parent with this idnumber.

get_error()   X-Ref
Get parse errors.

return: array of errors from parsing the xml.

create_competency($record, $parent, $framework)   X-Ref
Recursive function to add a competency with all it's children.

param: stdClass $record Raw data for the new competency
param: competency $parent
param: competency_framework $framework

get_scale_configuration($scaleid, $config)   X-Ref
Recreate the scale config to point to a new scaleid.

param: int $scaleid
param: string $config json encoded scale data.

get_scale_id($scalevalues, $competencyname)   X-Ref
Search for a global scale that matches this set of scalevalues.
If one is not found it will be created.

param: array $scalevalues
param: string $competencyname (Used to create a new scale if required)
return: int The id of the scale

set_related($record)   X-Ref
Walk through the idnumbers in the relatedidnumbers col and set the relations.

param: stdClass $record

set_rules($record)   X-Ref
Create any completion rule attached to this competency.

param: stdClass $record

import()   X-Ref
Do the job.

return: competency_framework