summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authoradityacp2020-09-03 18:18:18 +0530
committeradityacp2020-09-03 18:18:18 +0530
commit23c6caab733f5bba6458a07a6666a0580ee2e6a9 (patch)
tree36a9f3d185e6106f30d50c1ff07b0744afd87943 /yaksh/models.py
parent4183028cc7005cd46c8ccff2793030d736e232d7 (diff)
downloadonline_test-23c6caab733f5bba6458a07a6666a0580ee2e6a9.tar.gz
online_test-23c6caab733f5bba6458a07a6666a0580ee2e6a9.tar.bz2
online_test-23c6caab733f5bba6458a07a6666a0580ee2e6a9.zip
Change views, forms, models, urls
- Disable the question type in video question form - Change urls to add graded quiz, exercise, poll type question - Save the topic and question in table of contents - Rename lesson attribute in TableOfContents model
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 05bb459..f8b17d5 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -511,8 +511,6 @@ class Quiz(models.Model):
objects = QuizManager()
- content = GenericRelation("TableOfContents")
-
class Meta:
verbose_name_plural = "Quizzes"
@@ -1344,6 +1342,8 @@ class Question(models.Model):
# Solution for the question.
solution = models.TextField(blank=True)
+ content = GenericRelation("TableOfContents")
+
tc_code_types = {
"python": [
("standardtestcase", "Standard TestCase"),
@@ -2730,17 +2730,29 @@ class Comment(ForumBase):
class TableOfContents(models.Model):
+ toc_types = ((1, "Topic"), (2, "Graded Quiz"), (3, "Exercise"), (4, "Poll"))
course = models.ForeignKey(Course, on_delete=models.CASCADE,
related_name='course')
- Lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE,
+ lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE,
related_name='contents')
time = models.CharField(max_length=100, default=0)
+ content = models.IntegerField(choices=toc_types)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey()
+ class Meta:
+ verbose_name_plural = "Table Of Contents"
+
+ def get_toc_text(self):
+ if self.content == 1:
+ content_name = Topic.objects.get(id=self.object_id).name
+ else:
+ content_name = Question.objects.get(id=self.object_id).summary
+ return content_name
+
def __str__(self):
- return f"Contents in {self.lesson.name}"
+ return f"TOC for {self.lesson.name} with {self.get_content_display()}"
class Topic(models.Model):