Gestalte den Mitgliederbereich fuer den Kursraum
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
abcdc6908e
commit
1d8315c9a4
21 files changed
+1064
-169
No files matched your search
@@ -25,11 +25,12 @@ public function __construct(
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return array{programs: list<array<string, mixed>>, materials: list<array<string, mixed>>}
|
||||
* @return array{programs: list<array<string, mixed>>, modules: list<array<string, mixed>>, materials: list<array<string, mixed>>}
|
||||
*/
|
||||
public function index(User $user): array
|
||||
{
|
||||
$programs = [];
|
||||
$modules = [];
|
||||
$materials = [];
|
||||
|
||||
foreach ($this->grants($user) as $grant) {
|
||||
@@ -39,31 +40,42 @@ public function index(User $user): array
|
||||
$version = $release?->rootCompositionVersion;
|
||||
|
||||
if ($composition !== null && $version !== null && $this->display->isReleased($version)) {
|
||||
$programs[$composition->id] = [
|
||||
$card = [
|
||||
'composition' => $composition,
|
||||
'version' => $version,
|
||||
'title' => filled($composition->display_title) ? $composition->display_title : $composition->designation,
|
||||
'summary' => $composition->summary,
|
||||
'kind' => $composition->editorialContentKind?->label
|
||||
?? ($composition->kind?->label()),
|
||||
'coverage' => $this->coverageLabel($user, $composition),
|
||||
];
|
||||
$shelf = $composition->editorialContentKind?->slug === 'modul' ? 'modules' : 'programs';
|
||||
if ($shelf === 'modules') {
|
||||
$modules[$composition->id] = $card;
|
||||
} else {
|
||||
$programs[$composition->id] = $card;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$elementId = $release?->rootElementVersion?->element_id;
|
||||
$element = $release?->rootElementVersion?->element;
|
||||
$elementId = $element?->id;
|
||||
$key = $composition !== null
|
||||
? 'komposition-'.$composition->id
|
||||
: ($elementId !== null ? 'element-'.$elementId : 'artikel-'.$article->id);
|
||||
$materials[$key] = [
|
||||
'article' => $article,
|
||||
'title' => app(CourseOutline::class)->title($article),
|
||||
'summary' => $element?->summary ?? $composition?->summary,
|
||||
'kind' => app(CourseOutline::class)->kindLabel($article),
|
||||
'coverage' => 'nutzbar',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'programs' => array_values($programs),
|
||||
'modules' => array_values($modules),
|
||||
'materials' => array_values($materials),
|
||||
];
|
||||
}
|
||||
@@ -92,7 +104,7 @@ public function program(User $user, Composition $composition): array
|
||||
'learning_goal' => $version->learning_goal,
|
||||
'duration_minutes' => $version->duration_minutes,
|
||||
'material_note' => $version->material_note,
|
||||
'coverage' => $leaves === [] ? 'nicht nutzbar' : ($open === count($leaves) ? 'vollständig' : ($open === 0 ? 'nicht nutzbar' : 'teilweise')),
|
||||
'coverage' => $leaves === [] ? 'nicht enthalten' : ($open === count($leaves) ? 'nutzbar' : ($open === 0 ? 'nicht enthalten' : 'teilweise')),
|
||||
'nodes' => $nodes,
|
||||
];
|
||||
}
|
||||
@@ -146,6 +158,28 @@ private function leaves(array $nodes): array
|
||||
return $leaves;
|
||||
}
|
||||
|
||||
private function coverageLabel(User $user, Composition $composition): string
|
||||
{
|
||||
$version = $this->display->highestReleasedVersion($composition);
|
||||
|
||||
if ($version === null) {
|
||||
return 'nicht enthalten';
|
||||
}
|
||||
|
||||
$nodes = array_map(
|
||||
fn (StructureNode $node): array => $this->present($user, $node),
|
||||
$this->structure->tree($version),
|
||||
);
|
||||
$leaves = $this->leaves($nodes);
|
||||
$open = count(array_filter($leaves, fn (array $leaf): bool => $leaf['view_url'] !== null));
|
||||
|
||||
if ($leaves === [] || $open === 0) {
|
||||
return 'nicht enthalten';
|
||||
}
|
||||
|
||||
return $open === count($leaves) ? 'nutzbar' : 'teilweise';
|
||||
}
|
||||
|
||||
private function programUrl(StructureNode $node): ?string
|
||||
{
|
||||
if ($node->compositionId === null || $node->compositionVersionId === null) {
|
||||
|
||||
Reference in new issue
Block a user