From 9b4416ecee8b7522d1c3f4de25557a31315df397 Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 30 Nov 2016 17:37:03 +0530 Subject: Added field Instructions in Quiz --- yaksh/models.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'yaksh') diff --git a/yaksh/models.py b/yaksh/models.py index 2018198..dc12707 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -80,6 +80,10 @@ def has_profile(user): def get_upload_dir(instance, filename): return "question_%s/%s" % (instance.question.id, filename) +def get_quiz_instructions_info(): + file_path = os.path.join(os.getcwd(), "Quiz_instructions.txt") + with open(file_path, 'r') as file: + return file.read() ############################################################################### class CourseManager(models.Manager): @@ -534,6 +538,9 @@ class Quiz(models.Model): is_trial = models.BooleanField(default=False) + instructions = models.TextField('Instructions for Students', + default=get_quiz_instructions_info) + view_answerpaper = models.BooleanField('Allow student to view their answer\ paper', default=False) -- cgit From d0cbfb251f2cd606bee2b9cd7a8692f1d1146b47 Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 30 Nov 2016 17:38:26 +0530 Subject: Render Instructions from textarea --- yaksh/static/yaksh/js/add_quiz.js | 6 ++++++ yaksh/templates/yaksh/add_quiz.html | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'yaksh') diff --git a/yaksh/static/yaksh/js/add_quiz.js b/yaksh/static/yaksh/js/add_quiz.js index 3da4d5c..a026ec0 100644 --- a/yaksh/static/yaksh/js/add_quiz.js +++ b/yaksh/static/yaksh/js/add_quiz.js @@ -7,6 +7,12 @@ function test() { document.getElementById("submit").innerHTML = "Save"; } + var template = "
" + $(template).insertBefore("#id_instructions"); + $('#id_instructions').bind('keypress', function (event){ + document.getElementById('rendered_text').innerHTML = document.getElementById('id_instructions').value ; + }); + document.getElementById('rendered_text').innerHTML = document.getElementById('id_instructions').value ; } String.prototype.beginsWith = function (string) { diff --git a/yaksh/templates/yaksh/add_quiz.html b/yaksh/templates/yaksh/add_quiz.html index 2df97a2..b3b49ae 100644 --- a/yaksh/templates/yaksh/add_quiz.html +++ b/yaksh/templates/yaksh/add_quiz.html @@ -20,14 +20,17 @@Welcome {{user.first_name.title}} {{user.last_name.title}}, to the programming quiz!
-- This examination system has been developed with the intention of making you - learn programming and be assessed in an interactive and fun manner. - You will be presented with a series of programming questions and problems that - you will answer online and get immediate feedback for. -
-Here are some important instructions and rules that you should understand carefully.
-We hope you enjoy taking this exam !!!
+ {{ questionpaper.quiz.instructions|safe }}