diff options
author | adityacp | 2018-07-13 23:06:24 +0530 |
---|---|---|
committer | adityacp | 2018-07-13 23:06:24 +0530 |
commit | 4814ec20eb19ffad9150f8e67660bf402b1cd8b7 (patch) | |
tree | a2422112f00d200a2fe49bf7fdc114b675c76fc3 /yaksh/models.py | |
parent | d2f1328238f35373761686d3b405f4afbedfba7f (diff) | |
download | online_test-4814ec20eb19ffad9150f8e67660bf402b1cd8b7.tar.gz online_test-4814ec20eb19ffad9150f8e67660bf402b1cd8b7.tar.bz2 online_test-4814ec20eb19ffad9150f8e67660bf402b1cd8b7.zip |
Add default video in demo lesson
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 26 |
1 files changed, 19 insertions, 7 deletions
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="<center>Demo Module</center>", + creator=user, html_data="<center>Demo Module</center>", + check_prerequisite=False + ) learning_module.learning_unit.add(quiz_unit) learning_module.learning_unit.add(lesson_unit) course.learning_module.add(learning_module) |