Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion FusionIIIT/Fusion/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,12 @@
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, '..', 'static/')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
MEDIA_ROOT = os.path.join(BASE_DIR, '..', 'media/')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_EMAIL_REQUIRED = True
Expand Down
4 changes: 2 additions & 2 deletions FusionIIIT/applications/online_cms/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from .models import (Assignment, CourseDocuments, CourseVideo, Forum,
ForumReply, Quiz, QuizQuestion, QuizResult, StudentAnswer,
StudentAssignment, Topics)
StudentAssignment, Topics,CourseSlide)

class QuizResultAdmin(admin.ModelAdmin):
model = QuizResult
raw_id_fields = ("student_id",)

admin.site.register(CourseDocuments)

admin.site.register(CourseSlide)
admin.site.register(CourseVideo)

admin.site.register(Quiz)
Expand Down
14 changes: 13 additions & 1 deletion FusionIIIT/applications/online_cms/forms.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# from django import forms
import datetime
from datetime import time, timedelta
#import information from the models
from django import forms
# from .models import StoreMarks
from applications.academic_information.models import Student_attendance
from django.forms import ModelForm

from .models import *
#the types of exam whose marks can be stored from edit marks in assessment, related to StoreMarks table in models
EXAM_TYPES= [
('quiz1', 'Quiz 1'),
Expand Down Expand Up @@ -112,4 +115,13 @@ def clean(self):

examtype = self.cleaned_data.get("exam_type")
enteredmarks = self.cleaned_data.get("entered_marks")
return self.cleaned_data
return self.cleaned_data


class UploadSlideForm(forms.Form):
class Meta:
model=CourseDocuments
fields=['couse_id','doc']

# title = forms.CharField(max_length=50)
file = forms.FileField()
25 changes: 19 additions & 6 deletions FusionIIIT/applications/online_cms/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@


def semester(roll):
month = datetime.now().month
sem = 0
if month >= 8 and month <= 12:
sem = 1
semester = (datetime.now().year-int(roll))*2+sem
return semester
if not roll.isnumeric():
s=''
s+='2'
s+='0'
s+=roll[0]
s+=roll[1]
month = datetime.now().month
sem = 0
if month >= 8 and month <= 12:
sem = 1
semester = (datetime.now().year-int(s))*2+sem
return semester
else:
month = datetime.now().month
sem = 0
if month >= 8 and month <= 12:
sem = 1
semester = (datetime.now().year-int(roll))*2+sem
return semester

#storing media files like images, videos and assignments
def create_thumbnail(course_code,course, row, name, ext, attach_str, thumb_time, thumb_size):
Expand Down
39 changes: 38 additions & 1 deletion FusionIIIT/applications/online_cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,33 @@
from applications.academic_procedures.models import Register
from applications.globals.models import ExtraInfo




def content_file_name(instance, filename):
name, ext = filename.split('.')
obj=Curriculum.objects.get(course_id=instance.course_id)
course_code=obj.course_code
file_path = 'online_cms/{course_id}/doc/{fileName}.{ext}'.format(
course_id=course_code, fileName=instance.document_name, ext=ext)
return file_path
#the documents in the course (slides , ppt) added by the faculty and can be downloaded by the students
class CourseSlide(models.Model):
course_id = models.ForeignKey(Course, on_delete=models.CASCADE)
upload_time = models.DateTimeField(auto_now=True)
document_name = models.CharField(max_length=40)
description = models.CharField(max_length=100)
doc=models.FileField(upload_to=content_file_name, null=True, blank=True)
def __str__(self):
return '{} - {}'.format(self.course_id, self.document_name)

class CourseDocuments(models.Model):
course_id = models.ForeignKey(Course, on_delete=models.CASCADE)
upload_time = models.DateTimeField(auto_now=True)
description = models.CharField(max_length=100)
document_name = models.CharField(max_length=40)
document_url = models.CharField(max_length=100, null=True)
document_url = models.CharField(max_length=500, null=True,blank=True)
# media = models.FileField(upload_to=content_file_name, null=True, blank=True)

def __str__(self):
return '{} - {}'.format(self.course_id, self.document_name)
Expand Down Expand Up @@ -149,6 +169,23 @@ class Assignment(models.Model):
def __str__(self):
return '{} - {} - {}'.format(self.pk, self.course_id, self.assignment_name)

def assignment_file_name(instance, filename):
name, ext = filename.split('.')
obj=Curriculum.objects.get(course_id=instance.course_id)
course_code=obj.course_code
file_path = 'online_cms/{course_id}/doc/{fileName}.{ext}'.format(
course_id=course_code, fileName=instance.assignment_name, ext=ext)
return file_path
class CourseAssignment(models.Model):
course_id = models.ForeignKey(Course, on_delete=models.CASCADE)
upload_time = models.DateTimeField(auto_now=True)
submit_date = models.DateTimeField()
assignment_name = models.CharField(max_length=100)
doc = models.FileField(upload_to=assignment_file_name, null=True, blank=True)

def __str__(self):
return '{} - {} - {}'.format(self.pk, self.course_id, self.assignment_name)

#details of the solution uploaded by the student
class StudentAssignment(models.Model):
student_id = models.ForeignKey(Student, on_delete=models.CASCADE)
Expand Down
11 changes: 7 additions & 4 deletions FusionIIIT/applications/online_cms/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import url

from . import views
app_name = 'online_cms'
app_name = 'online_cms'

urlpatterns = [

url(r'^$', views.viewcourses, name='viewcourses'),
url(r'^(?P<course_code>[A-z]+[0-9]+[A-z]?)/$', views.course, name='course'),
# url(r'^(?P<course_code>[A-z]+[0-9]+[A-z]?)/edit_marks$', views.edit_marks, name='edit_marks'),
Expand Down Expand Up @@ -69,4 +70,6 @@
url(r'^(?P<course_code>[A-z]+[0-9]+[A-z]?)/edit_bank/(?P<qb_code>[0-9]+)$',
views.edit_bank, name='edit_bank'),
url(r'^(?P<course_code>[A-z]+[0-9]+[A-z]?)/attendance$', views.submit_attendance,
name='submit_attendance'),]
name='submit_attendance'),]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Loading