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 @@
{{ form.as_table }} +
+

-
+
@@ -55,4 +58,9 @@ Close {% endif %} + {% endblock %} -- cgit From d1c6bf1f0342cbc7cfaeed74161a525ed206f3ab Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 30 Nov 2016 17:44:53 +0530 Subject: Quiz instructions fetched from database instead of default text --- yaksh/templates/yaksh/intro.html | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'yaksh') diff --git a/yaksh/templates/yaksh/intro.html b/yaksh/templates/yaksh/intro.html index 81c460f..29723fa 100644 --- a/yaksh/templates/yaksh/intro.html +++ b/yaksh/templates/yaksh/intro.html @@ -21,24 +21,7 @@ {% endif %}

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 }}
{% if user == "moderator" %} -- cgit From 1043bccccd8ce24e24956ab771f49be5a29cd447 Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 30 Nov 2016 18:20:45 +0530 Subject: fix views tests for quiz --- yaksh/test_views.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'yaksh') diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 2b7ad9b..30ebcaa 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -1,6 +1,6 @@ from datetime import datetime import pytz - +import os from django.contrib.auth.models import Group from django.core.urlresolvers import reverse from django.test import TestCase @@ -146,7 +146,9 @@ class TestAddQuiz(TestCase): self.mod_group = Group.objects.create(name='moderator') tzone = pytz.timezone('UTC') - + file_path = os.path.join(os.getcwd(), "Quiz_instructions.txt") + with open(file_path, 'r') as file: + self.file_data = file.read() # Create Moderator with profile self.user_plaintext_pass = 'demo' self.user = User.objects.create_user( @@ -185,7 +187,7 @@ class TestAddQuiz(TestCase): self.pre_req_quiz = Quiz.objects.create( start_date_time=datetime(2014, 2, 1, 5, 8, 15, 0, tzone), end_date_time=datetime(2015, 10, 9, 10, 8, 15, 0, tzone), - duration=30, active=True, + duration=30, active=True, instructions=self.file_data, attempts_allowed=-1, time_between_attempts=0, description='pre requisite quiz', pass_criteria=40, language='Python', prerequisite=None, @@ -195,7 +197,7 @@ class TestAddQuiz(TestCase): self.quiz = Quiz.objects.create( start_date_time=datetime(2014, 10, 9, 10, 8, 15, 0, tzone), end_date_time=datetime(2015, 10, 9, 10, 8, 15, 0, tzone), - duration=30, active=True, + duration=30, active=True, instructions=self.file_data, attempts_allowed=-1, time_between_attempts=0, description='demo quiz', pass_criteria=40, language='Python', prerequisite=self.pre_req_quiz, @@ -272,6 +274,7 @@ class TestAddQuiz(TestCase): 'description': 'updated demo quiz', 'pass_criteria': 40, 'language': 'java', + 'instructions': self.file_data, 'prerequisite': self.pre_req_quiz.id, 'course': self.course.id } @@ -318,6 +321,7 @@ class TestAddQuiz(TestCase): 'description': 'new demo quiz', 'pass_criteria': 50, 'language': 'python', + 'instructions': self.file_data, 'prerequisite': self.pre_req_quiz.id, 'course': self.course.id } -- cgit From 134ae5e8ecdb5ff4aa6366d3081c7cd6d985fcb6 Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 1 Dec 2016 15:48:21 +0530 Subject: removed bind function instead used keypress --- yaksh/static/yaksh/js/add_quiz.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'yaksh') diff --git a/yaksh/static/yaksh/js/add_quiz.js b/yaksh/static/yaksh/js/add_quiz.js index a026ec0..e06c863 100644 --- a/yaksh/static/yaksh/js/add_quiz.js +++ b/yaksh/static/yaksh/js/add_quiz.js @@ -7,9 +7,9 @@ function test() { document.getElementById("submit").innerHTML = "Save"; } - var template = "

" + var template = "

"; $(template).insertBefore("#id_instructions"); - $('#id_instructions').bind('keypress', function (event){ + $('#id_instructions').keypress(function (event){ document.getElementById('rendered_text').innerHTML = document.getElementById('id_instructions').value ; }); document.getElementById('rendered_text').innerHTML = document.getElementById('id_instructions').value ; -- cgit From 4b501a76d19e0ecbb2f75d4e2402a24a3bb47429 Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 1 Dec 2016 16:00:14 +0530 Subject: removed extra html tag and changed alignment of rendered text --- yaksh/static/yaksh/js/add_quiz.js | 2 +- yaksh/templates/yaksh/add_quiz.html | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'yaksh') diff --git a/yaksh/static/yaksh/js/add_quiz.js b/yaksh/static/yaksh/js/add_quiz.js index e06c863..f4067ed 100644 --- a/yaksh/static/yaksh/js/add_quiz.js +++ b/yaksh/static/yaksh/js/add_quiz.js @@ -7,7 +7,7 @@ function test() { document.getElementById("submit").innerHTML = "Save"; } - var template = "

"; + var template = "

"; $(template).insertBefore("#id_instructions"); $('#id_instructions').keypress(function (event){ document.getElementById('rendered_text').innerHTML = document.getElementById('id_instructions').value ; diff --git a/yaksh/templates/yaksh/add_quiz.html b/yaksh/templates/yaksh/add_quiz.html index b3b49ae..38773b5 100644 --- a/yaksh/templates/yaksh/add_quiz.html +++ b/yaksh/templates/yaksh/add_quiz.html @@ -25,7 +25,6 @@ $("#id_start_date_time").datetimepicker({format: 'Y-m-d H:i:s'}); $("#id_end_date_time").datetimepicker({format: 'Y-m-d H:i:s'}); -

-- cgit From f76c6c7aab4df2f743259334aa91ca295cb854ee Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 1 Dec 2016 16:01:09 +0530 Subject: change in quiz model test to check instructions --- yaksh/test_models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'yaksh') diff --git a/yaksh/test_models.py b/yaksh/test_models.py index e7f3016..1aeffb6 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -46,7 +46,7 @@ def setUpModule(): attempts_allowed=1, time_between_attempts=0, description='demo quiz', pass_criteria=0, language='Python', prerequisite=None, - course=course) + course=course, instructions="Demo Instructions") Quiz.objects.create(start_date_time=datetime(2014, 10, 9, 10, 8, 15, 0, tzinfo=pytz.utc), @@ -56,7 +56,7 @@ def setUpModule(): attempts_allowed=-1, time_between_attempts=0, description='demo quiz', pass_criteria=40, language='Python', prerequisite=quiz, - course=course) + course=course, instructions="Demo Instructions") with open('/tmp/test.txt', 'wb') as f: f.write('2'.encode('ascii')) @@ -239,6 +239,7 @@ class QuizTestCases(unittest.TestCase): self.assertEqual(self.quiz1.language, 'Python') self.assertEqual(self.quiz1.pass_criteria, 0) self.assertEqual(self.quiz1.prerequisite, None) + self.assertEqual(self.quiz1.instructions, "Demo Instructions") def test_is_expired(self): self.assertFalse(self.quiz1.is_expired()) -- cgit