Commit 77371e2d authored by Andrew Nicols's avatar Andrew Nicols
Browse files

Merge branch 'MDL-55767-master-fix1' of http://github.com/damyon/moodle

parents b31984d5 9b807e6d
......@@ -52,6 +52,7 @@ class framework_importer {
protected $importid = 0;
protected $importer = null;
protected $foundheaders = array();
protected $scalecache = array();
/**
* Store an error message for display later
......@@ -355,13 +356,17 @@ class framework_importer {
require_once($CFG->libdir . '/gradelib.php');
$allscales = grade_scale::fetch_all_global();
$matchingscale = false;
foreach ($allscales as $scale) {
if ($scale->compact_items() == $scalevalues) {
$matchingscale = $scale;
if (empty($this->scalecache)) {
$allscales = grade_scale::fetch_all_global();
foreach ($allscales as $scale) {
$scale->load_items();
$this->scalecache[$scale->compact_items()] = $scale;
}
}
$matchingscale = false;
if (isset($this->scalecache[$scalevalues])) {
$matchingscale = $this->scalecache[$scalevalues];
}
if (!$matchingscale) {
// Create it.
$newscale = new grade_scale();
......@@ -371,6 +376,7 @@ class framework_importer {
$newscale->scale = $scalevalues;
$newscale->description = get_string('competencyscaledescription', 'tool_lpimportcsv');
$newscale->insert();
$this->scalecache[$scalevalues] = $newscale;
return $newscale->id;
}
return $matchingscale->id;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment