blob: 41f27f3bc1b3951ec59d4ed33b5f0efd925f58e4 [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>
6 div.card-hero-img {
7 height: 220px;
8 background-size: cover;
9 background-repeat: no-repeat;
10 background-position: center;
11 background-color: rgb(250, 251, 252);
12 }
13
14 .card-image-wrapper {
15 display: flex;
16 overflow: hidden;
17 height: 220px;
18 background-color: rgb(250, 251, 252);
19 justify-content: center;
20 }
21
22 .image-body {
23 align-self: center;
24 color: #d1d8dd;
25 font-size: 24px;
26 font-weight: 600;
27 line-height: 1;
28 padding: 20px;
29 }
30 </style>
31 <link rel="stylesheet" href="https://cdn.plyr.io/3.5.3/plyr.css" />
32{% endblock %}
33
34{% macro navigation() %}
35<div class="row">
36 <div class="col-md-7">
Shivam Mishrae94e9d22019-05-30 18:05:00 +053037 <h1>{{ content.name }} <span class="small text-muted">({{ position + 1 }}/{{length}})</span></h1>
Shivam Mishrac8c790a2019-05-21 12:04:50 +053038 </div>
Shivam Mishrad1a25212019-06-03 12:57:38 +053039 <div id="nav-buttons" class="col-md-5 text-right" {{ 'hidden' if content_type=='Quiz' }}>
Shivam Mishrac8c790a2019-05-21 12:04:50 +053040 {% if previous %}
Shivam Mishrae94e9d22019-05-30 18:05:00 +053041 <a href="/lms/content?program={{ program }}&course={{ course }}&topic={{ topic }}&type={{ previous.content_type }}&content={{ previous.content }}" class='btn btn-outline-secondary'>Previous</a>
Shivam Mishrac8c790a2019-05-21 12:04:50 +053042 {% else %}
Shivam Mishrae94e9d22019-05-30 18:05:00 +053043 <a href="/lms/course?name={{ course }}&program={{ program }}" class='btn btn-outline-secondary'>Back to Course</a>
Shivam Mishrac8c790a2019-05-21 12:04:50 +053044 {% endif %}
45
46 {% if next %}
Shivam Mishrae94e9d22019-05-30 18:05:00 +053047 <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 Mishrac8c790a2019-05-21 12:04:50 +053048 {% else %}
Shivam Mishrae94e9d22019-05-30 18:05:00 +053049 <button id="nextButton" onclick="handle('/lms/course?name={{ course }}&program={{ program }}')" class='btn btn-primary' disabled="true">Finish Topic</button>
Shivam Mishrac8c790a2019-05-21 12:04:50 +053050 {% endif %}
51 </div>
52 </div>
53{% endmacro %}
54
55{% macro video() %}
56<div class="mb-5">
57 {{ navigation() }}
58 <div class="text-muted">
59 {% if content.duration %}
60 {{ content.duration }} Mins
61 {% endif %}
62
63 {% if content.publish_date and content.duration%}
64 -
65 {% endif %}
66
67 {% if content.publish_date %}
68 Published on {{ content.publish_date.strftime('%d, %b %Y') }}
69 {% endif %}
70 </div>
71</div>
72<div id="player" data-plyr-provider="{{ content.provider|lower }}" data-plyr-embed-id="{{ content.url }}"></div>
Shivam Mishrad1a25212019-06-03 12:57:38 +053073<div class="my-5" style="line-height: 1.8em;">
Shivam Mishrac8c790a2019-05-21 12:04:50 +053074 {{ content.description }}
75</div>
Shivam Mishrac8c790a2019-05-21 12:04:50 +053076{% endmacro %}
77
78{% macro article() %}
79<div class="mb-5">
80 {{ navigation() }}
81 <div class="text-muted">
82 {% if content.author or content.publish_date %}
83 Published
84 {% endif %}
85 {% if content.author %}
86 by {{ content.author }}
87 {% endif %}
88 {% if content.publish_date %}
89 on {{ content.publish_date.strftime('%d, %b %Y') }}
90 {% endif %}
91 </div>
92</div>
Shivam Mishra24bd07d2019-05-30 16:36:58 +053093<div style="line-height: 1.8em;">
Shivam Mishrac8c790a2019-05-21 12:04:50 +053094 {{ content.content }}
95</div>
96{% endmacro %}
97
Shivam Mishrad1a25212019-06-03 12:57:38 +053098{% macro quiz() %}
99<div class="mb-5">
100 <div class="row">
101 <div class="col-md-7">
102 <h1>{{ content.name }} <span class="small text-muted">({{ position + 1 }}/{{length}})</span></h1>
103 </div>
104 </div>
105</div>
106<div id="quiz-wrapper">
107</div>
108{% endmacro %}
109
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530110{% block content %}
111<section class="section">
112 <div>
113 <div class='container pb-5'>
114 {% if content_type=='Video' %}
115 {{ video() }}
116 {% elif content_type=='Article'%}
117 {{ article() }}
118 {% elif content_type=='Quiz' %}
Shivam Mishrad1a25212019-06-03 12:57:38 +0530119 {{ quiz() }}
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530120 {% endif %}
121 </div>
122 </div>
123</section>
Shivam Mishraae2871f2019-05-29 13:11:34 +0530124{% endblock %}
125
126{% block script %}
127 {% if content_type=='Video' %}
Shivam Mishrad1a25212019-06-03 12:57:38 +0530128 <script src="https://cdn.plyr.io/3.5.3/plyr.js"></script>
129 {% elif content_type == 'Quiz' %}
130 <script src='/assets/erpnext/js/education/lms/quiz.js'></script>
Shivam Mishraae2871f2019-05-29 13:11:34 +0530131 {% endif %}
132 <script>
Shivam Mishrad1a25212019-06-03 12:57:38 +0530133 {% if content_type == 'Video' %}
Shivam Mishraae2871f2019-05-29 13:11:34 +0530134 const player = new Plyr('#player');
Shivam Mishrad1a25212019-06-03 12:57:38 +0530135 {% elif content_type == 'Quiz' %}
136 {% if next %}
137 const quiz_exit_button = 'Next'
138 const next_url = '/lms/content?program={{ program }}&course={{ course }}&topic={{ topic }}&type={{ next.content_type }}&content={{ next.content }}'
139 {% else %}
140 const quiz_exit_button = 'Finish Course'
141 const next_url = '/lms/course?name={{ course }}&program={{ program }}'
142 {% endif %}
143 frappe.ready(() => {
144 const quiz = new Quiz(document.getElementById('quiz-wrapper'), {
145 name: '{{ content.name }}',
146 course: '{{ course }}',
147 quiz_exit_button: quiz_exit_button,
148 next_url: next_url
149 })
150 window.quiz = quiz;
151 })
Shivam Mishraae2871f2019-05-29 13:11:34 +0530152 {% endif %}
153
Shivam Mishrad1a25212019-06-03 12:57:38 +0530154 {% if content_type != 'Quiz' %}
155
Shivam Mishraae2871f2019-05-29 13:11:34 +0530156 frappe.ready(() => {
157 next = document.getElementById('nextButton')
158 next.disabled = false;
159 })
160
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530161
Shivam Mishrad1a25212019-06-03 12:57:38 +0530162 function handle(url) {
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530163 opts = {
164 method: "erpnext.education.utils.add_activity",
165 args: {
Shivam Mishraae2871f2019-05-29 13:11:34 +0530166 course: "{{ course }}",
167 content_type: "{{ content_type }}",
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530168 content: "{{ content.name }}"
Shivam Mishraae2871f2019-05-29 13:11:34 +0530169 }
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530170 }
171 frappe.call(opts).then(res => {
172 window.location.href = url;
173 })
Shivam Mishraae2871f2019-05-29 13:11:34 +0530174 }
Shivam Mishrad1a25212019-06-03 12:57:38 +0530175
176 {% endif %}
Shivam Mishraae2871f2019-05-29 13:11:34 +0530177 </script>
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530178{% endblock %}