Commit f6c7a337 authored by Nigel McNie's avatar Nigel McNie
Browse files

Add rudimentary import of achievements.

This grabs them at two score levels, based on whether we know for sure
that it's a certification or not. This is because some other data
exported from Mahara counts as a certification, but will actually be
stitched together with other entries to make up e.g. professional
memberships.
parent 943ffc28
......@@ -44,6 +44,11 @@ class LeapImportResume extends LeapImportArtefactPlugin {
*/
const STRATEGY_IMPORT_AS_ABILITY = 2;
/**
* Achievements map in Mahara to certifications/accreditations
*/
const STRATEGY_IMPORT_AS_ACHIEVEMENT = 3;
/**
* Description of strategies used
*/
......@@ -74,6 +79,29 @@ class LeapImportResume extends LeapImportArtefactPlugin {
);
}
// Achievements
$correctrdftype = count($entry->xpath('rdf:type['
. $importer->curie_xpath('@rdf:resource', PluginImportLeap::NS_LEAPTYPE, 'achievement') . ']')) == 1;
if ($correctrdftype && $correctplugintype) {
if (count($entry->xpath('mahara:artefactplugin[@mahara:plugin="resume" and @mahara:type="pseudo:certification"]')) == 1) {
// We know for certain these are meant to be certifications within Mahara
$score = 100;
}
else {
// Some things are achievements, but are wrapped up in other things within Mahara,
// so these don't get the full score. Of course, if nothing
// else claims them, they'll be imported as certifications
$score = 50;
}
$strategies[] = array(
'strategy' => self::STRATEGY_IMPORT_AS_ACHIEVEMENT,
'score' => $score,
'other_required_entries' => array(),
);
}
// Employment
return $strategies;
}
......@@ -124,6 +152,38 @@ class LeapImportResume extends LeapImportArtefactPlugin {
}
}
break;
case self::STRATEGY_IMPORT_AS_ACHIEVEMENT:
$dateelement = $entry->xpath('leap:date[@leap:point="end"]');
if (count($dateelement) == 1) {
$dateelement = $dateelement[0];
}
$date = '';
if ($dateelement instanceof SimpleXMLElement) {
$date = (string)$dateelement;
if ($date) {
$date = strftime(get_string_from_language(/* TODO: user's language */'en.utf8', 'strftimedaydatetime'), strtotime($date));
}
else {
// Parse for leap:label
$leapattributes = array();
foreach ($dateelement->attributes(PluginImportLeap::NS_LEAP) as $key => $value) {
$leapattributes[$key] = (string)$value;
}
if (isset($leapattributes['label'])) {
$date = $leapattributes['label'];
}
}
}
$values = array(
'date' => $date,
'title' => $entry->title,
'description' => PluginImportLeap::get_entry_content($entry, $importer),
'displayorder' => '', // TODO: if it's part of a selection_type#Grouping of mahara:type=certification, get ordering from there
);
ArtefactTypeResumeComposite::ensure_composite_value($values, 'certification', $importer->get('usr'));
break;
default:
throw new ImportException($importer, 'TODO: get_string: unknown strategy chosen for importing entry');
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment