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.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 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   * Edit grading form in for a particular instance of workshop
  20   *
  21   * @package    mod_workshop
  22   * @copyright  2009 David Mudrak <david.mudrak@gmail.com>
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  require(__DIR__.'/../../config.php');
  27  require_once (__DIR__.'/locallib.php');
  28  
  29  $cmid       = required_param('cmid', PARAM_INT);
  30  
  31  $cm         = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST);
  32  $course     = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
  33  
  34  require_login($course, false, $cm);
  35  require_capability('mod/workshop:editdimensions', $PAGE->context);
  36  
  37  $workshop   = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
  38  $workshop   = new workshop($workshop, $cm, $course);
  39  
  40  // todo: check if there already is some assessment done and do not allowed the change of the form
  41  // once somebody already used it to assess
  42  
  43  $PAGE->set_url($workshop->editform_url());
  44  $PAGE->set_title($workshop->name);
  45  $PAGE->set_heading($course->fullname);
  46  $PAGE->navbar->add(get_string('editingassessmentform', 'workshop'));
  47  
  48  // load the grading strategy logic
  49  $strategy = $workshop->grading_strategy_instance();
  50  
  51  // load the form to edit the grading strategy dimensions
  52  $mform = $strategy->get_edit_strategy_form($PAGE->url);
  53  
  54  if ($mform->is_cancelled()) {
  55      redirect($workshop->view_url());
  56  } elseif ($data = $mform->get_data()) {
  57      if (($data->workshopid != $workshop->id) or ($data->strategy != $workshop->strategy)) {
  58          // this may happen if someone changes the workshop setting while the user had the
  59          // editing form opened
  60          throw new invalid_parameter_exception('Invalid workshop ID or the grading strategy has changed.');
  61      }
  62      $strategy->save_edit_strategy_form($data);
  63      if (isset($data->saveandclose)) {
  64          redirect($workshop->view_url());
  65      } elseif (isset($data->saveandpreview)) {
  66          redirect($workshop->previewform_url());
  67      } else {
  68          // save and continue - redirect to self to prevent data being re-posted by pressing "Reload"
  69          redirect($PAGE->url);
  70      }
  71  }
  72  
  73  // Output starts here
  74  
  75  echo $OUTPUT->header();
  76  echo $OUTPUT->heading(format_string($workshop->name));
  77  echo $OUTPUT->heading(get_string('pluginname', 'workshopform_' . $workshop->strategy), 3);
  78  
  79  $mform->display();
  80  
  81  echo $OUTPUT->footer();