diff --git a/FusionIIIT/applications/online_cms/admin.py b/FusionIIIT/applications/online_cms/admin.py index 24679190f..8bf6cd720 100644 --- a/FusionIIIT/applications/online_cms/admin.py +++ b/FusionIIIT/applications/online_cms/admin.py @@ -2,7 +2,8 @@ from .models import (Assignment, CourseDocuments, CourseVideo, Forum, ForumReply, Quiz, QuizQuestion, QuizResult, StudentAnswer, - StudentAssignment, Topics,CourseSlide) + StudentAssignment1, Topics,CourseSlide,CourseAssignment + ) class QuizResultAdmin(admin.ModelAdmin): model = QuizResult @@ -11,7 +12,7 @@ class QuizResultAdmin(admin.ModelAdmin): admin.site.register(CourseDocuments) admin.site.register(CourseSlide) admin.site.register(CourseVideo) - +admin.site.register(CourseAssignment) admin.site.register(Quiz) admin.site.register(Topics) @@ -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/forms.py b/FusionIIIT/applications/online_cms/forms.py index 802de9dbe..61d4f1c84 100644 --- a/FusionIIIT/applications/online_cms/forms.py +++ b/FusionIIIT/applications/online_cms/forms.py @@ -124,4 +124,8 @@ class Meta: fields=['couse_id','doc'] # title = forms.CharField(max_length=50) - file = forms.FileField() \ No newline at end of file + file = forms.FileField() + +class AssignmentMarks(forms.Form): + marks=forms.IntegerField() + feedback=forms.CharField(max_length=255) \ No newline at end of file diff --git a/FusionIIIT/applications/online_cms/migrations/0002_auto_20230406_1625.py b/FusionIIIT/applications/online_cms/migrations/0002_auto_20230406_1625.py new file mode 100644 index 000000000..f6d607f0b --- /dev/null +++ b/FusionIIIT/applications/online_cms/migrations/0002_auto_20230406_1625.py @@ -0,0 +1,60 @@ +# Generated by Django 3.1.5 on 2023-04-06 16:25 + +import applications.online_cms.models +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('academic_information', '0002_student_hall_id'), + ('online_cms', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='CourseAssignment', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('upload_time', models.DateTimeField(auto_now=True)), + ('submit_date', models.DateTimeField()), + ('assignment_name', models.CharField(max_length=100)), + ('doc', models.FileField(blank=True, null=True, upload_to=applications.online_cms.models.assignment_file_name)), + ('course_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.course')), + ], + ), + migrations.CreateModel( + name='CourseSlide', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('upload_time', models.DateTimeField(auto_now=True)), + ('document_name', models.CharField(max_length=40)), + ('description', models.CharField(max_length=100)), + ('doc', models.FileField(blank=True, null=True, upload_to=applications.online_cms.models.content_file_name)), + ('course_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.course')), + ], + ), + migrations.CreateModel( + name='StudentAssignment1', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('upload_time', models.DateTimeField(auto_now=True)), + ('course_code', models.CharField(max_length=100)), + ('doc', models.FileField(blank=True, null=True, upload_to=applications.online_cms.models.assignment_submit_name)), + ('score', models.IntegerField(null=True)), + ('feedback', models.CharField(max_length=100, null=True)), + ('assign_name', models.CharField(max_length=100)), + ('assignment_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='online_cms.courseassignment')), + ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), + ], + ), + migrations.AlterField( + model_name='coursedocuments', + name='document_url', + field=models.CharField(blank=True, max_length=100, null=True), + ), + migrations.DeleteModel( + name='StudentAssignment', + ), + ] diff --git a/FusionIIIT/applications/online_cms/models.py b/FusionIIIT/applications/online_cms/models.py index fe8dce565..fa890d2d3 100644 --- a/FusionIIIT/applications/online_cms/models.py +++ b/FusionIIIT/applications/online_cms/models.py @@ -29,8 +29,7 @@ class CourseDocuments(models.Model): 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=500, null=True,blank=True) - # media = models.FileField(upload_to=content_file_name, null=True, blank=True) + document_url = models.CharField(max_length=100, null=True,blank=True) def __str__(self): return '{} - {}'.format(self.course_id, self.document_name) @@ -186,16 +185,24 @@ class CourseAssignment(models.Model): 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('.') + 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 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) - def __str__(self): return '{} - {} - {} - {} - {}'.format( self.pk, self.student_id, diff --git a/FusionIIIT/applications/online_cms/urls.py b/FusionIIIT/applications/online_cms/urls.py index a15cc3029..07e5d178c 100644 --- a/FusionIIIT/applications/online_cms/urls.py +++ b/FusionIIIT/applications/online_cms/urls.py @@ -70,6 +70,8 @@ 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'), + url(r'^(?P[A-z]+[0-9]+[A-z]?)/edit-assignment-marks$', views.edit_assignment_marks, + name='assignment_marks'), ] 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 7f60b9363..e1a5fa9e5 100644 --- a/FusionIIIT/applications/online_cms/views.py +++ b/FusionIIIT/applications/online_cms/views.py @@ -14,6 +14,7 @@ from django.http import HttpResponse, HttpResponseBadRequest from django.shortcuts import redirect, render from django.utils import timezone +from django.contrib import messages from applications.academic_information.models import (Course, Curriculum_Instructor,Curriculum, Student,Student_attendance) @@ -25,6 +26,8 @@ # from .helpers import create_thumbnail, semester from .models import * from .helpers import create_thumbnail, semester +from django.shortcuts import HttpResponseRedirect +from django.urls import reverse @login_required @@ -171,15 +174,13 @@ def course(request, course_code): # 'title': res['snippet']['title'], # } - # 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,16 +310,16 @@ def course(request, course_code): # 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) + slides1 = CourseSlide.objects.select_related().filter(course_id=course) + slides=None 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) + for assi in assignment1: + sa = StudentAssignment1.objects.select_related().filter(assignment_id=assi) student_assignment.append(sa) for q in quiz: qs = QuizResult.objects.select_related().filter(quiz_id=q) @@ -370,28 +371,21 @@ 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!") filename = name - full_path = settings.MEDIA_ROOT + "/online_cms/" + course_code + "/assi/" #storing the media files - full_path = full_path + assign.assignment_name + "/" + student.id.id + "/" - url = settings.MEDIA_URL + filename - if not os.path.isdir(full_path): - 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 + # 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 + ) - sa.save() return HttpResponse("Upload successful.") else: return HttpResponse("not found") @@ -435,13 +429,7 @@ def add_document(request, course_code): 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: @@ -479,12 +467,12 @@ def delete(request, course_code): 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 @@ -607,8 +595,7 @@ def ajax_new(request, course_code): roll = student.id.id[:4] #course = Course.objects.get(course_id=course_code, sem=semester(roll)) curriculum_details = Curriculum.objects.select_related('course_id').filter(course_code=course_code) #curriculum id - #print(curriculum_details[0].course_id) - #print(Curriculum.objects.values_list('curriculum_id')) + course = curriculum_details[0].course_id else: @@ -670,33 +657,36 @@ def add_assignment(request, course_code): #from faculty side except: 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 - subprocess.call(cmd, shell=True) - fs = FileSystemStorage(full_path, url) - fs.save(filename+file_extenstion, assi) - uploaded_file_url = full_path + filename + file_extenstion - print(uploaded_file_url) + CourseAssignment.objects.create( course_id=course, submit_date=request.POST.get('myDate'), doc=assi, assignment_name=name ) - # 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") +@login_required +def edit_assignment_marks(request,*args, **kwargs): + if request.method=='POST': + print("hiii") + form=AssignmentMarks(request.POST) + if form.is_valid(): + sa=StudentAssignment1.objects.get(pk=int(request.POST['assignmentid'][0])) + # print() + sa.score=form.cleaned_data['marks'] + sa.feedback=form.cleaned_data['feedback'] + sa.save() + # print(sa.course_code) + course_code = sa.course_code + # url = reverse('course', args=[course_code]) + messages.success(request, 'Marks updated successfullt') + return HttpResponseRedirect('/ocms/'+course_code) + # return redirect(course,course_code='CS416e') + return HttpResponse("Error Occured!") @login_required def edit_bank(request, course_code, qb_code): diff --git a/FusionIIIT/templates/coursemanagement/assessment.html b/FusionIIIT/templates/coursemanagement/assessment.html index 41a7954e9..b4de45abc 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 %}
@@ -45,18 +45,30 @@

- - {% endfor %} @@ -352,7 +352,7 @@

{{course.course_name}}

@@ -416,6 +416,24 @@

Quiz Time Table

{% block comments %} {% include 'coursemanagement/comments.html' %} {% endblock %}
+
+
+ + {% if messages %} +
+
+ +
+ {% for message in messages %} + {{ message }} + {% endfor %} +
+
+
+ {% endif %} + +
+
diff --git a/FusionIIIT/templates/coursemanagement/viewperformance.html b/FusionIIIT/templates/coursemanagement/viewperformance.html index 386b6a9af..489c12d8e 100644 --- a/FusionIIIT/templates/coursemanagement/viewperformance.html +++ b/FusionIIIT/templates/coursemanagement/viewperformance.html @@ -59,13 +59,13 @@

You didn't submit any assignment

{% endif %} {% else %}

Results

- {% if assignment|length %} + {% if assignment1|length %} - {% for assi in assignment %} + {% for assi in assignment1 %}
+
+ {%csrf_token%}
- + {% comment %} {% endcomment %} + +
+
+
+
+ {% comment %} {% endcomment %} + +
- -
- +
-
-
- Download + + + + {% comment %}
+
{% endcomment %} + {% comment %}
+ +
{% endcomment %}
{% if sa.score %} @@ -85,46 +97,7 @@

-
- - {% csrf_token %} -
- - - - - - - - - - - {% for x in registered_students %} - - - - - {% endfor %} - -
Students
-
-

{{x.student_id}}

-
-
- - - -
-
- - -
+
{% endblock %} diff --git a/FusionIIIT/templates/coursemanagement/viewcourse.html b/FusionIIIT/templates/coursemanagement/viewcourse.html index 44f1d9fb8..a35078e4b 100644 --- a/FusionIIIT/templates/coursemanagement/viewcourse.html +++ b/FusionIIIT/templates/coursemanagement/viewcourse.html @@ -312,7 +312,7 @@

Submitable Assignments

{{forloop.counter}} {{assi.assignment_name}} {{assi.submit_date}}
+