Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Page to migrate frameworks.
  19   *
  20   * @package    tool_lpmigrate
  21   * @copyright  2016 Frédéric Massart - FMCorz.net
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  require_once(__DIR__ . '/../../../config.php');
  26  
  27  $context = context_system::instance();
  28  require_login(null, false);
  29  require_capability('tool/lpmigrate:frameworksmigrate', $context);
  30  
  31  $url = new moodle_url('/admin/tool/lpmigrate/frameworks.php');
  32  $title = get_string('migrateframeworks', 'tool_lpmigrate');
  33  $PAGE->set_context($context);
  34  $PAGE->set_pagelayout('standard');
  35  $PAGE->set_url($url);
  36  $PAGE->set_title($title);
  37  $PAGE->set_heading(get_string('pluginname', 'tool_lpmigrate'));
  38  
  39  $form = new \tool_lpmigrate\form\migrate_framework($context);
  40  if ($form->is_cancelled()) {
  41      redirect($url);
  42  }
  43  
  44  $output = $PAGE->get_renderer('tool_lpmigrate');
  45  echo $output->header();
  46  echo $output->heading($title);
  47  
  48  if ($data = $form->get_data()) {
  49  
  50      // Map competencies from both framework.
  51      $mapper = new \tool_lpmigrate\framework_mapper($data->from, $data->to);
  52      $mapper->automap();
  53  
  54      $progress = new \core\progress\display();
  55      $progress->set_display_names(true);
  56  
  57      $processor = new \tool_lpmigrate\framework_processor($mapper, $progress);
  58      if (!empty($data->allowedcourses)) {
  59          $processor->set_allowedcourses($data->allowedcourses);
  60      }
  61      if (!empty($data->disallowedcourses)) {
  62          $processor->set_disallowedcourses($data->disallowedcourses);
  63      }
  64      $processor->set_course_start_date_from($data->coursestartdate);
  65      $processor->proceed();
  66  
  67      $unmappedfrom = $mapper->get_unmapped_objects_from();
  68      $unmappedto = $mapper->get_unmapped_objects_to();
  69      $renderable = new \tool_lpmigrate\output\migrate_framework_results($context, $processor,
  70          \core_competency\api::read_framework($data->from), \core_competency\api::read_framework($data->to),
  71          $unmappedfrom, $unmappedto);
  72      echo $output->render($renderable);
  73  
  74  } else {
  75      echo html_writer::tag('p', get_string('explanation', 'tool_lpmigrate'));
  76      $form->display();
  77  }
  78  
  79  echo $output->footer();