[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/grade/import/direct/classes/ -> mapping_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  require_once($CFG->libdir.'/formslib.php');
  18  require_once($CFG->libdir.'/gradelib.php');
  19  
  20  if (!defined('MOODLE_INTERNAL')) {
  21      die('Direct access to this script is forbidden.');    // It must be included from a Moodle page.
  22  }
  23  
  24  /**
  25   * Form for mapping columns to the fields in the table.
  26   *
  27   * @package   gradeimport_direct
  28   * @copyright 2014 Adrian Greeve <[email protected]>
  29   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  30   */
  31  class gradeimport_direct_mapping_form extends moodleform {
  32  
  33      /**
  34       * Definition method.
  35       */
  36      public function definition() {
  37          global $CFG, $COURSE;
  38          $mform = $this->_form;
  39  
  40          // This is an array of headers.
  41          $header = $this->_customdata['header'];
  42          // Course id.
  43  
  44          $mform->addElement('header', 'general', get_string('identifier', 'grades'));
  45          $mapfromoptions = array();
  46  
  47          if ($header) {
  48              foreach ($header as $i => $h) {
  49                  $mapfromoptions[$i] = s($h);
  50              }
  51          }
  52          $mform->addElement('select', 'mapfrom', get_string('mapfrom', 'grades'), $mapfromoptions);
  53  
  54          $maptooptions = array(
  55              'userid'       => get_string('userid', 'grades'),
  56              'username'     => get_string('username'),
  57              'useridnumber' => get_string('idnumber'),
  58              'useremail'    => get_string('email'),
  59              '0'            => get_string('ignore', 'grades')
  60          );
  61          $mform->addElement('select', 'mapto', get_string('mapto', 'grades'), $maptooptions);
  62  
  63          $mform->addElement('header', 'general', get_string('mappings', 'grades'));
  64  
  65          // Add a feedback option.
  66          $feedbacks = array();
  67          if ($gradeitems = $this->_customdata['gradeitems']) {
  68              foreach ($gradeitems as $itemid => $itemname) {
  69                  $feedbacks['feedback_'.$itemid] = get_string('feedbackforgradeitems', 'grades', $itemname);
  70              }
  71          }
  72  
  73          if ($header) {
  74              $i = 0;
  75              foreach ($header as $h) {
  76                  $h = trim($h);
  77                  // This is what each header maps to.
  78                  $headermapsto = array(
  79                      get_string('others', 'grades') => array(
  80                          '0'   => get_string('ignore', 'grades'),
  81                          'new' => get_string('newitem', 'grades')
  82                      ),
  83                      get_string('gradeitems', 'grades') => $gradeitems,
  84                      get_string('feedbacks', 'grades')  => $feedbacks
  85                  );
  86                  $mform->addElement('selectgroups', 'mapping_'.$i, s($h), $headermapsto);
  87                  $i++;
  88              }
  89          }
  90          // Course id needs to be passed for auth purposes.
  91          $mform->addElement('hidden', 'map', 1);
  92          $mform->setType('map', PARAM_INT);
  93          $mform->setConstant('map', 1);
  94          $mform->addElement('hidden', 'id', $this->_customdata['id']);
  95          $mform->setType('id', PARAM_INT);
  96          $mform->setConstant('id', $this->_customdata['id']);
  97          $mform->addElement('hidden', 'iid', $this->_customdata['iid']);
  98          $mform->setType('iid', PARAM_INT);
  99          $mform->setConstant('iid', $this->_customdata['iid']);
 100          $mform->addElement('hidden', 'importcode', $this->_customdata['importcode']);
 101          $mform->setType('importcode', PARAM_FILE);
 102          $mform->setConstant('importcode', $this->_customdata['importcode']);
 103          $mform->addElement('hidden', 'verbosescales', 1);
 104          $mform->setType('verbosescales', PARAM_INT);
 105          $mform->setConstant('verbosescales', $this->_customdata['importcode']);
 106          $mform->addElement('hidden', 'groupid', groups_get_course_group($COURSE));
 107          $mform->setType('groupid', PARAM_INT);
 108          $mform->setConstant('groupid', groups_get_course_group($COURSE));
 109          $mform->addElement('hidden', 'forceimport', $this->_customdata['forceimport']);
 110          $mform->setType('forceimport', PARAM_BOOL);
 111          $mform->setConstant('forceimport', $this->_customdata['forceimport']);
 112          $this->add_action_buttons(false, get_string('uploadgrades', 'grades'));
 113      }
 114  }


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