MDL-9636 grade_items are now limited to current course only - can not import into other courses anymore

This commit is contained in:
skodak 2007-09-26 10:54:09 +00:00
parent d15da061a1
commit 235b07fb64
2 changed files with 4 additions and 6 deletions

View File

@ -1,5 +1,6 @@
<?php //$Id$
require_once '../../../config.php';
require_once $CFG->libdir.'/gradelib.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once '../grade_import_form.php';
require_once '../lib.php';
@ -226,8 +227,7 @@ if (($formdata = data_submitted()) && !empty($formdata->map)) {
// case of an id, only maps id of a grade_item
// this was idnumber
include_once($CFG->libdir.'/grade/grade_item.php');
if (!$gradeitem = new grade_item(array('id'=>$map[$key]))) {
if (!$gradeitem = new grade_item(array('id'=>$map[$key], 'courseid'=>$course->id))) {
// supplied bad mapping, should not be possible since user
// had to pick mapping
$status = false;
@ -319,7 +319,6 @@ if (($formdata = data_submitted()) && !empty($formdata->map)) {
} else if ($formdata = $mform->get_data()) {
// else if file is just uploaded
$filename = $mform->get_userfile_name();
// Large files are likely to take their time and memory. Let PHP know
@ -371,7 +370,6 @@ if (($formdata = data_submitted()) && !empty($formdata->map)) {
echo '</table>';
/// feeding gradeitems into the grade_import_mapping_form
include_once($CFG->libdir.'/grade/grade_item.php');
$gradeitems = array();
if ($id) {
if ($grade_items = grade_item::fetch_all(array('courseid'=>$id))) {

View File

@ -6,6 +6,7 @@
*/
require_once '../../../config.php';
require_once $CFG->libdir.'/gradelib.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once '../grade_import_form.php';
require_once '../lib.php';
@ -85,8 +86,7 @@ if ( $formdata = $mform->get_data()) {
$numlines ++;
}
include_once($CFG->libdir.'/grade/grade_item.php');
if (!$gradeitem = new grade_item(array('idnumber'=>$result['#']['assignment'][0]['#']))) {
if (!$gradeitem = new grade_item(array('idnumber'=>$result['#']['assignment'][0]['#'], 'courseid'=>$course->id))) {
// gradeitem does not exist
// no data in temp table so far, abort
$status = false;