Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
5fc2484f
Commit
5fc2484f
authored
3 years ago
by
Till Glöggler
Committed by
Till Glöggler
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fixes #278
parent
df37f9c7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/contents/courseware.php
+95
-20
95 additions, 20 deletions
app/controllers/contents/courseware.php
app/views/contents/courseware/courses_overview.php
+22
-9
22 additions, 9 deletions
app/views/contents/courseware/courses_overview.php
with
117 additions
and
29 deletions
app/controllers/contents/courseware.php
+
95
−
20
View file @
5fc2484f
...
@@ -188,8 +188,10 @@ class Contents_CoursewareController extends AuthenticatedController
...
@@ -188,8 +188,10 @@ class Contents_CoursewareController extends AuthenticatedController
if
(
$sem_key
===
'0'
||
$sem_key
===
null
)
{
if
(
$sem_key
===
'0'
||
$sem_key
===
null
)
{
$sem_key
=
'all'
;
$sem_key
=
'all'
;
$this
->
all_semesters
=
true
;
$this
->
all_semesters
=
true
;
$this
->
semesters
=
Semester
::
getAll
();
}
else
{
}
else
{
$this
->
all_semesters
=
false
;
$this
->
all_semesters
=
false
;
$this
->
semesters
=
[
Semester
::
find
(
$sem_key
)];
}
}
$params
=
[
$params
=
[
'order_by'
=>
null
,
'order_by'
=>
null
,
...
@@ -198,36 +200,109 @@ class Contents_CoursewareController extends AuthenticatedController
...
@@ -198,36 +200,109 @@ class Contents_CoursewareController extends AuthenticatedController
'deputies_enabled'
=>
Config
::
get
()
->
DEPUTIES_ENABLE
,
'deputies_enabled'
=>
Config
::
get
()
->
DEPUTIES_ENABLE
,
];
];
$sem_courses
=
MyRealmModel
::
getPreparedCourses
(
$sem_key
,
$params
);
$this
->
sem_courses
=
$this
->
getCoursewareCourses
(
$sem_key
);
}
/**
* Return list of coursewares grouped by semester_id
*
* @param string $sem_key currently selected semester or all (for all semesters)
*
* @return array
*/
private
function
getCoursewareCourses
(
$sem_key
)
{
$this
->
current_semester
=
Semester
::
findCurrent
();
$courses
=
Course
::
findThru
(
$this
->
user_id
,
[
'thru_table'
=>
'seminar_user'
,
'thru_key'
=>
'user_id'
,
'thru_assoc_key'
=>
'seminar_id'
,
'assoc_foreign_key'
=>
'seminar_id'
]);
if
(
Config
::
get
()
->
DEPUTIES_ENABLE
)
{
$deputy_courses
=
Deputy
::
findDeputyCourses
(
$GLOBALS
[
'user'
]
->
id
)
->
pluck
(
'course'
);
if
(
!
empty
(
$deputy_courses
))
{
$courses
=
array_merge
(
$courses
,
$deputy_courses
);
}
}
$
this
->
semesters
=
[]
;
$
courses
=
new
SimpleCollection
(
$courses
)
;
if
(
$sem_courses
)
{
if
(
!
Config
::
get
()
->
MY_COURSES_ENABLE_STUDYGROUPS
)
{
$i
=
0
;
$courses
=
$courses
->
filter
(
function
(
$a
)
{
foreach
(
$sem_courses
as
$sem
)
{
return
!
$a
->
isStudygroup
();
$this
->
semesters
[
$i
][
'semester_name'
]
=
array_values
(
$sem
)[
0
][
'start_semester'
];
});
$this
->
semesters
[
$i
][
'coursewares'
]
=
[];
}
$this
->
semesters
[
$i
][
'empty_courses'
]
=
[];
if
(
$sem_key
!=
'all'
)
{
$semester
=
Semester
::
find
(
$sem_key
);
$courses
=
$courses
->
filter
(
function
(
$a
)
use
(
$semester
)
{
if
(
$a
->
isInSemester
(
$semester
))
{
return
true
;
}
return
false
;
});
$coursewares
=
[];
foreach
(
$courses
as
$course
)
{
$element
=
StructuralElement
::
getCoursewareCourse
(
$course
->
id
);
if
(
!
empty
(
$element
)
&&
$this
->
isCoursewareEnabled
(
$course
->
id
))
{
$element
[
'payload'
]
=
json_decode
(
$element
[
'payload'
],
true
);
$coursewares
[]
=
$element
;
}
}
foreach
(
$sem
as
$cid
=>
$course
)
{
if
(
empty
(
$coursewares
))
{
$element
=
StructuralElement
::
getCoursewareCourse
(
$cid
);
return
[];
if
(
$element
)
{
}
$element
[
'payload'
]
=
json_decode
(
$element
[
'payload'
],
true
);
array_push
(
$this
->
semesters
[
$i
][
'coursewares'
],
$element
);
return
[
$semester
->
id
=>
[
'semester_name'
=>
$semester
->
name
,
'coursewares'
=>
$coursewares
]];
}
else
{
$all_semesters
=
Semester
::
getAll
();
$sem_courses
=
[];
foreach
(
$courses
as
$course
)
{
$element
=
StructuralElement
::
getCoursewareCourse
(
$course
->
id
);
if
(
!
empty
(
$element
)
&&
$this
->
isCoursewareEnabled
(
$course
->
id
))
{
$element
[
'payload'
]
=
json_decode
(
$element
[
'payload'
],
true
);
if
(
$course
->
duration_time
==
-
1
)
{
$sem_courses
[
$this
->
current_semester
->
id
][
'coursewares'
][]
=
$element
;
}
else
{
}
else
{
array_push
(
$this
->
semesters
[
$i
][
'empty_courses'
],
$course
);
$end_semester
=
$course
->
getEndSemester
();
$sem_courses
[
$end_semester
->
id
][
'coursewares'
][]
=
$element
;
}
}
}
}
$i
++
;
}
}
}
else
{
$semester
=
Semester
::
find
(
$sem_key
);
return
$sem_courses
;
$this
->
semesters
[
0
][
'semester_name'
]
=
$semester
->
name
;
$this
->
semesters
[
0
][
'coursewares'
]
=
[];
$this
->
semesters
[
0
][
'empty_courses'
]
=
[];
}
}
}
}
/**
* Returns true if the courseware module is enabled for the passed course
*
* @param string $course_id the course to check
* @return boolean true if courseware is enabled, false otherwise
*/
private
function
isCoursewareEnabled
(
$course_id
)
{
$studip_module
=
PluginManager
::
getInstance
()
->
getPlugin
(
'CoursewareModule'
);
if
(
!
$studip_module
||
!
$studip_module
->
isActivated
(
$course_id
))
{
return
false
;
}
return
true
;
}
private
function
getProjects
(
$purpose
)
private
function
getProjects
(
$purpose
)
{
{
...
...
This diff is collapsed.
Click to expand it.
app/views/contents/courseware/courses_overview.php
+
22
−
9
View file @
5fc2484f
<div
class=
"cw-content-projects"
>
<div
class=
"cw-content-projects"
>
<?
if
(
empty
(
$sem_courses
))
:
?>
<?
if
(
!
$all_semesters
)
:
?>
<h2>
<?=
htmlReady
(
$semesters
[
0
]
->
name
)
?>
<?
if
(
$current_semester
->
id
==
$semesters
[
0
]
->
id
)
:
?>
(
<?=
_
(
'Aktuelles Semester'
)
?>
)
<?
endif
?>
</h2>
<?
endif
?>
<?=
MessageBox
::
info
(
_
(
'Keine der Veranstaltungen auf die sie Zugriff '
.
'haben hat eine Courseware mit Inhalten.'
));
?>
<?
else
:
?>
<?
foreach
(
$semesters
as
$semester
)
:
?>
<?
foreach
(
$semesters
as
$semester
)
:
?>
<h2>
<?=
htmlReady
(
$semester
[
'semester_name'
])
?>
</h2>
<?
if
(
!
empty
(
$sem_courses
[
$semester
->
id
][
'coursewares'
]))
:
?>
<?
if
(
!
empty
(
$semester
[
'coursewares'
]))
:
?>
<h2>
<?=
htmlReady
(
$semester
->
name
)
?>
<?
if
(
$current_semester
->
id
==
$semester
->
id
)
:
?>
(
<?=
_
(
'Aktuelles Semester'
)
?>
)
<?
endif
?>
</h2>
<ul
class=
"cw-tiles"
>
<ul
class=
"cw-tiles"
>
<?
foreach
(
$sem
ester
[
'coursewares'
]
as
$element
)
:
?>
<?
foreach
(
$sem
_courses
[
$semester
->
id
]
[
'coursewares'
]
as
$element
)
:
?>
<li
class=
"tile
<?=
htmlReady
(
$element
[
'payload'
][
'color'
])
?>
"
>
<li
class=
"tile
<?=
htmlReady
(
$element
[
'payload'
][
'color'
])
?>
"
>
<a
href=
"
<?=
URLHelper
::
getLink
(
'dispatch.php/course/courseware/?cid='
.
$element
[
'range_id'
]
.
'#/structural_element/'
.
$element
[
'id'
])
?>
"
>
<a
href=
"
<?=
URLHelper
::
getLink
(
'dispatch.php/course/courseware/?cid='
.
$element
[
'range_id'
]
.
'#/structural_element/'
.
$element
[
'id'
])
?>
"
>
<div
class=
"preview-image"
style=
"background-image: url(
<?=
htmlReady
(
$element
->
getImageUrl
())
?>
)"
></div>
<div
class=
"preview-image"
style=
"background-image: url(
<?=
htmlReady
(
$element
->
getImageUrl
())
?>
)"
></div>
...
@@ -23,11 +41,6 @@
...
@@ -23,11 +41,6 @@
<?
endforeach
;
?>
<?
endforeach
;
?>
</ul>
</ul>
<?
endif
;
?>
<?
endif
;
?>
<?
if
(
empty
(
$semester
[
'coursewares'
])
&&
!
empty
(
$empty_courses
))
:
?>
<?=
MessageBox
::
info
(
_
(
'Es wurden noch keine Lernunterlagen angelegt.'
));
?>
<?
endif
;
?>
<?
if
(
empty
(
$semester
[
'coursewares'
])
&&
empty
(
$empty_courses
))
:
?>
<?=
MessageBox
::
info
(
_
(
'Es wurden keine Veranstaltungen gefunden.'
));
?>
<?
endif
;
?>
<?
endforeach
;
?>
<?
endforeach
;
?>
<?
endif
;
?>
</div>
</div>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment