aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurtaza Sultani <sultani@data-quest.de>2024-09-16 06:44:06 +0000
committerMurtaza Sultani <sultani@data-quest.de>2024-09-17 16:42:23 +0200
commite47363e30604a67be95db5a205f12a6ac19e1197 (patch)
tree87913f09652202bb9b99366a7aea46f218e23757
parent96b6b5a4e63d79e680d9b033111f5b7de28635f8 (diff)
Resolve "OER: Die Klasse `CoreDocuments` lädt zweimal"
Closes #4581 Merge request studip/studip!3390
-rw-r--r--app/controllers/oer/market.php57
1 files changed, 24 insertions, 33 deletions
diff --git a/app/controllers/oer/market.php b/app/controllers/oer/market.php
index 8c615f5..72133d7 100644
--- a/app/controllers/oer/market.php
+++ b/app/controllers/oer/market.php
@@ -404,41 +404,32 @@ class Oer_MarketController extends StudipController
if (Request::option("seminar_id") && $GLOBALS['perm']->have_studip_perm("autor", Request::option("seminar_id"))) {
$this->course = new Course(Request::option("seminar_id"));
- $this->classes = ["CoreDocuments"];
- foreach (get_declared_classes() as $class) {
- if (in_array('OERModule', class_implements($class))) {
- //check if module is even allowed in course
- $semclass = $this->course->getSemClass();
-
- if ($semclass->isModuleAllowed($class)
- && $class::oerModuleWantsToUseMaterial($this->material)) {
- $this->classes[] = $class;
+ $this->classes = $this->course->tools->filter(function (ToolActivation $tool) {
+ $module = $tool->getStudipModule();
+ return $module instanceof OERModule
+ && $module::oerModuleWantsToUseMaterial($this->material);
+ })->map(function (ToolActivation $tool): string {
+ return get_class($tool->getStudipModule());
+ });
+
+ if (Request::get('class') || count($this->classes) === 1) {
+ $class = Request::get('class') ?: $this->classes[0];
+ if (class_exists($class) && in_array($class, $this->classes)) {
+ $response = $class::oerModuleIntegrateMaterialToCourse(
+ $this->material,
+ $this->course
+ );
+
+ if ($response['type'] === 'error') {
+ PageLayout::postError($response['message'], $response['message_detail']);
+ } else {
+ PageLayout::postSuccess($response['message'], $response['message_detail']);
}
- }
- }
- if (Request::get("class") || count($this->classes) === 1) {
- $class = Request::get("class") ?: $this->classes[0];
- if (class_exists($class) && in_array('OERModule', class_implements($class))) {
- $semclass = $this->course->getSemClass();
- if ($semclass->isModuleAllowed($class)) {
- //activate module in course ?
- $response = $class::oerModuleIntegrateMaterialToCourse(
- $this->material,
- $this->course
- );
-
- if ($response['type'] === 'error') {
- PageLayout::postError($response['message'], $response['message_detail']);
- } else {
- PageLayout::postSuccess($response['message'], $response['message_detail']);
- }
-
- $this->response->add_header('X-Dialog-Close', 1);
- $this->relocate($response['redirect_url']);
-
- return;
- }
+ $this->response->add_header('X-Dialog-Close', 1);
+ $this->relocate($response['redirect_url']);
+
+ return;
}
} else {
$this->render_template("oer/market/add_to_course_select_class");