From: Vincent Vanwaelscappel Date: Thu, 9 Dec 2021 12:52:28 +0000 (+0100) Subject: wait #4951 @3 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f5a3eeb12ea792321e0488a2632ab972e94e9358;p=fluidbook-toolbox.git wait #4951 @3 --- diff --git a/app/Jobs/FluidbookCollectionDownload.php b/app/Jobs/FluidbookCollectionDownload.php index 0dc348373..753bceef9 100644 --- a/app/Jobs/FluidbookCollectionDownload.php +++ b/app/Jobs/FluidbookCollectionDownload.php @@ -9,6 +9,7 @@ use Cubist\Util\Files\Files; use Cubist\Util\PHP; use Cubist\Util\Str; use Cubist\Util\Zip; +use GuzzleHttp\Exception\RequestException; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -16,6 +17,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Mail; use InvalidArgumentException; +use Psr\Http\Message\ResponseInterface; use RusticiSoftware\Cloud\V2 as ScormCloud; @@ -77,13 +79,13 @@ class FluidbookCollectionDownload implements ShouldQueue try { if ($this->action === 'scormcloud') { - $scormURL = $this->sendToSCORMCloud($dest); + $scormURL = $this->sendToSCORMCloud($url); $body .= "

"; $body .= __('La collection peut être testée sur SCORM Cloud : :url', ['url' => $scormURL]); } } catch (\Exception $e) { $body .= "

"; - $body .= __('Une erreur s\'est produite lors de l\'envoi sur SCORM Cloud : :error', ['error' => $e->getMessage()]); + $body .= __('Une erreur s\'est produite lors de l\'envoi sur SCORM Cloud (App ID :appid) : :error', ['error' => $e->getMessage(), 'appid' => env('SCORM_CLOUD_APP_ID')]); } @@ -156,57 +158,60 @@ class FluidbookCollectionDownload implements ShouldQueue } $options = $this->getCollectionGlobalSettings(); + $options['scorm_enable'] = true; - if ($data->locale_switch) { - $multilang = []; - foreach ($langs as $fbid => $lang) { - if ($countries[$fbid]) { - $flag = $countries[$fbid]; - } else { - if (strlen($lang) === 5) { - $flag = substr($lang, 3, 2); - } else if (isset($defaultFlags[$lang])) { - $flag = $defaultFlags[$lang]; + if (count($data->publications) >= 2) { + + if ($data->locale_switch) { + $multilang = []; + foreach ($langs as $fbid => $lang) { + if ($countries[$fbid]) { + $flag = $countries[$fbid]; } else { - $flag = $lang; + if (strlen($lang) === 5) { + $flag = substr($lang, 3, 2); + } else if (isset($defaultFlags[$lang])) { + $flag = $defaultFlags[$lang]; + } else { + $flag = $lang; + } } + $multilang[] = $lang . ',' . strtolower($flag) . ',../' . $lang . '/index.html'; } - $multilang[] = $lang . ',' . strtolower($flag) . ',../' . $lang . '/index.html'; + $options['multilang'] = implode("\n", $multilang); + $options['multilangDisplay'] = 'lang'; + } else { + $options['multilang'] = ''; } - $options['multilang'] = implode("\n", $multilang); - $options['multilangDisplay'] = 'lang'; - } else { - $options['multilang'] = ''; - } - foreach ($data->publications as $publication) { - $fbid = $publication['fluidbook']; - $lang = $langs[$fbid]; - $dir = $path . '/' . $lang; - $ws->installBook($fbid, $dir, $options, 'scorm', 3); - } - - if (in_array('en', $langs)) { - $default = 'en'; - } else { - $default = $langs[0]; - } + foreach ($data->publications as $publication) { + $fbid = $publication['fluidbook']; + $lang = $langs[$fbid]; + $dir = $path . '/' . $lang; + $ws->installBook($fbid, $dir, $options, 'scorm', 3); + } - $manifestFile = $path . '/imsmanifest.xml'; - foreach ($langs as $lang) { - $manifest = $path . '/' . $lang . '/imsmanifest.xml'; - if ($lang === $default) { - rename($manifest, $manifestFile); + if (in_array('en', $langs)) { + $default = 'en'; } else { - unlink($manifest); + $default = $langs[0]; } - } - $manifestContent = file_get_contents($manifestFile); - $manifestContent = preg_replace('/\(.*)\<\/title\>/U', '' . htmlspecialchars($this->collection->title) . '', $manifestContent); - file_put_contents($manifestFile, $manifestContent); + $manifestFile = $path . '/imsmanifest.xml'; + foreach ($langs as $lang) { + $manifest = $path . '/' . $lang . '/imsmanifest.xml'; + if ($lang === $default) { + rename($manifest, $manifestFile); + } else { + unlink($manifest); + } + } + + $manifestContent = file_get_contents($manifestFile); + $manifestContent = preg_replace('/\(.*)\<\/title\>/U', '' . htmlspecialchars($this->collection->title) . '', $manifestContent); + file_put_contents($manifestFile, $manifestContent); - $redirectionScript = " + $redirectionScript = "