*/
protected $action;
+
/**
* @param $collection FluidbookCollection
* @param $user User
$url = url('storage/collection/download/' . $fname);
- $subject = __('Collection :nb prête au téléchargement', ['nb' => $this->collection->id]);
+ $subject = __('Collection ":title" (#:nb) prête au téléchargement', ['title' => $this->collection->title, 'nb' => $this->collection->id]);
$body = __('Le fichier est disponible à l\'adresse suivante : <a href=":url">:url</a>', ['url' => $url]);
- if ($this->action === 'scormcloud') {
- $scormURL = $this->sendToSCORMCloud($url);
+ try {
+ if ($this->action === 'scormcloud') {
+ $scormURL = $this->sendToSCORMCloud($dest);
+ $body .= "<br><br>";
+ $body .= __('La collection peut être testée sur SCORM Cloud : <a href=":url">:url</a>', ['url' => $scormURL]);
+ }
+ } catch (\Exception $e) {
$body .= "<br><br>";
- $body .= __('La collection peut être testée sur SCORM Cloud : <a href=":url">:url</a>', ['url' => $scormURL]);
+ $body .= __('Une erreur s\'est produite lors de l\'envoi sur SCORM Cloud : :error', ['error' => $e->getMessage()]);
}
return $ws;
}
+ protected function getCollectionGlobalSettings()
+ {
+
+ $options = [];
+ foreach ($this->collection->getPageData()->override_settings as $setting) {
+ $options[$setting['key']] = $setting['value'];
+ }
+
+ return $options;
+ }
+
+
/**
* @throws \Exception
*/
$countries[$fbid] = $metadata->settings->country;
}
-
- $options = [];
+ $options = $this->getCollectionGlobalSettings();
if ($data->locale_switch) {
$multilang = [];
}
}
- $manifestContent=file_get_contents($manifestFile);
- $manifestContent=preg_replace('/\<title\>(.*)\<\/title\>/U','<title>'.htmlspecialchars($this->collection->title).'</title>',$manifestContent);
- file_put_contents($manifestFile,$manifestContent);
+ $manifestContent = file_get_contents($manifestFile);
+ $manifestContent = preg_replace('/\<title\>(.*)\<\/title\>/U', '<title>' . htmlspecialchars($this->collection->title) . '</title>', $manifestContent);
+ file_put_contents($manifestFile, $manifestContent);
$redirectionScript = "<html>
<head></head>
{
$ws = $this->_getws2();
- $options = [];
+ $options = $this->getCollectionGlobalSettings();
$zipmerge = in_array($data->version, ['online', 'scorm', 'sharepoint', 'precompiled', 'win_exe_html', 'win_html', 'win_cd_html', 'mac_exe_html']);
foreach ($data->publications as $publication) {
}
}
- public function sendToSCORMCloud($url)
+ public function sendToSCORMCloud($file)
{
$config = new ScormCloud\Configuration();
$appId = env('SCORM_CLOUD_APP_ID');
$courseId = 'toolbox_collection_' . $this->collection->getKey();
$courseAPI = new ScormCloud\Api\CourseApi();
- $request = new ScormCloud\Model\ImportFetchRequestSchema(['url' => $url, 'content_type' => 'application/zip', 'media_file_metadata' => ['title' => $this->collection->title]]);
- while (true) {
- try {
- $jobId = $courseAPI->createFetchAndImportCourseJob($courseId, $request, true);
- break;
- } catch (\Exception $e) {
- sleep(1);
- }
+
+ try {
+ $courseAPI->deleteCourse($courseId);
+ } catch (\Exception $e) {
+
}
- while (true) {
- try {
- $jobResult = $courseAPI->getImportJobStatus($jobId->getResult());
+ $jobId = $courseAPI->createUploadAndImportCourseJob($courseId, true, null, 'application/zip', null, new \SplFileObject($file));
- if ($jobResult->getStatus() == ScormCloud\Model\ImportJobResultSchema::STATUS_RUNNING) {
- sleep(1);
- } else {
- break;
- }
- } catch (\Exception $e) {
- sleep(1);
- }
+
+ $jobResult = $courseAPI->getImportJobStatus($jobId->getResult());
+ while ($jobResult->getStatus() == ScormCloud\Model\ImportJobResultSchema::STATUS_RUNNING) {
+ sleep(1);
+ $jobResult = $courseAPI->getImportJobStatus($jobId->getResult());
}
if ($jobResult->getStatus() == ScormCloud\Model\ImportJobResultSchema::STATUS_ERROR)
use App\Fields\User;
use App\Http\Controllers\Admin\Operations\FluidbookCollection\DownloadOperation;
use App\SubForms\CollectionPublication;
+use App\SubForms\Fluidbook_Setting;
use Cubist\Backpack\Magic\Fields\BunchOfFieldsMultiple;
use Cubist\Backpack\Magic\Fields\Checkbox;
use Cubist\Backpack\Magic\Fields\SelectFromArray;
$this->addField('locale_switch', Checkbox::class, __('Permettre le changement de langue'), ['when' => ['type' => 'scorm_multilang'], 'default' => true]);
$this->addField('version', FluidbookExportVersion::class, __('Version'), ['when' => ['type' => 'export']]);
$this->addField('publications', BunchOfFieldsMultiple::class, __('Publications'), ['bunch' => CollectionPublication::class]);
+ $this->addField('override_settings',BunchOfFieldsMultiple::class,__('Redéfinir les paramètres lors de l\'export'),['bunch'=>Fluidbook_Setting::class]);
}