Merge branch 'MDL-55767-master' of git://github.com/damyon/moodle

This commit is contained in:
Andrew Nicols 2016-10-03 12:55:06 +08:00
commit aac3b0bebb
16 changed files with 1427 additions and 3 deletions

View File

@ -0,0 +1,68 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the form export a competency framework.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_lpimportcsv\form;
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
use moodleform;
use context_system;
use core_competency\api;
require_once($CFG->libdir.'/formslib.php');
/**
* Export Competency framework form.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class export extends moodleform {
/**
* Define the form - called by parent constructor
*/
public function definition() {
$mform = $this->_form;
$context = context_system::instance();
$frameworks = api::list_frameworks('shortname', 'ASC', null, null, $context);
$options = array();
foreach ($frameworks as $framework) {
$options[$framework->get_id()] = $framework->get_shortname();
}
if (empty($options)) {
$mform->addElement('static', 'frameworkid', '', get_string('noframeworks', 'tool_lpimportcsv'));
} else {
$mform->addElement('select', 'frameworkid', get_string('competencyframework', 'tool_lp'), $options);
$mform->setType('frameworkid', PARAM_INT);
$mform->addRule('frameworkid', null, 'required', null, 'client');
$this->add_action_buttons(true, get_string('export', 'tool_lpimportcsv'));
}
$mform->setDisableShortforms();
}
}

View File

@ -0,0 +1,88 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the form for importing a framework from a file.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_lpimportcsv\form;
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
use moodleform;
use core_competency\api;
use core_text;
use csv_import_reader;
require_once($CFG->libdir.'/formslib.php');
/**
* Import Competency framework form.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class import extends moodleform {
/**
* Define the form - called by parent constructor
*/
public function definition() {
global $CFG;
require_once($CFG->libdir . '/csvlib.class.php');
$mform = $this->_form;
$element = $mform->createElement('filepicker', 'importfile', get_string('importfile', 'tool_lpimportcsv'));
$mform->addElement($element);
$mform->addRule('importfile', null, 'required');
$mform->addElement('hidden', 'confirm', 0);
$mform->setType('confirm', PARAM_BOOL);
$choices = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_lpimportcsv'), $choices);
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
$mform->addHelpButton('delimiter_name', 'csvdelimiter', 'tool_lpimportcsv');
$choices = core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'tool_lpimportcsv'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$mform->addHelpButton('encoding', 'encoding', 'tool_lpimportcsv');
$this->add_action_buttons(false, get_string('import', 'tool_lpimportcsv'));
}
/**
* Display an error on the import form.
* @param string $msg
*/
public function set_import_error($msg) {
$mform = $this->_form;
$mform->setElementError('importfile', $msg);
}
}

View File

@ -0,0 +1,75 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the form to confirm the import options for a framework.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_lpimportcsv\form;
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
use moodleform;
use core_competency\api;
use tool_lpimportcsv\framework_importer;
require_once($CFG->libdir.'/formslib.php');
/**
* Import Competency framework form.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class import_confirm extends moodleform {
/**
* Define the form - called by parent constructor
*/
public function definition() {
$importer = $this->_customdata;
$mform = $this->_form;
$mform->addElement('hidden', 'confirm', 1);
$mform->setType('confirm', PARAM_BOOL);
$mform->addElement('hidden', 'importid', $importer->get_importid());
$mform->setType('importid', PARAM_INT);
$requiredheaders = $importer->list_required_headers();
$foundheaders = $importer->list_found_headers();
if (empty($foundheaders)) {
$foundheaders = range(0, count($requiredheaders));
}
$foundheaders[-1] = get_string('none');
foreach ($requiredheaders as $index => $requiredheader) {
$mform->addElement('select', 'header' . $index, $requiredheader, $foundheaders);
if (isset($foundheaders[$index])) {
$mform->setDefault('header' . $index, $index);
} else {
$mform->setDefault('header' . $index, -1);
}
}
$this->add_action_buttons(true, get_string('confirm', 'tool_lpimportcsv'));
}
}

View File

@ -0,0 +1,147 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the csv exporter for a competency framework.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_lpimportcsv;
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
use core_competency\api;
use stdClass;
use csv_export_writer;
/**
* Export Competency framework.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class framework_exporter {
/** @var $framework \core_competency\competency_framework */
protected $framework = null;
/** @var $error string */
protected $error = '';
/**
* Constructor
* @param int $frameworkid The framework id
*/
public function __construct($frameworkid) {
$this->framework = api::read_framework($frameworkid);
}
/**
* Export all the competencies from this framework to a csv file.
*/
public function export() {
global $CFG;
require_once($CFG->libdir . '/csvlib.class.php');
$writer = new csv_export_writer();
$filename = clean_param($this->framework->get_shortname() . '-' . $this->framework->get_idnumber(), PARAM_FILE);
$writer->set_filename($filename);
$headers = framework_importer::list_required_headers();
$writer->add_data($headers);
// Order and number of columns must match framework_importer::list_required_headers().
$row = array(
'',
$this->framework->get_idnumber(),
$this->framework->get_shortname(),
$this->framework->get_description(),
$this->framework->get_descriptionformat(),
$this->framework->get_scale()->compact_items(),
$this->framework->get_scaleconfiguration(),
'',
'',
'',
'',
'',
true,
implode(',', $this->framework->get_taxonomies())
);
$writer->add_data($row);
$filters = array('competencyframeworkid' => $this->framework->get_id());
$competencies = api::list_competencies($filters);
// Index by id so we can lookup parents.
$indexed = array();
foreach ($competencies as $competency) {
$indexed[$competency->get_id()] = $competency;
}
foreach ($competencies as $competency) {
$parentidnumber = '';
if ($competency->get_parentid() > 0) {
$parent = $indexed[$competency->get_parentid()];
$parentidnumber = $parent->get_idnumber();
}
$scalevalues = '';
$scaleconfig = '';
if ($competency->get_scaleid() !== null) {
$scalevalues = $competency->get_scale()->compact_items();
$scaleconfig = $competency->get_scaleconfiguration();
}
$ruleconfig = $competency->get_ruleconfig();
if ($ruleconfig === null) {
$ruleconfig = "null";
}
$allrelated = $competency->get_related_competencies();
$relatedidnumbers = array();
foreach ($allrelated as $onerelated) {
$relatedidnumbers[] = str_replace(',', '%2C', $onerelated->get_idnumber());
}
$relatedidnumbers = implode(',', $relatedidnumbers);
// Order and number of columns must match framework_importer::list_required_headers().
$row = array(
$parentidnumber,
$competency->get_idnumber(),
$competency->get_shortname(),
$competency->get_description(),
$competency->get_descriptionformat(),
$scalevalues,
$scaleconfig,
$competency->get_ruletype(),
$competency->get_ruleoutcome(),
$ruleconfig,
$relatedidnumbers,
$competency->get_id(),
false,
''
);
$writer->add_data($row);
}
$writer->download_file();
}
}

View File

@ -0,0 +1,455 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the class to import a competency framework.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_lpimportcsv;
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
use core_competency\api;
use grade_scale;
use stdClass;
use context_system;
use csv_import_reader;
/**
* This file contains the class to import a competency framework.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class framework_importer {
/** @var string $error The errors message from reading the xml */
protected $error = '';
/** @var array $flat The flat competencies tree */
protected $flat = array();
/** @var array $framework The framework info */
protected $framework = array();
protected $mappings = array();
protected $importid = 0;
protected $importer = null;
protected $foundheaders = array();
/**
* Store an error message for display later
* @param string $msg
*/
public function fail($msg) {
$this->error = $msg;
return false;
}
/**
* Get the CSV import id
* @return string The import id.
*/
public function get_importid() {
return $this->importid;
}
/**
* Get the list of headers required for import.
* @return array The headers (lang strings)
*/
public static function list_required_headers() {
return array(
get_string('parentidnumber', 'tool_lpimportcsv'),
get_string('idnumber', 'tool_lpimportcsv'),
get_string('shortname', 'tool_lpimportcsv'),
get_string('description', 'tool_lpimportcsv'),
get_string('descriptionformat', 'tool_lpimportcsv'),
get_string('scalevalues', 'tool_lpimportcsv'),
get_string('scaleconfiguration', 'tool_lpimportcsv'),
get_string('ruletype', 'tool_lpimportcsv'),
get_string('ruleoutcome', 'tool_lpimportcsv'),
get_string('ruleconfig', 'tool_lpimportcsv'),
get_string('relatedidnumbers', 'tool_lpimportcsv'),
get_string('exportid', 'tool_lpimportcsv'),
get_string('isframework', 'tool_lpimportcsv'),
get_string('taxonomy', 'tool_lpimportcsv'),
);
}
/**
* Get the list of headers found in the import.
* @return array The found headers (names from import)
*/
public function list_found_headers() {
return $this->foundheaders;
}
/**
* Read the data from the mapping form.
* @param array The mapping data.
*/
protected function read_mapping_data($data) {
if ($data) {
return array(
'parentidnumber' => $data->header0,
'idnumber' => $data->header1,
'shortname' => $data->header2,
'description' => $data->header3,
'descriptionformat' => $data->header4,
'scalevalues' => $data->header5,
'scaleconfiguration' => $data->header6,
'ruletype' => $data->header7,
'ruleoutcome' => $data->header8,
'ruleconfig' => $data->header9,
'relatedidnumbers' => $data->header10,
'exportid' => $data->header11,
'isframework' => $data->header12,
'taxonomies' => $data->header13
);
} else {
return array(
'parentidnumber' => 0,
'idnumber' => 1,
'shortname' => 2,
'description' => 3,
'descriptionformat' => 4,
'scalevalues' => 5,
'scaleconfiguration' => 6,
'ruletype' => 7,
'ruleoutcome' => 8,
'ruleconfig' => 9,
'relatedidnumbers' => 10,
'exportid' => 11,
'isframework' => 12,
'taxonomies' => 13
);
}
}
/**
* 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.
*/
protected function get_column_data($row, $index) {
if ($index < 0) {
return '';
}
return isset($row[$index]) ? $row[$index] : '';
}
/**
* 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.
*/
public function __construct($text = null, $encoding = null, $delimiter = null, $importid = 0, $mappingdata = null) {
global $CFG;
// The format of our records is:
// Parent ID number, ID number, Shortname, Description, Description format, Scale values, Scale configuration,
// Rule type, Rule outcome, Rule config, Is framework, Taxonomy.
// The idnumber is concatenated with the category names.
require_once($CFG->libdir . '/csvlib.class.php');
$type = 'competency_framework';
if (!$importid) {
if ($text === null) {
return;
}
$this->importid = csv_import_reader::get_new_iid($type);
$this->importer = new csv_import_reader($this->importid, $type);
if (!$this->importer->load_csv_content($text, $encoding, $delimiter)) {
$this->fail(get_string('invalidimportfile', 'tool_lpimportcsv'));
$this->importer->cleanup();
return;
}
} else {
$this->importid = $importid;
$this->importer = new csv_import_reader($this->importid, $type);
}
if (!$this->importer->init()) {
$this->fail(get_string('invalidimportfile', 'tool_lpimportcsv'));
$this->importer->cleanup();
return;
}
$this->foundheaders = $this->importer->get_columns();
$domainid = 1;
$flat = array();
$framework = null;
while ($row = $this->importer->next()) {
$mapping = $this->read_mapping_data($mappingdata);
$parentidnumber = $this->get_column_data($row, $mapping['parentidnumber']);
$idnumber = $this->get_column_data($row, $mapping['idnumber']);
$shortname = $this->get_column_data($row, $mapping['shortname']);
$description = $this->get_column_data($row, $mapping['description']);
$descriptionformat = $this->get_column_data($row, $mapping['descriptionformat']);
$scalevalues = $this->get_column_data($row, $mapping['scalevalues']);
$scaleconfiguration = $this->get_column_data($row, $mapping['scaleconfiguration']);
$ruletype = $this->get_column_data($row, $mapping['ruletype']);
$ruleoutcome = $this->get_column_data($row, $mapping['ruleoutcome']);
$ruleconfig = $this->get_column_data($row, $mapping['ruleconfig']);
$relatedidnumbers = $this->get_column_data($row, $mapping['relatedidnumbers']);
$exportid = $this->get_column_data($row, $mapping['exportid']);
$isframework = $this->get_column_data($row, $mapping['isframework']);
$taxonomies = $this->get_column_data($row, $mapping['taxonomies']);
if ($isframework) {
$framework = new stdClass();
$framework->idnumber = shorten_text(clean_param($idnumber, PARAM_TEXT), 100);
$framework->shortname = shorten_text(clean_param($shortname, PARAM_TEXT), 100);
$framework->description = clean_param($description, PARAM_RAW);
$framework->descriptionformat = clean_param($descriptionformat, PARAM_INT);
$framework->scalevalues = $scalevalues;
$framework->scaleconfiguration = $scaleconfiguration;
$framework->taxonomies = $taxonomies;
$framework->children = array();
} else {
$competency = new stdClass();
$competency->parentidnumber = clean_param($parentidnumber, PARAM_TEXT);
$competency->idnumber = shorten_text(clean_param($idnumber, PARAM_TEXT), 100);
$competency->shortname = shorten_text(clean_param($shortname, PARAM_TEXT), 100);
$competency->description = clean_param($description, PARAM_RAW);
$competency->descriptionformat = clean_param($descriptionformat, PARAM_INT);
$competency->ruletype = $ruletype;
$competency->ruleoutcome = clean_param($ruleoutcome, PARAM_INT);
$competency->ruleconfig = $ruleconfig;
$competency->relatedidnumbers = $relatedidnumbers;
$competency->exportid = $exportid;
$competency->scalevalues = $scalevalues;
$competency->scaleconfiguration = $scaleconfiguration;
$competency->children = array();
$flat[$idnumber] = $competency;
}
}
$this->flat = $flat;
$this->framework = $framework;
$this->importer->close();
if ($this->framework == null) {
$this->fail(get_string('invalidimportfile', 'tool_lpimportcsv'));
return;
} else {
// Build a tree from this flat list.
$this->add_children($this->framework, '');
}
}
/**
* 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.
*/
public function add_children(& $node, $parentidnumber) {
foreach ($this->flat as $competency) {
if ($competency->parentidnumber == $parentidnumber) {
$node->children[] = $competency;
$this->add_children($competency, $competency->idnumber);
}
}
}
/**
* Get parse errors.
* @return array of errors from parsing the xml.
*/
public function get_error() {
return $this->error;
}
/**
* 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
*/
public function create_competency($record, $parent, $framework) {
$competency = new stdClass();
$competency->competencyframeworkid = $framework->get_id();
$competency->shortname = $record->shortname;
if (!empty($record->description)) {
$competency->description = $record->description;
$competency->descriptionformat = $record->descriptionformat;
}
if ($record->scalevalues) {
$competency->scaleid = $this->get_scale_id($record->scalevalues, $competency->shortname);
$competency->scaleconfiguration = $this->get_scale_configuration($competency->scaleid, $record->scaleconfiguration);
}
if ($parent) {
$competency->parentid = $parent->get_id();
} else {
$competency->parentid = 0;
}
$competency->idnumber = $record->idnumber;
if (!empty($competency->idnumber) && !empty($competency->shortname)) {
$comp = api::create_competency($competency);
if ($record->exportid) {
$this->mappings[$record->exportid] = $comp;
}
$record->createdcomp = $comp;
foreach ($record->children as $child) {
$this->create_competency($child, $comp, $framework);
}
return $comp;
}
return false;
}
/**
* Recreate the scale config to point to a new scaleid.
* @param int $scaleid
* @param string $config json encoded scale data.
*/
public function get_scale_configuration($scaleid, $config) {
$asarray = json_decode($config);
$asarray[0]->scaleid = $scaleid;
return json_encode($asarray);
}
/**
* 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
*/
public function get_scale_id($scalevalues, $competencyname) {
global $CFG, $USER;
require_once($CFG->libdir . '/gradelib.php');
$allscales = grade_scale::fetch_all_global();
$matchingscale = false;
foreach ($allscales as $scale) {
if ($scale->compact_items() == $scalevalues) {
$matchingscale = $scale;
}
}
if (!$matchingscale) {
// Create it.
$newscale = new grade_scale();
$newscale->name = get_string('competencyscale', 'tool_lpimportcsv', $competencyname);
$newscale->courseid = 0;
$newscale->userid = $USER->id;
$newscale->scale = $scalevalues;
$newscale->description = get_string('competencyscaledescription', 'tool_lpimportcsv');
$newscale->insert();
return $newscale->id;
}
return $matchingscale->id;
}
/**
* Walk through the idnumbers in the relatedidnumbers col and set the relations.
* @param stdClass $record
*/
protected function set_related($record) {
$comp = $record->createdcomp;
if ($record->relatedidnumbers) {
$allidnumbers = explode(',', $record->relatedidnumbers);
foreach ($allidnumbers as $rawidnumber) {
$idnumber = str_replace('%2C', ',', $rawidnumber);
if (isset($this->flat[$idnumber])) {
$relatedcomp = $this->flat[$idnumber]->createdcomp;
api::add_related_competency($comp->get_id(), $relatedcomp->get_id());
}
}
}
foreach ($record->children as $child) {
$this->set_related($child);
}
}
/**
* Create any completion rule attached to this competency.
* @param stdClass $record
*/
protected function set_rules($record) {
$comp = $record->createdcomp;
if ($record->ruletype) {
$class = $record->ruletype;
if (class_exists($class)) {
$oldruleconfig = $record->ruleconfig;
if ($oldruleconfig == "null") {
$oldruleconfig = null;
}
$newruleconfig = $class::migrate_config($oldruleconfig, $this->mappings);
$comp->set_ruleconfig($newruleconfig);
$comp->set_ruletype($class);
$comp->set_ruleoutcome($record->ruleoutcome);
$comp->update();
}
}
foreach ($record->children as $child) {
$this->set_rules($child);
}
}
/**
* Do the job.
* @return competency_framework
*/
public function import() {
$record = clone $this->framework;
unset($record->children);
$record->scaleid = $this->get_scale_id($record->scalevalues, $record->shortname);
$record->scaleconfiguration = $this->get_scale_configuration($record->scaleid, $record->scaleconfiguration);
unset($record->scalevalues);
$record->contextid = context_system::instance()->id;
$framework = api::create_framework($record);
// Now all the children.
foreach ($this->framework->children as $comp) {
$this->create_competency($comp, null, $framework);
}
// Now create the rules.
foreach ($this->framework->children as $record) {
$this->set_rules($record);
$this->set_related($record);
}
$this->importer->cleanup();
return $framework;
}
}

View File

@ -0,0 +1,47 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Page to continue after an action.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../../../config.php');
require_once($CFG->libdir.'/adminlib.php');
$pagetitle = get_string('pluginname', 'tool_lpimportcsv');
$context = context_system::instance();
$id = required_param('id', PARAM_INT);
$url = new moodle_url("/admin/tool/lpimportcsv/index.php");
$PAGE->set_context($context);
$PAGE->set_url($url);
$PAGE->set_title($pagetitle);
$PAGE->set_pagelayout('admin');
$PAGE->set_heading($pagetitle);
echo $OUTPUT->header();
echo $OUTPUT->heading($pagetitle);
$urlparams = ['competencyframeworkid' => $id, 'pagecontextid' => $context->id];
$frameworksurl = new moodle_url('/admin/tool/lp/competencies.php', $urlparams);
echo $OUTPUT->notification(get_string('competencyframeworkcreated', 'tool_lp'), 'notifysuccess');
echo $OUTPUT->continue_button($frameworksurl);
echo $OUTPUT->footer();

View File

@ -0,0 +1,57 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Page to export a competency framework as a CSV.
*
* @package tool_lpimportcsv
* @copyright 2016 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../../../config.php');
require_once($CFG->libdir.'/adminlib.php');
$pagetitle = get_string('exportnavlink', 'tool_lpimportcsv');
$context = context_system::instance();
$url = new moodle_url("/admin/tool/lpimportcsv/export.php");
$PAGE->set_context($context);
$PAGE->set_url($url);
$PAGE->set_title($pagetitle);
$PAGE->set_pagelayout('admin');
$PAGE->set_heading($pagetitle);
$form = new \tool_lpimportcsv\form\export($url->out(false), array('persistent' => null, 'context' => $context));
if ($form->is_cancelled()) {
redirect(new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => $context->id)));
} else if ($data = $form->get_data()) {
require_sesskey();
$exporter = new \tool_lpimportcsv\framework_exporter($data->frameworkid);
$exporter->export();
die();
}
echo $OUTPUT->header();
echo $OUTPUT->heading($pagetitle);
$form->display();
echo $OUTPUT->footer();

View File

@ -0,0 +1,83 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Import a framework.
*
* @package tool_lpimportcsv
* @copyright 2016 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../../../config.php');
require_once($CFG->libdir.'/adminlib.php');
$pagetitle = get_string('pluginname', 'tool_lpimportcsv');
$context = context_system::instance();
$url = new moodle_url("/admin/tool/lpimportcsv/index.php");
$PAGE->set_context($context);
$PAGE->set_url($url);
$PAGE->set_title($pagetitle);
$PAGE->set_pagelayout('admin');
$PAGE->set_heading($pagetitle);
$form = null;
if (optional_param('needsconfirm', 0, PARAM_BOOL)) {
$form = new \tool_lpimportcsv\form\import($url->out(false));
} else if (optional_param('confirm', 0, PARAM_BOOL)) {
$importer = new \tool_lpimportcsv\framework_importer();
$form = new \tool_lpimportcsv\form\import_confirm(null, $importer);
} else {
$form = new \tool_lpimportcsv\form\import($url->out(false));
}
if ($form->is_cancelled()) {
$form = new \tool_lpimportcsv\form\import($url->out(false));
} else if ($data = $form->get_data()) {
require_sesskey();
if ($data->confirm) {
$importid = $data->importid;
$importer = new \tool_lpimportcsv\framework_importer(null, null, null, $importid, $data);
$error = $importer->get_error();
if ($error) {
$form = new \tool_lpimportcsv\form\import($url->out(false));
$form->set_import_error($error);
} else {
$framework = $importer->import();
redirect(new moodle_url('continue.php', array('id' => $framework->get_id())));
die();
}
} else {
$text = $form->get_file_content('importfile');
$encoding = $data->encoding;
$delimiter = $data->delimiter_name;
$importer = new \tool_lpimportcsv\framework_importer($text, $encoding, $delimiter);
$confirmform = new \tool_lpimportcsv\form\import_confirm(null, $importer);
$form = $confirmform;
$pagetitle = get_string('confirmcolumnmappings', 'tool_lpimportcsv');
}
}
echo $OUTPUT->header();
echo $OUTPUT->heading($pagetitle);
$form->display();
echo $OUTPUT->footer();

View File

@ -0,0 +1,53 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'tool_lpimportcsv', language 'en'
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['competencyscale'] = 'Competency Scale: {$a}';
$string['competencyscaledescription'] = 'Competency scale created by import';
$string['confirmcolumnmappings'] = 'Confirm the columns mappings';
$string['confirm'] = 'Confirm';
$string['csvdelimiter'] = 'CSV delimiter';
$string['csvdelimiter_help'] = 'CSV delimiter of the CSV file.';
$string['description'] = 'Description';
$string['descriptionformat'] = 'Description format';
$string['encoding'] = 'Encoding';
$string['encoding_help'] = 'Encoding of the CSV file.';
$string['export'] = 'Export';
$string['exportid'] = 'Exported id (optional)';
$string['exportnavlink'] = 'Export competency framework';
$string['idnumber'] = 'Id number';
$string['importfile'] = 'CSV framework description file';
$string['import'] = 'Import';
$string['invalidimportfile'] = 'File format is invalid.';
$string['isframework'] = 'Is framework';
$string['noframeworks'] = 'No competency frameworks have been created yet';
$string['parentidnumber'] = 'Parent id number';
$string['pluginname'] = 'Import competency framework';
$string['relatedidnumbers'] = 'Cross referenced competency id numbers';
$string['ruleconfig'] = 'Rule config (optional)';
$string['ruleoutcome'] = 'Rule outcome (optional)';
$string['ruletype'] = 'Rule type (optional)';
$string['scaleconfiguration'] = 'Scale configuration';
$string['scalevalues'] = 'Scale values';
$string['shortname'] = 'Shortname';
$string['taxonomy'] = 'Taxonomy';

View File

@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Links and settings
*
* This file contains links and settings used by tool_lpimportcsv
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
// Manage competency frameworks page.
$temp = new admin_externalpage(
'toollpimportcsv',
get_string('pluginname', 'tool_lpimportcsv'),
new moodle_url('/admin/tool/lpimportcsv/index.php'),
'moodle/competency:competencymanage'
);
$ADMIN->add('competencies', $temp);
// Export competency framework page.
$temp = new admin_externalpage(
'toollpexportcsv',
get_string('exportnavlink', 'tool_lpimportcsv'),
new moodle_url('/admin/tool/lpimportcsv/export.php'),
'moodle/competency:competencymanage'
);
$ADMIN->add('competencies', $temp);
// No report settings.
$settings = null;

View File

@ -0,0 +1,209 @@
"Parent id number","Id number",Shortname,Description,"Description format","Scale values","Scale configuration","Rule type (optional)","Rule outcome (optional)","Rule config (optional)","Cross referenced competency id numbers","Exported id (optional)","Is framework",Taxonomy
,OECD-CORE,OECD,"<p>The Core Competencies summarise the capabilities that are important across all jobs and that we believe
collectively contribute to the OECDs overall success. At the same time, the importance of Core
Competencies may vary according to the specific job duties and requirements.
The OECD Competency Framework displays fifteen Core Competencies grouped into three clusters.</p><p>• The delivery-related competencies <br>• The interpersonal competencies
<br>• The strategic competencies</p>",1,"Not yet competent,Competent","[{""scaleid"":""2""},{""id"":2,""scaledefault"":1,""proficient"":1}]",,,,,,1,"competency,competency,competency,competency"
,levels,Levels,"<p>Each level of the Core Competencies has behavioural indicators that highlight how an individual can
demonstrate that competency. Behavioural indicators are designed to show the requirements for successful
performance.<br></p>",1,,,,0,null,,1,,
levels,level-1,"Level 1","<p>Level 1 is typically associated with jobs such as Assistants, Secretaries and Operators.<br></p>",1,,,,0,null,"S-DT-1,S-DT-2,S-OA-1,S-OA-2,S-SN-1,S-SN-2,S-SN-3,S-ST-1,DR-AT1,DR-AT-2,DR-AF-1,DR-AF-2,DR-AF-3,DR-DS-1,DR-DS-2,DR-FT-1,DR-FT-2,DR-FT-3,DR-MR-1,DR-MR-2,DR-TW-1,DR-TW-2,DR-TW-3,I-CF-1,I-CF-2,I-CF-3,I-DS-1,I-DS-2,I-DS-3,I-DS-4,I-I-1,I-I-2,I-I-3,I-I-4,I-N-1,I-N-3,I-OK-1,I-OK-2,I-OK-3",2,,
levels,level-2,"Level 2","<p>Level 2 is typically associated with jobs such as Statisticians, Corporate Management and Administration
Assistants/Officers, Logistics Officers and Documentalists.<br></p>",1,,,,0,null,,3,,
levels,level-3,"Level 3","<p>Level 3 is typically associated with jobs such as Economists/Policy Analysts, IT Analysts and HR Advisers.<br></p>",1,,,,0,null,,4,,
levels,level-4,"Level 4","<p>Level 4 is typically associated with jobs such as Senior Economists/Policy Analysts or Managers<br></p>",1,,,,0,null,,5,,
levels,level-5,"Level 5","<p>Level 5 is typically associated with jobs such as Heads of Division, Counsellors, Deputy Directors and
Directors.<br></p>",1,,,,0,null,,6,,
,competencies,Competencies,,1,,,,0,null,,7,,
competencies,delivery,Delivery-related,"<p>Achieving Results<br></p>",1,,,,0,null,,8,,
competencies,interpersonal,Interpersonal,"<p>Building relationships</p>",1,,,,0,null,,9,,
competencies,strategic,Strategic,"<p>Planning for the future</p>",1,,,,0,null,,10,,
delivery,analytical-thinking,"Analytical Thinking","<p>Analytical Thinking is the ability to identify
patterns across situations that are not obviously
related, and to identify key or underlying issues in
complex situations.<br></p>",1,,,,0,null,,11,,
delivery,acheivement-focus,"Achievement Focus","<p>Achievement Focus is generating results by
assuming responsibility for one's performance
and the correctness of one's interventions, and
recognising opportunities and acting efficiently at
the appropriate moment and within the given
deadlines.<br></p>",1,,,,0,null,,12,,
delivery,drafting-skills,"Drafting Skills","<p>Drafting Skills are based on the ability to
respectfully communicate ideas and information
(often technical) in writing to ensure that
information and messages are understood and
have the desired impact.<br></p>",1,,,,0,null,,13,,
delivery,flexible-thinking,"Flexible Thinking","<p>Flexible Thinking involves the ability to
effectively adapt to a variety of situations,
individuals or groups. It is based on the ability to
understand and appreciate different and opposing perspectives on an issue, to adapt an approach
as the requirements of a situation change, and to
change or easily accept changes in ones own
organisational or job requirements.<br></p>",1,,,,0,null,,14,,
delivery,managing-resources,"Managing Resources","<p>Managing Resources is about understanding
human, financial, and operational resource issues
to make decisions aimed at building and planning
efficient project workflows, and at improving
overall organisational performance.<br></p>",1,,,,0,null,,15,,
delivery,teamwork,"Teamwork and Team Leadership","<p>Teamwork and Team Leadership implies
working co-operatively with others, being a part of
a team, and assuming the role of leader of a
team. In the OECD, people work not only with
their own teams but also with teams and groups
across and outside the Organisation. Therefore
they need to work together effectively with
interdependent goals and common values and
norms to foster a collaborative environment and
drive teams in the same direction.<br></p>",1,,,,0,null,,16,,
interpersonal,client-focus,"Client Focus","<p>Client Focus is based on the ability to
understand internal/external clients (e.g.
Committees, working groups, country
representatives, etc.,) needs and concerns in the
short to long-term and to provide sound
recommendations and/or solutions.<br></p>",1,,,,0,null,,17,,
interpersonal,diplomatic-sensitivity,"Diplomatic Sensitivity","<p>Diplomatic Sensitivity implies understanding
other people. It includes the ability to hear
accurately and understand unspoken, partly
expressed thoughts, feelings and concerns of
others. Included in this competency is an
emphasis on cross-cultural sensitivity.
Proficiency in Diplomatic Sensitivity requires the
ability to keep ones emotions under control and
restrain negative actions when faced with
opposition or hostility from others or when
working under stress.<br></p>",1,,,,0,null,,18,,
interpersonal,influencing,Influencing,"<p>Influencing implies an intention to convince
others in an honest, respectful and sensitive
manner in order to get them to go along with
ones objectives. It can also be the desire to have
a specific impact or effect on others.<br></p>",1,,,,0,null,,19,,
interpersonal,negotiating,Negotiating,"<p>Negotiating involves the ability to work towards
win-win outcomes. At lower levels, this
competency assumes an understanding of ones
counterparts and how to respond to them during
negotiations. At the higher levels, the competency
reflects a focus to achieve value-added results.<br></p>",1,,,,0,null,,20,,
interpersonal,organisational-knowledge,"Organisational Knowledge","<p>Organisational Knowledge is the ability to
understand the power relationships within the
Organisation and with other organisations. It
includes the ability to understand the formal rules
and structures including the ability to identify who
the real decision-makers are as well as the
individuals who can influence them.<br></p>",1,,,,0,null,,21,,
strategic,developing-talent,"Developing Talent","<p>Developing Talent means fostering an
environment that will encourage professional and
personal growth and the transfer of knowledge to
future talent.<br></p>",1,,,,0,null,,22,,
strategic,organisational-alignment,"Organisational Alignment","<p>Organisational Alignment is the ability and
willingness to align ones own behaviour with the
needs, priorities, and goals of the Organisation,
and to act in ways that promote the
Organisations goals or meet organisational
needs. Organisational Alignment means focusing
on the Organisation's mission before one's own
preferences or professional priorities.<br></p>",1,,,,0,null,,23,,
strategic,strategic-networking,"Strategic Networking","<p>Strategic Networking involves working to build
and maintain friendly, trustworthy and open
internal and external relationships and networks
with people who are, or might become, important
actors in achieving strategic-related goals.<br></p>",1,,,,0,null,,24,,
strategic,strategic-thinking,"Strategic Thinking","<p>Strategic Thinking is the ability to develop a
broad, big-picture view of the Organisation and its
mission. Competitive advantage and threats,
industry trends, emerging technology, market
opportunities, stakeholder focus Strategic
Thinking is where these all come together.
Strategic Thinking keeps individuals and groups
focused and helps decide where to invest critical
resources. It includes the ability to link long-range
visions and concepts to daily work.<br></p>",1,,,,0,null,,25,,
analytical-thinking,DR-AT1,"Distinguishes between critical and irrelevant pieces of information","<p>Distinguishes between critical and irrelevant
pieces of information<br></p>",1,,,,0,null,level-1,26,,
analytical-thinking,DR-AT-2,"Gathers information from a variety of sources to reach a conclusion.","<p>Gathers information from a variety of sources
to reach a conclusion.<br></p>",1,,,,0,null,level-1,27,,
acheivement-focus,DR-AF-1,"Defines ambitious, but realistic, personal goals.","<p>Defines ambitious, but realistic, personal
goals.<br></p>",1,,,,0,null,level-1,28,,
acheivement-focus,DR-AF-2,"Works while meeting quality and performance standards","<p>Works while meeting quality and performance
standards<br></p>",1,,,,0,null,level-1,29,,
acheivement-focus,DR-AF-3,"Promptly and efficiently completes work assignments.","<p>Promptly and efficiently completes work
assignments.<br></p>",1,,,,0,null,level-1,30,,
drafting-skills,DR-DS-1,"Tailors communication (e.g. content, style and medium) to diverse audiences. ","<p>Tailors communication (e.g. content, style and
medium) to diverse audiences.<br></p>",1,,,,0,null,level-1,31,,
drafting-skills,DR-DS-2,"Writes and presents factual material in a concise manner. ","<p>Writes and presents factual material in a
concise manner.<br></p>",1,,,,0,null,level-1,32,,
flexible-thinking,DR-FT-1,"Proposes ways to do things differently.","<p>Proposes ways to do things differently.<br></p>",1,,,,0,null,level-1,33,,
flexible-thinking,DR-FT-2,"Understands and recognises the value of other points of view and ways of doing things","<p>Understands and recognises the value of
other points of view and ways of doing things<br></p>",1,,,,0,null,level-1,34,,
flexible-thinking,DR-FT-3,"Displays a positive attitude in the face of ambiguity and change.","<p>Displays a positive attitude in the face of
ambiguity and change.<br></p>",1,,,,0,null,level-1,35,,
managing-resources,DR-MR-1,"Organises the use of resources to meet expectations and identifies difficulties. ","<p>Organises the use of resources to meet
expectations and identifies difficulties.<br></p>",1,,,,0,null,level-1,36,,
managing-resources,DR-MR-2,"Plans, coordinates and manages internal and external resources to accomplish assignments within the ","<p>Plans, coordinates and manages internal and
external resources to accomplish
assignments within the given deadlines.<br></p>",1,,,,0,null,level-1,37,,
teamwork,DR-TW-1,"Initiates collaboration with others and spontaneously assists others in the delivery of their work","<p>Initiates collaboration with others and
spontaneously assists others in the delivery of
their work<br></p>",1,,,,0,null,level-1,38,,
teamwork,DR-TW-2,"Shares all relevant information with others and seeks others' input. ","<p>Shares all relevant information with others
and seeks others' input.<br></p>",1,,,,0,null,level-1,39,,
teamwork,DR-TW-3,"Expresses own opinion while remaining factual and respectful.","<p>Expresses own opinion while remaining
factual and respectful.<br></p>",1,,,,0,null,level-1,40,,
client-focus,I-CF-1,"Responds to and anticipates client needs in a timely, professional, helpful and courteous manner, re","<p>Responds to and anticipates client needs in a
timely, professional, helpful and courteous
manner, regardless of client attitude.<br></p>",1,,,,0,null,level-1,41,,
client-focus,I-CF-2,"Clearly shows clients that their perspectives are valued","<p>Clearly shows clients that their perspectives
are valued<br></p>",1,,,,0,null,level-1,42,,
client-focus,I-CF-3,"Strives to consistently meet service standards.","<p>Strives to consistently meet service
standards.<br></p>",1,,,,0,null,level-1,43,,
diplomatic-sensitivity,I-DS-1,"Listens actively, considers peoples concerns and adjusts own behaviour in a helpful manner.","<p>Listens actively, considers peoples concerns
and adjusts own behaviour in a helpful
manner.<br></p>",1,,,,0,null,level-1,44,,
diplomatic-sensitivity,I-DS-2,"Understands the reason behind, or motivation for someones actions.","<p>Understands the reason behind, or motivation
for someones actions.<br></p>",1,,,,0,null,level-1,45,,
diplomatic-sensitivity,I-DS-3,"Is attentive when doing projects and assignments, or when interacting with people from different cou","<p>Is attentive when doing projects and
assignments, or when interacting with people
from different countries and backgrounds.<br></p>",1,,,,0,null,level-1,46,,
diplomatic-sensitivity,I-DS-4,"Expresses negative feelings constructively.","<p>Expresses negative feelings constructively.<br></p>",1,,,,0,null,level-1,47,,
influencing,I-I-1,"Checks own understanding of others' communication (e.g. paraphrases, asks questions).","<p>Checks own understanding of others'
communication (e.g. paraphrases, asks
questions).<br></p>",1,,,,0,null,level-1,48,,
influencing,I-I-2,"Maintains continuous, open and consistent communication with others.","<p>Maintains continuous, open and consistent
communication with others.<br></p>",1,,,,0,null,level-1,49,,
influencing,I-I-3,"Builds on successful initiatives to gain support for ideas.","<p>Builds on successful initiatives to gain support
for ideas.<br></p>",1,,,,0,null,level-1,50,,
influencing,I-I-4,"Adapts arguments to others' needs/interests. ","<p>Adapts arguments to others' needs/interests.<br></p>",1,,,,0,null,level-1,51,,
negotiating,I-N-1,"Identifies main negotiating points of a given issue and engages in negotiation.","<p>Identifies main negotiating points of a given
issue and engages in negotiation.<br></p>",1,,,,0,null,level-1,52,,
negotiating,I-N-3,"Listens to differing points of view and promotes mutual understanding.","<p>Listens to differing points of view and
promotes mutual understanding.<br></p>",1,,,,0,null,level-1,53,,
organisational-knowledge,I-OK-1,"Demonstrates understanding of the general environment in which the Organisation operates.","<p>Demonstrates understanding of the general
environment in which the Organisation
operates.<br></p>",1,,,,0,null,level-1,54,,
organisational-knowledge,I-OK-2,"Understands and uses the Organisation's structures, rules and networks.","<p>Understands and uses the Organisation's
structures, rules and networks.<br></p>",1,,,,0,null,level-1,55,,
organisational-knowledge,I-OK-3,"Knows and respects the Organisations Code of Conduct and values.","<p>Knows and respects the Organisations Code
of Conduct and values.<br></p>",1,,,,0,null,level-1,56,,
developing-talent,S-DT-1,"Takes advantage of learning opportunities provided (e.g. courses, feedback from supervisor or peers)","<p>Takes advantage of learning opportunities
provided (e.g. courses, feedback from
supervisor or peers) to meet requirements of
current job.<br></p>",1,,,,0,null,level-1,57,,
developing-talent,S-DT-2,"Sets clear self-development expectations.","<p>Sets clear self-development expectations.<br></p>",1,,,,0,null,level-1,58,,
organisational-alignment,S-OA-1,"Explains the role and goals of the Organisation and how they relate to own area of work.","<p>Explains the role and goals of the
Organisation and how they relate to own area
of work.<br></p>",1,,,,0,null,level-1,59,,
organisational-alignment,S-OA-2,"Is able to explain how own work relates to the work of the Organisation.","<p>Is able to explain how own work relates to the
work of the Organisation.<br></p>",1,,,,0,null,level-1,60,,
strategic-networking,S-SN-1,"Actively nurtures both formal and informal contacts to facilitate the progress of work by proactivel","<p>Actively nurtures both formal and informal
contacts to facilitate the progress of work by
proactively sharing information, best
practices, respective interests and areas of
expertise.<br></p>",1,,,,0,null,level-1,61,,
strategic-networking,S-SN-2,"Identifies current or past contacts that can provide work-related information or assistance","<p>Identifies current or past contacts that can
provide work-related information or
assistance<br></p>",1,,,,0,null,level-1,62,,
strategic-networking,S-SN-3,"Fosters two-way trust in dealing with contacts (e.g. maintains confidentiality regarding sensitive i","<p>Fosters two-way trust in dealing with contacts
(e.g. maintains confidentiality regarding
sensitive information).<br></p>",1,,,,0,null,level-1,63,,
strategic-thinking,S-ST-1,"Identifies new information or data to key decision-makers or stakeholders to support their understan","<p>Identifies new information or data to key
decision-makers or stakeholders to support
their understanding and decisions.<br></p>",1,,,,0,null,level-1,64,,
1 Parent id number Id number Shortname Description Description format Scale values Scale configuration Rule type (optional) Rule outcome (optional) Rule config (optional) Cross referenced competency id numbers Exported id (optional) Is framework Taxonomy
2 OECD-CORE OECD <p>The Core Competencies summarise the capabilities that are important across all jobs and that we believe collectively contribute to the OECD’s overall success. At the same time, the importance of Core Competencies may vary according to the specific job duties and requirements. The OECD Competency Framework displays fifteen Core Competencies grouped into three clusters.</p><p>• The delivery-related competencies <br>• The interpersonal competencies <br>• The strategic competencies</p> 1 Not yet competent,Competent [{"scaleid":"2"},{"id":2,"scaledefault":1,"proficient":1}] 1 competency,competency,competency,competency
3 levels Levels <p>Each level of the Core Competencies has behavioural indicators that highlight how an individual can demonstrate that competency. Behavioural indicators are designed to show the requirements for successful performance.<br></p> 1 0 null 1
4 levels level-1 Level 1 <p>Level 1 is typically associated with jobs such as Assistants, Secretaries and Operators.<br></p> 1 0 null S-DT-1,S-DT-2,S-OA-1,S-OA-2,S-SN-1,S-SN-2,S-SN-3,S-ST-1,DR-AT1,DR-AT-2,DR-AF-1,DR-AF-2,DR-AF-3,DR-DS-1,DR-DS-2,DR-FT-1,DR-FT-2,DR-FT-3,DR-MR-1,DR-MR-2,DR-TW-1,DR-TW-2,DR-TW-3,I-CF-1,I-CF-2,I-CF-3,I-DS-1,I-DS-2,I-DS-3,I-DS-4,I-I-1,I-I-2,I-I-3,I-I-4,I-N-1,I-N-3,I-OK-1,I-OK-2,I-OK-3 2
5 levels level-2 Level 2 <p>Level 2 is typically associated with jobs such as Statisticians, Corporate Management and Administration Assistants/Officers, Logistics Officers and Documentalists.<br></p> 1 0 null 3
6 levels level-3 Level 3 <p>Level 3 is typically associated with jobs such as Economists/Policy Analysts, IT Analysts and HR Advisers.<br></p> 1 0 null 4
7 levels level-4 Level 4 <p>Level 4 is typically associated with jobs such as Senior Economists/Policy Analysts or Managers<br></p> 1 0 null 5
8 levels level-5 Level 5 <p>Level 5 is typically associated with jobs such as Heads of Division, Counsellors, Deputy Directors and Directors.<br></p> 1 0 null 6
9 competencies Competencies 1 0 null 7
10 competencies delivery Delivery-related <p>Achieving Results<br></p> 1 0 null 8
11 competencies interpersonal Interpersonal <p>Building relationships</p> 1 0 null 9
12 competencies strategic Strategic <p>Planning for the future</p> 1 0 null 10
13 delivery analytical-thinking Analytical Thinking <p>Analytical Thinking is the ability to identify patterns across situations that are not obviously related, and to identify key or underlying issues in complex situations.<br></p> 1 0 null 11
14 delivery acheivement-focus Achievement Focus <p>Achievement Focus is generating results by assuming responsibility for one's performance and the correctness of one's interventions, and recognising opportunities and acting efficiently at the appropriate moment and within the given deadlines.<br></p> 1 0 null 12
15 delivery drafting-skills Drafting Skills <p>Drafting Skills are based on the ability to respectfully communicate ideas and information (often technical) in writing to ensure that information and messages are understood and have the desired impact.<br></p> 1 0 null 13
16 delivery flexible-thinking Flexible Thinking <p>Flexible Thinking involves the ability to effectively adapt to a variety of situations, individuals or groups. It is based on the ability to understand and appreciate different and opposing perspectives on an issue, to adapt an approach as the requirements of a situation change, and to change or easily accept changes in one’s own organisational or job requirements.<br></p> 1 0 null 14
17 delivery managing-resources Managing Resources <p>Managing Resources is about understanding human, financial, and operational resource issues to make decisions aimed at building and planning efficient project workflows, and at improving overall organisational performance.<br></p> 1 0 null 15
18 delivery teamwork Teamwork and Team Leadership <p>Teamwork and Team Leadership implies working co-operatively with others, being a part of a team, and assuming the role of leader of a team. In the OECD, people work not only with their own teams but also with teams and groups across and outside the Organisation. Therefore they need to work together effectively with interdependent goals and common values and norms to foster a collaborative environment and drive teams in the same direction.<br></p> 1 0 null 16
19 interpersonal client-focus Client Focus <p>Client Focus is based on the ability to understand internal/external clients’ (e.g. Committees, working groups, country representatives, etc.,) needs and concerns in the short to long-term and to provide sound recommendations and/or solutions.<br></p> 1 0 null 17
20 interpersonal diplomatic-sensitivity Diplomatic Sensitivity <p>Diplomatic Sensitivity implies understanding other people. It includes the ability to hear accurately and understand unspoken, partly expressed thoughts, feelings and concerns of others. Included in this competency is an emphasis on cross-cultural sensitivity. Proficiency in Diplomatic Sensitivity requires the ability to keep one’s emotions under control and restrain negative actions when faced with opposition or hostility from others or when working under stress.<br></p> 1 0 null 18
21 interpersonal influencing Influencing <p>Influencing implies an intention to convince others in an honest, respectful and sensitive manner in order to get them to go along with one’s objectives. It can also be the desire to have a specific impact or effect on others.<br></p> 1 0 null 19
22 interpersonal negotiating Negotiating <p>Negotiating involves the ability to work towards win-win outcomes. At lower levels, this competency assumes an understanding of one’s counterparts and how to respond to them during negotiations. At the higher levels, the competency reflects a focus to achieve value-added results.<br></p> 1 0 null 20
23 interpersonal organisational-knowledge Organisational Knowledge <p>Organisational Knowledge is the ability to understand the power relationships within the Organisation and with other organisations. It includes the ability to understand the formal rules and structures including the ability to identify who the real decision-makers are as well as the individuals who can influence them.<br></p> 1 0 null 21
24 strategic developing-talent Developing Talent <p>Developing Talent means fostering an environment that will encourage professional and personal growth and the transfer of knowledge to future talent.<br></p> 1 0 null 22
25 strategic organisational-alignment Organisational Alignment <p>Organisational Alignment is the ability and willingness to align one’s own behaviour with the needs, priorities, and goals of the Organisation, and to act in ways that promote the Organisation’s goals or meet organisational needs. Organisational Alignment means focusing on the Organisation's mission before one's own preferences or professional priorities.<br></p> 1 0 null 23
26 strategic strategic-networking Strategic Networking <p>Strategic Networking involves working to build and maintain friendly, trustworthy and open internal and external relationships and networks with people who are, or might become, important actors in achieving strategic-related goals.<br></p> 1 0 null 24
27 strategic strategic-thinking Strategic Thinking <p>Strategic Thinking is the ability to develop a broad, big-picture view of the Organisation and its mission. Competitive advantage and threats, industry trends, emerging technology, market opportunities, stakeholder focus – Strategic Thinking is where these all come together. Strategic Thinking keeps individuals and groups focused and helps decide where to invest critical resources. It includes the ability to link long-range visions and concepts to daily work.<br></p> 1 0 null 25
28 analytical-thinking DR-AT1 Distinguishes between critical and irrelevant pieces of information <p>Distinguishes between critical and irrelevant pieces of information<br></p> 1 0 null level-1 26
29 analytical-thinking DR-AT-2 Gathers information from a variety of sources to reach a conclusion. <p>Gathers information from a variety of sources to reach a conclusion.<br></p> 1 0 null level-1 27
30 acheivement-focus DR-AF-1 Defines ambitious, but realistic, personal goals. <p>Defines ambitious, but realistic, personal goals.<br></p> 1 0 null level-1 28
31 acheivement-focus DR-AF-2 Works while meeting quality and performance standards <p>Works while meeting quality and performance standards<br></p> 1 0 null level-1 29
32 acheivement-focus DR-AF-3 Promptly and efficiently completes work assignments. <p>Promptly and efficiently completes work assignments.<br></p> 1 0 null level-1 30
33 drafting-skills DR-DS-1 Tailors communication (e.g. content, style and medium) to diverse audiences. <p>Tailors communication (e.g. content, style and medium) to diverse audiences.<br></p> 1 0 null level-1 31
34 drafting-skills DR-DS-2 Writes and presents factual material in a concise manner. <p>Writes and presents factual material in a concise manner.<br></p> 1 0 null level-1 32
35 flexible-thinking DR-FT-1 Proposes ways to do things differently. <p>Proposes ways to do things differently.<br></p> 1 0 null level-1 33
36 flexible-thinking DR-FT-2 Understands and recognises the value of other points of view and ways of doing things <p>Understands and recognises the value of other points of view and ways of doing things<br></p> 1 0 null level-1 34
37 flexible-thinking DR-FT-3 Displays a positive attitude in the face of ambiguity and change. <p>Displays a positive attitude in the face of ambiguity and change.<br></p> 1 0 null level-1 35
38 managing-resources DR-MR-1 Organises the use of resources to meet expectations and identifies difficulties. <p>Organises the use of resources to meet expectations and identifies difficulties.<br></p> 1 0 null level-1 36
39 managing-resources DR-MR-2 Plans, coordinates and manages internal and external resources to accomplish assignments within the <p>Plans, coordinates and manages internal and external resources to accomplish assignments within the given deadlines.<br></p> 1 0 null level-1 37
40 teamwork DR-TW-1 Initiates collaboration with others and spontaneously assists others in the delivery of their work <p>Initiates collaboration with others and spontaneously assists others in the delivery of their work<br></p> 1 0 null level-1 38
41 teamwork DR-TW-2 Shares all relevant information with others and seeks others' input. <p>Shares all relevant information with others and seeks others' input.<br></p> 1 0 null level-1 39
42 teamwork DR-TW-3 Expresses own opinion while remaining factual and respectful. <p>Expresses own opinion while remaining factual and respectful.<br></p> 1 0 null level-1 40
43 client-focus I-CF-1 Responds to and anticipates client needs in a timely, professional, helpful and courteous manner, re <p>Responds to and anticipates client needs in a timely, professional, helpful and courteous manner, regardless of client attitude.<br></p> 1 0 null level-1 41
44 client-focus I-CF-2 Clearly shows clients that their perspectives are valued <p>Clearly shows clients that their perspectives are valued<br></p> 1 0 null level-1 42
45 client-focus I-CF-3 Strives to consistently meet service standards. <p>Strives to consistently meet service standards.<br></p> 1 0 null level-1 43
46 diplomatic-sensitivity I-DS-1 Listens actively, considers people’s concerns and adjusts own behaviour in a helpful manner. <p>Listens actively, considers people’s concerns and adjusts own behaviour in a helpful manner.<br></p> 1 0 null level-1 44
47 diplomatic-sensitivity I-DS-2 Understands the reason behind, or motivation for someone’s actions. <p>Understands the reason behind, or motivation for someone’s actions.<br></p> 1 0 null level-1 45
48 diplomatic-sensitivity I-DS-3 Is attentive when doing projects and assignments, or when interacting with people from different cou <p>Is attentive when doing projects and assignments, or when interacting with people from different countries and backgrounds.<br></p> 1 0 null level-1 46
49 diplomatic-sensitivity I-DS-4 Expresses negative feelings constructively. <p>Expresses negative feelings constructively.<br></p> 1 0 null level-1 47
50 influencing I-I-1 Checks own understanding of others' communication (e.g. paraphrases, asks questions). <p>Checks own understanding of others' communication (e.g. paraphrases, asks questions).<br></p> 1 0 null level-1 48
51 influencing I-I-2 Maintains continuous, open and consistent communication with others. <p>Maintains continuous, open and consistent communication with others.<br></p> 1 0 null level-1 49
52 influencing I-I-3 Builds on successful initiatives to gain support for ideas. <p>Builds on successful initiatives to gain support for ideas.<br></p> 1 0 null level-1 50
53 influencing I-I-4 Adapts arguments to others' needs/interests. <p>Adapts arguments to others' needs/interests.<br></p> 1 0 null level-1 51
54 negotiating I-N-1 Identifies main negotiating points of a given issue and engages in negotiation. <p>Identifies main negotiating points of a given issue and engages in negotiation.<br></p> 1 0 null level-1 52
55 negotiating I-N-3 Listens to differing points of view and promotes mutual understanding. <p>Listens to differing points of view and promotes mutual understanding.<br></p> 1 0 null level-1 53
56 organisational-knowledge I-OK-1 Demonstrates understanding of the general environment in which the Organisation operates. <p>Demonstrates understanding of the general environment in which the Organisation operates.<br></p> 1 0 null level-1 54
57 organisational-knowledge I-OK-2 Understands and uses the Organisation's structures, rules and networks. <p>Understands and uses the Organisation's structures, rules and networks.<br></p> 1 0 null level-1 55
58 organisational-knowledge I-OK-3 Knows and respects the Organisation’s Code of Conduct and values. <p>Knows and respects the Organisation’s Code of Conduct and values.<br></p> 1 0 null level-1 56
59 developing-talent S-DT-1 Takes advantage of learning opportunities provided (e.g. courses, feedback from supervisor or peers) <p>Takes advantage of learning opportunities provided (e.g. courses, feedback from supervisor or peers) to meet requirements of current job.<br></p> 1 0 null level-1 57
60 developing-talent S-DT-2 Sets clear self-development expectations. <p>Sets clear self-development expectations.<br></p> 1 0 null level-1 58
61 organisational-alignment S-OA-1 Explains the role and goals of the Organisation and how they relate to own area of work. <p>Explains the role and goals of the Organisation and how they relate to own area of work.<br></p> 1 0 null level-1 59
62 organisational-alignment S-OA-2 Is able to explain how own work relates to the work of the Organisation. <p>Is able to explain how own work relates to the work of the Organisation.<br></p> 1 0 null level-1 60
63 strategic-networking S-SN-1 Actively nurtures both formal and informal contacts to facilitate the progress of work by proactivel <p>Actively nurtures both formal and informal contacts to facilitate the progress of work by proactively sharing information, best practices, respective interests and areas of expertise.<br></p> 1 0 null level-1 61
64 strategic-networking S-SN-2 Identifies current or past contacts that can provide work-related information or assistance <p>Identifies current or past contacts that can provide work-related information or assistance<br></p> 1 0 null level-1 62
65 strategic-networking S-SN-3 Fosters two-way trust in dealing with contacts (e.g. maintains confidentiality regarding sensitive i <p>Fosters two-way trust in dealing with contacts (e.g. maintains confidentiality regarding sensitive information).<br></p> 1 0 null level-1 63
66 strategic-thinking S-ST-1 Identifies new information or data to key decision-makers or stakeholders to support their understan <p>Identifies new information or data to key decision-makers or stakeholders to support their understanding and decisions.<br></p> 1 0 null level-1 64

View File

@ -0,0 +1,62 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* External learning plans webservice API tests.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
use tool_lpimportcsv\framework_importer;
use tool_lpimportcsv\framework_exporter;
use core_competency\api;
/**
* External learning plans webservice API tests.
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_lpimportcsv_import_testcase extends advanced_testcase {
public function test_import_framework() {
$this->resetAfterTest(true);
$this->setAdminUser();
$importer = new framework_importer(file_get_contents(__DIR__ . '/fixtures/example.csv'));
$this->assertEquals('', $importer->get_error());
$framework = $importer->import();
$this->assertEmpty('', $importer->get_error());
$this->assertGreaterThan(0, $framework->get_id());
$filters = [
'competencyframeworkid' => $framework->get_id()
];
$count = api::count_competencies($filters);
$this->assertEquals(64, $count);
// We can't test the exporter because it sends force-download headers.
}
}

View File

@ -0,0 +1,32 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plugin version info
*
* @package tool_lpimportcsv
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2016083000; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2016051900; // Requires this Moodle version.
$plugin->component = 'tool_lpimportcsv'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = array('tool_lp' => 2016052300);

View File

@ -36,11 +36,13 @@ defined('MOODLE_INTERNAL') || die();
class invalid_persistent_exception extends \moodle_exception {
public function __construct(array $errors = array()) {
$forhumans = array();
$debuginfo = array();
foreach ($errors as $key => $message) {
$debuginfo[] = "$key: $message";
$forhumans[] = $message;
}
parent::__construct('invalidpersistent', 'core_competency', null, null, implode(' - ', $debuginfo));
parent::__construct('invalidpersistent', 'core_competency', null, implode(', ', $forhumans), implode(' - ', $debuginfo));
}
}

View File

@ -103,7 +103,7 @@ $string['evidence_manualoverrideincourse'] = 'The competency rating was manually
$string['evidence_manualoverrideinplan'] = 'The competency rating was manually set in the learning plan \'{$a}\'.';
$string['invalidevidencedesc'] = 'Invalid evidence description';
$string['invalidgrade'] = 'Invalid rating';
$string['invalidpersistent'] = 'Invalid persistent';
$string['invalidpersistent'] = 'Error: {$a}';
$string['invalidplan'] = 'Invalid learning plan';
$string['invalidtaxonomy'] = 'Invalid taxonomy: {$a}';
$string['invalidurl'] = 'The URL is not valid. Make sure it starts with \'http://\' or \'https://\'.';

View File

@ -1906,7 +1906,7 @@ class core_plugin_manager {
'tool' => array(
'assignmentupgrade', 'availabilityconditions', 'behat', 'capability', 'cohortroles', 'customlang',
'dbtransfer', 'filetypes', 'generator', 'health', 'innodb', 'installaddon',
'langimport', 'log', 'lp', 'lpmigrate', 'messageinbound', 'mobile', 'multilangupgrade', 'monitor',
'langimport', 'log', 'lp', 'lpimportcsv', 'lpmigrate', 'messageinbound', 'mobile', 'multilangupgrade', 'monitor',
'phpunit', 'profiling', 'recyclebin', 'replace', 'spamcleaner', 'task', 'templatelibrary',
'unittest', 'uploadcourse', 'uploaduser', 'unsuproles', 'xmldb'
),