Ejemplo n.º 1
0
 public function validation($data, $files)
 {
     $errors = array();
     if ($data['from'] == $data['to']) {
         $errors['to'] = get_string('errorcannotmigratetosameframework', 'tool_lpmigrate');
     } else {
         if (!empty($data['from']) && !empty($data['to'])) {
             $mapper = new \tool_lpmigrate\framework_mapper($data['from'], $data['to']);
             $mapper->automap();
             if (!$mapper->has_mappings()) {
                 $errors['to'] = 'Could not map to any competency in this framework.';
             }
         }
     }
     return $errors;
 }
Ejemplo n.º 2
0
$title = get_string('migrateframeworks', 'tool_lpmigrate');
$PAGE->set_context($context);
$PAGE->set_pagelayout('standard');
$PAGE->set_url($url);
$PAGE->set_title($title);
$PAGE->set_heading(get_string('pluginname', 'tool_lpmigrate'));
$output = $PAGE->get_renderer('tool_lpmigrate');
echo $output->header();
echo $output->heading($title);
$form = new \tool_lpmigrate\form\migrate_framework($context);
if ($form->is_cancelled()) {
    redirect($url);
} else {
    if ($data = $form->get_data()) {
        // Map competencies from both framework.
        $mapper = new \tool_lpmigrate\framework_mapper($data->from, $data->to);
        $mapper->automap();
        $progress = new \core\progress\display();
        $progress->set_display_names(true);
        $processor = new \tool_lpmigrate\framework_processor($mapper, $progress);
        if (!empty($data->allowedcourses)) {
            $processor->set_allowedcourses($data->allowedcourses);
        }
        if (!empty($data->disallowedcourses)) {
            $processor->set_disallowedcourses($data->disallowedcourses);
        }
        $processor->set_course_start_date_from($data->coursestartdate);
        $processor->proceed();
        $unmappedfrom = $mapper->get_unmapped_objects_from();
        $unmappedto = $mapper->get_unmapped_objects_to();
        $renderable = new \tool_lpmigrate\output\migrate_framework_results($context, $processor, \core_competency\api::read_framework($data->from), \core_competency\api::read_framework($data->to), $unmappedfrom, $unmappedto);