Example #1
0
def newdelivery(request, idpractice):
    idstudent = request.user.student_set.get(uid=request.user.username).pk
    student = Student.objects.get(pk=idstudent)
    practice = Practice.objects.get(pk=idpractice)
    if (practice.isExpired()):
        return HttpResponseRedirect(PATHEXPIRED % str(practice.course_id))
    else:
        if (request.method == 'POST'):
            delivery = Delivery(student=student,
                                practice=practice,
                                deliverDate=date.today())
            form = DeliveryForm(request.POST, request.FILES, instance=delivery)
            if (form.is_valid()):
                form.save()
                automatic_correction = AutomaticCorrection()
                automatic_correction.delivery = form.instance
                automatic_correction.save()
                return HttpResponseRedirect(PATHOKNEWDELIVERY %
                                            str(practice.pk))
        else:
            form = DeliveryForm()
        deliveries = Delivery.objects.filter(student=student,
                                             practice=practice)
        return render(
            request, 'delivery/uploaddelivery.html', {
                'form': form,
                'idstudent': idstudent,
                'idcourse': practice.course_id,
                'namepractice': practice.uid,
                'deliveries': deliveries
            })
Example #2
0
def step(context, practice_uid, course_name, student_uid):
    student = Student.objects.get(uid=student_uid)
    course = Course.objects.get(name=course_name)
    practice = Practice.objects.get(uid=practice_uid, course=course)
    delivery = Delivery()
    delivery.file = "data/delivery.zip"
    delivery.student = student
    delivery.practice = practice
    delivery.deliverDate = '2012-11-22'
    delivery.save()
    automatic_correction = AutomaticCorrection()
    automatic_correction.delivery = delivery
    automatic_correction.save()
Example #3
0
def step(context, practice_uid, course_name, student_uid):
    student = Student.objects.get(uid=student_uid)
    course = Course.objects.get(name=course_name)
    practice = Practice.objects.get(uid=practice_uid, course=course)
    delivery = Delivery()
    delivery.file = "data/delivery.zip"
    delivery.student = student
    delivery.practice = practice
    delivery.deliverDate = '2012-11-22'
    delivery.save()
    automatic_correction = AutomaticCorrection()
    automatic_correction.delivery = delivery
    automatic_correction.save()
Example #4
0
def create_an_automatic_correction(delivery_filepath, stdout, exit_value,
                                   status):
    automatic_correction = AutomaticCorrection()
    automatic_correction.delivery = Delivery.objects.get(
        file=delivery_filepath)
    automatic_correction.captured_stdout = stdout
    automatic_correction.exit_value = exit_value
    automatic_correction.status = status
    automatic_correction.save()
    return automatic_correction
Example #5
0
def create_an_automatic_correction(delivery_filepath, stdout, exit_value, status):
    automatic_correction = AutomaticCorrection()
    automatic_correction.delivery = Delivery.objects.get(file=delivery_filepath)
    automatic_correction.captured_stdout = stdout
    automatic_correction.exit_value = exit_value
    automatic_correction.status = status
    automatic_correction.save()
    return automatic_correction
Example #6
0
def step(context, practice_uid, course_name, student_uid, delivery_id):
    student = Student.objects.get(uid=student_uid)
    course = Course.objects.get(name=course_name)
    practice = Practice.objects.get(uid=practice_uid, course=course)
    # delivery = Delivery.objects.get_or_create(pk=delivery_id, student=student, practice=practice)
    delivery = Delivery()
    delivery.pk = delivery_id
    src = "data/delivery.zip"
    delivery_path = managepath.get_instance().get_delivery_path()
    dst = os.path.join(delivery_path, "delivery.zip")
    if (not os.path.exists(delivery_path)):
        makedirs(delivery_path)
    if (not os.path.exists(dst)):
        copyfile(src, dst)
    delivery.file = dst
    delivery.student = student
    delivery.practice = practice
    delivery.deliverDate = '2012-11-22'
    delivery.save()
    automatic_correction = AutomaticCorrection()
    automatic_correction.delivery = delivery
    automatic_correction.save()
Example #7
0
def step(context, practice_uid, course_name, student_uid, delivery_id):
    student = Student.objects.get(uid=student_uid)
    course = Course.objects.get(name=course_name)
    practice = Practice.objects.get(uid=practice_uid, course=course)
    # delivery = Delivery.objects.get_or_create(pk=delivery_id, student=student, practice=practice)
    delivery = Delivery()
    delivery.pk = delivery_id
    src = "data/delivery.zip"
    delivery_path = managepath.get_instance().get_delivery_path()
    dst = os.path.join(delivery_path, "delivery.zip")
    if(not os.path.exists(delivery_path)):
        makedirs(delivery_path)
    if(not os.path.exists(dst)):
        copyfile(src, dst)
    delivery.file = dst
    delivery.student = student
    delivery.practice = practice
    delivery.deliverDate = '2012-11-22'
    delivery.save()
    automatic_correction = AutomaticCorrection()
    automatic_correction.delivery = delivery
    automatic_correction.save()
Example #8
0
def newdelivery(request, idpractice):
    idstudent = request.user.student_set.get(uid=request.user.username).pk
    student = Student.objects.get(pk=idstudent)
    practice = Practice.objects.get(pk=idpractice)    
    if (practice.isExpired()):
        return HttpResponseRedirect(PATHEXPIRED % str(practice.course_id))
    else: 
        if (request.method == 'POST'):
            delivery = Delivery(student=student, practice=practice, deliverDate=date.today())
            form = DeliveryForm(request.POST, request.FILES, instance=delivery)
            if (form.is_valid()):
                form.save()
                automatic_correction = AutomaticCorrection()
                automatic_correction.delivery = form.instance
                automatic_correction.save()
                return HttpResponseRedirect(PATHOKNEWDELIVERY % str(practice.pk))
        else:
            form = DeliveryForm()
        deliveries = Delivery.objects.filter(student=student, practice=practice)
        return render(request, 'delivery/uploaddelivery.html', 
                      {'form': form, 'idstudent' : idstudent, 'idcourse' : practice.course_id, 
                       'namepractice':practice.uid, 'deliveries': deliveries})