Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show course videos in cw #1132

Merged
merged 4 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions assets/css/courseware.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@
white-space: nowrap;
}

.oc-cw-searchbar .oc-cw-searchbar-token {
margin: 3px;
padding: 5px;
border: solid thin $black;
background-color: $content-color-20;

display: inline;

span {
margin: 0 5px;
display: inline-block;
vertical-align: middle;
}

.oc-cw-remove-filter {
vertical-align: middle;
cursor: pointer;
}
}

.oc-cw-searchbar .oc-cw-searchbar-container .oc-cw-searchbar-input {
padding: 8px;
width: 100%;
Expand Down
26 changes: 25 additions & 1 deletion courseware/vueapp/components/CoursewareSearchBar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<template>
<div class="oc-cw-searchbar">
<ul class="oc-cw-searchbar-container">
<li class="oc-cw-searchbar-token" v-show="showCurrentCourse">
<span>{{ $gettext('Diese Veranstaltung') }}</span>
<studip-icon
shape="decline" role="clickable" class="oc-cw-remove-filter"
@click="removeCourse"
/>
</li>
<li class="oc-cw-searchbar-input">
<input type="text"
ref="searchbar"
Expand All @@ -26,6 +33,15 @@
export default {
name: "CoursewareSearchBar",

props: {
showCurrentCourse: {
type: Boolean,
default: true,
},
},

emits: ['doSearch'],

data() {
return {
inputSearch: '',
Expand All @@ -38,7 +54,10 @@ export default {
doSearch() {
clearTimeout(this.timer);

this.$emit('doSearch', this.inputSearch);
this.$emit('doSearch', {
searchText: this.inputSearch,
showCurrentCourse: this.showCurrentCourse,
});
},

doLiveSearch() {
Expand All @@ -47,6 +66,11 @@ export default {
this.timer = setTimeout(() => {
this.doSearch();
}, this.delay);
},

removeCourse() {
this.showCurrentCourse = false;
this.doSearch();
}
},
}
Expand Down
27 changes: 24 additions & 3 deletions courseware/vueapp/courseware-plugin-opencast-video.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<translate>Videos</translate>
</label>
<CoursewareSearchBar
:showCurrentCourse="showCurrentCourse"
@doSearch="performSearch"
/>
<CoursewareVideoTable
Expand Down Expand Up @@ -100,6 +101,7 @@ export default {

return {
searchText: '',
showCurrentCourse: undefined,
sorts: sorts,
sortObj: sorts[0],
limit: 15,
Expand Down Expand Up @@ -133,6 +135,10 @@ export default {
);
},

isCourse() {
return this.context.type === 'courses';
},

currentVideo() {
return this.videos.find(video => video.token === this.currentVideoId);
},
Expand Down Expand Up @@ -168,8 +174,9 @@ export default {
};
},

performSearch(searchText) {
performSearch({searchText, showCurrentCourse}) {
this.searchText = searchText;
this.showCurrentCourse = showCurrentCourse;
// this.resetPaging();
this.loadVideos();
},
Expand Down Expand Up @@ -217,6 +224,7 @@ export default {
},

initCurrentData() {
this.showCurrentCourse = this.isCourse;
this.currentVideoId = get(this.block, "attributes.payload.token", "");
this.currentEpisodeURL =STUDIP.ABSOLUTE_URI_STUDIP + 'plugins.php/opencastv3/redirect/perform/video/' + this.currentVideoId;
this.currentVisible = get(this.block, "attributes.payload.visible", "");
Expand All @@ -240,11 +248,24 @@ export default {
if (this.sortObj) {
params.append('order', this.sortObj.field + "_" + this.sortObj.order)
}

let filters = [];
if (this.searchText) {
let filters = [{
filters.push({
type: 'text',
value: this.searchText
}];
});
}

if (this.showCurrentCourse) {
filters.push({
type: 'course',
compare: '=',
value: this.context.id
});
}

if (filters.length > 0) {
params.append('filters', JSON.stringify(filters));
}
axios
Expand Down
8 changes: 4 additions & 4 deletions lib/Models/Videos.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public static function getFilteredVideoIDs($user_id)
{
global $perm;

if ($perm->have_perm('admin', $user_id)) {
if ($perm->have_perm('tutor', $user_id)) {
// get all courses and their playlists this user has access to. Only courses with activated OC plugin are included
$courses = Helpers::getMyCourses($user_id);

$stmt = \DBManager::get()->prepare($sql = 'SELECT oc_video.id FROM oc_video
JOIN oc_playlist_seminar ON (oc_playlist_seminar.seminar_id IN (:courses))
JOIN oc_playlist ON (oc_playlist_seminar.playlist_id = oc_playlist.id)
JOIN oc_playlist_video ON (oc_playlist.id = oc_playlist_video.playlist_id)
JOIN oc_playlist_video ON (oc_playlist.id = oc_playlist_video.playlist_id AND oc_video.id = oc_playlist_video.video_id)
WHERE 1
');

Expand Down Expand Up @@ -190,8 +190,8 @@ public static function getUserVideos($filters, $user_id = null)
':user_id'=> $user_id
];

if ($perm->have_perm('admin', $user_id)) {
$where = ' WHERE oc_video.id IN (:video_ids) ';
if ($perm->have_perm('tutor', $user_id)) {
$where = ' WHERE oc_video.id IN (:video_ids) OR p.user_id = :user_id';
$params[':video_ids'] = self::getFilteredVideoIDs($user_id);
} else {
$sql = ' INNER JOIN oc_video_user_perms AS p ON (p.user_id = :user_id AND p.video_id = oc_video.id) ';
Expand Down
Loading