Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Moodle Filter Opencast
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
elc
Moodle Filter Opencast
Commits
29ed1551
Commit
29ed1551
authored
6 years ago
by
Tobias Reischmann
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop'
parents
2b15e3c0
5764cef8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
filter.php
+16
-19
16 additions, 19 deletions
filter.php
lib.php
+1
-0
1 addition, 0 deletions
lib.php
with
17 additions
and
19 deletions
filter.php
+
16
−
19
View file @
29ed1551
...
...
@@ -43,7 +43,13 @@ class filter_opencast extends moodle_text_filter {
public
function
filter
(
$text
,
array
$options
=
array
())
{
global
$PAGE
;
if
(
stripos
(
$text
,
'</video>'
)
===
false
)
{
// Get baseurl either from engageurl setting or from opencast tool.
$baseurl
=
get_config
(
'filter_opencast'
,
'engageurl'
);
if
(
empty
(
$baseurl
))
{
$baseurl
=
get_config
(
'tool_opencast'
,
'apiurl'
);
}
if
(
stripos
(
$text
,
$baseurl
)
===
false
)
{
// Performance shortcut - if there are no </video> tags, nothing can match.
return
$text
;
}
...
...
@@ -56,7 +62,7 @@ class filter_opencast extends moodle_text_filter {
// Login if user is not logged in yet.
$loggedin
=
true
;
if
(
!
isset
(
$_COOKIE
[
'JSESSIONID'
])
&&
!
self
::
$loginrendered
)
{
if
(
!
self
::
$loginrendered
)
{
// Login and set cookie.
filter_opencast_login
();
$loggedin
=
false
;
...
...
@@ -73,29 +79,20 @@ class filter_opencast extends moodle_text_filter {
$video
=
false
;
if
(
substr
(
$match
,
0
,
7
)
===
"<source"
)
{
// Get baseurl either from engageurl setting or from opencast tool.
$baseurl
=
get_config
(
'filter_opencast'
,
'engageurl'
);
if
(
empty
(
$baseurl
))
{
$baseurl
=
get_config
(
'tool_opencast'
,
'apiurl'
);
}
// Check if video is from opencast.
if
(
strpos
(
$match
,
$baseurl
)
===
false
)
{
continue
;
}
if
(
strpos
(
$baseurl
,
'http'
)
!==
0
)
{
$baseurl
=
'http://'
.
$baseurl
;
}
// Extract id.
$id
=
substr
(
$match
,
strpos
(
$match
,
'api/'
)
+
4
,
36
);
// Create link to video.
$playerurl
=
get_config
(
'filter_opencast'
,
'playerurl'
);
// Extract url.
preg_match_all
(
'/<source[^>]+src=([\'"])(?<src>.+?)\1[^>]*>/i'
,
$match
,
$result
);
// Change url for loading the (Paella) Player.
$link
=
$baseurl
.
$playerurl
.
'?id='
.
$id
;
$link
=
$result
[
'src'
][
0
];
if
(
strpos
(
$link
,
'http'
)
!==
0
)
{
$link
=
'http://'
.
$link
;
}
// Create source with embedded mode.
$src
=
$link
;
...
...
@@ -109,7 +106,7 @@ class filter_opencast extends moodle_text_filter {
$newtext
=
$renderer
->
render_player
(
$mustachedata
);
// Replace video tag.
$text
=
preg_replace
(
'/<video.*<\/video>/'
,
$newtext
,
$text
,
1
);
$text
=
preg_replace
(
'/<video
(?:(?!<\/video>).)*?'
.
preg_quote
(
$match
,
'/'
)
.
'
.*
?
<\/video>/'
,
$newtext
,
$text
,
1
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
lib.php
+
1
−
0
View file @
29ed1551
...
...
@@ -92,6 +92,7 @@ function filter_opencast_create_parameters($endpoint) {
$params
[
'lti_message_type'
]
=
'basic-lti-launch-request'
;
$urlparts
=
parse_url
(
$CFG
->
wwwroot
);
$params
[
'tool_consumer_instance_guid'
]
=
$urlparts
[
'host'
];
$params
[
'custom_tool'
]
=
'/ltitools'
;
// User data.
$params
[
'user_id'
]
=
$USER
->
id
;
...
...
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