blob: 15afb097b94bc4a1ca893b50a96fe971274b72f3 [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 Mishra2a0483d2019-06-06 16:02:38 +05306 .lms-content {
7 line-height: 1.8em;
8 }
9
10 .lms-content h1 {
11 margin-top: 1em;
12 }
13
14 .lms-content h2 {
15 margin-top: 1em;
16 }
17
18 .lms-content h3 {
19 margin-top: 0.8em;
20 }
21
22 .lms-content h4 {
23 margin-top: 0.6em;
24 }
25
Shivam Mishrab3127652019-06-06 14:03:01 +053026 section {
27 padding: 5rem 0 5rem 0;
28 }
29 .plyr--video .plyr__control.plyr__tab-focus,
30 .plyr--video .plyr__control:hover,
31 .plyr--video .plyr__control[aria-expanded='true'] {
32 background: #5e64ff !important;
Shivam Mishrac8c790a2019-05-21 12:04:50 +053033 }
34
Shivam Mishrab3127652019-06-06 14:03:01 +053035 .plyr__control--overlaid:focus,
36 .plyr__control--overlaid:hover {
37 background: #5e64ff !important;
Shivam Mishrac8c790a2019-05-21 12:04:50 +053038 }
39
Shivam Mishrab3127652019-06-06 14:03:01 +053040 .plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]::before {
41 background: #5e64ff !important;
42 }
43
44 .plyr__menu__container
45 .plyr__control[role='menuitemradio'][aria-checked='true']::before {
46 background: #5e64ff;
47 }
48 .plyr--full-ui input[type='range'] {
49 color: #5e64ff !important;
50 }
51
52 .plyr__control--overlaid {
53 background: rgba(94, 100, 255, 0.8) !important;
Shivam Mishrac8c790a2019-05-21 12:04:50 +053054 }
55 </style>
56 <link rel="stylesheet" href="https://cdn.plyr.io/3.5.3/plyr.css" />
57{% endblock %}
58
Shivam Mishrab3127652019-06-06 14:03:01 +053059{% macro title() %}
60 <div class="mb-3">
Shivam Mishra44f98a92019-06-12 15:22:42 +053061 <a href="/lms/course?name={{ course }}&program={{ program }}" class="text-muted">
Alvaro43be1632020-06-22 07:36:12 +020062 {{_('Back to Course')}}
Shivam Mishrab3127652019-06-06 14:03:01 +053063 </a>
Shivam Mishrac8c790a2019-05-21 12:04:50 +053064 </div>
Jannat Pateldcdd3be2021-04-19 10:36:40 +053065 <div class="lms-title">
Shivam Mishra3251e132020-04-03 10:08:19 +053066 <h2>{{ content.name }} <span class="small text-muted">({{ position + 1 }}/{{length}})</span></h2>
Shivam Mishrab3127652019-06-06 14:03:01 +053067 </div>
68{% endmacro %}
69
70{% macro navigation() %}
71 {% if previous %}
Alvaro43be1632020-06-22 07:36:12 +020072 <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>
Shivam Mishrab3127652019-06-06 14:03:01 +053073 {% else %}
Alvaro43be1632020-06-22 07:36:12 +020074 <a href="/lms/course?name={{ course }}&program={{ program }}" class='btn text-muted' style="box-shadow: none;">{{ _('Back to Course') }}</a>
Shivam Mishrab3127652019-06-06 14:03:01 +053075 {% endif %}
76
77 {% if next %}
Alvaro43be1632020-06-22 07:36:12 +020078 <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>
Shivam Mishrab3127652019-06-06 14:03:01 +053079 {% else %}
Alvaro43be1632020-06-22 07:36:12 +020080 <button id="nextButton" onclick="handle('/lms/course?name={{ course }}&program={{ program }}')" class='btn btn-primary' disabled="true">{{_('Finish Topic')}}</button>
Shivam Mishrab3127652019-06-06 14:03:01 +053081 {% endif %}
Shivam Mishrac8c790a2019-05-21 12:04:50 +053082{% endmacro %}
83
84{% macro video() %}
85<div class="mb-5">
Shivam Mishrab3127652019-06-06 14:03:01 +053086 {{ title() }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +053087 <div class="text-muted">
88 {% if content.duration %}
Alvaro43be1632020-06-22 07:36:12 +020089 {{ content.duration }} {{_('Mins')}}
Shivam Mishrac8c790a2019-05-21 12:04:50 +053090 {% endif %}
91
92 {% if content.publish_date and content.duration%}
93 -
94 {% endif %}
95
96 {% if content.publish_date %}
Alvaro43be1632020-06-22 07:36:12 +020097 {{_('Published on')}} {{ content.publish_date.strftime('%d, %b %Y') }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +053098 {% endif %}
99 </div>
100</div>
101<div id="player" data-plyr-provider="{{ content.provider|lower }}" data-plyr-embed-id="{{ content.url }}"></div>
Shivam Mishra2a0483d2019-06-06 16:02:38 +0530102<div class="my-5 lms-content">
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530103 {{ content.description }}
104</div>
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530105{% endmacro %}
106
107{% macro article() %}
108<div class="mb-5">
Shivam Mishrab3127652019-06-06 14:03:01 +0530109 {{ title() }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530110 <div class="text-muted">
111 {% if content.author or content.publish_date %}
Alvaro43be1632020-06-22 07:36:12 +0200112 {{_('Published')}}
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530113 {% endif %}
114 {% if content.author %}
Alvaro43be1632020-06-22 07:36:12 +0200115 {{_('by')}} {{ content.author }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530116 {% endif %}
117 {% if content.publish_date %}
Alvaro43be1632020-06-22 07:36:12 +0200118 {{_('on')}} {{ content.publish_date.strftime('%d, %b %Y') }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530119 {% endif %}
120 </div>
121</div>
Shivam Mishra2a0483d2019-06-06 16:02:38 +0530122<div class="lms-content">
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530123 {{ content.content }}
124</div>
125{% endmacro %}
126
Shivam Mishrad1a25212019-06-03 12:57:38 +0530127{% macro quiz() %}
128<div class="mb-5">
Shivam Mishrab3127652019-06-06 14:03:01 +0530129 {{ title() }}
Shivam Mishrad1a25212019-06-03 12:57:38 +0530130</div>
131<div id="quiz-wrapper">
132</div>
133{% endmacro %}
134
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530135{% block content %}
136<section class="section">
137 <div>
138 <div class='container pb-5'>
139 {% if content_type=='Video' %}
140 {{ video() }}
141 {% elif content_type=='Article'%}
142 {{ article() }}
143 {% elif content_type=='Quiz' %}
Shivam Mishrad1a25212019-06-03 12:57:38 +0530144 {{ quiz() }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530145 {% endif %}
Shivam Mishrab3127652019-06-06 14:03:01 +0530146 <div class="pull-right" {{ 'hidden' if content_type=='Quiz'}}>
147 {{ navigation() }}
148 </div>
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530149 </div>
150 </div>
151</section>
Shivam Mishraae2871f2019-05-29 13:11:34 +0530152{% endblock %}
153
154{% block script %}
155 {% if content_type=='Video' %}
Shivam Mishrad1a25212019-06-03 12:57:38 +0530156 <script src="https://cdn.plyr.io/3.5.3/plyr.js"></script>
157 {% elif content_type == 'Quiz' %}
158 <script src='/assets/erpnext/js/education/lms/quiz.js'></script>
Shivam Mishraae2871f2019-05-29 13:11:34 +0530159 {% endif %}
160 <script>
Shivam Mishrad1a25212019-06-03 12:57:38 +0530161 {% if content_type == 'Video' %}
Shivam Mishraae2871f2019-05-29 13:11:34 +0530162 const player = new Plyr('#player');
Shivam Mishrad1a25212019-06-03 12:57:38 +0530163 {% elif content_type == 'Quiz' %}
164 {% if next %}
165 const quiz_exit_button = 'Next'
166 const next_url = '/lms/content?program={{ program }}&course={{ course }}&topic={{ topic }}&type={{ next.content_type }}&content={{ next.content }}'
167 {% else %}
168 const quiz_exit_button = 'Finish Course'
169 const next_url = '/lms/course?name={{ course }}&program={{ program }}'
170 {% endif %}
171 frappe.ready(() => {
Jannat Pateldcdd3be2021-04-19 10:36:40 +0530172 {% if content.is_time_bound %}
173 var duration = get_duration("{{content.duration}}")
174 var d = frappe.msgprint({
175 title: __('Important Notice'),
176 indicator: "red",
177 message: __(`This is a Time-Bound Quiz. <br><br>
178 A timer for <b>${duration}</b> will start, once you click on <b>Proceed</b>. <br><br>
179 If you fail to submit before the time is up, the Quiz will be submitted automatically.`),
180 primary_action: {
181 label: __("Proceed"),
182 action: () => {
183 create_quiz();
184 d.hide();
185 }
186 },
187 secondary_action: {
188 action: () => {
189 d.hide();
190 window.location.href = "/lms/course?name={{ course }}&program={{ program }}";
191 },
192 label: __("Go Back"),
193 }
194 });
195 {% else %}
196 create_quiz();
197 {% endif %}
198 function create_quiz() {
199 const quiz = new Quiz(document.getElementById('quiz-wrapper'), {
200 name: '{{ content.name }}',
201 course: '{{ course }}',
202 program: '{{ program }}',
203 quiz_exit_button: quiz_exit_button,
204 next_url: next_url
205 })
206 window.quiz = quiz;
207 }
208 function get_duration(seconds){
209 var hours = append_zero(Math.floor(seconds / 3600));
210 var minutes = append_zero(Math.floor(seconds % 3600 / 60));
211 var seconds = append_zero(Math.floor(seconds % 3600 % 60));
212 return `${hours}:${minutes}:${seconds}`;
213 }
214 function append_zero(time) {
215 return time > 9 ? time : "0" + time;
216 }
Shivam Mishrad1a25212019-06-03 12:57:38 +0530217 })
Shivam Mishraae2871f2019-05-29 13:11:34 +0530218 {% endif %}
219
Shivam Mishrad1a25212019-06-03 12:57:38 +0530220 {% if content_type != 'Quiz' %}
221
Shivam Mishraae2871f2019-05-29 13:11:34 +0530222 frappe.ready(() => {
223 next = document.getElementById('nextButton')
224 next.disabled = false;
225 })
226
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530227
Shivam Mishrad1a25212019-06-03 12:57:38 +0530228 function handle(url) {
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530229 opts = {
230 method: "erpnext.education.utils.add_activity",
231 args: {
Shivam Mishraae2871f2019-05-29 13:11:34 +0530232 course: "{{ course }}",
233 content_type: "{{ content_type }}",
Shivam Mishra8ddb63a2019-06-03 14:40:52 +0530234 content: "{{ content.name }}",
235 program: "{{ program }}"
Shivam Mishraae2871f2019-05-29 13:11:34 +0530236 }
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530237 }
238 frappe.call(opts).then(res => {
239 window.location.href = url;
240 })
Shivam Mishraae2871f2019-05-29 13:11:34 +0530241 }
Shivam Mishrad1a25212019-06-03 12:57:38 +0530242
243 {% endif %}
Shivam Mishraae2871f2019-05-29 13:11:34 +0530244 </script>
Alvaro43be1632020-06-22 07:36:12 +0200245{% endblock %}