From a9a8f286767468a55709215fbe584157f32a7300 Mon Sep 17 00:00:00 2001
From: adityacp
Date: Tue, 15 Sep 2020 13:50:24 +0530
Subject: Change multiple sections
- Show lesson topic description as per the video time
- Fix description preview for module and lesson
- Order table of contents by time
---
yaksh/static/yaksh/css/custom.css | 13 ------
yaksh/static/yaksh/js/lesson.js | 12 +++++
yaksh/static/yaksh/js/show_toc.js | 21 +++++++--
yaksh/templates/yaksh/add_lesson.html | 12 ++++-
yaksh/templates/yaksh/show_lesson_statistics.html | 2 +-
yaksh/templates/yaksh/show_video.html | 55 ++++++++++++-----------
yaksh/views.py | 4 +-
7 files changed, 73 insertions(+), 46 deletions(-)
(limited to 'yaksh')
diff --git a/yaksh/static/yaksh/css/custom.css b/yaksh/static/yaksh/css/custom.css
index 9f29349..26efbed 100644
--- a/yaksh/static/yaksh/css/custom.css
+++ b/yaksh/static/yaksh/css/custom.css
@@ -132,19 +132,6 @@ body, .dropdown-menu {
border: none;
}
-/* Simple MDE editor style */
-.editor-toolbar.fullscreen, .editor-preview-side {
- z-index: 2000 !important;
-}
-.CodeMirror, .CodeMirror-scroll {
- max-height: 400px !important;
-}
-.CodeMirror-fullscreen.CodeMirror {
- max-height: none !important;
-}
-.CodeMirror-fullscreen .CodeMirror-scroll {
- max-height: none !important;
-}
::-webkit-scrollbar {
width: 10px;
diff --git a/yaksh/static/yaksh/js/lesson.js b/yaksh/static/yaksh/js/lesson.js
index 60eff78..2cc2e62 100644
--- a/yaksh/static/yaksh/js/lesson.js
+++ b/yaksh/static/yaksh/js/lesson.js
@@ -1,7 +1,13 @@
$(document).ready(function() {
+ MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
var simplemde = new SimpleMDE({
element: document.getElementById("id_description"),
forceSync: true,
+ hideIcons: ["preview", "side-by-side", "fullscreen"]
+ });
+ simplemde.codemirror.on("change", function() {
+ MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
+ $("#description_body").html(simplemde.markdown(simplemde.value()));
});
const player = new Plyr('#player');
var timer = $("#vtimer");
@@ -34,6 +40,12 @@ $(document).ready(function() {
$("#id_type").hide();
$("#id_type").attr("required", false);
} else {
+ if(valueSelected == "4") {
+ $('#id_type option[value="mcq"]').prop("selected", true);
+ $('#id_type').attr("disabled", true);
+ } else {
+ $('#id_type').attr("disabled", false);
+ }
$("#id_type").show();
$("#id_type").attr("required", true);
}
diff --git a/yaksh/static/yaksh/js/show_toc.js b/yaksh/static/yaksh/js/show_toc.js
index 5fef923..b628eaa 100644
--- a/yaksh/static/yaksh/js/show_toc.js
+++ b/yaksh/static/yaksh/js/show_toc.js
@@ -10,9 +10,12 @@ $(document).ready(function() {
if (time_arr_length > 0 && player.currentTime >= video_time[loc]) {
var content = contents_by_time[loc];
loc += 1;
- if(content.content != 1) {
+ if(content.content == 1) {
+ show_topic($("#toc_desc_"+content.id).val(), false);
+ }
+ else {
player.pause();
- player.fullscreen.exit();
+ if(player.fullscreen.active) player.fullscreen.exit();
url = $("#toc_"+content.id).val();
ajax_call(url, "GET");
}
@@ -20,6 +23,15 @@ $(document).ready(function() {
});
});
+function show_topic(description, override) {
+ var topic_div = $("#topic-description");
+ if(override) {
+ topic_div.html(description);
+ } else {
+ topic_div.append("
" + description);
+ }
+}
+
function store_video_time(contents) {
for (var j = 0; j < contents.length; j++)
video_time.push(get_time_in_seconds(contents[j].time));
@@ -66,7 +78,10 @@ function select_toc(element) {
var content_type = element.getAttribute("data-toc-type");
var toc_time = $("#toc_time_"+toc_id).val();
player.currentTime = get_time_in_seconds(toc_time);
- if (content_type != 1) {
+ if (content_type == 1) {
+ show_topic($("#toc_desc_"+toc_id).val(), true);
+ }
+ else {
url = $("#toc_"+toc_id).val();
ajax_call(url, "GET");
}
diff --git a/yaksh/templates/yaksh/add_lesson.html b/yaksh/templates/yaksh/add_lesson.html
index 6018e54..8d889f3 100644
--- a/yaksh/templates/yaksh/add_lesson.html
+++ b/yaksh/templates/yaksh/add_lesson.html
@@ -68,6 +68,16 @@
{% endif %}
{{lesson_form.name}}
+