From d3d114f01adff6176460ba073d7dd44f5217ee00 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Tue, 3 Jan 2017 15:10:05 +0530 Subject: modified editing instructions. Instructions are now initialized in forms and not fetched from a file --- yaksh/forms.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ yaksh/models.py | 6 +----- yaksh/test_views.py | 11 ++++------- 3 files changed, 58 insertions(+), 12 deletions(-) (limited to 'yaksh') diff --git a/yaksh/forms.py b/yaksh/forms.py index 6fbaf5d..1d18d29 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -9,6 +9,7 @@ from taggit.managers import TaggableManager from taggit.forms import TagField from django.forms.models import inlineformset_factory from django.db.models import Q +from textwrap import dedent try: from string import letters except ImportError: @@ -165,6 +166,58 @@ class QuizForm(forms.ModelForm): self.fields['prerequisite'].required = False self.fields['course'] = forms.ModelChoiceField( queryset=Course.objects.filter(id=course_id), empty_label=None) + self.fields["instructions"].initial = dedent("""\ +

+ 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 !!! +

+ """) class Meta: model = Quiz diff --git a/yaksh/models.py b/yaksh/models.py index 2bf4a85..04bdd24 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -81,10 +81,6 @@ 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): @@ -550,7 +546,7 @@ class Quiz(models.Model): is_trial = models.BooleanField(default=False) instructions = models.TextField('Instructions for Students', - default=get_quiz_instructions_info) + default=None, blank=True, null=True) view_answerpaper = models.BooleanField('Allow student to view their answer\ paper', default=False) diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 2419591..e052441 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -146,9 +146,6 @@ 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( @@ -187,7 +184,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, instructions=self.file_data, + duration=30, active=True, instructions="Demo Instructions", attempts_allowed=-1, time_between_attempts=0, description='pre requisite quiz', pass_criteria=40, language='Python', prerequisite=None, @@ -197,7 +194,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, instructions=self.file_data, + duration=30, active=True, instructions="Demo Instructions", attempts_allowed=-1, time_between_attempts=0, description='demo quiz', pass_criteria=40, language='Python', prerequisite=self.pre_req_quiz, @@ -274,7 +271,7 @@ class TestAddQuiz(TestCase): 'description': 'updated demo quiz', 'pass_criteria': 40, 'language': 'java', - 'instructions': self.file_data, + 'instructions': "Demo Instructions", 'prerequisite': self.pre_req_quiz.id, 'course': self.course.id } @@ -321,7 +318,7 @@ class TestAddQuiz(TestCase): 'description': 'new demo quiz', 'pass_criteria': 50, 'language': 'python', - 'instructions': self.file_data, + 'instructions': "Demo Instructions", 'prerequisite': self.pre_req_quiz.id, 'course': self.course.id } -- cgit From feeb605573357fd8056f103b1043e192838bb23d Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Tue, 3 Jan 2017 15:21:30 +0530 Subject: MCQ/MCC choices HTML tags are rendered. --- yaksh/templates/yaksh/grade_user.html | 2 +- yaksh/templates/yaksh/question.html | 4 ++-- yaksh/templates/yaksh/user_data.html | 2 +- yaksh/templates/yaksh/view_answerpaper.html | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'yaksh') diff --git a/yaksh/templates/yaksh/grade_user.html b/yaksh/templates/yaksh/grade_user.html index 6fb8187..ec8c244 100644 --- a/yaksh/templates/yaksh/grade_user.html +++ b/yaksh/templates/yaksh/grade_user.html @@ -130,7 +130,7 @@ Status : Passed
{% if question.type == "mcq" or question.type == "mcc" %}
Choices:
{% for testcase in question.get_test_cases %} -
{{ forloop.counter }}. {{ testcase.options }} +
{{ forloop.counter }}. {{ testcase.options|safe }} {% endfor %} {% else %}
Test cases:
diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index 8b2012c..ba64b63 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -173,7 +173,7 @@ function call_skip(url)

{% endif %} {% for test_case in test_cases %} - {{ test_case.options }}
+ {{ test_case.options|safe }}
{% endfor %} {% endif %} {% if question.type == "mcc" %} @@ -189,7 +189,7 @@ function call_skip(url)

{% endif %} {% for test_case in test_cases %} - {{ test_case.options }} + {{ test_case.options|safe }}
{% endfor %} {% endif %} diff --git a/yaksh/templates/yaksh/user_data.html b/yaksh/templates/yaksh/user_data.html index 856433d..9c11dd9 100644 --- a/yaksh/templates/yaksh/user_data.html +++ b/yaksh/templates/yaksh/user_data.html @@ -66,7 +66,7 @@ User IP address: {{ paper.user_ip }} {% if question.type == "mcq" or question.type == "mcc" %}
Choices:
{% for testcase in question.get_test_cases %} -
{{ forloop.counter }}. {{ testcase.options }} +
{{ forloop.counter }}. {{ testcase.options|safe }} {% endfor %} {% else %}
Test cases:
diff --git a/yaksh/templates/yaksh/view_answerpaper.html b/yaksh/templates/yaksh/view_answerpaper.html index 9dfbda0..8dec5b3 100644 --- a/yaksh/templates/yaksh/view_answerpaper.html +++ b/yaksh/templates/yaksh/view_answerpaper.html @@ -42,7 +42,7 @@ {% if question.type == "mcq" or question.type == "mcc" %}
Choices:
{% for testcase in question.get_test_cases %} -
{{ forloop.counter }}. {{ testcase.options }} +
{{ forloop.counter }}. {{ testcase.options|safe }} {% endfor %} {%endif%} -- cgit From 25eb8d10045e1af6ab7c282b8df0b008223be545 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Tue, 3 Jan 2017 17:57:01 +0530 Subject: added completed and inprogress papers' status in monitor --- yaksh/templates/yaksh/monitor.html | 9 +++++++++ yaksh/templatetags/custom_filters.py | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'yaksh') diff --git a/yaksh/templates/yaksh/monitor.html b/yaksh/templates/yaksh/monitor.html index 7a3297b..0ad6401 100644 --- a/yaksh/templates/yaksh/monitor.html +++ b/yaksh/templates/yaksh/monitor.html @@ -1,4 +1,5 @@ {% extends "manage.html" %} +{% load custom_filters %} {% block pagetitle %} Quiz results {% endblock pagetitle %} @@ -49,6 +50,14 @@ $(document).ready(function() {% if papers %}

Number of papers: {{ papers|length }}

+{% completed papers as completed_papers %} + {# template tag used to get the count of completed papers #} +

Papers completed: {{ completed_papers }}

+ +{% inprogress papers as inprogress_papers %} + {# template tag used to get the count of inprogress papers #} +

Papers in progress: {{ inprogress_papers }}

+

Question Statisitics

Download CSV

diff --git a/yaksh/templatetags/custom_filters.py b/yaksh/templatetags/custom_filters.py index 9d7b939..f610cc6 100644 --- a/yaksh/templatetags/custom_filters.py +++ b/yaksh/templatetags/custom_filters.py @@ -10,4 +10,12 @@ def escape_quotes(value): escape_single_quotes = value.replace("'", "\\'") escape_single_and_double_quotes = escape_single_quotes.replace('"', '\\"') - return escape_single_and_double_quotes \ No newline at end of file + return escape_single_and_double_quotes + +@register.assignment_tag(name="completed") +def completed(answerpaper): + return answerpaper.filter(status="completed").count() + +@register.assignment_tag(name="inprogress") +def inprogress(answerpaper): + return answerpaper.filter(status="inprogress").count() -- cgit