Skip to content

Commit

Permalink
#106977 load all available libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
Ewa Soroka committed Oct 8, 2024
1 parent 6289773 commit fc55cd6
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 64 deletions.
62 changes: 30 additions & 32 deletions Moosh/Command/Moodle41/H5pCore/helpers/H5pCoreExportManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,47 +92,45 @@ private function export($filename, $verbose, $runnable){

// appending libraries (or content types)
$row_count = 0;
foreach ($libraries as $library) {
if($verbose) {
mtrace("Exporting object.");
}
foreach ($libraries as $librarytype) {
foreach($librarytype as $library) {
if($verbose) {
mtrace("Exporting object.");
}

// for default libraries are returned as 1-item arrays
if(is_array($library)) {
$library = reset($library);
}
// in case of unexpected data structure we don't want any thrown errors
if(!is_object($library)) {
mtrace("Cannot load one of the objects - skipping.");
continue;
}

// in case of unexpected data structure we don't want any thrown errors
if(!is_object($library)) {
mtrace("Cannot load one of the objects - skipping.");
continue;
}
// check object type
// runnable 0 - library, runnable 1 - content type
if($library->runnable != (int) $runnable) {
if($verbose) {
$expected_runnable = (int) $runnable;
mtrace("Skipping $library->title, cause of runnable: $library->runnable, expected: $expected_runnable.");
}

// check object type
// runnable 0 - library, runnable 1 - content type
if($library->runnable != (int) $runnable) {
if($verbose) {
$expected_runnable = (int) $runnable;
mtrace("Skipping $library->title, cause of runnable: $library->runnable, expected: $expected_runnable.");
// skipping
continue;
}

// skipping
continue;
}

if($verbose) {
mtrace("Mapping object $library->title.");
}
if($verbose) {
mtrace("Mapping object $library->title.");
}

// mapping to avoid duplicating expected fields values
$row = $this->mapCsvRow($library, $expected_fields, $verbose);
// mapping to avoid duplicating expected fields values
$row = $this->mapCsvRow($library, $expected_fields, $verbose);

$csv_writer->add_data($row);
$row_count++;
$csv_writer->add_data($row);
$row_count++;

if($verbose) {
mtrace("Object $library->title mapped.");
if($verbose) {
mtrace("Object $library->title mapped.");
}
}

}

if($verbose) {
Expand Down
62 changes: 30 additions & 32 deletions Moosh/Command/Moodle41/H5pPlugin/helpers/H5pPluginExportManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,46 +91,43 @@ private function export($filename, $verbose, $runnable){

// appending libraries (or content types)
$row_count = 0;
foreach ($libraries as $library) {
if($verbose) {
mtrace("Exporting object.");
}
foreach ($libraries as $librarytype) {
foreach($librarytype as $library) {
if ($verbose) {
mtrace("Exporting object.");
}

// for default libraries are returned as 1-item arrays
if(is_array($library)) {
$library = reset($library);
}
// in case of unexpected data structure we don't want any thrown errors
if (!is_object($library)) {
mtrace("Cannot load one of the objects - skipping.");
continue;
}

// in case of unexpected data structure we don't want any thrown errors
if(!is_object($library)) {
mtrace("Cannot load one of the objects - skipping.");
continue;
}
// check object type
// runnable 0 - library, runnable 1 - content type
if ($library->runnable != (int)$runnable) {
if ($verbose) {
$expected_runnable = (int)$runnable;
mtrace("Skipping $library->title, cause of runnable: $library->runnable, expected: $expected_runnable.");
}

// check object type
// runnable 0 - library, runnable 1 - content type
if($library->runnable != (int) $runnable) {
if($verbose) {
$expected_runnable = (int) $runnable;
mtrace("Skipping $library->title, cause of runnable: $library->runnable, expected: $expected_runnable.");
// skipping
continue;
}

// skipping
continue;
}

if($verbose) {
mtrace("Mapping object $library->title.");
}
if ($verbose) {
mtrace("Mapping object $library->title.");
}

// mapping to avoid duplicating expected fields values
$row = $this->mapCsvRow($library, $expected_fields, $verbose);
// mapping to avoid duplicating expected fields values
$row = $this->mapCsvRow($library, $expected_fields, $verbose);

$csv_writer->add_data($row);
$row_count++;
$csv_writer->add_data($row);
$row_count++;

if($verbose) {
mtrace("Object $library->title mapped.");
if ($verbose) {
mtrace("Object $library->title mapped.");
}
}
}

Expand All @@ -141,6 +138,7 @@ private function export($filename, $verbose, $runnable){
file_put_contents($filename, $csv_writer->print_csv_data(true));

mtrace("Exported file $filename with $row_count elements.");

}

/**
Expand Down

0 comments on commit fc55cd6

Please sign in to comment.