UPD 2
- add RuTube servise
This commit is contained in:
@@ -222,6 +222,7 @@ lms_markdown_macro_renderers = {
|
||||
"Exercise": "lms.plugins.exercise_renderer",
|
||||
"Quiz": "lms.plugins.quiz_renderer",
|
||||
"YouTubeVideo": "lms.plugins.youtube_video_renderer",
|
||||
"RuTubeVideo": "lms.plugins.rutube_video_renderer",
|
||||
"Video": "lms.plugins.video_renderer",
|
||||
"Assignment": "lms.plugins.assignment_renderer",
|
||||
"Embed": "lms.plugins.embed_renderer",
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"instructor_notes",
|
||||
"section_break_6",
|
||||
"youtube",
|
||||
"rutube",
|
||||
"column_break_9",
|
||||
"quiz_id",
|
||||
"section_break_16",
|
||||
@@ -104,6 +105,12 @@
|
||||
"fieldtype": "Data",
|
||||
"label": "YouTube Video URL"
|
||||
},
|
||||
{
|
||||
"description": "RuTube Video will appear at the top of the lesson.",
|
||||
"fieldname": "rutube",
|
||||
"fieldtype": "Data",
|
||||
"label": "RuTube Video URL"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_16",
|
||||
"fieldtype": "Section Break",
|
||||
|
||||
@@ -35,6 +35,7 @@ def find_macros(text):
|
||||
>>> find_macros(text)
|
||||
[
|
||||
('YouTubeVideo': 'abcd1234')
|
||||
('RuTubeVideo': 'abcd1234')
|
||||
('Exercise', 'two-circles'),
|
||||
('Exercise', 'four-circles')
|
||||
]
|
||||
@@ -119,5 +120,7 @@ def sanitize_html(html, macro):
|
||||
classname = ""
|
||||
if macro == "YouTubeVideo":
|
||||
classname = "lesson-video"
|
||||
elif macro == "RutubeVideo": # Добавлено
|
||||
classname = "rutube-video"
|
||||
|
||||
return "<div class='" + classname + "'>" + "\n".join(str(node) for node in nodes) + "</div>"
|
||||
|
||||
@@ -145,6 +145,7 @@ def get_lesson_details(chapter, progress=False):
|
||||
"body",
|
||||
"creation",
|
||||
"youtube",
|
||||
"rutube",
|
||||
"quiz_id",
|
||||
"question",
|
||||
"file_type",
|
||||
@@ -334,12 +335,17 @@ def render_html(lesson):
|
||||
youtube = lesson.youtube
|
||||
quiz_id = lesson.quiz_id
|
||||
body = lesson.body
|
||||
rutube = lesson.get("rutube")
|
||||
|
||||
if youtube and "/" in youtube:
|
||||
youtube = youtube.split("/")[-1]
|
||||
|
||||
if rutube and "/" in rutube:
|
||||
rutube = rutube.split("/")[-1]
|
||||
|
||||
quiz_id = "{{ Quiz('" + quiz_id + "') }}" if quiz_id else ""
|
||||
youtube = "{{ YouTubeVideo('" + youtube + "') }}" if youtube else ""
|
||||
rutube = "{{ RutubeVideo('" + rutube + "') }}" if rutube else ""
|
||||
text = youtube + body + quiz_id
|
||||
|
||||
if lesson.question:
|
||||
@@ -1276,6 +1282,7 @@ def get_lesson(course, chapter, lesson):
|
||||
"body",
|
||||
"creation",
|
||||
"youtube",
|
||||
"rutube",
|
||||
"quiz_id",
|
||||
"question",
|
||||
"file_type",
|
||||
@@ -1815,6 +1822,7 @@ def get_lesson_creation_details(course, chapter, lesson):
|
||||
"instructor_notes",
|
||||
"instructor_content",
|
||||
"youtube",
|
||||
"rutube",
|
||||
"quiz_id",
|
||||
],
|
||||
as_dict=1,
|
||||
|
||||
@@ -174,6 +174,17 @@ def youtube_video_renderer(video_id):
|
||||
</iframe>
|
||||
"""
|
||||
|
||||
def rutube_video_renderer(video_id):
|
||||
return f"""
|
||||
<iframe width="100%" height="400"
|
||||
src="https://rutube.ru/play/embed/{video_id}"
|
||||
title="Rutube video player"
|
||||
frameborder="0"
|
||||
class="rutube-video"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowfullscreen>
|
||||
</iframe>
|
||||
"""
|
||||
|
||||
def embed_renderer(details):
|
||||
type = details.split("|||")[0]
|
||||
|
||||
Reference in New Issue
Block a user