Skip to content

Commit

Permalink
Maintenance: Course import: Improve links imported from moodle - refs…
Browse files Browse the repository at this point in the history
… BT#20060

Author: @christianbeeznest
  • Loading branch information
christianbeeznest committed Jan 10, 2023
1 parent f6c7cd2 commit 6591c8c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main/inc/lib/MoodleImport.php
Expand Up @@ -510,13 +510,14 @@ public function import($uploadedFile)
$moduleXml = @file_get_contents($destinationDir.'/'.$moduleDir.'/'.$moduleName.'.xml');
$moduleValues = $this->readUrlModule($moduleXml);
$sectionPath = isset($sectionLpValues[$currentItem['sectionid']]) ? $sectionLpValues[$currentItem['sectionid']]['sectionPath'] : '';
$sectionName = isset($sectionLpValues[$currentItem['sectionid']]) ? $sectionLpValues[$currentItem['sectionid']]['sectionName'] : '';
$categoryId = 0;
if (!empty($sectionPath)) {
$category = Link::getCategoryByName($sectionPath);
if (!empty($sectionName)) {
$category = Link::getCategoryByName($sectionName);
if (!empty($category)) {
$categoryId = $category['iid'];
} else {
$_POST['category_title'] = $sectionPath;
$_POST['category_title'] = $sectionName;
$_POST['description'] = '';
$categoryId = Link::addlinkcategory('category');
}
Expand All @@ -531,7 +532,7 @@ public function import($uploadedFile)
if ($importedFiles) {
$this->fixPathInText($importedFiles, $moduleValues['intro']);
}
$_POST['description'] = $moduleValues['intro'];
$_POST['description'] = strip_tags($moduleValues['intro']);
$_POST['category_id'] = $categoryId;
$_POST['target'] = '_blank';

Expand Down Expand Up @@ -680,6 +681,7 @@ public function processSections($sections, $activities)
$lpAdded[$sectionId] = [
'lpId' => $lpId,
'sectionPath' => $dirName,
'sectionName' => $lpName,
];
$i++;
}
Expand Down

0 comments on commit 6591c8c

Please sign in to comment.