本文整理汇总了Python中Challenge.models.Challenge类的典型用法代码示例。如果您正苦于以下问题:Python Challenge类的具体用法?Python Challenge怎么用?Python Challenge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Challenge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_stack
def test_get_stack(self):
challenge = Challenge(
title='test_title',
subtitle='test_subtitle',
description='test_description',
course=self.course
)
challenge.save()
assert challenge.get_stack() is None
assert self.challenge.get_stack() == self.stack
示例2: result_elabs_nonfinal
def result_elabs_nonfinal(request):
"""
username (mnr) TAB elabID TAB challenge-title TAB challenge-ID TAB creation time TAB submission time TAB
reviewID 1 TAB review-verdict 1 TAB review-creation-date 1 TAB review-submission-date 1 TAB reviewID 2 TAB
review-verdict 2 TAB review-creation-date 2 TAB review-submission-date 2 TAB usw.
"""
final_challenge_ids = Challenge.get_final_challenge_ids()
elabs = Elaboration.objects.exclude(challenge__id__in=final_challenge_ids).prefetch_related()
s = ""
for elab in elabs:
s += "\t".join(["{}"] * 6).format(
str(elab.user.matriculation_number),
str(elab.id),
elab.challenge.title,
str(elab.challenge.id),
time_to_unix_string(elab.creation_time),
time_to_unix_string(elab.submission_time)
)
for review in Review.objects.filter(elaboration=elab):
s += "\t" + str(review.id)
s += "\t" + str(review.appraisal)
s += "\t" + time_to_unix_string(review.creation_time)
s += "\t" + time_to_unix_string(review.submission_time)
s += "\n"
return HttpResponse(s, mimetype="text/plain; charset=utf-8")
示例3: final_tasks
def final_tasks(course):
final_task_ids = Challenge.get_course_final_challenge_ids(course)
result = []
for id in final_task_ids:
data = {}
data['id'] = id
data['title'] = (
Challenge.objects.get(pk=id).title
)
a = Challenge.objects.get(pk=id).get_stack()
data['challenge'] = (
Challenge.objects.get(pk=id).get_stack().title
)
data['evaluated'] = (
Evaluation.objects
.filter(submission__challenge__course=course)
.filter(submission_time__isnull=False)
.filter(submission__challenge__id=id)
.count()
)
data['not_evaluated'] = (
Elaboration.get_top_level_tasks(course)
.filter(challenge__id=id)
.count()
)
result.append(data)
return result
示例4: get_extra_reviews
def get_extra_reviews(user, course):
from Challenge.models import Challenge
user_submitted_challenge_ids = Elaboration.objects.filter(user_id=user.id, submission_time__isnull=False).values_list('challenge_id', flat=True)
final_challenge_ids = Challenge.get_course_final_challenge_ids(course)
already_written_review_elaboration_ids = Review.objects.filter(reviewer_id=user.id).values_list('elaboration_id', flat=True)
missing_reviews = (
Elaboration.objects
.annotate(num_reviews=Count('review'))
.filter(challenge__id__in=user_submitted_challenge_ids,
submission_time__isnull=False,
user__is_staff=False,
challenge__course=course,
num_reviews__lt=2)
.exclude(challenge__id__in=final_challenge_ids)
.exclude(id__in=already_written_review_elaboration_ids)
.exclude(user=user)
.order_by('num_reviews', 'submission_time')
)
missing_reviews = list(missing_reviews)
missing_reviews.sort(key=lambda e: e.user.review_karma(course))
# Add Open Reviews to top of list
has_open_review = False
open_reviews = Review.objects.filter(submission_time__isnull=True, reviewer=user)
for review in open_reviews:
print(review.id)
has_open_review = True
missing_reviews = [review.elaboration] + missing_reviews
return { 'has_open_review': has_open_review, 'missing_reviews': missing_reviews[:7] }
示例5: get_final_evaluation_top_level_tasks
def get_final_evaluation_top_level_tasks(course):
# final_top_level_tasks = []
# top_level_tasks = Elaboration.get_top_level_tasks(course)
# for elaboration in top_level_tasks:
#
# cache_key = str(elaboration.user.id) + '_submitted_points'
# if (cache.has_key(cache_key)):
# submitted_points = cache.get(cache_key)
# else:
# submitted_points = elaboration.user.total_points_submitted(course)
# cache.set(cache_key, submitted_points, 60*30)
#
# if submitted_points >= 57:
# final_top_level_tasks.append(elaboration)
#
# return final_top_level_tasks
from Challenge.models import Challenge
final_challenge_ids = Challenge.get_course_final_challenge_ids(course)
possible_user_ids = CourseUserRelation.objects.filter(course=course, positive_completion_possible=True).values_list('user_id', flat=True)
final_top_level_challenges = (
Elaboration.objects
.filter(challenge__id__in=final_challenge_ids, submission_time__isnull=False, user__is_staff=False, user_id__in=possible_user_ids)
.annotate(evaluated=Min('evaluation__submission_time'))
.filter(evaluated=None)
.order_by('-submission_time')
)
return final_top_level_challenges
示例6: handle_noargs
def handle_noargs(self, **options):
"""
username (mnr) TAB elabID TAB challenge-title TAB challenge-ID TAB creation time TAB submission time TAB
reviewID 1 TAB review-verdict 1 TAB review-creation-date 1 TAB review-submission-date 1 TAB reviewID 2 TAB
review-verdict 2 TAB review-creation-date 2 TAB review-submission-date 2 TAB usw.
"""
final_challenge_ids = Challenge.get_final_challenge_ids()
elabs = Elaboration.objects.exclude(challenge__id__in=final_challenge_ids).prefetch_related()
for elab in elabs:
s = "\t".join(["{}"] * 6).format(
elab.user.username + " (" + str(elab.user.matriculation_number) + ")",
str(elab.id),
elab.challenge.title,
str(elab.challenge.id),
str(elab.creation_time),
str(elab.submission_time)
)
for review in Review.objects.filter(elaboration=elab):
s += "\t" + str(review.id)
s += "\t" + str(review.appraisal)
s += "\t" + str(review.creation_time)
s += "\t" + str(review.submission_time)
print(s)
示例7: questions
def questions(request, course_short_title=None):
course = Course.get_or_raise_404(short_title=course_short_title)
challenges = Challenge.get_questions(course)
# store selected challenges in session
request.session["challenges"] = serializers.serialize("json", challenges)
# store selected elaborations in session
elaborations = []
request.session["elaborations"] = elaborations
request.session["selection"] = "questions"
request.session["count"] = len(challenges)
return render_to_response(
"evaluation.html",
{
"challenges": challenges,
"overview": render_to_string(
"questions.html", {"challenges": challenges, "course": course}, RequestContext(request)
),
"count_questions": request.session.get("count", "0"),
"stabilosiert_questions": "stabilosiert",
"selection": request.session["selection"],
"course": course,
},
context_instance=RequestContext(request),
)
示例8: create_challenge
def create_challenge(self):
self.challenge = Challenge(
title='test_title',
subtitle='test_subtitle',
description='test_description',
course=self.course,
)
self.challenge.save()
示例9: students_with_at_least_one_submission
def students_with_at_least_one_submission(course):
final_challenge_ids = Challenge.get_final_challenge_ids()
elaborations = (
Elaboration.objects
.filter(challenge__course=course)
.filter(challenge__id__in=final_challenge_ids)
.filter(submission_time__isnull=False)
.values_list('user__id', flat=True)
)
elaborations = list(set(elaborations)) # make user ids distinct
return len(elaborations)
示例10: get_top_level_tasks
def get_top_level_tasks(course):
from Challenge.models import Challenge
final_challenge_ids = Challenge.get_course_final_challenge_ids(course)
top_level_challenges = (
Elaboration.objects
.filter(challenge__id__in=final_challenge_ids, submission_time__isnull=False, user__is_staff=False)
.annotate(evaluated=Min('evaluation__submission_time'))
.filter(evaluated=None)
.order_by('-submission_time')
)
return top_level_challenges
示例11: test_notification_too_soon
def test_notification_too_soon(self):
challenge1 = self.challenge
challenge2 = Challenge(
course=self.course,
prerequisite=challenge1,
)
challenge2.save()
challenge3 = Challenge(
course=self.course,
prerequisite=challenge2,
)
challenge3.save()
stack = Stack(course=self.course)
stack.save()
StackChallengeRelation(stack=stack, challenge=challenge1).save()
StackChallengeRelation(stack=stack, challenge=challenge2).save()
StackChallengeRelation(stack=stack, challenge=challenge3).save()
elab1 = challenge1.get_elaboration(self.users[0])
elab2 = Elaboration(challenge=challenge2, user=self.users[0])
elab2.save()
assert stack.has_enough_peer_reviews(self.users[0]) is False
Review(elaboration=elab2, reviewer=self.users[1], appraisal='S', submission_time=datetime.now()).save()
Review(elaboration=elab2, reviewer=self.users[2], appraisal='S', submission_time=datetime.now()).save()
assert stack.has_enough_peer_reviews(self.users[0]) is False
Review(elaboration=elab1, reviewer=self.users[1], appraisal='S', submission_time=datetime.now()).save()
Review(elaboration=elab1, reviewer=self.users[2], appraisal='S', submission_time=datetime.now()).save()
assert stack.has_enough_peer_reviews(self.users[0]) is True
示例12: get_missing_reviews
def get_missing_reviews(course):
from Challenge.models import Challenge
final_challenge_ids = Challenge.get_course_final_challenge_ids(course)
missing_reviews = (
Elaboration.objects
.filter(submission_time__lte=datetime.now() - timedelta(days=1), user__is_staff=False,
challenge__course=course)
.annotate(num_reviews=Count('review'))
.exclude(challenge__id__in=final_challenge_ids)
)
final_elaborations = []
for elaboration in missing_reviews:
if elaboration.num_reviews < 2:
final_elaborations.append(elaboration.id)
else:
if Review.objects.filter(elaboration=elaboration, submission_time__isnull=False).count() < 2:
final_elaborations.append(elaboration.id)
missing_reviews = Elaboration.objects.filter(id__in=final_elaborations)
return missing_reviews
示例13: questions
def questions(request, course_short_title=None):
course = Course.get_or_raise_404(short_title=course_short_title)
challenges = Challenge.get_questions(course)
# store selected challenges in session
request.session['challenges'] = serializers.serialize('json', challenges)
# store selected elaborations in session
elaborations = []
request.session['elaborations'] = elaborations
request.session['selection'] = 'questions'
request.session['count'] = len(challenges)
return render_to_response('evaluation.html',
{'challenges': challenges,
'overview': render_to_string('questions.html', {'challenges': challenges, 'course': course},
RequestContext(request)),
'count_questions': request.session.get('count', '0'),
'stabilosiert_questions': 'stabilosiert',
'selection': request.session['selection'],
'course': course
},
context_instance=RequestContext(request))
示例14: StackTest
class StackTest(TestCase):
def setUp(self):
self.create_test_users(4)
self.create_course()
self.create_stack()
self.create_challenge()
self.create_review_question()
def create_test_user(self, username):
user = AuroraUser(username=username)
user.email = '%[email protected]' % username
user.first_name = 'Firstname_%s' % username
user.last_name = 'Lastname_%s' % username
user.nickname = 'Nickname_%s' % username
user.is_staff = False
user.is_superuser = False
password = username
user.set_password(password)
user.save()
return user
def create_test_users(self, amount):
self.users = []
for i in range(amount):
self.users.append(self.create_test_user("s%s" % i))
def create_course(self):
self.course = Course(
title='test_title',
short_title='test_short_title',
description='test_description',
course_number='test_course_number',
)
self.course.save()
for user in self.users:
CourseUserRelation(course=self.course, user=user).save()
def create_stack(self):
self.stack = Stack(title="test stack", description="test description", course=self.course)
self.stack.save()
def create_challenge(self):
self.challenge = Challenge(
title='test_title',
subtitle='test_subtitle',
description='test_description',
course=self.course,
)
self.challenge.save()
StackChallengeRelation(stack=self.stack, challenge=self.challenge).save()
def create_review_question(self):
self.review_question = ReviewQuestion(
challenge=self.challenge,
order=1,
text="Can you find any additional material not included in this submission?"
)
self.review_question.save()
def create_review(self, elaboration, reviewer):
Review(elaboration=elaboration, submission_time=datetime.now(), reviewer=reviewer, appraisal='S').save()
def test_get_challenges(self):
challenge1 = self.challenge
assert challenge1 in self.stack.get_challenges()
self.create_challenge()
challenge2 = self.challenge
challenge2.prerequisite = challenge1
challenge2.save()
assert challenge1 in self.stack.get_challenges()
assert challenge2 in self.stack.get_challenges()
self.create_challenge()
challenge3 = self.challenge
challenge3.prerequisite = challenge2
challenge3.save()
assert challenge1 in self.stack.get_challenges()
assert challenge2 in self.stack.get_challenges()
assert challenge3 in self.stack.get_challenges()
def test_final_challenge(self):
challenge1 = self.challenge
self.create_challenge()
challenge2 = self.challenge
challenge2.prerequisite = challenge1
challenge2.save()
self.create_challenge()
challenge3 = self.challenge
challenge3.prerequisite = challenge2
challenge3.save()
assert self.stack.get_final_challenge().id is challenge3.id
def test_first_challenge(self):
challenge1 = self.challenge
self.create_challenge()
challenge2 = self.challenge
challenge2.prerequisite = challenge1
challenge2.save()
self.create_challenge()
challenge3 = self.challenge
challenge3.prerequisite = challenge2
#.........这里部分代码省略.........
示例15: import_data
#.........这里部分代码省略.........
description='GSI Description',
course_number='123.456',
start_date=date.today() - timedelta(days=100),
end_date=date.today() + timedelta(days=100),
)
gsi.save()
print('adding course hci')
hci = Course(
title='Human Computer Interaction',
short_title='hci',
description='HCI Description',
course_number='123.457',
start_date=date.today() - timedelta(days=100),
end_date=date.today() + timedelta(days=100),
)
hci.save()
# add faq
print('adding faq')
faqs = [
(
Faq(
question="Wie unterscheidet sich der Modus zu dem des Vorjahres?",
answer="So gut wie gar nicht. Aurora wurde überarbeitet, viele Bugs wurden behoben, und es wurden einige "
"kleine Verbesserungen implementiert. Wir haben aber noch Pläne, über das Semester hinweg ein paar "
"neue Dinge zu versuchen.",
order=0
),
[hci, gsi]
),
(
Faq(
question="Kann ich einfach irgendwelche Challenges machen, bis ich genug Punkte habe?",
answer="Nein. Sie müssen für eine positive Note aus jeder der vier Kategorien (s.u.) mindestens "
"eine Challenge absolvieren. Ansonsten steht Ihnen frei, was sie wann machen.",
order=1
),
[hci, gsi]
),
(
Faq(
question="Was sind die 4 Kategorien in BHCI?",
answer="<ul><li>Kategorie 1: User-centered design + design basics (B1cX)</li>"
"<li>Kategorie 2: Methoden (B2cX)</li>"
"<li>Kategorie 3: psycholog. Grundlagen, Evaluation (B3cX)</li>"
"<li>Kategorie 4: Prototyping, Beyond the desktop (B4cX)</li></ul>",
order=2
),
[hci]
),
(
Faq(
question="Was sind die 4 Kategorien in GSI?",
answer="<ul><li>Kategorie 1: Praxis (G1cX)</li>"
"<li>Kategorie 2: IT-Branche (G2cX)</li>"
"<li>Kategorie 3: Ideen (G3cX)</li>"
"<li>Kategorie 4: Gesellschaft (G4cX)</li></ul>",
order=2
),
[gsi]
),
(
Faq(
question="Wann ist die Deadline für (eine/diese/alle) Challenges?",
answer="Für eine positive Note müssen sie bis Ende des Semesters (Fr 3.7., 23:59) ausreichend Punkte "