def student_list(request, course_id): try: course = Course.objects.get(id=course_id) except Course.DoesNotExist: raise Http404('course with provided request does not exist') # we've to provide a message here if someone is not logged in as # a student, intructor or creator...because only this 3 type of person # can see student data # so if anyone is logged in as such # redirect them to a page telling them that only creator, instructor # or student can only see this data # it's not written yet if request.user.is_authenticated(): is_ok = check_is_creator(course, request.user) or check_is_instructor( course, request.user) or check_is_student(course, request.user) else: is_ok = False if not is_ok: message = 'The only people have access to view this page is the students, instructors or creator of this course' context = { 'message': message, } return render(request, 'unauthorized.html', context=context) student_list = Student.objects.filter(course=course).order_by('class_id') context = { 'course': course, 'student_list': student_list, } return render(request, 'course/student_list.html', context=context)
def course_index(request, course_id): try: course = Course.objects.get(id=course_id) except Course.DoesNotExist: raise Http404('course with provided request deos not exist') if request.user.is_authenticated(): is_ok = check_is_creator(course, request.user) or check_is_instructor( course, request.user) or check_is_student(course, request.user) else: is_ok = False instructor_list = Instructor.objects.filter(course=course) student_list = Student.objects.filter(course=course).order_by('class_id') topic_list = Topic.objects.filter(course=course).order_by('topic_serial') if is_ok: is_instructor = check_is_instructor(course, request.user) is_creator = check_is_creator(course, request.user) else: is_instructor = False is_creator = False context = { 'course': course, 'is_ok': is_ok, 'instructor_list': instructor_list, 'student_list': student_list, 'topic_list': topic_list, 'is_instructor': is_instructor, 'is_creator': is_creator, } return render(request, 'course/course_index.html', context=context)
def material_list(request, topic_id): try: topic = Topic.objects.get(id=topic_id) except Topic.DoesNotExist: raise Http404('topic with provided request does not exist') course = topic.course # have to provide a message # if user is not an instructor of this course # becuase only instructor can add materials # even creator or student cant do it..so.. # i'll do it later...done it actually...see below codes if request.user.is_authenticated(): is_ok = check_is_creator(course, request.user) or check_is_instructor( course, request.user) or check_is_student(course, request.user) else: is_ok = False if not is_ok: message = 'The only people have access to view this page is the students, instructors or creator of this course' context = { 'message': message, } return render(request, 'unauthorized.html', context=context) material_list = Material.objects.filter(topic=topic) is_instructor = check_is_instructor(course, request.user) context = { 'course': course, 'topic': topic, 'material_list': material_list, 'is_instructor': is_instructor, } return render(request, 'material/material_list.html', context=context)
def topic_list(request, course_id): try: course = Course.objects.get(id=course_id) except Course.DoesNotExist: raise Http404('course with provided request does not exist') # have to provide a message # if user is not a student, instructor, or creator of this course # i'll do it later if request.user.is_authenticated(): is_ok = check_is_creator(course, request.user) or check_is_instructor( course, request.user) or check_is_student(course, request.user) else: is_ok = False if not is_ok: message = 'The only people have access to view this page is the students, instructors or creator of this course' context = { 'message': message, } return render(request, 'unauthorized.html', context=context) topic_list = Topic.objects.filter(course=course).order_by('topic_serial') is_instructor = check_is_instructor(course, request.user) context = { 'course': course, 'topic_list': topic_list, 'is_instructor': is_instructor, } return render(request, 'material/topic_list.html', context=context)
def course_index(request, course_id): try: course = Course.objects.get(id=course_id) except Course.DoesNotExist: raise Http404('course with provided request deos not exist') if request.user.is_authenticated(): is_ok = check_is_creator(course, request.user) or check_is_instructor(course, request.user) or check_is_student(course, request.user) else: is_ok = False context = { 'course' : course, 'is_ok' : is_ok, } return render(request, 'course/course_index.html', context=context)