[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/question/behaviour/manualgraded/db/ -> upgrade.php (source)

   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   * Post-install script for the manual graded question behaviour.
  19   *
  20   * @package   qbehaviour_manualgraded
  21   * @copyright 2013 The Open Universtiy
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  
  26  defined('MOODLE_INTERNAL') || die();
  27  
  28  
  29  /**
  30   * Manual graded question behaviour upgrade code.
  31   */
  32  function xmldb_qbehaviour_manualgraded_upgrade($oldversion) {
  33      global $CFG, $DB;
  34  
  35      $dbman = $DB->get_manager();
  36  
  37      // Moodle v2.4.0 release upgrade line
  38      // Put any upgrade step following this
  39  
  40      if ($oldversion < 2013050200) {
  41          // Hide the manualgraded behaviour from the list of behaviours that users
  42          // can select in the user-interface. If a user accidentally chooses manual
  43          // graded behaviour for a quiz, there is no way to get the questions automatically
  44          // graded after the student has answered them. If teachers really want to do
  45          // this they can ask their admin to enable it on the manage behaviours
  46          // screen in the UI.
  47          $disabledbehaviours = get_config('question', 'disabledbehaviours');
  48          if (!empty($disabledbehaviours)) {
  49              $disabledbehaviours = explode(',', $disabledbehaviours);
  50          } else {
  51              $disabledbehaviours = array();
  52          }
  53          if (array_search('manualgraded', $disabledbehaviours) === false) {
  54              $disabledbehaviours[] = 'manualgraded';
  55              set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
  56          }
  57  
  58          // Manual graded question behaviour savepoint reached.
  59          upgrade_plugin_savepoint(true, 2013050200, 'qbehaviour', 'manualgraded');
  60      }
  61  
  62      if ($oldversion < 2013050800) {
  63          // Also, fix any other admin settings that currently select manualgraded behaviour.
  64  
  65          // Work out a sensible default alternative to manualgraded.
  66          require_once($CFG->libdir . '/questionlib.php');
  67          $behaviours = question_engine::get_behaviour_options('');
  68          if (array_key_exists('deferredfeedback', $behaviours)) {
  69               $defaultbehaviour = 'deferredfeedback';
  70          } else {
  71              reset($behaviours);
  72              $defaultbehaviour = key($behaviours);
  73          }
  74  
  75          // Fix the question preview default.
  76          if (get_config('question_preview', 'behaviour') == 'manualgraded') {
  77              set_config('behaviour', $defaultbehaviour, 'question_preview');
  78          }
  79  
  80          // Fix the quiz settings default.
  81          if (get_config('quiz', 'preferredbehaviour') == 'manualgraded') {
  82              set_config('preferredbehaviour', $defaultbehaviour, 'quiz');
  83          }
  84  
  85          // Manual graded question behaviour savepoint reached.
  86          upgrade_plugin_savepoint(true, 2013050800, 'qbehaviour', 'manualgraded');
  87      }
  88  
  89      // Moodle v2.5.0 release upgrade line.
  90      // Put any upgrade step following this.
  91  
  92  
  93      // Moodle v2.6.0 release upgrade line.
  94      // Put any upgrade step following this.
  95  
  96      // Moodle v2.7.0 release upgrade line.
  97      // Put any upgrade step following this.
  98  
  99      // Moodle v2.8.0 release upgrade line.
 100      // Put any upgrade step following this.
 101  
 102      return true;
 103  }
 104  


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1