blob: 5607c0814d45d45381533a0eb8a89b4d6c2c633a [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">
Shivam Mishrab3127652019-06-06 14:03:01 +053062 Back to Course
63 </a>
Shivam Mishrac8c790a2019-05-21 12:04:50 +053064 </div>
Shivam Mishrab3127652019-06-06 14:03:01 +053065 <div>
66 <h1>{{ content.name }} <span class="small text-muted">({{ position + 1 }}/{{length}})</span></h1>
67 </div>
68{% endmacro %}
69
70{% macro navigation() %}
71 {% if previous %}
72 <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>
73 {% else %}
74 <a href="/lms/course?name={{ course }}&program={{ program }}" class='btn text-muted' style="box-shadow: none;">Back to Course</a>
75 {% endif %}
76
77 {% if next %}
78 <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>
79 {% else %}
80 <button id="nextButton" onclick="handle('/lms/course?name={{ course }}&program={{ program }}')" class='btn btn-primary' disabled="true">Finish Topic</button>
81 {% 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 %}
89 {{ content.duration }} Mins
90 {% endif %}
91
92 {% if content.publish_date and content.duration%}
93 -
94 {% endif %}
95
96 {% if content.publish_date %}
97 Published on {{ content.publish_date.strftime('%d, %b %Y') }}
98 {% 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 %}
112 Published
113 {% endif %}
114 {% if content.author %}
115 by {{ content.author }}
116 {% endif %}
117 {% if content.publish_date %}
118 on {{ content.publish_date.strftime('%d, %b %Y') }}
119 {% 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(() => {
172 const quiz = new Quiz(document.getElementById('quiz-wrapper'), {
173 name: '{{ content.name }}',
174 course: '{{ course }}',
Shivam Mishra8ddb63a2019-06-03 14:40:52 +0530175 program: '{{ program }}',
Shivam Mishrad1a25212019-06-03 12:57:38 +0530176 quiz_exit_button: quiz_exit_button,
177 next_url: next_url
178 })
179 window.quiz = quiz;
180 })
Shivam Mishraae2871f2019-05-29 13:11:34 +0530181 {% endif %}
182
Shivam Mishrad1a25212019-06-03 12:57:38 +0530183 {% if content_type != 'Quiz' %}
184
Shivam Mishraae2871f2019-05-29 13:11:34 +0530185 frappe.ready(() => {
186 next = document.getElementById('nextButton')
187 next.disabled = false;
188 })
189
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530190
Shivam Mishrad1a25212019-06-03 12:57:38 +0530191 function handle(url) {
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530192 opts = {
193 method: "erpnext.education.utils.add_activity",
194 args: {
Shivam Mishraae2871f2019-05-29 13:11:34 +0530195 course: "{{ course }}",
196 content_type: "{{ content_type }}",
Shivam Mishra8ddb63a2019-06-03 14:40:52 +0530197 content: "{{ content.name }}",
198 program: "{{ program }}"
Shivam Mishraae2871f2019-05-29 13:11:34 +0530199 }
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530200 }
201 frappe.call(opts).then(res => {
202 window.location.href = url;
203 })
Shivam Mishraae2871f2019-05-29 13:11:34 +0530204 }
Shivam Mishrad1a25212019-06-03 12:57:38 +0530205
206 {% endif %}
Shivam Mishraae2871f2019-05-29 13:11:34 +0530207 </script>
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530208{% endblock %}