Skip to content

Commit

Permalink
Merge branch 'MDL-44585-master' of https://github.com/StudiUM/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Mar 17, 2014
2 parents e658258 + 3d90e53 commit 7aafc49
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
3 changes: 2 additions & 1 deletion grade/import/csv/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
}

// Set up the import form.
$mform = new grade_import_form(null, array('includeseparator'=>true, 'verbosescales'=>true));
$mform = new grade_import_form(null, array('includeseparator' => true, 'verbosescales' => true, 'acceptedtypes' =>
array('.csv', '.txt')));

// If the csv file hasn't been imported yet then look for a form submission or
// show the initial submission form.
Expand Down
12 changes: 10 additions & 2 deletions grade/import/grade_import_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ function definition (){
$mform->addElement('hidden', 'id', optional_param('id', 0, PARAM_INT));
$mform->setType('id', PARAM_INT);
$mform->addElement('header', 'general', get_string('importfile', 'grades'));
// file upload
$mform->addElement('filepicker', 'userfile', get_string('file'));

// Restrict the possible upload file types.
if (!empty($features['acceptedtypes'])) {
$acceptedtypes = $features['acceptedtypes'];
} else {
$acceptedtypes = '*';
}

// File upload.
$mform->addElement('filepicker', 'userfile', get_string('file'), null, array('accepted_types' => $acceptedtypes));
$mform->addRule('userfile', null, 'required');
$encodings = core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
Expand Down
17 changes: 15 additions & 2 deletions grade/import/xml/grade_import_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ function definition () {

$mform =& $this->_form;

if (isset($this->_customdata)) {
$features = $this->_customdata;
} else {
$features = array();
}

// course id needs to be passed for auth purposes
$mform->addElement('hidden', 'id', optional_param('id', 0, PARAM_INT));
$mform->setType('id', PARAM_INT);
Expand All @@ -36,8 +42,15 @@ function definition () {
$mform->addElement('advcheckbox', 'feedback', get_string('importfeedback', 'grades'));
$mform->setDefault('feedback', 0);

// file upload
$mform->addElement('filepicker', 'userfile', get_string('file'));
// Restrict the possible upload file types.
if (!empty($features['acceptedtypes'])) {
$acceptedtypes = $features['acceptedtypes'];
} else {
$acceptedtypes = '*';
}

// File upload.
$mform->addElement('filepicker', 'userfile', get_string('file'), null, array('accepted_types' => $acceptedtypes));
$mform->disabledIf('userfile', 'url', 'noteq', '');

$mform->addElement('text', 'url', get_string('fileurl', 'gradeimport_xml'), 'size="80"');
Expand Down
2 changes: 1 addition & 1 deletion grade/import/xml/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$CFG->gradepublishing = has_capability('gradeimport/xml:publish', $context);
}

$mform = new grade_import_form();
$mform = new grade_import_form(null, array('acceptedtypes' => array('.xml')));

if ($data = $mform->get_data()) {
// Large files are likely to take their time and memory. Let PHP know
Expand Down

0 comments on commit 7aafc49

Please sign in to comment.