Skip to content
Snippets Groups Projects
Commit 52497ee6 authored by Murtaza Sultani's avatar Murtaza Sultani Committed by David Siegfried
Browse files

Resolve "OER: Besser zurück Typ der Methode (oerModuleIntegrateMaterialToCourse())"

Closes #4561

Merge request studip/studip!3373
parent f03841d5
No related branches found
No related tags found
No related merge requests found
...@@ -423,18 +423,20 @@ class Oer_MarketController extends StudipController ...@@ -423,18 +423,20 @@ class Oer_MarketController extends StudipController
$semclass = $this->course->getSemClass(); $semclass = $this->course->getSemClass();
if ($semclass->isModuleAllowed($class)) { if ($semclass->isModuleAllowed($class)) {
//activate module in course ? //activate module in course ?
$newfile = $class::oerModuleIntegrateMaterialToCourse( $response = $class::oerModuleIntegrateMaterialToCourse(
$this->material, $this->material,
$this->course $this->course
); );
if (is_array($newfile)) {
PageLayout::postError(_("Beim Kopieren ist ein Fehler aufgetaucht."), $newfile); if ($response['type'] === 'error') {
PageLayout::postError($response['message'], $response['message_detail']);
} else { } else {
PageLayout::postSuccess(_("Das Lernmaterial wurde kopiert.")); PageLayout::postSuccess($response['message'], $response['message_detail']);
} }
$this->response->add_header("X-Location", URLHelper::getURL("dispatch.php/course/files", array('cid' => $this->course->id)));
$this->response->add_header("X-Dialog-Close", 1); $this->response->add_header('X-Dialog-Close', 1);
$this->redirect(URLHelper::getURL("dispatch.php/course/files", array('cid' => $this->course->id))); $this->relocate($response['redirect_url']);
return; return;
} }
} }
......
...@@ -12,11 +12,8 @@ ...@@ -12,11 +12,8 @@
class CoreDocuments extends CorePlugin implements StudipModule, OERModule class CoreDocuments extends CorePlugin implements StudipModule, OERModule
{ {
/** /**
* Determines if the StudipModule wants to handle the OERMaterial. Returns false if not. * {@inheritdoc}
* @param OERMaterial $material
* @return false|Icon
*/ */
static public function oerModuleWantsToUseMaterial(OERMaterial $material) static public function oerModuleWantsToUseMaterial(OERMaterial $material)
{ {
...@@ -24,9 +21,7 @@ class CoreDocuments extends CorePlugin implements StudipModule, OERModule ...@@ -24,9 +21,7 @@ class CoreDocuments extends CorePlugin implements StudipModule, OERModule
} }
/** /**
* Returns an Icon class object with the given role. * {@inheritdoc}
* @param string $role
* @return null|Icon
*/ */
public function oerGetIcon($role = Icon::ROLE_CLICKABLE) public function oerGetIcon($role = Icon::ROLE_CLICKABLE)
{ {
...@@ -34,11 +29,7 @@ class CoreDocuments extends CorePlugin implements StudipModule, OERModule ...@@ -34,11 +29,7 @@ class CoreDocuments extends CorePlugin implements StudipModule, OERModule
} }
/** /**
* This function is triggered i a user chose to use this module as the target of the oermaterial. * {@inheritdoc}
* Now this module should put a copy of $material in its own area of the given course.
* @param OERMaterial $material
* @param Course $course
* @return array|FileType
*/ */
static public function oerModuleIntegrateMaterialToCourse(OERMaterial $material, Course $course) static public function oerModuleIntegrateMaterialToCourse(OERMaterial $material, Course $course)
{ {
...@@ -89,12 +80,24 @@ class CoreDocuments extends CorePlugin implements StudipModule, OERModule ...@@ -89,12 +80,24 @@ class CoreDocuments extends CorePlugin implements StudipModule, OERModule
if (!$newfile) { if (!$newfile) {
return [_('Daten konnten nicht kopiert werden!')]; return [_('Daten konnten nicht kopiert werden!')];
} }
return $newfile;
return [
'type' => 'success',
'message' => _('Das Lernmaterial wurde kopiert.'),
'message_detail' => [],
'redirect_url' => URLHelper::getURL('dispatch.php/course/files', ['cid' => $course->id])
];
} else { } else {
if ($tmp_name) { if ($tmp_name) {
@unlink($tmp_name); @unlink($tmp_name);
} }
return [_('Daten konnten nicht kopiert werden!')];
return [
'type' => 'error',
'message' => _('Beim Kopieren ist ein Fehler aufgetaucht.'),
'message_detail' => [_('Daten konnten nicht kopiert werden!')],
'redirect_url' => URLHelper::getURL('dispatch.php/oer/market/details/' . $material->id)
];
} }
} }
......
...@@ -5,7 +5,7 @@ interface OERModule ...@@ -5,7 +5,7 @@ interface OERModule
/** /**
* Determines if the StudipModule wants to handle the OERMaterial. Returns false if not. * Determines if the StudipModule wants to handle the OERMaterial. Returns false if not.
* @param OERMaterial $material * @param OERMaterial $material
* @return false|Icon * @return false
*/ */
public static function oerModuleWantsToUseMaterial(OERMaterial $material); public static function oerModuleWantsToUseMaterial(OERMaterial $material);
...@@ -14,7 +14,7 @@ interface OERModule ...@@ -14,7 +14,7 @@ interface OERModule
* Now this module should put a copy of $material in its own area of the given course. * Now this module should put a copy of $material in its own area of the given course.
* @param OERMaterial $material * @param OERMaterial $material
* @param Course $course * @param Course $course
* @return void * @return array
*/ */
public static function oerModuleIntegrateMaterialToCourse(OERMaterial $material, Course $course); public static function oerModuleIntegrateMaterialToCourse(OERMaterial $material, Course $course);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment