diff options
author | adityacp | 2020-08-26 20:29:03 +0530 |
---|---|---|
committer | adityacp | 2020-08-26 20:29:03 +0530 |
commit | d54b62c2803f0f0edb45348f47d6a541ca09e022 (patch) | |
tree | 67c5f3ee03d1a3702db00a5dab3d699be9692e9e /yaksh/models.py | |
parent | 3999e744fe1a3a4c4fcb7d2763b36def9d7bb213 (diff) | |
download | online_test-d54b62c2803f0f0edb45348f47d6a541ca09e022.tar.gz online_test-d54b62c2803f0f0edb45348f47d6a541ca09e022.tar.bz2 online_test-d54b62c2803f0f0edb45348f47d6a541ca09e022.zip |
First cut for in video quizzes
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 6542daa..05bb459 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1,3 +1,4 @@ +# Python Imports from __future__ import unicode_literals, division from datetime import datetime, timedelta import uuid @@ -8,14 +9,6 @@ from ruamel.yaml.scalarstring import PreservedScalarString from ruamel.yaml.comments import CommentedMap from random import sample from collections import Counter, defaultdict - -from django.db import models -from django.contrib.auth.models import User, Group, Permission -from django.core.exceptions import ValidationError -from django.contrib.contenttypes.models import ContentType -from taggit.managers import TaggableManager -from django.utils import timezone -from django.core.files import File import glob try: @@ -31,14 +24,29 @@ import zipfile import tempfile from textwrap import dedent from ast import literal_eval -from .file_utils import extract_files, delete_files + +# Django Imports +from django.db import models +from django.contrib.auth.models import User, Group, Permission +from django.core.exceptions import ValidationError +from django.contrib.contenttypes.models import ContentType +from taggit.managers import TaggableManager +from django.utils import timezone +from django.core.files import File +from django.contrib.contenttypes.fields import ( + GenericForeignKey, GenericRelation +) +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 + +# Local Imports from yaksh.code_server import ( submit, get_result as get_result_from_code_server ) from yaksh.settings import SERVER_POOL_PORT, SERVER_HOST_NAME -from django.conf import settings -from django.forms.models import model_to_dict +from .file_utils import extract_files, delete_files from grades.models import GradingSystem languages = ( @@ -286,6 +294,11 @@ class Lesson(models.Model): help_text="Please upload video files in mp4, ogv, webm format" ) + video_path = models.CharField( + max_length=255, default=None, null=True, blank=True, + help_text="Youtube id, vimeo id, others" + ) + def __str__(self): return "{0}".format(self.name) @@ -498,6 +511,8 @@ class Quiz(models.Model): objects = QuizManager() + content = GenericRelation("TableOfContents") + class Meta: verbose_name_plural = "Quizzes" @@ -2712,3 +2727,25 @@ class Comment(ForumBase): def __str__(self): return 'Comment by {0}: {1}'.format(self.creator.username, self.post_field.title) + + +class TableOfContents(models.Model): + course = models.ForeignKey(Course, on_delete=models.CASCADE, + related_name='course') + Lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE, + related_name='contents') + time = models.CharField(max_length=100, default=0) + content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) + object_id = models.PositiveIntegerField() + content_object = GenericForeignKey() + + def __str__(self): + return f"Contents in {self.lesson.name}" + + +class Topic(models.Model): + name = models.CharField(max_length=255) + content = GenericRelation(TableOfContents) + + def __str__(self): + return f"{self.name}" |