Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * At this page, teachers allocate submissions to students for a review
  20   *
  21   * The allocation logic itself is delegated to allocators - subplugins in ./allocation
  22   * folder.
  23   *
  24   * @package    mod_workshop
  25   * @copyright  2009 David Mudrak <david.mudrak@gmail.com>
  26   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  27   */
  28  
  29  require(__DIR__.'/../../config.php');
  30  require_once (__DIR__.'/locallib.php');
  31  require_once (__DIR__.'/allocation/lib.php');
  32  
  33  $cmid       = required_param('cmid', PARAM_INT);                    // course module
  34  $method     = optional_param('method', 'manual', PARAM_ALPHA);      // method to use
  35  
  36  $cm         = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST);
  37  $course     = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
  38  $workshop   = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
  39  $workshop   = new workshop($workshop, $cm, $course);
  40  
  41  $PAGE->set_url($workshop->allocation_url($method));
  42  
  43  require_login($course, false, $cm);
  44  $context = $PAGE->context;
  45  require_capability('mod/workshop:allocate', $context);
  46  
  47  $PAGE->set_title($workshop->name);
  48  $PAGE->set_heading($course->fullname);
  49  $PAGE->navbar->add(get_string('allocation', 'workshop'));
  50  
  51  $allocator  = $workshop->allocator_instance($method);
  52  $initresult = $allocator->init();
  53  
  54  //
  55  // Output starts here
  56  //
  57  $output = $PAGE->get_renderer('mod_workshop');
  58  echo $output->header();
  59  echo $OUTPUT->heading(format_string($workshop->name));
  60  
  61  $allocators = workshop::installed_allocators();
  62  if (!empty($allocators)) {
  63      $tabs       = array();
  64      $row        = array();
  65      $inactive   = array();
  66      $activated  = array();
  67      foreach ($allocators as $methodid => $methodname) {
  68          $row[] = new tabobject($methodid, $workshop->allocation_url($methodid)->out(), $methodname);
  69          if ($methodid == $method) {
  70              $currenttab = $methodid;
  71          }
  72      }
  73  }
  74  $tabs[] = $row;
  75  print_tabs($tabs, $currenttab, $inactive, $activated);
  76  
  77  if (is_null($initresult->get_status()) or $initresult->get_status() == workshop_allocation_result::STATUS_VOID) {
  78      echo $output->container_start('allocator-ui');
  79      echo $allocator->ui();
  80      echo $output->container_end();
  81  } else {
  82      echo $output->container_start('allocator-init-results');
  83      echo $output->render($initresult);
  84      echo $output->continue_button($workshop->allocation_url($method));
  85      echo $output->container_end();
  86  }
  87  echo $output->footer();