From e1e334964aaaed89e7e6d85094048518cb7ad88c Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Sat, 8 Aug 2020 00:56:26 +0530 Subject: Add select all checkbox in design qp for fixed questions. --- yaksh/models.py | 2 +- yaksh/static/yaksh/js/question_paper_creation.js | 34 ++++++++++- yaksh/templates/yaksh/add_quiz.html | 2 +- yaksh/templates/yaksh/design_questionpaper.html | 72 +++++++++++++----------- yaksh/views.py | 13 +++++ 5 files changed, 87 insertions(+), 36 deletions(-) diff --git a/yaksh/models.py b/yaksh/models.py index 6542daa..d3d90c9 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1729,7 +1729,7 @@ class QuestionPaper(models.Model): total_marks = models.FloatField(default=0.0, blank=True) # Sequence or Order of fixed questions - fixed_question_order = models.CharField(max_length=255, blank=True) + fixed_question_order = models.TextField(blank=True) # Shuffle testcase order. shuffle_testcases = models.BooleanField("Shuffle testcase for each user", diff --git a/yaksh/static/yaksh/js/question_paper_creation.js b/yaksh/static/yaksh/js/question_paper_creation.js index 9d04728..871d6cc 100644 --- a/yaksh/static/yaksh/js/question_paper_creation.js +++ b/yaksh/static/yaksh/js/question_paper_creation.js @@ -57,7 +57,38 @@ $(document).ready(function(){ $('#design_q').submit(function(eventObj) { $(this).append(''); return true; -}); + }); + + $('#add_checkall').change(function () { + if($(this).prop("checked")) { + $("#fixed-available input:checkbox").each(function(index, element) { + if(isNaN($(this).val())) {return}; + $(this).prop("checked", true); + checked_vals.push(parseInt($(this).val())) + }); + } else { + $("#fixed-available input:checkbox").each(function(index, element){ + $(this).prop('checked', false); + checked_vals.pop(parseInt($(this).val())); + }); + } + }); + + $('#remove_checkall').change(function () { + if($(this).prop("checked")) { + $("#fixed-added input:checkbox").each(function (index, element) { + if(isNaN($(this).val())) { return }; + $(this).prop('checked', true); + checked_vals.push(parseInt($(this).val())); + }); + } else { + $("#fixed-added input:checkbox").each(function (index, element) { + console.log('unchecked'); + $(this).prop('checked', false); + checked_vals.pop(parseInt($(this).val())); + }); + } + }); });//document function append_tag(tag){ @@ -69,3 +100,4 @@ function append_tag(tag){ tag_name.value = tag.value; } } + diff --git a/yaksh/templates/yaksh/add_quiz.html b/yaksh/templates/yaksh/add_quiz.html index 55e3bd6..01b6f8c 100644 --- a/yaksh/templates/yaksh/add_quiz.html +++ b/yaksh/templates/yaksh/add_quiz.html @@ -55,7 +55,7 @@ {% if quiz and course_id %} {% if quiz.questionpaper_set.get.id %}
Select questions to add:
Fixed questions currently in paper:
+Fixed questions currently in paper:
-- User Mode: Attempt quiz the way normal users will attempt i.e. - + Try as student: Attempt quiz the way students will attempt i.e. -
Total number of participants: {{ total }}
-Question | Type | Total | Answered Correctly |
---|
Question | Type | Total | Answered Correctly | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
{{ question.summary }} - + | {{ question.summary }}
-
+
+
Summary:
@@ -38,7 +37,7 @@
Description:
- {{ question.description }} + {{ question.description|safe }} Points: @@ -50,7 +49,7 @@ Type:- {{ question.type }} + {{ question.get_type_display }} {% if question.type in 'mcq mcc' %} @@ -72,6 +71,11 @@ |
+ + + | {{ question.type }} | {{value.1}} | {{ value.0 }} ({% widthratio value.0 value.1 100 %}%) | diff --git a/yaksh/views.py b/yaksh/views.py index 15ebd03..c1798b5 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -821,7 +821,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None, previous_question=current_question) else: user_answer = request.POST.get('answer') - if not user_answer: + if not str(user_answer): msg = "Please submit a valid answer." return show_question( request, current_question, paper, notification=msg, -- cgit From ebe75b31c225eaa71d6963b8ac493e37a63efb50 Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 28 Aug 2020 09:11:23 +0530 Subject: fix tests --- yaksh/test_models.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 37baf6e..a77c8bf 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -27,7 +27,7 @@ from yaksh import settings def setUpModule(): - Group.objects.create(name='moderator') + Group.objects.get_or_create(name='moderator') # create user profile user = User.objects.create_user(username='creator', @@ -842,7 +842,11 @@ class QuestionPaperTestCases(unittest.TestCase): total_marks=0.0, shuffle_questions=True ) - + self.question_paper_with_time_between_attempts.fixed_question_order = \ + "{0}, {1}".format(self.questions[3].id, self.questions[5].id) + self.question_paper_with_time_between_attempts.fixed_questions.add( + self.questions[3], self.questions[5] + ) self.question_paper.fixed_question_order = "{0}, {1}".format( self.questions[3].id, self.questions[5].id ) @@ -1030,7 +1034,7 @@ class QuestionPaperTestCases(unittest.TestCase): qu_list = [str(self.questions_list[0]), str(self.questions_list[1])] trial_paper = \ QuestionPaper.objects.create_trial_paper_to_test_quiz( - self.trial_quiz, self.quiz.id + self.trial_quiz, self.quiz_with_time_between_attempts.id ) trial_paper.random_questions.add(self.question_set_1) trial_paper.random_questions.add(self.question_set_2) -- cgit From e3c3a0d9f7819f851890ea2611ba12b4f6255f06 Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 28 Aug 2020 11:26:51 +0530 Subject: fix design question paper views and tests --- yaksh/static/yaksh/js/question_paper_creation.js | 5 +-- yaksh/test_views.py | 54 +++++++++++++----------- yaksh/views.py | 12 ++++++ 3 files changed, 44 insertions(+), 27 deletions(-) diff --git a/yaksh/static/yaksh/js/question_paper_creation.js b/yaksh/static/yaksh/js/question_paper_creation.js index 871d6cc..1159dd3 100644 --- a/yaksh/static/yaksh/js/question_paper_creation.js +++ b/yaksh/static/yaksh/js/question_paper_creation.js @@ -59,7 +59,7 @@ $(document).ready(function(){ return true; }); - $('#add_checkall').change(function () { + $('#add_checkall').on("change", function () { if($(this).prop("checked")) { $("#fixed-available input:checkbox").each(function(index, element) { if(isNaN($(this).val())) {return}; @@ -74,7 +74,7 @@ $(document).ready(function(){ } }); - $('#remove_checkall').change(function () { + $('#remove_checkall').on("change", function () { if($(this).prop("checked")) { $("#fixed-added input:checkbox").each(function (index, element) { if(isNaN($(this).val())) { return }; @@ -83,7 +83,6 @@ $(document).ready(function(){ }); } else { $("#fixed-added input:checkbox").each(function (index, element) { - console.log('unchecked'); $(this).prop('checked', false); checked_vals.pop(parseInt($(this).val())); }); diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 5876f03..df408bb 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -5964,12 +5964,11 @@ class TestQuestionPaper(TestCase): 'add-random': ['']} ) - self.assertEqual(response.status_code, 200) - self.assertTemplateUsed(response, 'yaksh/design_questionpaper.html') - random_set = response.context['random_sets'][0] - added_random_ques = random_set.questions.all() - self.assertIn(self.random_que1, added_random_ques) - self.assertIn(self.random_que2, added_random_ques) + self.assertEqual(response.status_code, 302) + self.assertTrue( + self.question_paper.random_questions.filter( + id__in=[self.random_que1.id, self.random_que2.id]).exists() + ) # Check if questions already exists self.client.login( @@ -5996,10 +5995,11 @@ class TestQuestionPaper(TestCase): data={'checked_ques': [self.fixed_que.id], 'add-fixed': ''} ) - self.assertEqual(response.status_code, 200) - self.assertEqual(response.context['qpaper'], self.fixed_question_paper) - self.assertEqual(response.context['fixed_questions'][0], - self.fixed_que) + self.assertEqual(response.status_code, 302) + self.assertTrue( + self.fixed_question_paper.fixed_questions.filter( + id=self.fixed_que.id).exists() + ) # Add one more fixed question in question paper response = self.client.post( @@ -6010,10 +6010,11 @@ class TestQuestionPaper(TestCase): data={'checked_ques': [self.question_float.id], 'add-fixed': ''} ) - self.assertEqual(response.status_code, 200) - self.assertEqual(response.context['qpaper'], self.fixed_question_paper) - self.assertEqual(response.context['fixed_questions'], - [self.fixed_que, self.question_float]) + self.assertEqual(response.status_code, 302) + self.assertTrue( + self.fixed_question_paper.fixed_questions.filter( + id=self.question_float.id).exists() + ) # Remove fixed question from question paper response = self.client.post( @@ -6024,10 +6025,11 @@ class TestQuestionPaper(TestCase): data={'added-questions': [self.fixed_que.id], 'remove-fixed': ''} ) - self.assertEqual(response.status_code, 200) - self.assertEqual(response.context['qpaper'], self.fixed_question_paper) - self.assertEqual(response.context['fixed_questions'], - [self.question_float]) + self.assertEqual(response.status_code, 302) + self.assertFalse( + self.fixed_question_paper.fixed_questions.filter( + id=self.fixed_que.id).exists() + ) # Remove one more fixed question from question paper response = self.client.post( @@ -6038,9 +6040,11 @@ class TestQuestionPaper(TestCase): data={'added-questions': [self.question_float.id], 'remove-fixed': ''} ) - self.assertEqual(response.status_code, 200) - self.assertEqual(response.context['qpaper'], self.fixed_question_paper) - self.assertEqual(response.context['fixed_questions'], []) + self.assertEqual(response.status_code, 302) + self.assertFalse( + self.fixed_question_paper.fixed_questions.filter( + id=self.question_float.id).exists() + ) # Remove random questions from question paper random_que_set = self.question_paper.random_questions.all().first() @@ -6052,9 +6056,11 @@ class TestQuestionPaper(TestCase): data={'random_sets': random_que_set.id, 'remove-random': ''} ) - self.assertEqual(response.status_code, 200) - self.assertEqual(response.context['qpaper'], self.question_paper) - self.assertEqual(len(response.context['random_sets']), 0) + self.assertEqual(response.status_code, 302) + self.assertFalse( + self.question_paper.random_questions.filter( + id=random_que_set.id).exists() + ) class TestLearningModule(TestCase): diff --git a/yaksh/views.py b/yaksh/views.py index afa673f..2fe93ea 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1491,6 +1491,12 @@ def design_questionpaper(request, course_id, quiz_id, questionpaper_id=None): random_set.questions.add(*random_ques) question_paper.random_questions.add(random_set) messages.success(request, "Questions removed successfully") + return redirect( + 'yaksh:designquestionpaper', + course_id=course_id, + quiz_id=quiz_id, + questionpaper_id=questionpaper_id + ) else: messages.warning(request, "Please select atleast one question") @@ -1499,6 +1505,12 @@ def design_questionpaper(request, course_id, quiz_id, questionpaper_id=None): if random_set_ids: question_paper.random_questions.remove(*random_set_ids) messages.success(request, "Questions removed successfully") + return redirect( + 'yaksh:designquestionpaper', + course_id=course_id, + quiz_id=quiz_id, + questionpaper_id=questionpaper_id + ) else: messages.warning(request, "Please select question set") -- cgit From 348a6a5b0786ffc28cb988c1fcc62232a7e57fc2 Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 28 Aug 2020 12:49:32 +0530 Subject: Release changes --- yaksh/migrations/0021_auto_20200703_1556.py | 25 ++++++++++++++++++++++++ yaksh/migrations/0022_release_0_22_1.py | 30 +++++++++++++++++++++++++++++ yaksh/templates/yaksh/question.html | 6 +++--- yaksh/templatetags/custom_filters.py | 23 ++++++++++++++++++++++ 4 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 yaksh/migrations/0021_auto_20200703_1556.py create mode 100644 yaksh/migrations/0022_release_0_22_1.py diff --git a/yaksh/migrations/0021_auto_20200703_1556.py b/yaksh/migrations/0021_auto_20200703_1556.py new file mode 100644 index 0000000..713b2d8 --- /dev/null +++ b/yaksh/migrations/0021_auto_20200703_1556.py @@ -0,0 +1,25 @@ +# Generated by Django 3.0.7 on 2020-07-03 10:26 + +import datetime +from django.db import migrations, models +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('yaksh', '0020_release_0_21_0'), + ] + + operations = [ + migrations.AlterField( + model_name='course', + name='end_enroll_time', + field=models.DateTimeField(default=datetime.datetime(2198, 12, 31, 18, 7, tzinfo=utc), null=True, verbose_name='End Date and Time for enrollment of course'), + ), + migrations.AlterField( + model_name='quiz', + name='end_date_time', + field=models.DateTimeField(default=datetime.datetime(2198, 12, 31, 18, 7, tzinfo=utc), null=True, verbose_name='End Date and Time of the quiz'), + ), + ] diff --git a/yaksh/migrations/0022_release_0_22_1.py b/yaksh/migrations/0022_release_0_22_1.py new file mode 100644 index 0000000..5275b86 --- /dev/null +++ b/yaksh/migrations/0022_release_0_22_1.py @@ -0,0 +1,30 @@ +# Generated by Django 3.0.7 on 2020-08-28 07:17 + +import datetime +from django.db import migrations, models +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('yaksh', '0021_auto_20200703_1556'), + ] + + operations = [ + migrations.AlterField( + model_name='course', + name='end_enroll_time', + field=models.DateTimeField(default=datetime.datetime(2199, 1, 1, 0, 0, tzinfo=utc), null=True, verbose_name='End Date and Time for enrollment of course'), + ), + migrations.AlterField( + model_name='questionpaper', + name='fixed_question_order', + field=models.TextField(blank=True), + ), + migrations.AlterField( + model_name='quiz', + name='end_date_time', + field=models.DateTimeField(default=datetime.datetime(2199, 1, 1, 0, 0, tzinfo=utc), null=True, verbose_name='End Date and Time of the quiz'), + ), + ] diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index 6489b38..3f7e67e 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -239,21 +239,21 @@ question_type = "{{ question.type }}"; {% if question.type == "integer" %} Enter Integer:Institute | Marks | Attempts | -Time | +Time Left | Status | +Special Attempt | {{ paper.marks_obtained }} | {{ paper.answers.count }} | {{ paper.time_left }} | -{{ paper.status }} | +{% if paper.is_attempt_inprogress %} + + {% else %} + Completed + {% endif %} + | +{% specail_attempt_monitor paper.user.id course.id quiz.id %} | {% endfor %} @@ -126,7 +152,6 @@ $(document).ready(function()