コード例 #1
0
ファイル: views.py プロジェクト: KITPraktomatTeam/Praktomat
def attestation_run_checker(request, attestation_id):
    if not (request.user.is_tutor or request.user.is_trainer or request.user.is_superuser):
        return access_denied(request)

    attestation = get_object_or_404(Attestation, pk=attestation_id)
    if not (attestation.author == request.user or request.user.is_trainer or request.user.is_superuser):
        return access_denied(request)

    if attestation.published:
        return access_denied(request)

    if not get_settings().attestation_allow_run_checkers:
        return access_denied(request)



    solution = attestation.solution
    check_solution(solution, True)
    return HttpResponseRedirect(reverse('edit_attestation', args=[attestation_id]))
コード例 #2
0
ファイル: views.py プロジェクト: serkandikmen/Praktomat
def attestation_run_checker(request, attestation_id):
    if not (request.user.is_tutor or request.user.is_trainer or request.user.is_superuser):
        return access_denied(request)

    attestation = get_object_or_404(Attestation, pk=attestation_id)
    if not (attestation.author == request.user or request.user.is_trainer or request.user.is_superuser):
        return access_denied(request)

    if attestation.published:
        return access_denied(request)

    if not get_settings().attestation_allow_run_checkers:
        return access_denied(request)



    solution = attestation.solution
    check_solution(solution, True)
    return HttpResponseRedirect(reverse('edit_attestation', args=[attestation_id]))
コード例 #3
0
	def run_all_checkers_on_latest_only_failed(self,request, queryset):
		""" Rerun all checker on latest of only failed solutions including "not always" action """
		from checker.basemodels import check_solution
		from accounts.models import User
		start = timer()
		count = 0
		for task in queryset:
			solution_queryset = task.solution_set
			final_solutions_queryset = solution_queryset.filter(final=True)
			finalusers = list(set(final_solutions_queryset.values('author').values_list('author', flat=True)))
			only_failed_solution_set = solution_queryset.exclude(author__in=finalusers)

			nonfinalusers = list( set(User.objects.all().values('id').values_list('id',flat=True)) - set(finalusers))
						
			for user in User.objects.filter(id__in=nonfinalusers) :
				users_only_failed_solution = only_failed_solution_set.filter(author=user).order_by('author','number') 
				ucount = int(users_only_failed_solution.count())
				if ucount :
					latest_only_failed_solution=users_only_failed_solution.latest('number')
					check_solution(latest_only_failed_solution,True)					
					count += 1
		end = timer()
		self.message_user(request, "%d users with only failed solutions were checked (%d seconds elapsed)." % (count, end-start))
コード例 #4
0
	def check_solution(self, run_secret = 0): 
		"""Builds and tests this solution."""
		from checker.basemodels import check_solution
		check_solution(self, run_secret)
コード例 #5
0
ファイル: views.py プロジェクト: serkandikmen/Praktomat
def solution_run_checker(request, solution_id):
    solution = Solution.objects.get(pk=solution_id)
    check_solution(solution, True)
    return HttpResponseRedirect(
        reverse('solution_detail_full', args=[solution_id]))
コード例 #6
0
ファイル: models.py プロジェクト: freundTech/Praktomat
 def check_solution(self, run_secret=0, debug_keep_tmp=False):
     """Builds and tests this solution."""
     from checker.basemodels import check_solution
     check_solution(self, run_secret, debug_keep_tmp)
コード例 #7
0
ファイル: views.py プロジェクト: ifrh/Praktomat
def solution_run_checker(request,solution_id):
	solution = Solution.objects.get(pk=solution_id)
	check_solution(solution,True)
	return HttpResponseRedirect(reverse('solution_detail_full', args=[solution_id]))
コード例 #8
0
	def run_all_uploadtime_checkers_on_all(self, request, queryset):
		from checker.basemodels import check_multiple
		from accounts.models import User
		from django.template import Context, loader
		from django.contrib.sites.requests import RequestSite
		from django.conf import settings
		from django.core.mail import send_mail
		from django.utils.translation import ugettext_lazy as _
		myRequestUser = User.objects.filter(id=request.user.id)
		allstart = timer()
	  	task_set = queryset
		for task in task_set:
			start = timer()
			#solutions = Solution.objects.filter(task=task.id).order_by('author', 'number')			
			solution_set = task.solution_set.order_by('author','number') 
			
			old_final_solution_set =  solution_set.filter(final=True)			
			users_with_old_final_solution = list(set(old_final_solution_set.values('author').values_list('author',flat = True)))
			
			for solution in old_final_solution_set:
				solution.final = False
				solution.accepted = False
				solution.save()
			
			print("rerun checkers ... wait much time ...")			
			#this takes many time !!!!
			if  solution_set.count() > 1 :
				check_multiple(solution_set,False)  # just run upload-time_checkers  ... should we ignore Testuploads?
			elif  solution_set.count() == 1 :
				check_solution(latest_only_failed_solution,False)
			
			new_accepted_solution_set = Solution.objects.filter(task=task.id , accepted=True , testupload=False ).order_by('author', 'number')
			users_with_accepted_solutions = list(set(
							 new_accepted_solution_set.values('author').values_list('author', flat=True)
							))
			

			for userid in users_with_accepted_solutions :
				new_final_solution = new_accepted_solution_set.filter(author = userid).latest('number')
				new_final_solution.final = True
				new_final_solution.save()
			
			
			new_final_solution_set =  new_accepted_solution_set.filter(final=True)
			users_with_final_solution =  list(set(new_final_solution_set.values('author').values_list('author',flat = True)))  
			
			users_missing_in_new_final_solution = list(set(users_with_old_final_solution) - set(users_with_final_solution))
			missing_users_in_new_final_solution_set = task.solution_set.filter(author__in=users_missing_in_new_final_solution).order_by('author','number') 	
			
			for userid in users_missing_in_new_final_solution :				
				user = User.objects.filter(id=userid)
				latestfailed_user_solution = missing_users_in_new_final_solution_set.filter(author=userid).latest('number') 
				# Send final solution lost email to current RequestUser tutor/trainer/superuser
				t = loader.get_template('solutions/submission_final_lost_email.html')
				c = {
					'protocol': request.is_secure() and "https" or "http",
					'domain': RequestSite(request).domain, 
					'site_name': settings.SITE_NAME,
					'solution': latestfailed_user_solution,
					'request_user': myRequestUser,
				}
				if request.user.email and latestfailed_user_solution.author.email:
					send_mail(_("[%s] lost final submission confirmation") % settings.SITE_NAME, t.render(Context(c)), None, [request.user.email, latestfailed_user_solution.author.email])
				elif request.user.email and not latestfailed_user_solution.author.email:
					send_mail(_("[%s] lost final submission confirmation") % settings.SITE_NAME, t.render(Context(c)), None, [request.user.email])				  
				elif not request.user.email and latestfailed_user_solution.author.email:
					send_mail(_("%s lost final submission confirmation") % settings.SITE_NAME, t.render(Context(c)), None, [latestfailed_user_solution.author.email])					
			end = timer()
			self.message_user(request, "Task %s : Checked %d authors lost their finals: LoopTimer: %d seconds elapsed "%(task.title, len(users_missing_in_new_final_solution),(end-start)),"warning")
		allend = timer()
		self.message_user(request, "%d Tasks rechecked : LoopTimer: %d seconds elapsed" % (task_set.count(),allend-allstart))
コード例 #9
0
 def check_solution(self, run_secret=0):
     """Builds and tests this solution."""
     from checker.basemodels import check_solution
     check_solution(self, run_secret)
コード例 #10
0
ファイル: models.py プロジェクト: KITPraktomatTeam/Praktomat
 def check_solution(self, run_secret = 0, debug_keep_tmp = False):
     """Builds and tests this solution."""
     from checker.basemodels import check_solution
     check_solution(self, run_secret, debug_keep_tmp)