Exemple #1
0
def run_test():
#    transaction.commit(using='test')

    ################################################################################################
    
    print
    print
    semester = Semester.objects.all()[0]
    print "testing assign_tasks for every member of semester:", semester
    print
    print "which review milestone would you like to perform a routing for?"
    # print "choose from one of the following:", [int(rm.id) for rm in list(ReviewMilestone.objects.all())]
    print "choose an id from one of the following:"
    for rm in list(ReviewMilestone.objects.all()):
        print str(int(rm.id))+":",rm.assignment.name
    review_milestone = ReviewMilestone.objects.get(id=int(raw_input()))
    print "review milestone selected:", review_milestone
    reviewers = list(User.objects.filter(membership__semester=review_milestone.assignment.semester))
    random.shuffle(reviewers)
    print "assigning reviewers... this may take a while--please be patient."
    l = len(reviewers)

    # assign every reviewer in the class
    for r in xrange(l):
        print "assigning reviewer", r, "out of", l
        rr.assign_tasks(review_milestone, reviewers[r])
    
    # ################################################################################################

    print 'look at the db to see changes, then press enter:'
    raw_input()
    print 'rolling back'
    # delete and recreate all ChunkReviews in this ReviewMilestone
    ChunkReview.objects.filter(chunk__file__submission__milestone=review_milestone.submit_milestone).delete()
Exemple #2
0
from django.db.models.query import prefetch_related_objects
from tasks.models import Task, app_settings
from chunks.models import Chunk, ReviewMilestone, SubmitMilestone, Assignment, Semester, Milestone, Submission, File
from accounts.models import Member
import random
import sys
import logging
import randomrouting.random_routing as rr

print
print "testing assign_tasks for every member of 6.005 - Spring 2013"
print "number of chunks with at least 1 student line:", Chunk.objects.filter(student_lines__gte=1).count()
print "number of chunks by rcm:", Chunk.objects.filter(student_lines__gte=1, pk__in=Chunk.objects.filter(file__submission__authors__username='******')).count()
review_milestone = ReviewMilestone.objects.get(pk=2)
print "review milestone:",review_milestone
reviewers = list(User.objects.filter(membership__semester=review_milestone.assignment.semester))
random.shuffle(reviewers)
print "members of 6.005 - Spring 2013:",[r.username for r in reviewers]
print
num_chunks = 0;
for r in reviewers:
  role = str(Member.objects.get(user=r,semester=review_milestone.assignment.semester).get_role_display())
  num_tasks_to_assign = rr.get_num_tasks_for_user(review_milestone, r)
  print "reviewer:",r,"("+role+" - needs "+str(num_tasks_to_assign)+" chunks)"
  print "num reviewable chunks:",len(rr.get_reviewable_chunks(review_milestone, r))
  chunks_to_assign = rr.assign_tasks(review_milestone, r, routing_algorithm='random', tasks_to_assign=None, simulate=False)
  print "chunks assigned:",[c['id'] for c in chunks_to_assign]
  num_chunks+=len(chunks_to_assign)
  print
print "total number of chunks assigned:",num_chunks
Exemple #3
0
rr_task3.save()

# There are 50 chunks that are a part of the fake SubmitMilestone
print "num chunks in caesar               :",Chunk.objects.count()
# None of the chunks are assigned to any reviewers
# None of the chunks have too few student lines
# None of the chunks are excluded from the review process
# None of the chunks were authored by anyone in the class
print "num chunks in fake SubmitMilestone :",Chunk.objects.filter(file__submission__milestone=rr_submit_milestone).count()
# All 50 chunks are reviewable by ANY reviewer in the class
print "num chunks reviewable by",user_in_class.username," :",len(rr.get_reviewable_chunks(rr_review_milestone, user_in_class))
print

# If I run the routing algorithm for one student in the class
print "assigning chunks to",user_in_class.username,"..."
assigned_chunks = rr.assign_tasks(rr_review_milestone,user_in_class,simulate=True)
rr_tasks = [Task(reviewer_id=user_in_class.id,chunk_id=c.id,milestone=rr_review_milestone,submission_id=c.file.submission.id) for c in assigned_chunks]
[t.save() for t in rr_tasks]
print "chunks assigned to",user_in_class.username,"       :",[c.id for c in assigned_chunks]
print

# Now 0 chunks are reviewable by the same reviewer
print "num chunks reviewable by",user_in_class.username," :",len(rr.get_reviewable_chunks(rr_review_milestone, user_in_class))
# If I run the routing algorithm again for the same student
print "assigning chunks to",user_in_class.username,"..."
assigned_chunks = rr.assign_tasks(rr_review_milestone,user_in_class,simulate=True)
rr_tasks2 = [Task(reviewer_id=user_in_class.id,chunk_id=c.id,milestone=rr_review_milestone,submission_id=c.file.submission.id) for c in assigned_chunks]
[t.save() for t in rr_tasks2]
print "chunks assigned to",user_in_class.username,"       :",[c.id for c in assigned_chunks]
print