From 4814ec20eb19ffad9150f8e67660bf402b1cd8b7 Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 13 Jul 2018 23:06:24 +0530 Subject: Add default video in demo lesson --- yaksh/models.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 1e5492c..49a2384 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -208,7 +208,7 @@ def write_templates_to_zip(zipfile, template_path, data, filename, filepath): str(rendered_template)) -def render_template(template_path, data): +def render_template(template_path, data=None): with open(template_path) as f: template_data = f.read() template = Template(template_data) @@ -855,16 +855,28 @@ class Course(models.Model): demo_que_ppr = QuestionPaper() demo_que_ppr.create_demo_quiz_ppr(demo_quiz, user) success = True + file_path = os.sep.join( + (os.path.dirname(__file__), "templates", "yaksh", + "demo_video.html") + ) + rendered_text = render_template(file_path) + lesson_data = "Demo Lesson\n{0}".format(rendered_text) demo_lesson = Lesson.objects.create( - name="Demo lesson", description="demo lesson", - html_data="demo lesson", creator=user) + name="Demo Lesson", description=lesson_data, + html_data=lesson_data, creator=user + ) quiz_unit = LearningUnit.objects.create( - order=1, type="quiz", quiz=demo_quiz) + order=1, type="quiz", quiz=demo_quiz, check_prerequisite=False + ) lesson_unit = LearningUnit.objects.create( - order=2, type="lesson", lesson=demo_lesson) + order=2, type="lesson", lesson=demo_lesson, + check_prerequisite=False + ) learning_module = LearningModule.objects.create( - name="demo module", description="demo module", creator=user, - html_data="demo module") + name="Demo Module", description="