예제 #1
0
파일: views.py 프로젝트: stanri/caesar-web
def view_code_upload_chunk(request):
    '''
    Creates the necessary db objects for code to be created in Caesar as a chunk and redirects the user
    to their new chunk after submission.
    '''
    user = request.user
    if request.method == "POST":
        code = request.POST["code"]
        file_name = request.POST["filename"]

        assignment = Assignment.objects.get(name='Personal Code Upload')
        new_submit_milestone = SubmitMilestone(assignment=assignment, name=file_name, duedate=datetime.datetime.now())
        new_submit_milestone.save()
        new_submission = Submission(milestone=new_submit_milestone, name=file_name)
        new_submission.save() #save it so you can add an author which is a ManyToManyField
        new_submission.authors.add(user)
        new_submission.save()
        new_file = File(submission=new_submission, data=code, path=user.username+"/"+file_name) #does file path matter?
        new_file.save()
        code_size = len(code.split('\n'))
        new_chunk = Chunk(file=new_file, name=file_name, start=0, end=len(code), student_lines=code_size, staff_portion=0) #start, end, name
        new_chunk.save()

    return HttpResponseRedirect(reverse('chunks.views.view_chunk', args=(new_chunk.id,) ))
예제 #2
0
파일: rr3.py 프로젝트: khobbs91/caesar-web
from accounts.models import Member
from review.models import Comment
import random
import sys
import logging
import randomrouting.random_routing as rr

# creating a fake SubmitMilestone, ReviewMilestone, Submission, File, and 50 Chunks
assignment = Assignment.objects.all()[1]
semester = assignment.semester
semester_members = User.objects.filter(membership__semester=semester)
user_in_class = semester_members[0]

semester_non_members = User.objects.exclude(pk__in=semester_members)
user_not_in_class = semester_non_members[0]
rr_submit_milestone = SubmitMilestone(assignment=assignment,name="rr3_submit_milestone")
rr_submit_milestone.save()
rr_review_milestone = ReviewMilestone(assignment=assignment,submit_milestone=rr_submit_milestone,name="rr3_review_milestone")
rr_review_milestone.save()
rr_submission = Submission(milestone=rr_submit_milestone,name="rr3_submission")
rr_submission.milestone_id = rr_submit_milestone.id
rr_submission.save()
rr_submission.authors.add(user_not_in_class)
rr_file = Chunk.objects.filter(student_lines__gte=5)[0].file
rr_file.pk = None
rr_file.submission = rr_submission
rr_file.save()
rr_chunks = []
for i in range(1):
	rr_chunk = Chunk.objects.filter(student_lines__gte=5)[0]
	rr_chunk.pk = None
예제 #3
0
# create a Semester
semester = Semester(subject=subject, semester="semester")
semester.save()
# create a Assignment
assignment = Assignment(semester=semester, name="assignment")
assignment.save()
# create 300  users that will become members of the semester
users = User.objects.exclude(username__contains="user").order_by('?').all()
for i in range(300):
	u = users[i%20]
	u.pk = None
	u.username = "******"+str(100+i)
	u.save()
semester_members = User.objects.filter(username__contains="user").order_by('?').all()
# create a SubmitMilestone
submit_milestone = SubmitMilestone(assignment=assignment,name="submit_milestone")
submit_milestone.save()
# create a ReviewMilestone
review_milestone = ReviewMilestone(assignment=assignment,submit_milestone=submit_milestone,name="review_milestone")
review_milestone.save()

chunk_to_copy = Chunk.objects.filter(student_lines__gte=5)[0]
file_to_copy = chunk_to_copy.file
# make all the users members of the class
# create a Submission for every member in the class
for m in semester_members:
	roles = [Member.STUDENT, Member.STUDENT, Member.TEACHER, Member.VOLUNTEER]
	member = Member(semester=semester,user=m,role=roles[m.id%4])
	# member = Member(semester=semester,user=m,role=Member.STUDENT)
	member.save()
	m.membership.add(member)