From 89cf10c2e9f97d561c96b2f15f1f76ab3cb9a19a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Ctech-akash=E2=80=9D?= <“20bcs020@iiitdmj.ac.in”> Date: Mon, 30 Jan 2023 01:37:38 +0530 Subject: [PATCH 1/8] Fixed bug related to fetching semester and issues in template --- FusionIIIT/applications/online_cms/helpers.py | 25 ++++++++++++++----- FusionIIIT/applications/online_cms/views.py | 16 +++++++++--- .../coursemanagement/coursemanagement1.html | 20 +++++++-------- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/FusionIIIT/applications/online_cms/helpers.py b/FusionIIIT/applications/online_cms/helpers.py index 8fb9f530e..05babe3bc 100644 --- a/FusionIIIT/applications/online_cms/helpers.py +++ b/FusionIIIT/applications/online_cms/helpers.py @@ -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): diff --git a/FusionIIIT/applications/online_cms/views.py b/FusionIIIT/applications/online_cms/views.py index cc74626f3..6e91bad23 100644 --- a/FusionIIIT/applications/online_cms/views.py +++ b/FusionIIIT/applications/online_cms/views.py @@ -39,13 +39,21 @@ def viewcourses(request): student = Student.objects.select_related('id').get(id=extrainfo) roll = student.id.id[:4] #get the roll no. of the student register = Register.objects.select_related().filter(student_id=student, semester=semester(roll)) #info of registered student - courses = collections.OrderedDict() #courses in which student is registerd + courses = [] #courses in which student is registerd + print(register) + # serializer=OCMSStudentSerializer(register,many=True) + for reg in register: #info of the courses - instructor = Curriculum_Instructor.objects.select_related().get(course_id=reg.course_id) - courses[reg] = instructor + course={} + course['data']=reg.curr_id + # course=reg.curr_id + course['instructor'] = Curriculum_Instructor.objects.select_related().get(curriculum_id=reg.curr_id) + courses.append(course) + # print(serializer.data) + # return Response(serializer.data) + # return Response({'status':200}) return render(request, 'coursemanagement/coursemanagement1.html', {'courses': courses, - 'extrainfo': extrainfo}) else: #if the user is lecturer instructor = Curriculum_Instructor.objects.select_related('curriculum_id').filter(instructor_id=extrainfo) #get info of the instructor diff --git a/FusionIIIT/templates/coursemanagement/coursemanagement1.html b/FusionIIIT/templates/coursemanagement/coursemanagement1.html index 678d79b71..f4dcb29e4 100644 --- a/FusionIIIT/templates/coursemanagement/coursemanagement1.html +++ b/FusionIIIT/templates/coursemanagement/coursemanagement1.html @@ -85,16 +85,17 @@

Course Code Name Of the Course - {% ifequal extrainfo.designation|stringformat:"s" "student" %} + {% ifequal extrainfo.user_type|stringformat:"s" "student" %} Instructor {% endifequal %} - {% ifequal extrainfo.designation|stringformat:"s" "student" %} {% for course,instructor in courses.items %} + {% ifequal extrainfo.user_type|stringformat:"s" "student" %} {% for x in courses %} - {{course.course_id.course_name}} - {{course.course_id.course_id}} - {{instructor.instructor_id.user.username}} + {% comment %} {{x.data}} {% endcomment %} + {{x.data.course_code}} + {{x.data.course_id}} + {{x.instructor.instructor_id.user.username}} {% endfor %} {% else %} {% for curriculum in curriculum_list %} @@ -113,14 +114,13 @@

{% comment %}The Basic Course details segment ends here!{% endcomment %} {% comment %}The Assignment segment starts here!{% endcomment %} - -
- + {% comment %}

hfexlelel

{% endcomment %} +

-
+
- +
From cf8401c513bd70a5868b187608fc1b8bf53318a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Ctech-akash=E2=80=9D?= <“20bcs020@iiitdmj.ac.in”> Date: Sat, 4 Feb 2023 12:34:15 +0530 Subject: [PATCH 2/8] Added Online CMS module to dashboard and minor fixes at teacher side in ocms --- FusionIIIT/applications/online_cms/views.py | 245 ++++++++++---------- FusionIIIT/templates/dashboard/modules.html | 14 ++ requirements.txt | 146 ++++++------ 3 files changed, 210 insertions(+), 195 deletions(-) diff --git a/FusionIIIT/applications/online_cms/views.py b/FusionIIIT/applications/online_cms/views.py index 6e91bad23..b27e37757 100644 --- a/FusionIIIT/applications/online_cms/views.py +++ b/FusionIIIT/applications/online_cms/views.py @@ -89,86 +89,86 @@ def course(request, course_code): #course material uploaded by the instructor # videos = CourseVideo.objects.filter(course_id=course) videos = [] - if request.method == 'POST': - search_url = "https://www.googleapis.com/youtube/v3/search" - video_url = "https://www.googleapis.com/youtube/v3/videos" - search_params = { - 'part': 'snippet', - 'q': request.POST['search'], - 'key': settings.YOUTUBE_DATA_API_KEY, - 'type': 'video', - 'channelId': 'channel_id' - } - videos_ids = [] - r = requests.get(search_url, params=search_params) - # print(r) - results = r.json()['items'] - for result in results: - videos_ids.append(result['id']['videoId']) - - video_params = { - 'key': settings.YOUTUBE_DATA_API_KEY, - 'part': 'snippet,contentDetails', - 'id': ','.join(videos_ids), - 'maxResults': 9 - } - - p = requests.get(video_url, params=video_params) - results1 = p.json()['items'] - - for result in results1: - video_data = { - 'id': result['id'], - # 'url': f'https://www.youtube.com/watch?v={result["id"]}', - 'title': result['snippet']['title'], - # 'duration': int(parse_duration(result['contentDetails']['duration']).total_seconds() // 60), - # 'thumbnails': result['snippet']['thumbnails']['high']['url'] - } - - videos.append(video_data) - else: - channel_url = "https://www.googleapis.com/youtube/v3/channels" - playlist_url = "https://www.googleapis.com/youtube/v3/playlistItems" - videos_url = "https://www.googleapis.com/youtube/v3/videos" - - videos_list = [] - channel_params = { - 'part': 'contentDetails', - 'id': 'channel_id', - 'key': settings.YOUTUBE_DATA_API_KEY, - } - r = requests.get(channel_url, params=channel_params) - results = r.json()['items'][0]['contentDetails']['relatedPlaylists']['uploads'] - - playlist_params = { - 'key': settings.YOUTUBE_DATA_API_KEY, - 'part': 'snippet', - 'playlistId': results, - 'maxResults': 5, - } - p = requests.get(playlist_url, params=playlist_params) - results1 = p.json()['items'] - - for result in results1: - # print(results) - videos_list.append(result['snippet']['resourceId']['videoId']) - - videos_params = { - 'key': settings.YOUTUBE_DATA_API_KEY, - 'part': 'snippet', - 'id': ','.join(videos_list) - } - - v = requests.get(videos_url, params=videos_params) - results2 = v.json()['items'] - videos = [] - for res in results2: - video_data = { - 'id': res['id'], - 'title': res['snippet']['title'], - } - - videos.append(video_data) + # if request.method == 'POST': + # search_url = "https://www.googleapis.com/youtube/v3/search" + # video_url = "https://www.googleapis.com/youtube/v3/videos" + # search_params = { + # 'part': 'snippet', + # 'q': request.POST['search'], + # 'key': settings.YOUTUBE_DATA_API_KEY, + # 'type': 'video', + # 'channelId': 'channel_id' + # } + # videos_ids = [] + # r = requests.get(search_url, params=search_params) + # # print(r) + # results = r.json()['items'] + # for result in results: + # videos_ids.append(result['id']['videoId']) + + # video_params = { + # 'key': settings.YOUTUBE_DATA_API_KEY, + # 'part': 'snippet,contentDetails', + # 'id': ','.join(videos_ids), + # 'maxResults': 9 + # } + + # p = requests.get(video_url, params=video_params) + # results1 = p.json()['items'] + + # for result in results1: + # video_data = { + # 'id': result['id'], + # # 'url': f'https://www.youtube.com/watch?v={result["id"]}', + # 'title': result['snippet']['title'], + # # 'duration': int(parse_duration(result['contentDetails']['duration']).total_seconds() // 60), + # # 'thumbnails': result['snippet']['thumbnails']['high']['url'] + # } + + # videos.append(video_data) + # else: + # channel_url = "https://www.googleapis.com/youtube/v3/channels" + # playlist_url = "https://www.googleapis.com/youtube/v3/playlistItems" + # videos_url = "https://www.googleapis.com/youtube/v3/videos" + + # videos_list = [] + # channel_params = { + # 'part': 'contentDetails', + # 'id': 'channel_id', + # 'key': settings.YOUTUBE_DATA_API_KEY, + # } + # r = requests.get(channel_url, params=channel_params) + # results = r.json()['items'][0]['contentDetails']['relatedPlaylists']['uploads'] + + # playlist_params = { + # 'key': settings.YOUTUBE_DATA_API_KEY, + # 'part': 'snippet', + # 'playlistId': results, + # 'maxResults': 5, + # } + # p = requests.get(playlist_url, params=playlist_params) + # results1 = p.json()['items'] + + # for result in results1: + # # print(results) + # videos_list.append(result['snippet']['resourceId']['videoId']) + + # videos_params = { + # 'key': settings.YOUTUBE_DATA_API_KEY, + # 'part': 'snippet', + # 'id': ','.join(videos_list) + # } + + # v = requests.get(videos_url, params=videos_params) + # results2 = v.json()['items'] + # videos = [] + # for res in results2: + # video_data = { + # 'id': res['id'], + # 'title': res['snippet']['title'], + # } + + # videos.append(video_data) # print(videos) slides = CourseDocuments.objects.select_related().filter(course_id=course) quiz = Quiz.objects.select_related().filter(course_id=course) @@ -255,48 +255,49 @@ def course(request, course_code): lec = 1 # videos = CourseVideo.objects.filter(course_id=course) - channel_url = "https://www.googleapis.com/youtube/v3/channels" - playlist_url = "https://www.googleapis.com/youtube/v3/playlistItems" - videos_url = "https://www.googleapis.com/youtube/v3/videos" - - videos_list = [] - channel_params = { - 'part': 'contentDetails', - # 'forUsername': 'TechGuyWeb', - 'id': 'UCdGQeihs84hyCssI2KuAPmA', - 'key': settings.YOUTUBE_DATA_API_KEY, - } - r = requests.get(channel_url, params=channel_params) - results = r.json()['items'][0]['contentDetails']['relatedPlaylists']['uploads'] - - playlist_params = { - 'key': settings.YOUTUBE_DATA_API_KEY, - 'part': 'snippet', - 'playlistId': results, - 'maxResults': 5, - } - p = requests.get(playlist_url, params=playlist_params) - results1 = p.json()['items'] - - for result in results1: - videos_list.append(result['snippet']['resourceId']['videoId']) - - videos_params = { - 'key': settings.YOUTUBE_DATA_API_KEY, - 'part': 'snippet', - 'id': ','.join(videos_list) - } - - v = requests.get(videos_url, params=videos_params) - results2 = v.json()['items'] - videos = [] - for res in results2: - video_data = { - 'id': res['id'], - 'title': res['snippet']['title'], - } - - videos.append(video_data) + # channel_url = "https://www.googleapis.com/youtube/v3/channels" + # playlist_url = "https://www.googleapis.com/youtube/v3/playlistItems" + # videos_url = "https://www.googleapis.com/youtube/v3/videos" + + # videos_list = [] + # channel_params = { + # 'part': 'contentDetails', + # # 'forUsername': 'TechGuyWeb', + # 'id': 'UCdGQeihs84hyCssI2KuAPmA', + # 'key': settings.YOUTUBE_DATA_API_KEY, + # } + # r = requests.get(channel_url, params=channel_params) + # results = r.json()['items'][0]['contentDetails']['relatedPlaylists']['uploads'] + + # playlist_params = { + # 'key': settings.YOUTUBE_DATA_API_KEY, + # 'part': 'snippet', + # 'playlistId': results, + # 'maxResults': 5, + # } + # p = requests.get(playlist_url, params=playlist_params) + # results1 = p.json()['items'] + + # for result in results1: + # videos_list.append(result['snippet']['resourceId']['videoId']) + + # videos_params = { + # 'key': settings.YOUTUBE_DATA_API_KEY, + # 'part': 'snippet', + # 'id': ','.join(videos_list) + # } + + # v = requests.get(videos_url, params=videos_params) + # results2 = v.json()['items'] + # videos = [] + # for res in results2: + # video_data = { + # 'id': res['id'], + # 'title': res['snippet']['title'], + # } + + # videos.append(video_data) + videos=[] slides = CourseDocuments.objects.select_related().filter(course_id=course) quiz = Quiz.objects.select_related().filter(course_id=course) marks = [] diff --git a/FusionIIIT/templates/dashboard/modules.html b/FusionIIIT/templates/dashboard/modules.html index 06011717b..777adac05 100755 --- a/FusionIIIT/templates/dashboard/modules.html +++ b/FusionIIIT/templates/dashboard/modules.html @@ -219,7 +219,21 @@
+
+
{% comment %} diff --git a/requirements.txt b/requirements.txt index da704c688..43e1891c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,74 +1,74 @@ -amqp==5.0.2 -arabic-reshaper==2.1.1 -asgiref==3.3.1 -attrs==20.3.0 -beautifulsoup4==4.9.3 -billiard==3.6.3.0 -Brotli==1.0.9 -bs4==0.0.1 -celery==5.2.3 -certifi==2020.12.5 -cffi==1.14.4 -chardet==4.0.0 -click==7.1.2 -click-didyoumean==0.0.3 -click-plugins==1.1.1 -click-repl==0.1.6 -cryptography==36.0.2 -defusedxml==0.6.0 -Django==3.1.5 -django-allauth==0.44.0 -django-cleanup==5.1.0 -django-cors-headers==3.7.0 -django-debug-toolbar==3.2.4 -django-extensions==3.1.1 -django-filter==2.4.0 -django-markdown-deux==1.0.5 -django-model-utils==4.1.1 -django-notifications-hq==1.6.0 -django-pagedown==2.2.0 -djangorestframework==3.12.2 -django-semanticui-forms==1.6.5 -django-unused-media==0.2.2 -future==0.18.2 +amqp +arabic-reshaper +asgiref +attrs +beautifulsoup4 +billiard +Brotli +bs4 +celery +certifi +cffi +chardet +click +click-didyoumean +click-plugins +click-repl +cryptography +defusedxml +Django==3.2.4 +django-allauth +django-cleanup +django-cors-headers +django-debug-toolbar +django-extensions +django-filter +django-markdown-deux +django-model-utils +django-notifications-hq +django-pagedown +djangorestframework +django-semanticui-forms +django-unused-media +future # gunicorn -html-text==0.5.2 -html5lib==1.1 -idna==2.10 -ipython==8.2.0 -ipython-genutils==0.2.0 -jsonfield==3.1.0 -jsonschema==3.2.0 -kombu==5.0.2 -lxml==4.8.0 -markdown2==2.4.2 -numpy==1.22.3 -oauthlib==3.1.0 -openpyxl==3.0.7 -Pillow==8.1.0 -prompt-toolkit==3.0.10 -psycopg2-binary==2.8.6 -pycparser==2.20 -PyJWT==2.0.1 -PyPDF2==1.26.0 -pyrsistent==0.17.3 -python-bidi==0.4.2 -python-dateutil==2.8.1 -python3-openid==3.2.0 -pytz==2020.5 -reportlab==3.5.59 -requests==2.25.1 -requests-oauthlib==1.3.0 -six==1.15.0 -soupsieve==2.1 -sqlparse==0.4.2 -swapper==1.1.2.post1 -urllib3==1.26.8 -vine==5.0.0 -wcwidth==0.2.5 -webencodings==0.5.1 -whitenoise==5.2.0 -xhtml2pdf==0.2.5 -xlrd==2.0.1 -XlsxWriter==1.3.7 -xlwt==1.3.0 +html-text +html5lib +idna +ipython +ipython-genutils +jsonfield +jsonschema +kombu +lxml +markdown2 +numpy +oauthlib +openpyxl +Pillow +prompt-toolkit +psycopg2-binary +pycparser +PyJWT +PyPDF2 +pyrsistent +python-bidi +python-dateutil +python3-openid +pytz +reportlab +requests +requests-oauthlib +six +soupsieve +sqlparse +swapper +urllib3 +vine +wcwidth +webencodings +whitenoise +xhtml2pdf +xlrd +XlsxWriter +xlwt From 44a3121a238b6897add5ec06a7fa5103bb1ed6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Ctech-akash=E2=80=9D?= <“20bcs020@iiitdmj.ac.in”> Date: Fri, 10 Feb 2023 02:14:21 +0530 Subject: [PATCH 3/8] Fixed File Upload and viewing in both assignment and Slides for Insturctor --- FusionIIIT/Fusion/settings/common.py | 6 ++- FusionIIIT/applications/online_cms/admin.py | 4 +- FusionIIIT/applications/online_cms/forms.py | 14 +++++- FusionIIIT/applications/online_cms/models.py | 39 ++++++++++++++- FusionIIIT/applications/online_cms/urls.py | 11 +++-- FusionIIIT/applications/online_cms/views.py | 48 ++++++++++++++++--- .../coursemanagement/addcontent.html | 6 +-- .../coursemanagement/submitassignments.html | 4 +- .../coursemanagement/viewcourse.html | 3 ++ 9 files changed, 114 insertions(+), 21 deletions(-) diff --git a/FusionIIIT/Fusion/settings/common.py b/FusionIIIT/Fusion/settings/common.py index 9fbf57256..99c6e6361 100644 --- a/FusionIIIT/Fusion/settings/common.py +++ b/FusionIIIT/Fusion/settings/common.py @@ -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 diff --git a/FusionIIIT/applications/online_cms/admin.py b/FusionIIIT/applications/online_cms/admin.py index ac9eb780a..24679190f 100644 --- a/FusionIIIT/applications/online_cms/admin.py +++ b/FusionIIIT/applications/online_cms/admin.py @@ -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) diff --git a/FusionIIIT/applications/online_cms/forms.py b/FusionIIIT/applications/online_cms/forms.py index e656a838f..802de9dbe 100644 --- a/FusionIIIT/applications/online_cms/forms.py +++ b/FusionIIIT/applications/online_cms/forms.py @@ -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'), @@ -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 \ No newline at end of file + 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() \ No newline at end of file diff --git a/FusionIIIT/applications/online_cms/models.py b/FusionIIIT/applications/online_cms/models.py index a34e5c3ee..fe8dce565 100644 --- a/FusionIIIT/applications/online_cms/models.py +++ b/FusionIIIT/applications/online_cms/models.py @@ -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) @@ -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) diff --git a/FusionIIIT/applications/online_cms/urls.py b/FusionIIIT/applications/online_cms/urls.py index c24c69cc2..a15cc3029 100644 --- a/FusionIIIT/applications/online_cms/urls.py +++ b/FusionIIIT/applications/online_cms/urls.py @@ -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[A-z]+[0-9]+[A-z]?)/$', views.course, name='course'), # url(r'^(?P[A-z]+[0-9]+[A-z]?)/edit_marks$', views.edit_marks, name='edit_marks'), @@ -69,4 +70,6 @@ url(r'^(?P[A-z]+[0-9]+[A-z]?)/edit_bank/(?P[0-9]+)$', views.edit_bank, name='edit_bank'), url(r'^(?P[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) diff --git a/FusionIIIT/applications/online_cms/views.py b/FusionIIIT/applications/online_cms/views.py index b27e37757..7f60b9363 100644 --- a/FusionIIIT/applications/online_cms/views.py +++ b/FusionIIIT/applications/online_cms/views.py @@ -70,6 +70,7 @@ def viewcourses(request): + @login_required def course(request, course_code): ''' @@ -89,6 +90,8 @@ def course(request, course_code): #course material uploaded by the instructor # videos = CourseVideo.objects.filter(course_id=course) videos = [] + # if request.method == 'POST': + # if(request) # if request.method == 'POST': # search_url = "https://www.googleapis.com/youtube/v3/search" # video_url = "https://www.googleapis.com/youtube/v3/videos" @@ -170,6 +173,7 @@ def course(request, course_code): # videos.append(video_data) # print(videos) + slides = CourseDocuments.objects.select_related().filter(course_id=course) quiz = Quiz.objects.select_related().filter(course_id=course) assignment = Assignment.objects.select_related().filter(course_id=course) @@ -218,6 +222,7 @@ def course(request, course_code): 'curriculum': curriculum}) else: + instructor = Curriculum_Instructor.objects.select_related('curriculum_id').filter(instructor_id=extrainfo) for ins in instructor: if ins.curriculum_id.course_code == course_code: @@ -297,12 +302,20 @@ def course(request, course_code): # } # videos.append(video_data) + # if request.method == 'POST': + # form = UploadSlideForm(request.POST, request.FILES) + # if form.is_valid(): + # tempform=form.save(commit=False) + # tempform.course_id=course + # tempform.save() videos=[] + slides1=CourseSlide.objects.select_related().filter(course_id=course) slides = CourseDocuments.objects.select_related().filter(course_id=course) quiz = Quiz.objects.select_related().filter(course_id=course) marks = [] quizs = [] assignment = Assignment.objects.select_related().filter(course_id=course) + assignment1 = CourseAssignment.objects.select_related().filter(course_id=course) student_assignment = [] for assi in assignment: sa = StudentAssignment.objects.select_related().filter(assignment_id=assi) @@ -335,13 +348,15 @@ def course(request, course_code): 'course': course, 'answers': answers, 'assignment': assignment, + 'assignment1': assignment1, 'student_assignment': student_assignment, 'Lecturer': lec, 'questionbank': qb, 'students': students, 'total_attendance' : total_attendance, 'present_attendance':present_attendance, - 'test_marks': test_marks + 'test_marks': test_marks, + 'slides1':slides1 }) #when student uploads the assignment's solution @@ -396,6 +411,8 @@ def add_document(request, course_code): description = request.POST.get('description') doc = request.FILES.get('img') name = request.POST.get('name') + # obj =CourseDocuments.objects.create(course_id=course,description=description,) + # = request.FILES['img'] filename, file_extenstion = os.path.splitext(request.FILES.get('img').name) except: return HttpResponse("Please fill each and every field correctly!") @@ -410,15 +427,24 @@ def add_document(request, course_code): fs.save(filename + file_extenstion, doc) uploaded_file_url = full_path + filename + file_extenstion #save the info/details in the database - CourseDocuments.objects.create( + print(settings.MEDIA_ROOT) + CourseSlide.objects.create( course_id=course, upload_time=datetime.datetime.now(), description=description, - document_url=uploaded_file_url, - document_name=name+file_extenstion + document_name=name, + doc=doc ) + # CourseDocuments.objects.create( + # course_id=course, + # upload_time=datetime.datetime.now(), + # description=description, + # document_url=uploaded_file_url, + # document_name=name+file_extenstion + # ) return HttpResponse("Upload successful.") else: + return HttpResponse("not found") #it is to delete things(assignment, slides, videos, ) from the dustin icon or delete buttons @@ -645,6 +671,7 @@ def add_assignment(request, course_code): #from faculty side return HttpResponse("Please Enter The Form Properly") filename = name full_path = settings.MEDIA_ROOT + "/online_cms/" + course_code + "/assi/" + name + "/" + print(full_path) url = settings.MEDIA_URL + filename if not os.path.isdir(full_path): cmd = "mkdir " + full_path @@ -652,13 +679,20 @@ def add_assignment(request, course_code): #from faculty side fs = FileSystemStorage(full_path, url) fs.save(filename+file_extenstion, assi) uploaded_file_url = full_path + filename + file_extenstion - assign = Assignment( + print(uploaded_file_url) + CourseAssignment.objects.create( course_id=course, submit_date=request.POST.get('myDate'), - assignment_url=uploaded_file_url, + doc=assi, assignment_name=name ) - assign.save() + # assign = Assignment( + # course_id=course, + # submit_date=request.POST.get('myDate'), + # assignment_url=uploaded_file_url, + # assignment_name=name + # ) + # assign.save() return HttpResponse("Upload successful.") else: return HttpResponse("not found") diff --git a/FusionIIIT/templates/coursemanagement/addcontent.html b/FusionIIIT/templates/coursemanagement/addcontent.html index 22e9986c7..17b3363dc 100644 --- a/FusionIIIT/templates/coursemanagement/addcontent.html +++ b/FusionIIIT/templates/coursemanagement/addcontent.html @@ -69,13 +69,13 @@

Report:

- {% for slide in slides %} + {% for slide in slides1 %} {{forloop.counter}} {{slide.document_name}} + {% comment %}

{{slide.document_url}}

{% endcomment %} diff --git a/FusionIIIT/templates/coursemanagement/submitassignments.html b/FusionIIIT/templates/coursemanagement/submitassignments.html index 217a12bde..945a74ffc 100644 --- a/FusionIIIT/templates/coursemanagement/submitassignments.html +++ b/FusionIIIT/templates/coursemanagement/submitassignments.html @@ -188,12 +188,12 @@

Report:

- {% for assi in assignment %} + {% for assi in assignment1 %} {{forloop.counter}} {{assi.assignment_name}} {{assi.submit_date}} -
+
diff --git a/FusionIIIT/templates/coursemanagement/viewcourse.html b/FusionIIIT/templates/coursemanagement/viewcourse.html index 88e91fb2a..44f1d9fb8 100644 --- a/FusionIIIT/templates/coursemanagement/viewcourse.html +++ b/FusionIIIT/templates/coursemanagement/viewcourse.html @@ -333,11 +333,13 @@

Submitable Assignments

{% if Lecturer == 1 %} + {% comment %}

{{course.course_name}}

{% endcomment %}
{% block addcontent %} {% include 'coursemanagement/addcontent.html' %} {% endblock %}
{% else %} +

{{course.course_name}}

@@ -349,6 +351,7 @@

{{course.course_name}}

From 8c8d5c3bc729c97f4de5a915f2df7dc1cd06363c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Ctech-akash=E2=80=9D?= <“20bcs020@iiitdmj.ac.in”> Date: Fri, 10 Feb 2023 02:21:47 +0530 Subject: [PATCH 4/8] Revert in changes in requirements.txt --- requirements.txt | 146 +++++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/requirements.txt b/requirements.txt index 43e1891c9..da704c688 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,74 +1,74 @@ -amqp -arabic-reshaper -asgiref -attrs -beautifulsoup4 -billiard -Brotli -bs4 -celery -certifi -cffi -chardet -click -click-didyoumean -click-plugins -click-repl -cryptography -defusedxml -Django==3.2.4 -django-allauth -django-cleanup -django-cors-headers -django-debug-toolbar -django-extensions -django-filter -django-markdown-deux -django-model-utils -django-notifications-hq -django-pagedown -djangorestframework -django-semanticui-forms -django-unused-media -future +amqp==5.0.2 +arabic-reshaper==2.1.1 +asgiref==3.3.1 +attrs==20.3.0 +beautifulsoup4==4.9.3 +billiard==3.6.3.0 +Brotli==1.0.9 +bs4==0.0.1 +celery==5.2.3 +certifi==2020.12.5 +cffi==1.14.4 +chardet==4.0.0 +click==7.1.2 +click-didyoumean==0.0.3 +click-plugins==1.1.1 +click-repl==0.1.6 +cryptography==36.0.2 +defusedxml==0.6.0 +Django==3.1.5 +django-allauth==0.44.0 +django-cleanup==5.1.0 +django-cors-headers==3.7.0 +django-debug-toolbar==3.2.4 +django-extensions==3.1.1 +django-filter==2.4.0 +django-markdown-deux==1.0.5 +django-model-utils==4.1.1 +django-notifications-hq==1.6.0 +django-pagedown==2.2.0 +djangorestframework==3.12.2 +django-semanticui-forms==1.6.5 +django-unused-media==0.2.2 +future==0.18.2 # gunicorn -html-text -html5lib -idna -ipython -ipython-genutils -jsonfield -jsonschema -kombu -lxml -markdown2 -numpy -oauthlib -openpyxl -Pillow -prompt-toolkit -psycopg2-binary -pycparser -PyJWT -PyPDF2 -pyrsistent -python-bidi -python-dateutil -python3-openid -pytz -reportlab -requests -requests-oauthlib -six -soupsieve -sqlparse -swapper -urllib3 -vine -wcwidth -webencodings -whitenoise -xhtml2pdf -xlrd -XlsxWriter -xlwt +html-text==0.5.2 +html5lib==1.1 +idna==2.10 +ipython==8.2.0 +ipython-genutils==0.2.0 +jsonfield==3.1.0 +jsonschema==3.2.0 +kombu==5.0.2 +lxml==4.8.0 +markdown2==2.4.2 +numpy==1.22.3 +oauthlib==3.1.0 +openpyxl==3.0.7 +Pillow==8.1.0 +prompt-toolkit==3.0.10 +psycopg2-binary==2.8.6 +pycparser==2.20 +PyJWT==2.0.1 +PyPDF2==1.26.0 +pyrsistent==0.17.3 +python-bidi==0.4.2 +python-dateutil==2.8.1 +python3-openid==3.2.0 +pytz==2020.5 +reportlab==3.5.59 +requests==2.25.1 +requests-oauthlib==1.3.0 +six==1.15.0 +soupsieve==2.1 +sqlparse==0.4.2 +swapper==1.1.2.post1 +urllib3==1.26.8 +vine==5.0.0 +wcwidth==0.2.5 +webencodings==0.5.1 +whitenoise==5.2.0 +xhtml2pdf==0.2.5 +xlrd==2.0.1 +XlsxWriter==1.3.7 +xlwt==1.3.0 From dbdf1820ec25063d11219c0c1f2c07d088165f3a Mon Sep 17 00:00:00 2001 From: Akash Singh Date: Fri, 17 Mar 2023 17:17:20 +0530 Subject: [PATCH 5/8] Now Prof can give marks to Students Assignment and Made site responsive --- FusionIIIT/applications/online_cms/admin.py | 5 +- FusionIIIT/applications/online_cms/models.py | 34 +++++++++++-- FusionIIIT/applications/online_cms/views.py | 49 ++++++++++++------- .../coursemanagement/assessment.html | 7 +-- .../coursemanagement/viewcourse.html | 12 +++-- .../coursemanagement/viewperformance.html | 13 ++--- requirements.txt | 4 +- 7 files changed, 87 insertions(+), 37 deletions(-) diff --git a/FusionIIIT/applications/online_cms/admin.py b/FusionIIIT/applications/online_cms/admin.py index 24679190f..9f2fde11f 100644 --- a/FusionIIIT/applications/online_cms/admin.py +++ b/FusionIIIT/applications/online_cms/admin.py @@ -2,13 +2,14 @@ from .models import (Assignment, CourseDocuments, CourseVideo, Forum, ForumReply, Quiz, QuizQuestion, QuizResult, StudentAnswer, - StudentAssignment, Topics,CourseSlide) + StudentAssignment1, Topics,CourseAssignment,CourseSlide) class QuizResultAdmin(admin.ModelAdmin): model = QuizResult raw_id_fields = ("student_id",) admin.site.register(CourseDocuments) +admin.site.register(CourseAssignment) admin.site.register(CourseSlide) admin.site.register(CourseVideo) @@ -22,7 +23,7 @@ class QuizResultAdmin(admin.ModelAdmin): admin.site.register(Assignment) -admin.site.register(StudentAssignment) +admin.site.register(StudentAssignment1) admin.site.register(QuizResult, QuizResultAdmin) diff --git a/FusionIIIT/applications/online_cms/models.py b/FusionIIIT/applications/online_cms/models.py index fe8dce565..0c564dabc 100644 --- a/FusionIIIT/applications/online_cms/models.py +++ b/FusionIIIT/applications/online_cms/models.py @@ -14,7 +14,7 @@ def content_file_name(instance, filename): 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 +# 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) @@ -187,11 +187,37 @@ 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): +def assignment_submit_name(instance, filename): + name, ext = filename.split('.') + # obj=Curriculum.objects.get(course_id=instance.course_id) + course_code=instance.course_code + assignmentName=instance.assignment_id.assignment_name + file_path = 'online_cms/{course_id}/assi/{assignmentName}/{fileName}.{ext}'.format( + course_id=course_code,assignmentName=assignmentName, fileName=name, ext=ext) + return file_path +# class StudentAssignment(models.Model): +# student_id = models.ForeignKey(Student, on_delete=models.CASCADE) +# assignment_id = models.ForeignKey(CourseAssignment, on_delete=models.CASCADE) +# upload_time = models.DateTimeField(auto_now=True) +# # upload_url = models.TextField(max_length=200) +# doc = models.FileField(upload_to=assignment_submit_name, null=True, blank=True) +# score = models.IntegerField(null=True) #score is submitted by faculty +# feedback = models.CharField(max_length=100, null=True) #feedback by the faculty for the solution of the assignment submitted +# assign_name = models.CharField(max_length=100) + +# def __str__(self): +# return '{} - {} - {} - {} - {}'.format( +# self.pk, self.student_id, +# self.assignment_id, self.score, +# self.feedback) + +class StudentAssignment1(models.Model): student_id = models.ForeignKey(Student, on_delete=models.CASCADE) - assignment_id = models.ForeignKey(Assignment, on_delete=models.CASCADE) + assignment_id = models.ForeignKey(CourseAssignment, on_delete=models.CASCADE) upload_time = models.DateTimeField(auto_now=True) - upload_url = models.TextField(max_length=200) + # upload_url = models.TextField(max_length=200) + course_code=models.CharField(max_length=100) + doc = models.FileField(upload_to=assignment_submit_name, null=True, blank=True) score = models.IntegerField(null=True) #score is submitted by faculty feedback = models.CharField(max_length=100, null=True) #feedback by the faculty for the solution of the assignment submitted assign_name = models.CharField(max_length=100) diff --git a/FusionIIIT/applications/online_cms/views.py b/FusionIIIT/applications/online_cms/views.py index 7f60b9363..810a9d3e8 100644 --- a/FusionIIIT/applications/online_cms/views.py +++ b/FusionIIIT/applications/online_cms/views.py @@ -174,12 +174,12 @@ def course(request, course_code): # videos.append(video_data) # print(videos) - slides = CourseDocuments.objects.select_related().filter(course_id=course) + slides = CourseSlide.objects.select_related().filter(course_id=course) quiz = Quiz.objects.select_related().filter(course_id=course) - assignment = Assignment.objects.select_related().filter(course_id=course) + assignment = CourseAssignment.objects.select_related().filter(course_id=course) student_assignment = [] for assi in assignment: - sa = StudentAssignment.objects.select_related().filter(assignment_id=assi, student_id=student) + sa = StudentAssignment1.objects.select_related().filter(assignment_id=assi, student_id=student) student_assignment.append(sa) ''' marks to store the marks of quizes of student @@ -309,7 +309,10 @@ def course(request, course_code): # tempform.course_id=course # tempform.save() videos=[] + # slides1=None + # assignment1=None slides1=CourseSlide.objects.select_related().filter(course_id=course) + # slides slides = CourseDocuments.objects.select_related().filter(course_id=course) quiz = Quiz.objects.select_related().filter(course_id=course) marks = [] @@ -317,8 +320,9 @@ def course(request, course_code): assignment = Assignment.objects.select_related().filter(course_id=course) assignment1 = CourseAssignment.objects.select_related().filter(course_id=course) student_assignment = [] - for assi in assignment: - sa = StudentAssignment.objects.select_related().filter(assignment_id=assi) + for assi in assignment1: + sa = StudentAssignment1.objects.select_related().filter(assignment_id=assi) + print("hii",sa) student_assignment.append(sa) for q in quiz: qs = QuizResult.objects.select_related().filter(quiz_id=q) @@ -370,7 +374,7 @@ def upload_assignment(request, course_code): doc = request.FILES.get('img') #the images in the assignment assi_name = request.POST.get('assignment_topic') name = request.POST.get('name') - assign = Assignment.objects.get(pk=assi_name) + assign = CourseAssignment.objects.get(pk=assi_name) filename, file_extenstion = os.path.splitext(request.FILES.get('img').name) except: return HttpResponse("Please fill each and every field correctly!") @@ -382,16 +386,27 @@ def upload_assignment(request, course_code): cmd = "mkdir " + full_path subprocess.call(cmd, shell=True) fs = FileSystemStorage(full_path, url) - fs.save(name + file_extenstion, doc) #saving the media files - uploaded_file_url = full_path+ "/" + name + file_extenstion + # fs.save(name + file_extenstion, doc) #saving the media files + # uploaded_file_url = full_path+ "/" + name + file_extenstion # to save the solution of assignment the database - sa = StudentAssignment( - student_id=student, - assignment_id=assign, - upload_url=uploaded_file_url, - assign_name=name+file_extenstion + StudentAssignment1.objects.create( + student_id=student, + doc=doc, + assignment_id=assign, + course_code=course_code, + assign_name=name+file_extenstion + # upload_time=datetime.datetime.now(), + # description=description, + # document_name=name, + # doc=doc ) - sa.save() + # sa = StudentAssignment( + # student_id=student, + # assignment_id=assign, + # upload_url=uploaded_file_url, + # assign_name=name+file_extenstion + # ) + # sa.save() return HttpResponse("Upload successful.") else: return HttpResponse("not found") @@ -474,17 +489,17 @@ def delete(request, course_code): video.delete() #to delete slides/documents elif data_type == 'slide': - slide = CourseDocuments.objects.select_related().get(pk=pk, course_id=course) + slide = CourseSlide.objects.select_related().get(pk=pk, course_id=course) path = slide.document_url slide.delete() #to delete the submitted assignment elif data_type == 'stuassignment': - stu_assi = StudentAssignment.objects.select_related().get(pk=pk) + stu_assi = StudentAssignment1.objects.select_related().get(pk=pk) path = stu_assi.upload_url stu_assi.delete() #to delete the assignment uploaded by faculty elif data_type == 'lecassignment': - lec_assi = Assignment.objects.select_related().get(pk=pk) + lec_assi = CourseAssignment.objects.select_related().get(pk=pk) path = lec_assi.assignment_url lec_assi.delete() cmd = "rm "+path diff --git a/FusionIIIT/templates/coursemanagement/assessment.html b/FusionIIIT/templates/coursemanagement/assessment.html index 41a7954e9..458edb9d6 100644 --- a/FusionIIIT/templates/coursemanagement/assessment.html +++ b/FusionIIIT/templates/coursemanagement/assessment.html @@ -11,11 +11,11 @@

{{course.course_name}}

- {% for assi in assignment %} + {% for assi in assignment1 %}
@@ -54,9 +54,10 @@

+

- Download + Download {% if sa.score %} diff --git a/FusionIIIT/templates/coursemanagement/viewcourse.html b/FusionIIIT/templates/coursemanagement/viewcourse.html index 44f1d9fb8..55d024ffc 100644 --- a/FusionIIIT/templates/coursemanagement/viewcourse.html +++ b/FusionIIIT/templates/coursemanagement/viewcourse.html @@ -74,7 +74,7 @@

{{course.course_name}}

-
+
-