示例#1
0
def course_dashboard(request, course_id):
    course = get_course(int(course_id))
    assignments = get_assignments(course)
    course_materials = CourseMaterial.objects.all().filter(course=course)
    lectures = course.lecture_set.all()
    context = {'assignments' : assignments,
		       'course' : course,
		       'course_materials' : course_materials,
		       'lectures' : lectures}
    return render(request, 'instructor_portal/course_dashboard.html', context)
示例#2
0
def course_dashboard(request, course_id):
    course = get_course(int(course_id))
    assignments = get_assignments(course)
    course_materials = CourseMaterial.objects.all().filter(course=course)
    lectures = course.lecture_set.all()
    context = {
        'assignments': assignments,
        'course': course,
        'course_materials': course_materials,
        'lectures': lectures
    }
    return render(request, 'instructor_portal/course_dashboard.html', context)
示例#3
0
def upload_course_material(request, course_id):
    if request.method == 'POST':
        a = request.POST #the post dict
        form = SubmissionForm(request.POST, request.FILES)
        if form.is_valid():
            course = get_course(int(course_id))
            handle_uploaded_course_material(request.FILES['file'], course.department, course.id, a['description'], request.user)
            return HttpResponseRedirect('/instructor/' + course_id + '/dashboard')

    else:
        form = SubmissionForm()
    
    context = {'form' : form}
    context.update(csrf(request))
    return render_to_response('upload.html', context)
示例#4
0
def display_course_info(request, course_department, course_id):
    course = get_course(int(course_id))
    lecture_list = get_lectures(course)
    assignment_list = get_assignments(course)
    print assignment_list
    if request.user.is_authenticated():
	instructor = Instructor.objects.all().get(id=request.user.instructor.id)
	taught_courses, not_taught_courses = get_separated_course_list(instructor, Course.objects.all())
	is_taught = course in taught_courses
    
    is_enrolled = False
    return render(request, 'course_info.html', { 'course' : course,
					     'is_enrolled': is_enrolled,
					     'lecture_list' : lecture_list,
					     'assignment_list': assignment_list,
					     'is_student' : False})
示例#5
0
def upload_course_material(request, course_id):
    if request.method == 'POST':
        a = request.POST  #the post dict
        form = SubmissionForm(request.POST, request.FILES)
        if form.is_valid():
            course = get_course(int(course_id))
            handle_uploaded_course_material(request.FILES['file'],
                                            course.department, course.id,
                                            a['description'], request.user)
            return HttpResponseRedirect('/instructor/' + course_id +
                                        '/dashboard')

    else:
        form = SubmissionForm()

    context = {'form': form}
    context.update(csrf(request))
    return render_to_response('upload.html', context)
示例#6
0
def handle_uploaded_course_material(file, course_department, course_id, cm_description, user):
    if file:
        cm = CourseMaterial(course = get_course(int(course_id)),
                            description = cm_description)
        cm.save()
                            
        directory = settings.MEDIA_ROOT+ '/' + course_department + '/' + unicode(course_id) +  '/course_material/'
        if not os.path.exists(directory):
            os.makedirs(directory)
        _, fileExtension = os.path.splitext(file.name)
        filename = course_department + '_' + unicode(course_id) + '_' + unicode(cm.id)  + fileExtension
        print filename
        destination = open(directory+filename, 'wb+')
        for chunk in file.chunks():
            destination.write(chunk)
        destination.close()
        cm.file.name = directory+filename
        cm.save()
示例#7
0
def handle_uploaded_course_material(file, course_department, course_id,
                                    cm_description, user):
    if file:
        cm = CourseMaterial(course=get_course(int(course_id)),
                            description=cm_description)
        cm.save()

        directory = settings.MEDIA_ROOT + '/' + course_department + '/' + unicode(
            course_id) + '/course_material/'
        if not os.path.exists(directory):
            os.makedirs(directory)
        _, fileExtension = os.path.splitext(file.name)
        filename = course_department + '_' + unicode(
            course_id) + '_' + unicode(cm.id) + fileExtension
        print filename
        destination = open(directory + filename, 'wb+')
        for chunk in file.chunks():
            destination.write(chunk)
        destination.close()
        cm.file.name = directory + filename
        cm.save()
示例#8
0
def display_course_info(request, course_department, course_id):
    course = get_course(int(course_id))
    lecture_list = get_lectures(course)
    assignment_list = get_assignments(course)
    print assignment_list
    if request.user.is_authenticated():
        instructor = Instructor.objects.all().get(
            id=request.user.instructor.id)
        taught_courses, not_taught_courses = get_separated_course_list(
            instructor, Course.objects.all())
        is_taught = course in taught_courses

    is_enrolled = False
    return render(
        request, 'course_info.html', {
            'course': course,
            'is_enrolled': is_enrolled,
            'lecture_list': lecture_list,
            'assignment_list': assignment_list,
            'is_student': False
        })