[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/grade/edit/tree/ -> category_form.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   * A moodleform to edit the grade options for an individual grade category
  19   *
  20   * @package   core_grades
  21   * @copyright 2007 Petr Skoda
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  if (!defined('MOODLE_INTERNAL')) {
  26      die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
  27  }
  28  
  29  require_once $CFG->libdir.'/formslib.php';
  30  
  31  class edit_category_form extends moodleform {
  32      private $aggregation_options = array();
  33  
  34      function definition() {
  35          global $CFG, $COURSE, $DB;
  36          $mform =& $this->_form;
  37  
  38          $category = $this->_customdata['current'];
  39  
  40          $this->aggregation_options = grade_helper::get_aggregation_strings();
  41  
  42          // visible elements
  43          $mform->addElement('header', 'headercategory', get_string('gradecategory', 'grades'));
  44          $mform->addElement('text', 'fullname', get_string('categoryname', 'grades'));
  45          $mform->setType('fullname', PARAM_TEXT);
  46          $mform->addRule('fullname', null, 'required', null, 'client');
  47  
  48          $mform->addElement('select', 'aggregation', get_string('aggregation', 'grades'), $this->aggregation_options);
  49          $mform->addHelpButton('aggregation', 'aggregation', 'grades');
  50  
  51          if ((int)$CFG->grade_aggregation_flag & 2) {
  52              $mform->setAdvanced('aggregation');
  53          }
  54  
  55          $mform->addElement('checkbox', 'aggregateonlygraded', get_string('aggregateonlygraded', 'grades'));
  56          $mform->addHelpButton('aggregateonlygraded', 'aggregateonlygraded', 'grades');
  57  
  58          if ((int)$CFG->grade_aggregateonlygraded_flag & 2) {
  59              $mform->setAdvanced('aggregateonlygraded');
  60          }
  61  
  62          if (empty($CFG->enableoutcomes)) {
  63              $mform->addElement('hidden', 'aggregateoutcomes');
  64              $mform->setType('aggregateoutcomes', PARAM_INT);
  65          } else {
  66              $mform->addElement('checkbox', 'aggregateoutcomes', get_string('aggregateoutcomes', 'grades'));
  67              $mform->addHelpButton('aggregateoutcomes', 'aggregateoutcomes', 'grades');
  68              if ((int)$CFG->grade_aggregateoutcomes_flag & 2) {
  69                  $mform->setAdvanced('aggregateoutcomes');
  70              }
  71          }
  72  
  73          $mform->addElement('text', 'keephigh', get_string('keephigh', 'grades'), 'size="3"');
  74          $mform->setType('keephigh', PARAM_INT);
  75          $mform->addHelpButton('keephigh', 'keephigh', 'grades');
  76          if ((int)$CFG->grade_keephigh_flag & 2) {
  77              $mform->setAdvanced('keephigh');
  78          }
  79  
  80          $mform->addElement('text', 'droplow', get_string('droplow', 'grades'), 'size="3"');
  81          $mform->setType('droplow', PARAM_INT);
  82          $mform->addHelpButton('droplow', 'droplow', 'grades');
  83          $mform->disabledIf('droplow', 'keephigh', 'noteq', 0);
  84          if ((int)$CFG->grade_droplow_flag & 2) {
  85              $mform->setAdvanced('droplow');
  86          }
  87  
  88          $mform->disabledIf('keephigh', 'droplow', 'noteq', 0);
  89          $mform->disabledIf('droplow', 'keephigh', 'noteq', 0);
  90  
  91          // Grade item settings
  92          // Displayed as Category total to avoid confusion between grade items requiring marking and category totals
  93          $mform->addElement('header', 'general', get_string('categorytotal', 'grades'));
  94  
  95          $mform->addElement('text', 'grade_item_itemname', get_string('categorytotalname', 'grades'));
  96          $mform->setType('grade_item_itemname', PARAM_TEXT);
  97          $mform->setAdvanced('grade_item_itemname');
  98  
  99          $mform->addElement('text', 'grade_item_iteminfo', get_string('iteminfo', 'grades'));
 100          $mform->addHelpButton('grade_item_iteminfo', 'iteminfo', 'grades');
 101          $mform->setType('grade_item_iteminfo', PARAM_TEXT);
 102  
 103          $mform->addElement('text', 'grade_item_idnumber', get_string('idnumbermod'));
 104          $mform->addHelpButton('grade_item_idnumber', 'idnumbermod');
 105          $mform->setType('grade_item_idnumber', PARAM_RAW);
 106  
 107          $options = array(GRADE_TYPE_NONE=>get_string('typenone', 'grades'),
 108                           GRADE_TYPE_VALUE=>get_string('typevalue', 'grades'),
 109                           GRADE_TYPE_SCALE=>get_string('typescale', 'grades'),
 110                           GRADE_TYPE_TEXT=>get_string('typetext', 'grades'));
 111  
 112          $mform->addElement('select', 'grade_item_gradetype', get_string('gradetype', 'grades'), $options);
 113          $mform->addHelpButton('grade_item_gradetype', 'gradetype', 'grades');
 114          $mform->setDefault('grade_item_gradetype', GRADE_TYPE_VALUE);
 115          $mform->disabledIf('grade_item_gradetype', 'aggregation', 'eq', GRADE_AGGREGATE_SUM);
 116  
 117          //$mform->addElement('text', 'calculation', get_string('calculation', 'grades'));
 118          //$mform->disabledIf('calculation', 'gradetype', 'eq', GRADE_TYPE_TEXT);
 119          //$mform->disabledIf('calculation', 'gradetype', 'eq', GRADE_TYPE_NONE);
 120  
 121          $options = array(0=>get_string('usenoscale', 'grades'));
 122          if ($scales = grade_scale::fetch_all_local($COURSE->id)) {
 123              foreach ($scales as $scale) {
 124                  $options[$scale->id] = $scale->get_name();
 125              }
 126          }
 127          if ($scales = grade_scale::fetch_all_global()) {
 128              foreach ($scales as $scale) {
 129                  $options[$scale->id] = $scale->get_name();
 130              }
 131          }
 132          // ugly BC hack - it was possible to use custom scale from other courses :-(
 133          if (!empty($category->grade_item_scaleid) and !isset($options[$category->grade_item_scaleid])) {
 134              if ($scale = grade_scale::fetch(array('id'=>$category->grade_item_scaleid))) {
 135                  $options[$scale->id] = $scale->get_name().' '.get_string('incorrectcustomscale', 'grades');
 136              }
 137          }
 138          $mform->addElement('select', 'grade_item_scaleid', get_string('scale'), $options);
 139          $mform->addHelpButton('grade_item_scaleid', 'typescale', 'grades');
 140          $mform->disabledIf('grade_item_scaleid', 'grade_item_gradetype', 'noteq', GRADE_TYPE_SCALE);
 141          $mform->disabledIf('grade_item_scaleid', 'aggregation', 'eq', GRADE_AGGREGATE_SUM);
 142  
 143          $mform->addElement('text', 'grade_item_grademax', get_string('grademax', 'grades'));
 144          $mform->setType('grade_item_grademax', PARAM_RAW);
 145          $mform->addHelpButton('grade_item_grademax', 'grademax', 'grades');
 146          $mform->disabledIf('grade_item_grademax', 'grade_item_gradetype', 'noteq', GRADE_TYPE_VALUE);
 147          $mform->disabledIf('grade_item_grademax', 'aggregation', 'eq', GRADE_AGGREGATE_SUM);
 148  
 149          if ((bool) get_config('moodle', 'grade_report_showmin')) {
 150              $mform->addElement('text', 'grade_item_grademin', get_string('grademin', 'grades'));
 151              $mform->setType('grade_item_grademin', PARAM_RAW);
 152              $mform->addHelpButton('grade_item_grademin', 'grademin', 'grades');
 153              $mform->disabledIf('grade_item_grademin', 'grade_item_gradetype', 'noteq', GRADE_TYPE_VALUE);
 154              $mform->disabledIf('grade_item_grademin', 'aggregation', 'eq', GRADE_AGGREGATE_SUM);
 155          }
 156  
 157          $mform->addElement('text', 'grade_item_gradepass', get_string('gradepass', 'grades'));
 158          $mform->setType('grade_item_gradepass', PARAM_RAW);
 159          $mform->addHelpButton('grade_item_gradepass', 'gradepass', 'grades');
 160          $mform->disabledIf('grade_item_gradepass', 'grade_item_gradetype', 'eq', GRADE_TYPE_NONE);
 161          $mform->disabledIf('grade_item_gradepass', 'grade_item_gradetype', 'eq', GRADE_TYPE_TEXT);
 162  
 163          /// grade display prefs
 164          $default_gradedisplaytype = grade_get_setting($COURSE->id, 'displaytype', $CFG->grade_displaytype);
 165          $options = array(GRADE_DISPLAY_TYPE_DEFAULT            => get_string('default', 'grades'),
 166                           GRADE_DISPLAY_TYPE_REAL               => get_string('real', 'grades'),
 167                           GRADE_DISPLAY_TYPE_PERCENTAGE         => get_string('percentage', 'grades'),
 168                           GRADE_DISPLAY_TYPE_LETTER             => get_string('letter', 'grades'),
 169                           GRADE_DISPLAY_TYPE_REAL_PERCENTAGE    => get_string('realpercentage', 'grades'),
 170                           GRADE_DISPLAY_TYPE_REAL_LETTER        => get_string('realletter', 'grades'),
 171                           GRADE_DISPLAY_TYPE_LETTER_REAL        => get_string('letterreal', 'grades'),
 172                           GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE  => get_string('letterpercentage', 'grades'),
 173                           GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER  => get_string('percentageletter', 'grades'),
 174                           GRADE_DISPLAY_TYPE_PERCENTAGE_REAL    => get_string('percentagereal', 'grades')
 175                           );
 176  
 177          asort($options);
 178  
 179          foreach ($options as $key=>$option) {
 180              if ($key == $default_gradedisplaytype) {
 181                  $options[GRADE_DISPLAY_TYPE_DEFAULT] = get_string('defaultprev', 'grades', $option);
 182                  break;
 183              }
 184          }
 185          $mform->addElement('select', 'grade_item_display', get_string('gradedisplaytype', 'grades'), $options);
 186          $mform->addHelpButton('grade_item_display', 'gradedisplaytype', 'grades');
 187  
 188          $default_gradedecimals = grade_get_setting($COURSE->id, 'decimalpoints', $CFG->grade_decimalpoints);
 189          $options = array(-1=>get_string('defaultprev', 'grades', $default_gradedecimals), 0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5);
 190          $mform->addElement('select', 'grade_item_decimals', get_string('decimalpoints', 'grades'), $options);
 191          $mform->addHelpButton('grade_item_decimals', 'decimalpoints', 'grades');
 192          $mform->setDefault('grade_item_decimals', -1);
 193          $mform->disabledIf('grade_item_decimals', 'grade_item_display', 'eq', GRADE_DISPLAY_TYPE_LETTER);
 194  
 195          if ($default_gradedisplaytype == GRADE_DISPLAY_TYPE_LETTER) {
 196              $mform->disabledIf('grade_item_decimals', 'grade_item_display', "eq", GRADE_DISPLAY_TYPE_DEFAULT);
 197          }
 198  
 199          /// hiding
 200          // advcheckbox is not compatible with disabledIf!
 201          $mform->addElement('checkbox', 'grade_item_hidden', get_string('hidden', 'grades'));
 202          $mform->addHelpButton('grade_item_hidden', 'hidden', 'grades');
 203          $mform->addElement('date_time_selector', 'grade_item_hiddenuntil', get_string('hiddenuntil', 'grades'), array('optional'=>true));
 204          $mform->disabledIf('grade_item_hidden', 'grade_item_hiddenuntil[off]', 'notchecked');
 205  
 206          /// locking
 207          $mform->addElement('checkbox', 'grade_item_locked', get_string('locked', 'grades'));
 208          $mform->addHelpButton('grade_item_locked', 'locked', 'grades');
 209  
 210          $mform->addElement('date_time_selector', 'grade_item_locktime', get_string('locktime', 'grades'), array('optional'=>true));
 211          $mform->disabledIf('grade_item_locktime', 'grade_item_gradetype', 'eq', GRADE_TYPE_NONE);
 212  
 213  /// parent category related settings
 214          $mform->addElement('header', 'headerparent', get_string('parentcategory', 'grades'));
 215  
 216          $mform->addElement('advcheckbox', 'grade_item_weightoverride', get_string('adjustedweight', 'grades'));
 217          $mform->addHelpButton('grade_item_weightoverride', 'weightoverride', 'grades');
 218  
 219          $mform->addElement('text', 'grade_item_aggregationcoef2', get_string('weight', 'grades'));
 220          $mform->addHelpButton('grade_item_aggregationcoef2', 'weight', 'grades');
 221          $mform->setType('grade_item_aggregationcoef2', PARAM_RAW);
 222          $mform->disabledIf('grade_item_aggregationcoef2', 'grade_item_weightoverride');
 223  
 224          $options = array();
 225          $default = -1;
 226          $categories = grade_category::fetch_all(array('courseid'=>$COURSE->id));
 227  
 228          foreach ($categories as $cat) {
 229              $cat->apply_forced_settings();
 230              $options[$cat->id] = $cat->get_name();
 231              if ($cat->is_course_category()) {
 232                  $default = $cat->id;
 233              }
 234          }
 235  
 236          if (count($categories) > 1) {
 237              $mform->addElement('select', 'parentcategory', get_string('parentcategory', 'grades'), $options);
 238              $mform->setDefault('parentcategory', $default);
 239              $mform->addElement('static', 'currentparentaggregation', get_string('currentparentaggregation', 'grades'));
 240          }
 241  
 242          // hidden params
 243          $mform->addElement('hidden', 'id', 0);
 244          $mform->setType('id', PARAM_INT);
 245  
 246          $mform->addElement('hidden', 'courseid', 0);
 247          $mform->setType('courseid', PARAM_INT);
 248  
 249  /// add return tracking info
 250          $gpr = $this->_customdata['gpr'];
 251          $gpr->add_mform_elements($mform);
 252  
 253  /// mark advanced according to site settings
 254          if (isset($CFG->grade_item_advanced)) {
 255              $advanced = explode(',', $CFG->grade_item_advanced);
 256              foreach ($advanced as $el) {
 257                  $el = 'grade_item_'.$el;
 258                  if ($mform->elementExists($el)) {
 259                      $mform->setAdvanced($el);
 260                  }
 261              }
 262          }
 263  
 264  //-------------------------------------------------------------------------------
 265          // buttons
 266          $this->add_action_buttons();
 267  //-------------------------------------------------------------------------------
 268          $this->set_data($category);
 269      }
 270  
 271  
 272  /// tweak the form - depending on existing data
 273      function definition_after_data() {
 274          global $CFG, $COURSE;
 275  
 276          $mform =& $this->_form;
 277  
 278          $somecat = new grade_category();
 279  
 280          foreach ($somecat->forceable as $property) {
 281              if ((int)$CFG->{"grade_{$property}_flag"} & 1) {
 282                  if ($mform->elementExists($property)) {
 283                      if (empty($CFG->grade_hideforcedsettings)) {
 284                          $mform->hardFreeze($property);
 285                      } else {
 286                          if ($mform->elementExists($property)) {
 287                              $mform->removeElement($property);
 288                          }
 289                      }
 290                  }
 291              }
 292          }
 293  
 294          if ($CFG->grade_droplow > 0) {
 295              if ($mform->elementExists('keephigh')) {
 296                  $mform->removeElement('keephigh');
 297              }
 298          } else if ($CFG->grade_keephigh > 0) {
 299              if ($mform->elementExists('droplow')) {
 300                  $mform->removeElement('droplow');
 301              }
 302          }
 303  
 304          if ($id = $mform->getElementValue('id')) {
 305              $grade_category = grade_category::fetch(array('id'=>$id));
 306              $grade_item = $grade_category->load_grade_item();
 307  
 308              // remove agg coef if not used
 309              if ($grade_category->is_course_category()) {
 310                  if ($mform->elementExists('parentcategory')) {
 311                      $mform->removeElement('parentcategory');
 312                  }
 313                  if ($mform->elementExists('currentparentaggregation')) {
 314                      $mform->removeElement('currentparentaggregation');
 315                  }
 316  
 317              } else {
 318                  // if we wanted to change parent of existing category - we would have to verify there are no circular references in parents!!!
 319                  if ($mform->elementExists('parentcategory')) {
 320                      $mform->hardFreeze('parentcategory');
 321                  }
 322                  $parent_cat = $grade_category->get_parent_category();
 323                  $mform->setDefault('currentparentaggregation', $this->aggregation_options[$parent_cat->aggregation]);
 324  
 325              }
 326  
 327              // Prevent the user from using drop lowest/keep highest when the aggregation method cannot handle it.
 328              if (!$grade_category->can_apply_limit_rules()) {
 329                  if ($mform->elementExists('keephigh')) {
 330                      $mform->setConstant('keephigh', 0);
 331                      $mform->hardFreeze('keephigh');
 332                  }
 333                  if ($mform->elementExists('droplow')) {
 334                      $mform->setConstant('droplow', 0);
 335                      $mform->hardFreeze('droplow');
 336                  }
 337              }
 338  
 339              if ($grade_item->is_calculated()) {
 340                  // following elements are ignored when calculation formula used
 341                  if ($mform->elementExists('aggregation')) {
 342                      $mform->removeElement('aggregation');
 343                  }
 344                  if ($mform->elementExists('keephigh')) {
 345                      $mform->removeElement('keephigh');
 346                  }
 347                  if ($mform->elementExists('droplow')) {
 348                      $mform->removeElement('droplow');
 349                  }
 350                  if ($mform->elementExists('aggregateonlygraded')) {
 351                      $mform->removeElement('aggregateonlygraded');
 352                  }
 353                  if ($mform->elementExists('aggregateoutcomes')) {
 354                      $mform->removeElement('aggregateoutcomes');
 355                  }
 356              }
 357  
 358              // If it is a course category, remove the "required" rule from the "fullname" element
 359              if ($grade_category->is_course_category()) {
 360                  unset($mform->_rules['fullname']);
 361                  $key = array_search('fullname', $mform->_required);
 362                  unset($mform->_required[$key]);
 363              }
 364  
 365              // If it is a course category and its fullname is ?, show an empty field
 366              if ($grade_category->is_course_category() && $mform->getElementValue('fullname') == '?') {
 367                  $mform->setDefault('fullname', '');
 368              }
 369              // remove unwanted aggregation options
 370              if ($mform->elementExists('aggregation')) {
 371                  $allaggoptions = array_keys($this->aggregation_options);
 372                  $agg_el =& $mform->getElement('aggregation');
 373                  $visible = explode(',', $CFG->grade_aggregations_visible);
 374                  if (!is_null($grade_category->aggregation)) {
 375                      // current type is always visible
 376                      $visible[] = $grade_category->aggregation;
 377                  }
 378                  foreach ($allaggoptions as $type) {
 379                      if (!in_array($type, $visible)) {
 380                          $agg_el->removeOption($type);
 381                      }
 382                  }
 383              }
 384  
 385          } else {
 386              // adding new category
 387              if ($mform->elementExists('currentparentaggregation')) {
 388                  $mform->removeElement('currentparentaggregation');
 389              }
 390              // remove unwanted aggregation options
 391              if ($mform->elementExists('aggregation')) {
 392                  $allaggoptions = array_keys($this->aggregation_options);
 393                  $agg_el =& $mform->getElement('aggregation');
 394                  $visible = explode(',', $CFG->grade_aggregations_visible);
 395                  foreach ($allaggoptions as $type) {
 396                      if (!in_array($type, $visible)) {
 397                          $agg_el->removeOption($type);
 398                      }
 399                  }
 400              }
 401          }
 402  
 403  
 404          // no parent header for course category
 405          if (!$mform->elementExists('parentcategory')) {
 406              $mform->removeElement('headerparent');
 407          }
 408  
 409  /// GRADE ITEM
 410          if ($id = $mform->getElementValue('id')) {
 411              $grade_category = grade_category::fetch(array('id'=>$id));
 412              $grade_item = $grade_category->load_grade_item();
 413  
 414              $mform->setDefault('grade_item_hidden', (int) $grade_item->hidden);
 415  
 416              if ($grade_item->is_outcome_item()) {
 417                  // we have to prevent incompatible modifications of outcomes if outcomes disabled
 418                  $mform->removeElement('grade_item_grademax');
 419                  if ($mform->elementExists('grade_item_grademin')) {
 420                      $mform->removeElement('grade_item_grademin');
 421                  }
 422                  $mform->removeElement('grade_item_gradetype');
 423                  $mform->removeElement('grade_item_display');
 424                  $mform->removeElement('grade_item_decimals');
 425                  $mform->hardFreeze('grade_item_scaleid');
 426              }
 427  
 428              //remove the aggregation coef element if not needed
 429              if ($grade_item->is_course_item()) {
 430                  if ($mform->elementExists('grade_item_aggregationcoef')) {
 431                      $mform->removeElement('grade_item_aggregationcoef');
 432                  }
 433  
 434                  if ($mform->elementExists('grade_item_weightoverride')) {
 435                      $mform->removeElement('grade_item_weightoverride');
 436                  }
 437                  if ($mform->elementExists('grade_item_aggregationcoef2')) {
 438                      $mform->removeElement('grade_item_aggregationcoef2');
 439                  }
 440              } else {
 441                  if ($grade_item->is_category_item()) {
 442                      $category = $grade_item->get_item_category();
 443                      $parent_category = $category->get_parent_category();
 444                  } else {
 445                      $parent_category = $grade_item->get_parent_category();
 446                  }
 447  
 448                  $parent_category->apply_forced_settings();
 449  
 450                  if (!$parent_category->is_aggregationcoef_used()) {
 451                      if ($mform->elementExists('grade_item_aggregationcoef')) {
 452                          $mform->removeElement('grade_item_aggregationcoef');
 453                      }
 454                  } else {
 455  
 456                      $coefstring = $grade_item->get_coefstring();
 457  
 458                      if ($coefstring == 'aggregationcoefextrasum' || $coefstring == 'aggregationcoefextraweightsum') {
 459                          // advcheckbox is not compatible with disabledIf!
 460                          $coefstring = 'aggregationcoefextrasum';
 461                          $element =& $mform->createElement('checkbox', 'grade_item_aggregationcoef', get_string($coefstring, 'grades'));
 462                      } else {
 463                          $element =& $mform->createElement('text', 'grade_item_aggregationcoef', get_string($coefstring, 'grades'));
 464                      }
 465                      $mform->insertElementBefore($element, 'parentcategory');
 466                      $mform->addHelpButton('grade_item_aggregationcoef', $coefstring, 'grades');
 467                  }
 468  
 469                  // Remove fields used by natural weighting if the parent category is not using natural weighting.
 470                  // Or if the item is a scale and scales are not used in aggregation.
 471                  if ($parent_category->aggregation != GRADE_AGGREGATE_SUM
 472                          || (empty($CFG->grade_includescalesinaggregation) && $grade_item->gradetype == GRADE_TYPE_SCALE)) {
 473                      if ($mform->elementExists('grade_item_weightoverride')) {
 474                          $mform->removeElement('grade_item_weightoverride');
 475                      }
 476                      if ($mform->elementExists('grade_item_aggregationcoef2')) {
 477                          $mform->removeElement('grade_item_aggregationcoef2');
 478                      }
 479                  }
 480              }
 481          }
 482      }
 483  
 484  /// perform extra validation before submission
 485      function validation($data, $files) {
 486          global $COURSE;
 487  
 488          $errors = parent::validation($data, $files);
 489  
 490          if (array_key_exists('grade_item_gradetype', $data) and $data['grade_item_gradetype'] == GRADE_TYPE_SCALE) {
 491              if (empty($data['grade_item_scaleid'])) {
 492                  $errors['grade_item_scaleid'] = get_string('missingscale', 'grades');
 493              }
 494          }
 495          if (array_key_exists('grade_item_grademin', $data) and array_key_exists('grade_item_grademax', $data)) {
 496              if (($data['grade_item_grademax'] != 0 OR $data['grade_item_grademin'] != 0) AND
 497                  ($data['grade_item_grademax'] == $data['grade_item_grademin'] OR
 498                   $data['grade_item_grademax'] < $data['grade_item_grademin'])) {
 499                   $errors['grade_item_grademin'] = get_string('incorrectminmax', 'grades');
 500                   $errors['grade_item_grademax'] = get_string('incorrectminmax', 'grades');
 501               }
 502          }
 503  
 504          return $errors;
 505      }
 506  }
 507  
 508  


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