PageRenderTime 33ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/mod/assign/feedback/offline/uploadgradesform.php

https://bitbucket.org/moodle/moodle
PHP | 89 lines | 43 code | 15 blank | 31 comment | 1 complexity | 84c2ef0b995c29d1c84ac12ab6095c18 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1, BSD-3-Clause, MIT, GPL-3.0
  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. * This file contains the forms to create and edit an instance of this module
  18. *
  19. * @package assignfeedback_offline
  20. * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
  24. require_once($CFG->libdir.'/formslib.php');
  25. /**
  26. * Upload modified grading worksheet
  27. *
  28. * @package assignfeedback_offline
  29. * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  30. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  31. */
  32. class assignfeedback_offline_upload_grades_form extends moodleform {
  33. /**
  34. * Define this form - called by the parent constructor
  35. */
  36. public function definition() {
  37. global $COURSE, $USER;
  38. $mform = $this->_form;
  39. $params = $this->_customdata;
  40. $mform->addElement('header', 'uploadgrades', get_string('uploadgrades', 'assignfeedback_offline'));
  41. $fileoptions = array('subdirs'=>0,
  42. 'maxbytes'=>$COURSE->maxbytes,
  43. 'accepted_types'=>'csv',
  44. 'maxfiles'=>1,
  45. 'return_types'=>FILE_INTERNAL);
  46. $mform->addElement('filepicker', 'gradesfile', get_string('uploadafile'), null, $fileoptions);
  47. $mform->addRule('gradesfile', get_string('uploadnofilefound'), 'required', null, 'client');
  48. $mform->addHelpButton('gradesfile', 'gradesfile', 'assignfeedback_offline');
  49. $encodings = core_text::get_encodings();
  50. $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
  51. $mform->addHelpButton('encoding', 'encoding', 'grades');
  52. $radio = array();
  53. $radio[] = $mform->createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab');
  54. $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepcomma', 'grades'), 'comma');
  55. $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepcolon', 'grades'), 'colon');
  56. $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepsemicolon', 'grades'), 'semicolon');
  57. $mform->addGroup($radio, 'separator', get_string('separator', 'grades'), ' ', false);
  58. $mform->addHelpButton('separator', 'separator', 'grades');
  59. $mform->setDefault('separator', 'comma');
  60. $mform->addElement('checkbox', 'ignoremodified', '', get_string('ignoremodified', 'assignfeedback_offline'));
  61. $mform->addHelpButton('ignoremodified', 'ignoremodified', 'assignfeedback_offline');
  62. $mform->addElement('hidden', 'id', $params['cm']);
  63. $mform->setType('id', PARAM_INT);
  64. $mform->addElement('hidden', 'action', 'viewpluginpage');
  65. $mform->setType('action', PARAM_ALPHA);
  66. $mform->addElement('hidden', 'pluginaction', 'uploadgrades');
  67. $mform->setType('pluginaction', PARAM_ALPHA);
  68. $mform->addElement('hidden', 'plugin', 'offline');
  69. $mform->setType('plugin', PARAM_PLUGIN);
  70. $mform->addElement('hidden', 'pluginsubtype', 'assignfeedback');
  71. $mform->setType('pluginsubtype', PARAM_PLUGIN);
  72. $this->add_action_buttons(true, get_string('uploadgrades', 'assignfeedback_offline'));
  73. }
  74. }