blob: a02b2c75005b4b4519a78395e2ef9d29f90feffc [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>
39 <div class="col-md-5 text-right">
40 {% 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>
73<div class="my-5">
74 {{ 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
98{% block content %}
99<section class="section">
100 <div>
101 <div class='container pb-5'>
102 {% if content_type=='Video' %}
103 {{ video() }}
104 {% elif content_type=='Article'%}
105 {{ article() }}
106 {% elif content_type=='Quiz' %}
107 <h2>Quiz: {{ content.name }}</h2>
108 {% endif %}
109 </div>
110 </div>
111</section>
Shivam Mishraae2871f2019-05-29 13:11:34 +0530112{% endblock %}
113
114{% block script %}
115 {% if content_type=='Video' %}
116 <script src="https://cdn.plyr.io/3.5.3/plyr.js"></script>
117 {% endif %}
118 <script>
119 {% if content_type=='Video' %}
120 const player = new Plyr('#player');
121 {% endif %}
122
123 frappe.ready(() => {
124 next = document.getElementById('nextButton')
125 next.disabled = false;
126 })
127
128 function handle(url) {
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530129
130 opts = {
131 method: "erpnext.education.utils.add_activity",
132 args: {
Shivam Mishraae2871f2019-05-29 13:11:34 +0530133 course: "{{ course }}",
134 content_type: "{{ content_type }}",
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530135 content: "{{ content.name }}"
Shivam Mishraae2871f2019-05-29 13:11:34 +0530136 }
Shivam Mishrae94e9d22019-05-30 18:05:00 +0530137 }
138 frappe.call(opts).then(res => {
139 window.location.href = url;
140 })
Shivam Mishraae2871f2019-05-29 13:11:34 +0530141 }
142 </script>
Shivam Mishrac8c790a2019-05-21 12:04:50 +0530143{% endblock %}