mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge from 19_STABLE (MDL-10639)
This commit is contained in:
parent
944f423afd
commit
20d61ce52b
@ -24,9 +24,10 @@
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->libdir.'/gradelib.php';
|
||||
/// THIS SCRIPT IS CALLED WITH "require_once()" FROM index.php
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.');
|
||||
}
|
||||
|
||||
$courseid = optional_param('id', 0, PARAM_INT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
@ -93,7 +94,9 @@ if ($courseid) {
|
||||
$caneditcoursescales = $caneditsystemscales;
|
||||
}
|
||||
|
||||
if ($_FILES['userfile']['size'] == 0) {
|
||||
$imported_file = $upload_form->_upload_manager->files;
|
||||
|
||||
if ($imported_file['userfile']['size'] == 0) {
|
||||
redirect('index.php'. ($courseid ? "?id=$courseid" : ''), get_string('importfilemissing', 'grades'));
|
||||
}
|
||||
|
||||
@ -110,7 +113,7 @@ if (isset($courseid) && ($scope == 'local')) {
|
||||
}
|
||||
|
||||
// open the file, start importing data
|
||||
if ($handle = fopen($_FILES['userfile']['tmp_name'], 'r')) {
|
||||
if ($handle = fopen($imported_file['userfile']['tmp_name'], 'r')) {
|
||||
$line = 0; // will keep track of current line, to give better error messages.
|
||||
$file_headers = '';
|
||||
|
||||
|
34
grade/edit/outcome/import_outcomes_form.php
Normal file
34
grade/edit/outcome/import_outcomes_form.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php /* $Id$ */
|
||||
|
||||
require_once($CFG->dirroot.'/lib/formslib.php');
|
||||
|
||||
class import_outcomes_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
global $COURSE, $USER;
|
||||
|
||||
$mform =& $this->_form;
|
||||
//$this->set_upload_manager(new upload_manager('importfile', false, false, null, false, 0, true, true, false));
|
||||
|
||||
$mform->addElement('hidden', 'action', 'upload');
|
||||
$mform->addElement('hidden', 'id', $COURSE->id);
|
||||
|
||||
$scope = array();
|
||||
if (($COURSE->id > 1) && has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$mform->addElement('radio', 'scope', get_string('importcustom', 'grades'), null, 'custom');
|
||||
$mform->addElement('radio', 'scope', get_string('importstandard', 'grades'), null, 'global');
|
||||
$mform->setDefault('scope', 'custom');
|
||||
}
|
||||
|
||||
$mform->addElement('file', 'userfile', get_string('importoutcomes', 'grades'));
|
||||
|
||||
$mform->addElement('submit', 'save', get_string('uploadthisfile'));
|
||||
|
||||
}
|
||||
|
||||
function get_um() {
|
||||
return $this->_upload_manager;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -25,6 +25,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once '../../../config.php';
|
||||
require_once($CFG->dirroot.'/lib/formslib.php');
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->libdir.'/gradelib.php';
|
||||
|
||||
@ -52,6 +53,14 @@ if ($courseid) {
|
||||
/// return tracking object
|
||||
$gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'outcome', 'courseid'=>$courseid));
|
||||
|
||||
require_once('import_outcomes_form.php');
|
||||
$upload_form = new import_outcomes_form();
|
||||
|
||||
if ($upload_form_data = $upload_form->get_data()) {
|
||||
require_once('import.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$strgrades = get_string('grades');
|
||||
$pagename = get_string('outcomes', 'grades');
|
||||
@ -118,7 +127,10 @@ if ($courseid) {
|
||||
|
||||
print('<form action="export.php" method="post">' ."\n");
|
||||
|
||||
$outcomes_to_export = false;
|
||||
|
||||
if ($courseid and $outcomes = grade_outcome::fetch_all_local($courseid)) {
|
||||
$outcomes_to_export = true;
|
||||
|
||||
print_heading($strcustomoutcomes);
|
||||
$data = array();
|
||||
@ -175,7 +187,8 @@ if ($courseid and $outcomes = grade_outcome::fetch_all_local($courseid)) {
|
||||
|
||||
|
||||
if ($outcomes = grade_outcome::fetch_all_global()) {
|
||||
|
||||
$outcomes_to_export = true;
|
||||
|
||||
print_heading($strstandardoutcome);
|
||||
$data = array();
|
||||
foreach($outcomes as $outcome) {
|
||||
@ -235,7 +248,9 @@ if ($outcomes = grade_outcome::fetch_all_global()) {
|
||||
|
||||
echo '<div class="buttons">';
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />";
|
||||
print('<input type="submit" value="'. get_string('exportselectedoutcomes', 'grades') .'" name="export_outcomes"></form>');
|
||||
if ( $outcomes_to_export ) {
|
||||
print('<input type="submit" value="'. get_string('exportselectedoutcomes', 'grades') .'" name="export_outcomes"></form>');
|
||||
}
|
||||
print_single_button('edit.php', array('courseid'=>$courseid), $srtcreatenewoutcome);
|
||||
echo '</div>';
|
||||
|
||||
@ -243,34 +258,13 @@ echo '<div>';
|
||||
$upload_max_filesize = get_max_upload_file_size($CFG->maxbytes);
|
||||
$filesize = display_size($upload_max_filesize);
|
||||
|
||||
$strimportoutcomes = get_string('importoutcomes', 'grades');
|
||||
$struploadthisfile = get_string('uploadthisfile');
|
||||
$strimportcustom = get_string('importcustom', 'grades');
|
||||
$strimportstandard = get_string('importstandard', 'grades');
|
||||
$strmaxsize = get_string("maxsize", "", $filesize);
|
||||
//$strimportoutcomes = get_string('importoutcomes', 'grades');
|
||||
//$struploadthisfile = get_string('uploadthisfile');
|
||||
//$strimportcustom = get_string('importcustom', 'grades');
|
||||
//$strimportstandard = get_string('importstandard', 'grades');
|
||||
//$strmaxsize = get_string("maxsize", "", $filesize);
|
||||
|
||||
require_once($CFG->dirroot.'/lib/uploadlib.php');
|
||||
|
||||
echo '<div>';
|
||||
echo '<form enctype="multipart/form-data" method="post" action="import.php">';
|
||||
echo '<input type="hidden" name="action" value="upload" />';
|
||||
echo '<input type="hidden" name="id" value="'. $courseid .'" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'. $USER->sesskey .'" />';
|
||||
echo '<table class="generalbox boxaligncenter" width="50%" cellspacing="1" cellpadding="5">';
|
||||
if ($courseid && has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
echo '<tr><td><ul style="list-style-type:none;">';
|
||||
echo '<li><label><input type="radio" name="scope" value="local" checked="checked">'. $strimportcustom .'</label>';
|
||||
echo '<li><label><input type="radio" name="scope" value="global">'. $strimportstandard .'</label>';
|
||||
echo '</ul></td></tr>';
|
||||
}
|
||||
echo '<tr><td><p>'. $strimportoutcomes .'('. $strmaxsize .')</p></td></tr>';
|
||||
echo '<tr><td>'.
|
||||
upload_print_form_fragment(1,array('userfile'),null,false,null,$upload_max_filesize,0,true) .
|
||||
'<input type="submit" name="save" value="'. $struploadthisfile .'" /></td></tr>';
|
||||
echo '</table>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
$upload_form->display();
|
||||
|
||||
if ($courseid) {
|
||||
print_footer($course);
|
||||
|
Loading…
x
Reference in New Issue
Block a user