blob: bdbacc1f3d1d50acfa6da79e9f879e2ed06d2bbf [file] [log] [blame]
Shivam Mishrac8c790a2019-05-21 12:04:50 +05301{% extends "templates/base.html" %}
Shivam Mishraae2871f2019-05-29 13:11:34 +05302{% block title %}{{ content.name or 'Content Page' }}{% endblock %}
Shivam Mishrac8c790a2019-05-21 12:04:50 +05303
4{% block head_include %}
5 <style>
Shivam Mishrab3127652019-06-06 14:03:01 +05306 section {
7 padding: 5rem 0 5rem 0;
8 }
9 .plyr--video .plyr__control.plyr__tab-focus,
10 .plyr--video .plyr__control:hover,
11 .plyr--video .plyr__control[aria-expanded='true'] {
12 background: #5e64ff !important;
Shivam Mishrac8c790a2019-05-21 12:04:50 +053013 }
14
Shivam Mishrab3127652019-06-06 14:03:01 +053015 .plyr__control--overlaid:focus,
16 .plyr__control--overlaid:hover {
17 background: #5e64ff !important;
Shivam Mishrac8c790a2019-05-21 12:04:50 +053018 }
19
Shivam Mishrab3127652019-06-06 14:03:01 +053020 .plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]::before {
21 background: #5e64ff !important;
22 }
23
24 .plyr__menu__container
25 .plyr__control[role='menuitemradio'][aria-checked='true']::before {
26 background: #5e64ff;
27 }
28 .plyr--full-ui input[type='range'] {
29 color: #5e64ff !important;
30 }
31
32 .plyr__control--overlaid {
33 background: rgba(94, 100, 255, 0.8) !important;
Shivam Mishrac8c790a2019-05-21 12:04:50 +053034 }
35 </style>
36 <link rel="stylesheet" href="https://cdn.plyr.io/3.5.3/plyr.css" />
37{% endblock %}
38
Shivam Mishrab3127652019-06-06 14:03:01 +053039{% macro title() %}
40 <div class="mb-3">
41 <a href="#" class="text-muted">
42 Back to Course
43 </a>
Shivam Mishrac8c790a2019-05-21 12:04:50 +053044 </div>
Shivam Mishrab3127652019-06-06 14:03:01 +053045 <div>
46 <h1>{{ content.name }} <span class="small text-muted">({{ position + 1 }}/{{length}})</span></h1>
47 </div>
48{% endmacro %}
49
50{% macro navigation() %}
51 {% if previous %}
52 <a href="/lms/content?program={{ program }}&course={{ course }}&topic={{ topic }}&type={{ previous.content_type }}&content={{ previous.content }}" class='btn text-muted' style="box-shadow: none;">Previous</a>
53 {% else %}
54 <a href="/lms/course?name={{ course }}&program={{ program }}" class='btn text-muted' style="box-shadow: none;">Back to Course</a>
55 {% endif %}
56
57 {% if next %}
58 <button id="nextButton" onclick="handle('/lms/content?program={{ program }}&course={{ course }}&topic={{ topic }}&type={{ next.content_type }}&content={{ next.content }}')" class='btn btn-primary' disabled="true">Next</button>
59 {% else %}
60 <button id="nextButton" onclick="handle('/lms/course?name={{ course }}&program={{ program }}')" class='btn btn-primary' disabled="true">Finish Topic</button>
61 {% endif %}
Shivam Mishrac8c790a2019-05-21 12:04:50 +053062{% endmacro %}
63
64{% macro video() %}
65<div class="mb-5">
Shivam Mishrab3127652019-06-06 14:03:01 +053066 {{ title() }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +053067 <div class="text-muted">
68 {% if content.duration %}
69 {{ content.duration }} Mins
70 {% endif %}
71
72 {% if content.publish_date and content.duration%}
73 -
74 {% endif %}
75
76 {% if content.publish_date %}
77 Published on {{ content.publish_date.strftime('%d, %b %Y') }}
78 {% endif %}
79 </div>
80</div>
81<div id="player" data-plyr-provider="{{ content.provider|lower }}" data-plyr-embed-id="{{ content.url }}"></div>
Shivam Mishrad1a25212019-06-03 12:57:38 +053082<div class="my-5" style="line-height: 1.8em;">
Shivam Mishrac8c790a2019-05-21 12:04:50 +053083 {{ content.description }}
84</div>
Shivam Mishrac8c790a2019-05-21 12:04:50 +053085{% endmacro %}
86
87{% macro article() %}
88<div class="mb-5">
Shivam Mishrab3127652019-06-06 14:03:01 +053089 {{ title() }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +053090 <div class="text-muted">
91 {% if content.author or content.publish_date %}
92 Published
93 {% endif %}
94 {% if content.author %}
95 by {{ content.author }}
96 {% endif %}
97 {% if content.publish_date %}
98 on {{ content.publish_date.strftime('%d, %b %Y') }}
99 {% endif %}
100 </div>
101</div>
Shivam Mishra24bd07d2019-05-30 16:36:58 +0530102<div style="line-height: 1.8em;">
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530103 {{ content.content }}
104</div>
105{% endmacro %}
106
Shivam Mishrad1a25212019-06-03 12:57:38 +0530107{% macro quiz() %}
108<div class="mb-5">
Shivam Mishrab3127652019-06-06 14:03:01 +0530109 {{ title() }}
Shivam Mishrad1a25212019-06-03 12:57:38 +0530110</div>
111<div id="quiz-wrapper">
112</div>
113{% endmacro %}
114
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530115{% block content %}
116<section class="section">
117 <div>
118 <div class='container pb-5'>
119 {% if content_type=='Video' %}
120 {{ video() }}
121 {% elif content_type=='Article'%}
122 {{ article() }}
123 {% elif content_type=='Quiz' %}
Shivam Mishrad1a25212019-06-03 12:57:38 +0530124 {{ quiz() }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530125 {% endif %}
Shivam Mishrab3127652019-06-06 14:03:01 +0530126 <div class="pull-right" {{ 'hidden' if content_type=='Quiz'}}>
127 {{ navigation() }}
128 </div>
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530129 </div>
130 </div>
131</section>
Shivam Mishraae2871f2019-05-29 13:11:34 +0530132{% endblock %}
133
134{% block script %}
135 {% if content_type=='Video' %}
Shivam Mishrad1a25212019-06-03 12:57:38 +0530136 <script src="https://cdn.plyr.io/3.5.3/plyr.js"></script>
137 {% elif content_type == 'Quiz' %}
138 <script src='/assets/erpnext/js/education/lms/quiz.js'></script>
Shivam Mishraae2871f2019-05-29 13:11:34 +0530139 {% endif %}
140 <script>
Shivam Mishrad1a25212019-06-03 12:57:38 +0530141 {% if content_type == 'Video' %}
Shivam Mishraae2871f2019-05-29 13:11:34 +0530142 const player = new Plyr('#player');
Shivam Mishrad1a25212019-06-03 12:57:38 +0530143 {% elif content_type == 'Quiz' %}
144 {% if next %}
145 const quiz_exit_button = 'Next'
146 const next_url = '/lms/content?program={{ program }}&course={{ course }}&topic={{ topic }}&type={{ next.content_type }}&content={{ next.content }}'
147 {% else %}
148 const quiz_exit_button = 'Finish Course'
149 const next_url = '/lms/course?name={{ course }}&program={{ program }}'
150 {% endif %}
151 frappe.ready(() => {
152 const quiz = new Quiz(document.getElementById('quiz-wrapper'), {
153 name: '{{ content.name }}',
154 course: '{{ course }}',
Shivam Mishra8ddb63a2019-06-03 14:40:52 +0530155 program: '{{ program }}',
Shivam Mishrad1a25212019-06-03 12:57:38 +0530156 quiz_exit_button: quiz_exit_button,
157 next_url: next_url
158 })
159 window.quiz = quiz;
160 })
Shivam Mishraae2871f2019-05-29 13:11:34 +0530161 {% endif %}
162
Shivam Mishrad1a25212019-06-03 12:57:38 +0530163 {% if content_type != 'Quiz' %}
164
Shivam Mishraae2871f2019-05-29 13:11:34 +0530165 frappe.ready(() => {
166 next = document.getElementById('nextButton')
167 next.disabled = false;
168 })
169
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530170
Shivam Mishrad1a25212019-06-03 12:57:38 +0530171 function handle(url) {
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530172 opts = {
173 method: "erpnext.education.utils.add_activity",
174 args: {
Shivam Mishraae2871f2019-05-29 13:11:34 +0530175 course: "{{ course }}",
176 content_type: "{{ content_type }}",
Shivam Mishra8ddb63a2019-06-03 14:40:52 +0530177 content: "{{ content.name }}",
178 program: "{{ program }}"
Shivam Mishraae2871f2019-05-29 13:11:34 +0530179 }
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530180 }
181 frappe.call(opts).then(res => {
182 window.location.href = url;
183 })
Shivam Mishraae2871f2019-05-29 13:11:34 +0530184 }
Shivam Mishrad1a25212019-06-03 12:57:38 +0530185
186 {% endif %}
Shivam Mishraae2871f2019-05-29 13:11:34 +0530187 </script>
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530188{% endblock %}