Skip to content

Commit

Permalink
'gradebook'
Browse files Browse the repository at this point in the history
  • Loading branch information
NgoYves1802 committed Aug 24, 2023
1 parent 1fd873c commit e9850fc
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
Binary file modified db.sqlite3
Binary file not shown.
4 changes: 3 additions & 1 deletion phobos/templates/phobos/course_management.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
<br/>
<h4>{{course.name}}</h4><hr/>
<a href="{% url 'phobos:create_assignment' course_id=course.id %}" style="display: inline;"> Create a new assigment</a>

<button><a href="{% url 'phobos:gradebook' course_id=course.id %}" style="display: inline;"> GradeBook </a></button>

<!-- Display course's assignments -->
<ul class="courses course-list">
{% for assignment in assignments %}
{% include 'phobos/assignment_display.html' with assignment=assignment course=course %}
{% endfor %}
</ul>


{% endblock %}
3 changes: 2 additions & 1 deletion phobos/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
path('courses/<int:course_id>/assignments/<int:assignment_id>/<int:question_id>',
views.question_view, name='question_view'),
path('calci', views.calci, name='calci'),
path('create_question/upload-image/', views.upload_image, name='upload_image')
path('create_question/upload-image/', views.upload_image, name='upload_image'),
path('courses/<int:course_id>/gradebook', views.gradebook, name='gradebook')
]
49 changes: 47 additions & 2 deletions phobos/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from django.shortcuts import get_object_or_404
from django.middleware import csrf
from django.utils.timesince import timesince

from deimos.models import AssignmentStudent, Student

# Create your views here.
@login_required(login_url='astros:login')
Expand Down Expand Up @@ -326,4 +326,49 @@ def upload_image(request):

# Return the URL of the uploaded image in the response
return JsonResponse({'image_url': image.url})
return JsonResponse({'error': 'Invalid request'}, status=400)
return JsonResponse({'error': 'Invalid request'}, status=400)

def gradebook(request, course_id):
course = Course.objects.get(pk = course_id)
assignments= Assignment.objects.filter(course = course)
assignmentstudent = list()
students = {
'student':[], 'name': []
}
studentsname =[]
for i in assignments:
# getting a set of sets of submitted assignments
assignmentstudent.append(AssignmentStudent.objects.filter(assignment = i))
# getting the name of all the students enrolled in the course
for i in assignmentstudent:
for j in i:
if j.student.get_username() in students['name']:
print('already')
else:
students['student'].append(j.student)
students['name'].append(j.student.get_username())
for x, y in students.items():
print(x, y)

return render(request,'phobos/gradebook.html',{'studentd': students['student'], 'studentname': students['name'],'assignmentcourse':assignments ,'submittedassigmentsSeTs': assignmentstudent})

def gradebok(course):
assignments= Assignment.objects.filter(course = course)
assignmentstudent = list()
students = {
'student':[], 'name': []
}
studentsname =[]
for i in assignments:
# getting a set of sets of submitted assignments
assignmentstudent.append(AssignmentStudent.objects.filter(assignment = i))
# getting the name of all the students enrolled in the course
for i in assignmentstudent:
for j in i:
if j.student in students['student']:
print('already')
else:
students['student'].append(j.student)
students['name'].append(j.student.get_username())
for x, y in students.items():
print(x, y)

0 comments on commit e9850fc

Please sign in to comment.