Clone course
This commit is contained in:
parent
62d1a00a91
commit
2d4e835269
@ -38,6 +38,7 @@ class course extends common
|
||||
'userHistoryExport' => self::GROUP_EDITOR,
|
||||
'backup' => self::GROUP_EDITOR,
|
||||
'restore' => self::GROUP_EDITOR,
|
||||
'clone' => self::GROUP_ADMIN
|
||||
];
|
||||
|
||||
public static $courseAccess = [
|
||||
@ -92,9 +93,11 @@ class course extends common
|
||||
: '';
|
||||
$categorieUrl = helper::baseUrl() . 'course/swap/' . $courseId;
|
||||
$info = sprintf('<strong>%s<br /></strong>Auteur : %s<br />Id : <a href="%s" target="_blank">%s<br />', $this->getData(['course', $courseId, 'title']), $author, $categorieUrl, $courseId);
|
||||
$enrolment = sprintf('Accès : %s<br />Inscription : %s<br />',
|
||||
$enrolment = sprintf(
|
||||
'Accès : %s<br />Inscription : %s<br />',
|
||||
self::$courseAccess[$this->getData(['course', $courseId, 'access'])],
|
||||
self::$courseEnrolment[$this->getData(['course', $courseId, 'enrolment'])]);
|
||||
self::$courseEnrolment[$this->getData(['course', $courseId, 'enrolment'])]
|
||||
);
|
||||
self::$courses[] = [
|
||||
$info,
|
||||
$this->getData(['course', $courseId, 'description']),
|
||||
@ -311,6 +314,34 @@ class course extends common
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplique un cours et l'affiche dans l'éditeur
|
||||
*/
|
||||
public function clone()
|
||||
{
|
||||
// Cours à dupliquer
|
||||
$courseId = $this->getUrl(2);
|
||||
|
||||
// Id du nouveau cours
|
||||
$target = uniqid();
|
||||
|
||||
// Créer la structure de données
|
||||
mkdir(self::DATA_DIR . $target);
|
||||
|
||||
$this->copyDir(self::DATA_DIR . $courseId, self::DATA_DIR . $target);
|
||||
|
||||
$data = $this->getData(['course', $courseId]);
|
||||
$this->setData(['course', $target, $data]);
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'course/edit/' . $target,
|
||||
'notification' => helper::translate('Espace dupliqué'),
|
||||
'state' => true
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
@ -342,7 +373,7 @@ class course extends common
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'course/manage',
|
||||
'redirect' => helper::baseUrl() . 'course',
|
||||
'notification' => $success ? helper::translate('Espace supprimé') : helper::translate('Erreur de suppression'),
|
||||
'state' => $success
|
||||
]);
|
||||
|
@ -6,37 +6,45 @@
|
||||
'value' => template::ico('left')
|
||||
]); ?>
|
||||
</div>
|
||||
|
||||
<div class="col1 offset7">
|
||||
</div>
|
||||
<div class="row textAlignCenter">
|
||||
<div class="col2">
|
||||
<?php echo template::button('categoryUser' . $this->getUrl(2), [
|
||||
'href' => helper::baseUrl() . 'course/users/' . $this->getUrl(2),
|
||||
'value' => template::ico('users'),
|
||||
'help' => 'Participants'
|
||||
'value' => 'Participants',
|
||||
'ico' => 'users'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col1">
|
||||
<?php echo
|
||||
template::button('courseManageEdit' . $this->getUrl(2), [
|
||||
<div class="col2">
|
||||
<?php echo template::button('courseManageEdit' . $this->getUrl(2), [
|
||||
'href' => helper::baseUrl() . 'course/edit/' . $this->getUrl(2),
|
||||
'value' => template::ico('pencil'),
|
||||
'help' => 'Éditer'
|
||||
'value' => 'Éditer',
|
||||
'ico' => 'pencil'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col1">
|
||||
<div class="col2">
|
||||
<?php echo
|
||||
template::button('courseManageDuplicate' . $this->getUrl(2), [
|
||||
'href' => helper::baseUrl() . 'course/clone/' . $this->getUrl(2),
|
||||
'value' => 'Cloner',
|
||||
'ico' => 'clone'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col2">
|
||||
<?php echo
|
||||
template::button('courseManageDownload' . $this->getUrl(2), [
|
||||
'href' => helper::baseUrl() . 'course/backup/' . $this->getUrl(2),
|
||||
'value' => template::ico('download-cloud'),
|
||||
'help' => 'Sauvegarder'
|
||||
'value' => 'Sauvegarder',
|
||||
'ico' => 'download-cloud'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col1 ">
|
||||
<div class="col2 ">
|
||||
<?php echo
|
||||
template::button('courseManageDelete' . $this->getUrl(2), [
|
||||
'class' => 'courseDelete buttonRed',
|
||||
'href' => helper::baseUrl() . 'course/delete/' . $this->getUrl(2),
|
||||
'value' => template::ico('trash'),
|
||||
'help' => 'Supprimer'
|
||||
'value' => 'Supprimer',
|
||||
'ico' => 'trash'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
Loading…
Reference in New Issue
Block a user