Ejemplo n.º 1
0
def import_everything(request):
    """ View for handeling admin import functionality
    """
    if request.POST:
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            from ecwsp.sis.importer import Importer
            importer = Importer(request.FILES['file'], request.user)
            msg = ""
            msg_to_add, filename = importer.magic_import_everything()
            msg += msg_to_add
            form = UploadFileForm()
            return render_to_response(
                'upload.html', {
                    'form': form,
                    'msg': msg,
                    'error_filename': filename,
                    'request': request,
                })
        else:
            return render_to_response('upload.html', {
                'form': form,
                'request': request,
            })
    form = UploadFileForm()
    return render_to_response('upload.html', {
        'form': form,
        'request': request,
    }, RequestContext(request, {}))
Ejemplo n.º 2
0
def import_naviance(request):
    """ Import only naviance data
    """
    from ecwsp.standard_test.forms import UploadNaviance
    msg = 'Import a test directly from Naviance such as SAT and ACT. You must have unique id (SWORD) and hs_student_id (Naviance)' \
          ' be the same. You must have already set up the <a href="/admin/schedule/standardtest/"> tests </a> <br/>' \
          'In Naviance, click setup, then Import/Export then export the test you want. At this time only SAT and ACT is supported.'
    if request.method == 'POST':
        form = UploadNaviance(request.POST, request.FILES)
        if form.is_valid():
            test = form.cleaned_data['test']
            from ecwsp.sis.importer import Importer
            importer = Importer(file=form.cleaned_data['import_file'],
                                user=request.user)
            msg, filename = importer.import_just_standard_test(test)
            msg += '<br/><a href="/media/import_error.xls">Download Errors</a>'
    else:
        form = UploadNaviance()
    msg = mark_safe(msg)
    return render_to_response(
        'sis/generic_form.html',
        {
            'form': form,
            'msg': msg
        },
        RequestContext(request, {}),
    )
Ejemplo n.º 3
0
 def form_valid(self, form):
     from ecwsp.sis.importer import Importer
     course_section = self.object
     importer = Importer(self.request.FILES['file'], self.request.user)
     error = importer.import_grades(course_section, form.cleaned_data['marking_period'])
     if error:
         messages.warning(self.request, error)
     else:
         course_section.last_grade_submission = datetime.datetime.now()
         course_section.save()
     return super(CourseSectionGrades, self).form_valid(form)
Ejemplo n.º 4
0
 def form_valid(self, form):
     from ecwsp.sis.importer import Importer
     course_section = self.object
     importer = Importer(self.request.FILES['file'], self.request.user)
     error = importer.import_grades(course_section, form.cleaned_data['marking_period'])
     if error:
         messages.warning(self.request, error)
     else:
         course_section.last_grade_submission = datetime.datetime.now()
         course_section.save()
     return super(CourseSectionGrades, self).form_valid(form)
Ejemplo n.º 5
0
def import_clearinghouse(request):
    from ecwsp.sis.forms import UploadFileForm
    msg = 'Import a alumni data file from Student Clearinghouse'
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            from ecwsp.sis.importer import Importer
            importer = Importer(file=form.cleaned_data['file'], user=request.user)
            msg, filename = importer.import_just_alumni_data()
            msg += '<br/><a href="/media/import_error.xls">Download Errors</a>'
    else:
        form = UploadFileForm()
    msg = mark_safe(msg)
    return render(request, 'sis/generic_form.html', {'form':form, 'msg':msg}, )
Ejemplo n.º 6
0
def import_everything(request):
    """ View for handeling admin import functionality
    """
    if request.POST:
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            from ecwsp.sis.importer import Importer
            importer = Importer(request.FILES['file'], request.user)
            msg = ""
            msg_to_add, filename = importer.magic_import_everything()
            msg += msg_to_add
            form = UploadFileForm()
            return render_to_response('upload.html', {'form': form, 'msg': msg, 'error_filename':filename, 'request': request,})
        else:
            return render_to_response('upload.html', {'form': form, 'request': request,})
    form = UploadFileForm()
    return render_to_response('upload.html', {'form': form, 'request': request,}, RequestContext(request, {}))
Ejemplo n.º 7
0
def import_naviance(request):
    """ Import only naviance data
    """
    from ecwsp.standard_test.forms import UploadNaviance
    msg = 'Import a test directly from Naviance such as SAT and ACT. You must have unique id (SWORD) and hs_student_id (Naviance)' \
          ' be the same. You must have already set up the <a href="/admin/schedule/standardtest/"> tests </a> <br/>' \
          'In Naviance, click setup, then Import/Export then export the test you want. At this time only SAT and ACT is supported.'
    if request.method == 'POST':
        form = UploadNaviance(request.POST, request.FILES)
        if form.is_valid():
            test = form.cleaned_data['test']
            from ecwsp.sis.importer import Importer
            importer = Importer(file=form.cleaned_data['import_file'], user=request.user)
            msg, filename = importer.import_just_standard_test(test)
            msg += '<br/><a href="/media/import_error.xls">Download Errors</a>'
    else:
        form = UploadNaviance()
    msg = mark_safe(msg)
    return render_to_response('sis/generic_form.html', {'form':form, 'msg':msg}, RequestContext(request, {}), )
Ejemplo n.º 8
0
def import_clearinghouse(request):
    from ecwsp.sis.forms import UploadFileForm
    msg = 'Import a alumni data file from Student Clearinghouse'
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            from ecwsp.sis.importer import Importer
            importer = Importer(file=form.cleaned_data['file'],
                                user=request.user)
            msg, filename = importer.import_just_alumni_data()
            msg += '<br/><a href="/media/import_error.xls">Download Errors</a>'
    else:
        form = UploadFileForm()
    msg = mark_safe(msg)
    return render(
        request,
        'sis/generic_form.html',
        {
            'form': form,
            'msg': msg
        },
    )
Ejemplo n.º 9
0
def teacher_grade_upload(request, id):
    """ This view is for inputing grades. It usually is done by uploading a spreadsheet.
    However it can also be done by manually overriding grades. This requires
    registrar level access. """
    
    course = Course.objects.get(id=id)
    
    students = course.get_enrolled_students(show_deleted=True)
    grades = course.grade_set.all()
    
    if request.method == 'POST' and 'upload' in request.POST:
        import_form = GradeUpload(request.POST, request.FILES)
        if import_form.is_valid():
            from ecwsp.sis.importer import Importer
            importer = Importer(request.FILES['file'], request.user)
            error = importer.import_grades(course, import_form.cleaned_data['marking_period'])
            if error:
                messages.warning(request, error)
            else:
                course.last_grade_submission = datetime.datetime.now()
                course.save()
    else:
        import_form = GradeUpload()
        import_form.fields['marking_period'].queryset = import_form.fields['marking_period'].queryset.filter(course=course)
        
    if request.method == 'POST' and 'edit' in request.POST:
        handle_grade_save(request, course)
    
    marking_periods = course.marking_period.all().order_by('start_date')
    
    # Ensure grades exists
    for mp in marking_periods:
        for student in students:
            grade, created = Grade.objects.get_or_create(student=student, course=course, marking_period=mp)
    
    for student in students:
        student.grades = student.grade_set.filter(course=course, override_final=False)
        try:
            student.final = student.grade_set.get(course=course, override_final=True).get_grade()
            student.final_override = True
        except Grade.DoesNotExist:
            student.final = course.calculate_final_grade(student)
    
    if request.user.is_superuser or \
        request.user.has_perm('grades.change_own_final_grade') or \
        request.user.has_perm('grades.change_grade'):
        edit_final = True
    else:
        edit_final = False
    if request.user.is_superuser or \
        request.user.has_perm('grades.change_own_grade') or \
        request.user.has_perm('grades.change_grade'):
        edit = True
    else:
        edit = False
    
    letter_grade_required_for_pass = Configuration.get_or_default('letter_grade_required_for_pass', '60').value
    
    return render_to_response('grades/teacher_grade_upload.html', {
        'request': request, 
        'course': course, 
        'marking_periods': marking_periods, 
        'students': students, 
        'import_form': import_form,
        'edit': edit,
        'edit_final': edit_final,
        'letter_grade_required_for_pass': letter_grade_required_for_pass
    }, RequestContext(request, {}),)
Ejemplo n.º 10
0
def teacher_grade_upload(request, id):
    """ This view is for inputing grades. It usually is done by uploading a spreadsheet.
    However it can also be done by manually overriding grades. This requires
    registrar level access. """

    course = Course.objects.get(id=id)

    students = Student.objects.filter(courseenrollment__course=course)
    grades = course.grade_set.all()

    if request.method == 'POST' and 'upload' in request.POST:
        import_form = GradeUpload(request.POST, request.FILES)
        if import_form.is_valid():
            from ecwsp.sis.importer import Importer
            importer = Importer(request.FILES['file'], request.user)
            error = importer.import_grades(
                course, import_form.cleaned_data['marking_period'])
            if error:
                messages.warning(request, error)
            else:
                course.last_grade_submission = datetime.datetime.now()
                course.save()
    else:
        import_form = GradeUpload()
        import_form.fields['marking_period'].queryset = import_form.fields[
            'marking_period'].queryset.filter(course=course)

    if request.method == 'POST' and 'edit' in request.POST:
        handle_grade_save(request, course)

    marking_periods = course.marking_period.all().order_by('start_date')

    # Ensure grades exists
    for mp in marking_periods:
        for student in students:
            grade, created = Grade.objects.get_or_create(student=student,
                                                         course=course,
                                                         marking_period=mp)

    for student in students:
        student.grades = student.grade_set.filter(course=course,
                                                  override_final=False)
        try:
            student.final = student.grade_set.get(
                course=course, override_final=True).get_grade()
            student.final_override = True
        except Grade.DoesNotExist:
            student.final = course.calculate_final_grade(student)

    if request.user.is_superuser or \
        request.user.has_perm('grades.change_own_final_grade') or \
        request.user.has_perm('grades.change_grade'):
        edit_final = True
    else:
        edit_final = False
    if request.user.is_superuser or \
        request.user.has_perm('grades.change_own_grade') or \
        request.user.has_perm('grades.change_grade'):
        edit = True
    else:
        edit = False

    letter_grade_required_for_pass = Configuration.get_or_default(
        'letter_grade_required_for_pass', '60').value

    return render_to_response(
        'grades/teacher_grade_upload.html',
        {
            'request': request,
            'course': course,
            'marking_periods': marking_periods,
            'students': students,
            'import_form': import_form,
            'edit': edit,
            'edit_final': edit_final,
            'letter_grade_required_for_pass': letter_grade_required_for_pass
        },
        RequestContext(request, {}),
    )