From ec55273fcc0c374dbaf213910f760660fb1419a6 Mon Sep 17 00:00:00 2001
From: CruiseDevice
Date: Fri, 31 May 2019 18:46:03 +0530
Subject: Add templates and more features
---
yaksh/models.py | 47 ++++++++++++++++++++++---
yaksh/templates/yaksh/index.html | 20 +++++++----
yaksh/templates/yaksh/module.html | 33 ++++++++++++------
yaksh/templates/yaksh/quiz.html | 73 +++++++++++++++++++++++++++++++++++++++
yaksh/templates/yaksh/unit.html | 22 +++++++-----
yaksh/views.py | 1 +
6 files changed, 165 insertions(+), 31 deletions(-)
create mode 100644 yaksh/templates/yaksh/quiz.html
diff --git a/yaksh/models.py b/yaksh/models.py
index d0161c1..24cb996 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -298,7 +298,7 @@ class Lesson(models.Model):
if os.path.exists(file_path):
os.remove(file_path)
- def _add_lesson_to_zip(self, module, course, zip_file, path):
+ def _add_lesson_to_zip(self, next_unit, module, course, zip_file, path):
lesson_name = self.name.replace(" ", "_")
course_name = course.name.replace(" ", "_")
module_name = module.name.replace(" ", "_")
@@ -319,7 +319,8 @@ class Lesson(models.Model):
path, "templates", "yaksh", "unit.html"
))
lesson_data = {"course": course, "module": module,
- "lesson": self, "lesson_files": lesson_files}
+ "lesson": self, "next_unit": next_unit,
+ "lesson_files": lesson_files}
write_templates_to_zip(zip_file, unit_file_path, lesson_data,
lesson_name, sub_folder_name)
@@ -567,6 +568,31 @@ class Quiz(models.Model):
return '%s: on %s for %d minutes' % (desc, self.start_date_time,
self.duration)
+ def _add_quiz_to_zip(self, next_unit, module, course, zip_file, path):
+ quiz_name = self.description.replace(" ", "_")
+ course_name = course.name.replace(" ", "_")
+ module_name = module.name.replace(" ", "_")
+ sub_folder_name = os.sep.join((
+ course_name, module_name, quiz_name
+ ))
+ # lesson_files = self.get_files()
+ # if self.video_file:
+ # video_file = os.sep.join((sub_folder_name, os.path.basename(
+ # self.video_file.name)))
+ # zip_file.writestr(video_file, self.video_file.read())
+ # for lesson_file in lesson_files:
+ # if os.path.exists(lesson_file.file.path):
+ # filename = os.sep.join((sub_folder_name, os.path.basename(
+ # lesson_file.file.name)))
+ # zip_file.writestr(filename, lesson_file.file.read())
+ unit_file_path = os.sep.join((
+ path, "templates", "yaksh", "quiz.html"
+ ))
+ quiz_data = {"course": course, "module": module,
+ "quiz": self, "next_unit": next_unit}
+
+ write_templates_to_zip(zip_file, unit_file_path, quiz_data,
+ quiz_name, sub_folder_name)
##########################################################################
class LearningUnit(models.Model):
@@ -577,6 +603,9 @@ class LearningUnit(models.Model):
quiz = models.ForeignKey(Quiz, null=True, blank=True)
check_prerequisite = models.BooleanField(default=True)
+ def get_lesson_or_quiz(self):
+ return self.lesson if self.lesson else self.quiz
+
def toggle_check_prerequisite(self):
if self.check_prerequisite:
self.check_prerequisite = False
@@ -774,12 +803,19 @@ class LearningModule(models.Model):
course_name = course.name.replace(" ", "_")
folder_name = os.sep.join((course_name, module_name))
lessons = self.get_lesson_units()
- for lesson in lessons:
- lesson._add_lesson_to_zip(self, course, zip_file, path)
+
+ units = self.get_learning_units()
+ for idx, unit in enumerate(units):
+ next_unit = units[(idx + 1) % len(units)]
+ if unit.type == 'lesson':
+ unit.lesson._add_lesson_to_zip(next_unit, self, course, zip_file, path)
+ else:
+ unit.quiz._add_quiz_to_zip(next_unit, self, course, zip_file, path)
+
module_file_path = os.sep.join((
path, "templates", "yaksh", "module.html"
))
- module_data = {"course": course, "module": self, "lessons": lessons}
+ module_data = {"course": course, "module": self, "units": units}
write_templates_to_zip(zip_file, module_file_path, module_data,
module_name, folder_name)
@@ -1042,6 +1078,7 @@ class Course(models.Model):
def create_zip(self, path, static_files):
zip_file_name = string_io()
with zipfile.ZipFile(zip_file_name, "a") as zip_file:
+ # print("HELLOOOOOOO - - - -- - - -- ")
course_name = self.name.replace(" ", "_")
modules = self.get_learning_modules()
file_path = os.sep.join((path, "templates", "yaksh", "index.html"))
diff --git a/yaksh/templates/yaksh/index.html b/yaksh/templates/yaksh/index.html
index c89405d..9bd28d5 100644
--- a/yaksh/templates/yaksh/index.html
+++ b/yaksh/templates/yaksh/index.html
@@ -1,12 +1,15 @@
{% load custom_filters %}
-
-
-
-
-
-{% block pagetitle %} {{course.name}} {% endblock %}
-
--
cgit
From 745426ecc20bba58fd3721a960057ad8d41e3b99 Mon Sep 17 00:00:00 2001
From: CruiseDevice
Date: Wed, 3 Jul 2019 17:31:38 +0530
Subject: Minor changes
- Remove commented code.
- Add active class to the tab selected on sidebar.
---
yaksh/models.py | 10 ----------
yaksh/templates/yaksh/quiz.html | 4 ++--
yaksh/templates/yaksh/unit.html | 4 ++--
yaksh/views.py | 1 -
4 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/yaksh/models.py b/yaksh/models.py
index 24cb996..2ae6f45 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -575,16 +575,6 @@ class Quiz(models.Model):
sub_folder_name = os.sep.join((
course_name, module_name, quiz_name
))
- # lesson_files = self.get_files()
- # if self.video_file:
- # video_file = os.sep.join((sub_folder_name, os.path.basename(
- # self.video_file.name)))
- # zip_file.writestr(video_file, self.video_file.read())
- # for lesson_file in lesson_files:
- # if os.path.exists(lesson_file.file.path):
- # filename = os.sep.join((sub_folder_name, os.path.basename(
- # lesson_file.file.name)))
- # zip_file.writestr(filename, lesson_file.file.read())
unit_file_path = os.sep.join((
path, "templates", "yaksh", "quiz.html"
))
diff --git a/yaksh/templates/yaksh/quiz.html b/yaksh/templates/yaksh/quiz.html
index fca0cad..3240244 100644
--- a/yaksh/templates/yaksh/quiz.html
+++ b/yaksh/templates/yaksh/quiz.html
@@ -38,13 +38,13 @@
{% for unit in module.get_learning_units %}
{% if unit.type == 'lesson' %}
-
+
{{unit.lesson.name}}
{% else %}
-
+
{{unit.quiz.description}}
diff --git a/yaksh/templates/yaksh/unit.html b/yaksh/templates/yaksh/unit.html
index 1ceffe8..45092a6 100644
--- a/yaksh/templates/yaksh/unit.html
+++ b/yaksh/templates/yaksh/unit.html
@@ -38,13 +38,13 @@
{% for unit in module.get_learning_units %}
{% if unit.type == 'lesson' %}
-
+
{{unit.lesson.name}}
{% else %}
-
+
{{unit.quiz.description}}
diff --git a/yaksh/views.py b/yaksh/views.py
index 319acde..5f0c41c 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -2954,4 +2954,3 @@ def download_course(request, course_id):
)
response.write(zip_file.read())
return response
- # return HttpResponse("Success")
\ No newline at end of file
--
cgit
From 323e34a6755e794c0177afdb36cd931d25db3d77 Mon Sep 17 00:00:00 2001
From: CruiseDevice
Date: Fri, 12 Jul 2019 15:43:53 +0530
Subject: Resolve comments
- Remove print statements.
- Remove commented css from offline.css.
- Change 127.0.0.1 to yaksh.fossee.in quiz.html for offline application.
---
yaksh/models.py | 18 +++++++++++++-----
yaksh/static/yaksh/css/offline.css | 12 ------------
yaksh/templates/yaksh/quiz.html | 6 +++---
3 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/yaksh/models.py b/yaksh/models.py
index 2ae6f45..c97a616 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -578,12 +578,13 @@ class Quiz(models.Model):
unit_file_path = os.sep.join((
path, "templates", "yaksh", "quiz.html"
))
- quiz_data = {"course": course, "module": module,
- "quiz": self, "next_unit": next_unit}
+ quiz_data = {"course": course, "module": module,
+ "quiz": self, "next_unit": next_unit}
write_templates_to_zip(zip_file, unit_file_path, quiz_data,
quiz_name, sub_folder_name)
+
##########################################################################
class LearningUnit(models.Model):
""" Maintain order of lesson and quiz added in the course """
@@ -798,9 +799,17 @@ class LearningModule(models.Model):
for idx, unit in enumerate(units):
next_unit = units[(idx + 1) % len(units)]
if unit.type == 'lesson':
- unit.lesson._add_lesson_to_zip(next_unit, self, course, zip_file, path)
+ unit.lesson._add_lesson_to_zip(next_unit,
+ self,
+ course,
+ zip_file,
+ path)
else:
- unit.quiz._add_quiz_to_zip(next_unit, self, course, zip_file, path)
+ unit.quiz._add_quiz_to_zip(next_unit,
+ self,
+ course,
+ zip_file,
+ path)
module_file_path = os.sep.join((
path, "templates", "yaksh", "module.html"
@@ -1068,7 +1077,6 @@ class Course(models.Model):
def create_zip(self, path, static_files):
zip_file_name = string_io()
with zipfile.ZipFile(zip_file_name, "a") as zip_file:
- # print("HELLOOOOOOO - - - -- - - -- ")
course_name = self.name.replace(" ", "_")
modules = self.get_learning_modules()
file_path = os.sep.join((path, "templates", "yaksh", "index.html"))
diff --git a/yaksh/static/yaksh/css/offline.css b/yaksh/static/yaksh/css/offline.css
index 79584e0..134f102 100644
--- a/yaksh/static/yaksh/css/offline.css
+++ b/yaksh/static/yaksh/css/offline.css
@@ -78,15 +78,3 @@ section{
.bg-grey{
background-color:#dbf9f2;
}
-
-
-/*.footer {
- position: fixed;
- left: 0;
- bottom: 0;
- width: 100%;
- background-color: #D3D3D3;
- color: black;
- text-align: center;
-}
-*/
\ No newline at end of file
diff --git a/yaksh/templates/yaksh/quiz.html b/yaksh/templates/yaksh/quiz.html
index 3240244..156a2b1 100644
--- a/yaksh/templates/yaksh/quiz.html
+++ b/yaksh/templates/yaksh/quiz.html
@@ -22,7 +22,7 @@