summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authoradityacp2020-09-12 11:44:01 +0530
committeradityacp2020-09-12 11:44:01 +0530
commitb1d2b88746fc670d7362f9b4d175d5e570f3ac77 (patch)
tree7225713597b09645ce7b75ffe44271691e3e28b0 /yaksh/models.py
parentbee8d54d8ae094db5e3c9c04c5e28fb5b2abb1df (diff)
downloadonline_test-b1d2b88746fc670d7362f9b4d175d5e570f3ac77.tar.gz
online_test-b1d2b88746fc670d7362f9b4d175d5e570f3ac77.tar.bz2
online_test-b1d2b88746fc670d7362f9b4d175d5e570f3ac77.zip
Mulitple changes
- Remove all alerts and add toast messages - Accept user submissions for the lesson quiz and evaluate - Initial lesson statistics
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 570c4c6..19f3302 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -40,7 +40,7 @@ from django.contrib.contenttypes.models import ContentType
from django.template import Context, Template
from django.conf import settings
from django.forms.models import model_to_dict
-
+from django.db.models import Count
# Local Imports
from yaksh.code_server import (
submit, get_result as get_result_from_code_server
@@ -2745,6 +2745,18 @@ class Comment(ForumBase):
self.post_field.title)
+class TOCManager(models.Manager):
+
+ def get_data(self, course_id, lesson_id):
+ toc = TableOfContents.objects.filter(
+ course_id=course_id, lesson_id=lesson_id, content__in=[2, 3, 4]
+ )
+ answers = LessonQuizAnswer.objects.select_related("toc").filter(
+ toc__course_id=course_id, toc__lesson_id=lesson_id
+ )
+ return answers
+
+
class TableOfContents(models.Model):
toc_types = ((1, "Topic"), (2, "Graded Quiz"), (3, "Exercise"), (4, "Poll"))
course = models.ForeignKey(Course, on_delete=models.CASCADE,
@@ -2757,6 +2769,8 @@ class TableOfContents(models.Model):
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey()
+ objects = TOCManager()
+
class Meta:
verbose_name_plural = "Table Of Contents"
@@ -2773,13 +2787,14 @@ class TableOfContents(models.Model):
class Topic(models.Model):
name = models.CharField(max_length=255)
+ description = models.TextField(null=True, blank=True)
content = GenericRelation(TableOfContents)
def __str__(self):
return f"{self.name}"
-class VideoQuizAnswer(models.Model):
+class LessonQuizAnswer(models.Model):
toc = models.ForeignKey(TableOfContents, on_delete=models.CASCADE)
student = models.ForeignKey(User, on_delete=models.CASCADE)
answer = models.ForeignKey(Answer, on_delete=models.CASCADE)
@@ -2849,6 +2864,7 @@ class VideoQuizAnswer(models.Model):
if ans_status:
self.answer.marks = self.answer.question.points
self.answer.save()
+ return result
def __str__(self):
return f"Lesson answer of {self.toc} by {self.student.get_full_name()}"