diff --git a/yaksh/templatetags/custom_filters.py b/yaksh/templatetags/custom_filters.py
index 57ec7dd..a3cd3f1 100644
--- a/yaksh/templatetags/custom_filters.py
+++ b/yaksh/templatetags/custom_filters.py
@@ -3,6 +3,7 @@ from django.template.defaultfilters import stringfilter
from django.forms.fields import CheckboxInput
from ast import literal_eval
import os
+import pandas as pd
try:
from itertools import zip_longest
except ImportError:
@@ -192,4 +193,10 @@ def has_lesson_video(lesson_id):
status = True if lesson.first().video_path else False
else:
status = False
- return status
\ No newline at end of file
+ return status
+
+
+@register.simple_tag
+def get_tc_percent(tc_id, data):
+ return data.get(str(tc_id), 0)
+
diff --git a/yaksh/views.py b/yaksh/views.py
index 69a7414..e01bf86 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -4025,8 +4025,19 @@ def lesson_statistics(request, course_id, lesson_id, toc_id=None):
context['course_id'] = course_id
if toc_id:
per_que_data = TableOfContents.objects.get_question_stats(toc_id)
- paginator = Paginator(per_que_data[1], 50)
- context['question'] = per_que_data[0]
+ question = per_que_data[0]
+ answers = per_que_data[1]
+ is_percent_reqd = (
+ True if question.type == "mcq" or question.type == "mcc"
+ else False
+ )
+ per_tc_ans, total_count = TableOfContents.objects.get_per_tc_ans(
+ toc_id, question.type, is_percent_reqd
+ )
+ context['per_tc_ans'] = per_tc_ans
+ context['total_count'] = total_count
+ paginator = Paginator(answers, 50)
+ context['question'] = question
page = request.GET.get('page')
per_que_data = paginator.get_page(page)
context['is_que_data'] = True
--
cgit
From 54740d2e9b3e9c67521074380730cc949dfaefb0 Mon Sep 17 00:00:00 2001
From: adityacp
Date: Mon, 26 Oct 2020 09:52:39 +0530
Subject: Improve tests for lesson statistics
---
yaksh/test_views.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
(limited to 'yaksh')
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index e7bbd91..2db217f 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -8195,6 +8195,29 @@ class TestLessonContents(TestCase):
'integertestcase_set-0-type': 'integertestcase',
'integertestcase_set-0-correct': "1"}
)
+ self.client.post(
+ reverse('yaksh:add_marker_quiz',
+ kwargs={"content_type": '3',
+ "course_id": self.user1_course1.id,
+ "lesson_id": self.lesson1.id}),
+ data={'timer': '00:00:00', 'summary': 'Mcc_Lesson_stats',
+ 'description': 'My lesson question description',
+ 'language': 'other', 'type': 'mcc', 'topic': 'test',
+ 'points': '1', 'form-TOTAL_FORMS': 2,
+ 'form-MAX_NUM_FORMS': '',
+ 'form-INITIAL_FORMS': 0,
+ 'mcqtestcase_set-TOTAL_FORMS': 2,
+ 'mcqtestcase_set-INITIAL_FORMS': 0,
+ 'mcqtestcase_set-MIN_NUM_FORMS': 0,
+ 'mcqtestcase_set-MAX_NUM_FORMS': 0,
+ 'mcqtestcase_set-0-type': 'mcqtestcase',
+ 'mcqtestcase_set-0-options': "1",
+ 'mcqtestcase_set-0-correct': True,
+ 'mcqtestcase_set-1-type': 'mcqtestcase',
+ 'mcqtestcase_set-1-options': "2",
+ 'mcqtestcase_set-1-correct': False
+ }
+ )
que = Question.objects.filter(summary="My_Lesson_question")
single_que = que.first()
@@ -8247,6 +8270,43 @@ class TestLessonContents(TestCase):
)
self.assertEqual(student_info.get("student_id"), self.student.id)
+ # Test for mcc lesson question statistics
+ # Given
+ que = Question.objects.filter(summary="Mcc_Lesson_stats")
+
+ single_que = que.first()
+ toc = TableOfContents.objects.get(
+ course_id=self.user1_course1.id, lesson_id=self.lesson1.id,
+ object_id=single_que.id
+ )
+ self.client.logout()
+
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ response = self.client.post(
+ reverse('yaksh:submit_marker_quiz',
+ kwargs={"course_id": self.user1_course1.id,
+ "toc_id": toc.id}),
+ data={'answer': [str(i.id) for i in single_que.get_test_cases()]}
+ )
+ self.client.logout()
+
+ # Then
+ self.client.login(
+ username=self.user1.username,
+ password=self.user1_plaintext_pass
+ )
+ response = self.client.get(
+ reverse('yaksh:lesson_statistics',
+ kwargs={"course_id": self.user1_course1.id,
+ "lesson_id": self.lesson1.id,
+ "toc_id": toc.id})
+ )
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(student_info.get("student_id"), self.student.id)
+
def test_multiple_lesson_question_types(self):
self.client.login(
username=self.user1.username,
--
cgit
From 167b53a673630c4243c5d82a5966797213a5fa28 Mon Sep 17 00:00:00 2001
From: adityacp
Date: Mon, 2 Nov 2020 15:45:29 +0530
Subject: Minor UI fixes
---
yaksh/templates/yaksh/add_lesson.html | 18 +++++++++++-------
yaksh/templates/yaksh/show_toc.html | 2 +-
yaksh/templates/yaksh/show_video.html | 4 ++--
3 files changed, 14 insertions(+), 10 deletions(-)
(limited to 'yaksh')
diff --git a/yaksh/templates/yaksh/add_lesson.html b/yaksh/templates/yaksh/add_lesson.html
index 329a8e0..d8ce09c 100644
--- a/yaksh/templates/yaksh/add_lesson.html
+++ b/yaksh/templates/yaksh/add_lesson.html
@@ -89,9 +89,11 @@
{{lesson_form.video_path}}
Video File:
-
- {{lesson_form.video_file.help_text}}
-
+
+
+ {{lesson_form.video_file.help_text}}
+
+
{{lesson_form.video_file}}
@@ -210,10 +212,12 @@
{% endwith %}
{% else %}
-
diff --git a/yaksh/templates/yaksh/show_toc.html b/yaksh/templates/yaksh/show_toc.html
index 92ea0cd..104815f 100644
--- a/yaksh/templates/yaksh/show_toc.html
+++ b/yaksh/templates/yaksh/show_toc.html
@@ -16,7 +16,7 @@