aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRasmus Fuhse <fuhse@data-quest.de>2023-06-06 06:58:46 +0000
committerRasmus Fuhse <fuhse@data-quest.de>2023-06-06 06:58:46 +0000
commitcd36e99958024cc33431f76f35099a71e26e3bce (patch)
tree5bbab8d10046d3e61ecd2dce268e09d2b4840054 /lib
parentfff82e7148bcfa3c3e3eef2ed37a312549a5f48c (diff)
Resolve "OER Campus: OERSI Ergebnisse unvollständig"
Closes #2521 Merge request studip/studip!1825
Diffstat (limited to 'lib')
-rw-r--r--lib/models/OERHost.php3
-rw-r--r--lib/models/OERHostOERSI.php27
-rw-r--r--lib/models/OERMaterial.php8
3 files changed, 17 insertions, 21 deletions
diff --git a/lib/models/OERHost.php b/lib/models/OERHost.php
index 19f2bb2..6db0747 100644
--- a/lib/models/OERHost.php
+++ b/lib/models/OERHost.php
@@ -264,8 +264,9 @@ class OERHost extends OERIdentity
{
$users = [];
foreach ($material->users as $materialdata) {
- if ($materialdata['external_contact']) {
+ if ($materialdata['oeruser']) {
$user = $materialdata['oeruser'];
+
$users[] = [
'user_id' => $user['foreign_id'],
'name' => $user['name'],
diff --git a/lib/models/OERHostOERSI.php b/lib/models/OERHostOERSI.php
index 3bb5d9f..5e6b9dc 100644
--- a/lib/models/OERHostOERSI.php
+++ b/lib/models/OERHostOERSI.php
@@ -69,13 +69,20 @@ class OERHostOERSI extends OERHost
'front_image_url' => $material_data['_source']['image'],
'download' => $material_data['_source']['encoding'][0]['contentUrl'] ?: '',
'id' => $material_data['_id'],
- 'authors' => $material_data['_source']['creator'],
'organization' => $material_data['_source']['sourceOrganization'][0]['name'] ?: $material_data['_source']['publisher'][0]['name']
];
$material->store();
- //set topics:
- //$material->setUsers([]);
+ //set users:
+ $userdata = [];
+ foreach ((array) $material_data['_source']['creator'] as $creator) {
+ $userdata[] = [
+ 'user_id' => md5($creator['name']),
+ 'name' => $creator['name'],
+ 'host_url' => $this['url']
+ ];
+ }
+ $material->setUsers($userdata);
//set topics:
$material->setTopics($material_data['_source']['keywords']);
@@ -128,7 +135,6 @@ class OERHostOERSI extends OERHost
$data['data'] = $material['data']->getArrayCopy();
$data['data']['download'] = $output['encoding'][0]['contentUrl'] ?? '';
$data['data']['front_image_url'] = $output['image'] ?? '';
- $data['data']['authors'] = $output['creator'];
$data['data']['organization'] = $output['sourceOrganization'][0]['name'] ?? $output['publisher'][0]['name'] ?? '';
return [
'data' => $data,
@@ -167,19 +173,6 @@ class OERHostOERSI extends OERHost
return false;
}
- public function getAuthorsForMaterial(OERMaterial $material)
- {
- $users = [];
- $data = $material->data->getArrayCopy();
- foreach ((array) $data['authors'] as $author) {
- $users[] = [
- 'name' => $author['name'],
- 'hostname' => $data['organization'] ?: $this['name']
- ];
- }
- return $users;
- }
-
public function getDownloadURLForMaterial(OERMaterial $material)
{
return $material['uri'];
diff --git a/lib/models/OERMaterial.php b/lib/models/OERMaterial.php
index 911aaa2..ea36035 100644
--- a/lib/models/OERMaterial.php
+++ b/lib/models/OERMaterial.php
@@ -166,9 +166,11 @@ class OERMaterial extends SimpleORMap
$cache_name = "oer_remote_searched_for_".md5($text)."_".($tag ? 1 : 0);
$already_searched = (bool) StudipCacheFactory::getCache()->read($cache_name);
if (!$already_searched) {
- $host = OERHost::findOneBySQL("index_server = '1' AND allowed_as_index_server = '1' ORDER BY RAND()");
- if ($host && !$host->isMe()) {
- $host->fetchRemoteSearch($text, $tag);
+ $hosts = OERHost::findBySQL("index_server = '1' AND allowed_as_index_server = '1' ORDER BY RAND()");
+ foreach ($hosts as $host) {
+ if (!$host->isMe()) {
+ $host->fetchRemoteSearch($text, $tag);
+ }
}
StudipCacheFactory::getCache()->read($cache_name, "1", 60);
}