Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

   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   * Script creates a standardised large course for testing reliability and performance.
  19   *
  20   * @package tool_generator
  21   * @copyright 2013 The Open University
  22   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  // Disable buffering so that the progress output displays gradually without
  26  // needing to call flush().
  27  define('NO_OUTPUT_BUFFERING', true);
  28  
  29  require('../../../config.php');
  30  
  31  require_once($CFG->libdir . '/adminlib.php');
  32  
  33  // Initialise page and check permissions.
  34  admin_externalpage_setup('toolgeneratorcourse');
  35  
  36  // Start page.
  37  echo $OUTPUT->header();
  38  echo $OUTPUT->heading(get_string('maketestcourse', 'tool_generator'));
  39  
  40  // Information message.
  41  $context = context_system::instance();
  42  echo $OUTPUT->box(format_text(get_string('courseexplanation', 'tool_generator'),
  43          FORMAT_MARKDOWN, array('context' => $context)));
  44  
  45  // Check debugging is set to DEVELOPER.
  46  if (!debugging('', DEBUG_DEVELOPER)) {
  47      echo $OUTPUT->notification(get_string('error_notdebugging', 'tool_generator'));
  48      echo $OUTPUT->footer();
  49      exit;
  50  }
  51  
  52  // Set up the form.
  53  $mform = new tool_generator_make_course_form('maketestcourse.php');
  54  if ($data = $mform->get_data()) {
  55      // Do actual work.
  56      echo $OUTPUT->heading(get_string('creating', 'tool_generator'));
  57      $backend = new tool_generator_course_backend(
  58          $data->shortname,
  59          $data->size,
  60          false,
  61          false,
  62          true,
  63          $data->fullname,
  64          $data->summary['text'],
  65          $data->summary['format']
  66      );
  67      $id = $backend->make();
  68  
  69      echo html_writer::div(
  70              html_writer::link(new moodle_url('/course/view.php', array('id' => $id)),
  71                  get_string('continue')));
  72  } else {
  73      // Display form.
  74      $mform->display();
  75  }
  76  
  77  // Finish page.
  78  echo $OUTPUT->footer();