blob: d22ef66d2a8fee40f3e71d030478b52f099af30a [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>
pateljannatbbf07d92021-06-08 17:05:44 +053067 <div class="lms-timer float-right fond-weight-bold hide"></div>
Shivam Mishrab3127652019-06-06 14:03:01 +053068 </div>
69{% endmacro %}
70
71{% macro navigation() %}
72 {% if previous %}
Alvaro43be1632020-06-22 07:36:12 +020073 <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 +053074 {% else %}
Alvaro43be1632020-06-22 07:36:12 +020075 <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 +053076 {% endif %}
77
78 {% if next %}
Alvaro43be1632020-06-22 07:36:12 +020079 <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 +053080 {% else %}
Alvaro43be1632020-06-22 07:36:12 +020081 <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 +053082 {% endif %}
Shivam Mishrac8c790a2019-05-21 12:04:50 +053083{% endmacro %}
84
85{% macro video() %}
86<div class="mb-5">
Shivam Mishrab3127652019-06-06 14:03:01 +053087 {{ title() }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +053088 <div class="text-muted">
89 {% if content.duration %}
Alvaro43be1632020-06-22 07:36:12 +020090 {{ content.duration }} {{_('Mins')}}
Shivam Mishrac8c790a2019-05-21 12:04:50 +053091 {% endif %}
92
93 {% if content.publish_date and content.duration%}
94 -
95 {% endif %}
96
97 {% if content.publish_date %}
Alvaro43be1632020-06-22 07:36:12 +020098 {{_('Published on')}} {{ content.publish_date.strftime('%d, %b %Y') }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +053099 {% endif %}
100 </div>
101</div>
102<div id="player" data-plyr-provider="{{ content.provider|lower }}" data-plyr-embed-id="{{ content.url }}"></div>
Shivam Mishra2a0483d2019-06-06 16:02:38 +0530103<div class="my-5 lms-content">
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530104 {{ content.description }}
105</div>
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530106{% endmacro %}
107
108{% macro article() %}
109<div class="mb-5">
Shivam Mishrab3127652019-06-06 14:03:01 +0530110 {{ title() }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530111 <div class="text-muted">
112 {% if content.author or content.publish_date %}
Alvaro43be1632020-06-22 07:36:12 +0200113 {{_('Published')}}
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530114 {% endif %}
115 {% if content.author %}
Alvaro43be1632020-06-22 07:36:12 +0200116 {{_('by')}} {{ content.author }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530117 {% endif %}
118 {% if content.publish_date %}
Alvaro43be1632020-06-22 07:36:12 +0200119 {{_('on')}} {{ content.publish_date.strftime('%d, %b %Y') }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530120 {% endif %}
121 </div>
122</div>
Shivam Mishra2a0483d2019-06-06 16:02:38 +0530123<div class="lms-content">
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530124 {{ content.content }}
125</div>
126{% endmacro %}
127
Shivam Mishrad1a25212019-06-03 12:57:38 +0530128{% macro quiz() %}
129<div class="mb-5">
Shivam Mishrab3127652019-06-06 14:03:01 +0530130 {{ title() }}
Shivam Mishrad1a25212019-06-03 12:57:38 +0530131</div>
132<div id="quiz-wrapper">
133</div>
134{% endmacro %}
135
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530136{% block content %}
137<section class="section">
138 <div>
139 <div class='container pb-5'>
140 {% if content_type=='Video' %}
141 {{ video() }}
142 {% elif content_type=='Article'%}
143 {{ article() }}
144 {% elif content_type=='Quiz' %}
Shivam Mishrad1a25212019-06-03 12:57:38 +0530145 {{ quiz() }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530146 {% endif %}
Shivam Mishrab3127652019-06-06 14:03:01 +0530147 <div class="pull-right" {{ 'hidden' if content_type=='Quiz'}}>
148 {{ navigation() }}
149 </div>
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530150 </div>
151 </div>
152</section>
Shivam Mishraae2871f2019-05-29 13:11:34 +0530153{% endblock %}
154
155{% block script %}
156 {% if content_type=='Video' %}
Shivam Mishrad1a25212019-06-03 12:57:38 +0530157 <script src="https://cdn.plyr.io/3.5.3/plyr.js"></script>
158 {% elif content_type == 'Quiz' %}
159 <script src='/assets/erpnext/js/education/lms/quiz.js'></script>
Shivam Mishraae2871f2019-05-29 13:11:34 +0530160 {% endif %}
161 <script>
Shivam Mishrad1a25212019-06-03 12:57:38 +0530162 {% if content_type == 'Video' %}
Shivam Mishraae2871f2019-05-29 13:11:34 +0530163 const player = new Plyr('#player');
Shivam Mishrad1a25212019-06-03 12:57:38 +0530164 {% elif content_type == 'Quiz' %}
165 {% if next %}
166 const quiz_exit_button = 'Next'
167 const next_url = '/lms/content?program={{ program }}&course={{ course }}&topic={{ topic }}&type={{ next.content_type }}&content={{ next.content }}'
168 {% else %}
169 const quiz_exit_button = 'Finish Course'
170 const next_url = '/lms/course?name={{ course }}&program={{ program }}'
171 {% endif %}
172 frappe.ready(() => {
Jannat Pateldcdd3be2021-04-19 10:36:40 +0530173 {% if content.is_time_bound %}
174 var duration = get_duration("{{content.duration}}")
175 var d = frappe.msgprint({
176 title: __('Important Notice'),
177 indicator: "red",
178 message: __(`This is a Time-Bound Quiz. <br><br>
179 A timer for <b>${duration}</b> will start, once you click on <b>Proceed</b>. <br><br>
180 If you fail to submit before the time is up, the Quiz will be submitted automatically.`),
181 primary_action: {
182 label: __("Proceed"),
183 action: () => {
184 create_quiz();
185 d.hide();
186 }
187 },
188 secondary_action: {
189 action: () => {
190 d.hide();
191 window.location.href = "/lms/course?name={{ course }}&program={{ program }}";
192 },
193 label: __("Go Back"),
194 }
195 });
196 {% else %}
197 create_quiz();
198 {% endif %}
199 function create_quiz() {
200 const quiz = new Quiz(document.getElementById('quiz-wrapper'), {
201 name: '{{ content.name }}',
202 course: '{{ course }}',
203 program: '{{ program }}',
204 quiz_exit_button: quiz_exit_button,
205 next_url: next_url
206 })
207 window.quiz = quiz;
208 }
209 function get_duration(seconds){
210 var hours = append_zero(Math.floor(seconds / 3600));
211 var minutes = append_zero(Math.floor(seconds % 3600 / 60));
212 var seconds = append_zero(Math.floor(seconds % 3600 % 60));
213 return `${hours}:${minutes}:${seconds}`;
214 }
215 function append_zero(time) {
216 return time > 9 ? time : "0" + time;
217 }
Shivam Mishrad1a25212019-06-03 12:57:38 +0530218 })
Shivam Mishraae2871f2019-05-29 13:11:34 +0530219 {% endif %}
220
Shivam Mishrad1a25212019-06-03 12:57:38 +0530221 {% if content_type != 'Quiz' %}
222
Shivam Mishraae2871f2019-05-29 13:11:34 +0530223 frappe.ready(() => {
224 next = document.getElementById('nextButton')
225 next.disabled = false;
226 })
227
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530228
Shivam Mishrad1a25212019-06-03 12:57:38 +0530229 function handle(url) {
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530230 opts = {
231 method: "erpnext.education.utils.add_activity",
232 args: {
Shivam Mishraae2871f2019-05-29 13:11:34 +0530233 course: "{{ course }}",
234 content_type: "{{ content_type }}",
Shivam Mishra8ddb63a2019-06-03 14:40:52 +0530235 content: "{{ content.name }}",
236 program: "{{ program }}"
Shivam Mishraae2871f2019-05-29 13:11:34 +0530237 }
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530238 }
239 frappe.call(opts).then(res => {
240 window.location.href = url;
241 })
Shivam Mishraae2871f2019-05-29 13:11:34 +0530242 }
Shivam Mishrad1a25212019-06-03 12:57:38 +0530243
244 {% endif %}
Shivam Mishraae2871f2019-05-29 13:11:34 +0530245 </script>
Alvaro43be1632020-06-22 07:36:12 +0200246{% endblock %}