本文整理汇总了Python中Elaboration.models.Elaboration.save方法的典型用法代码示例。如果您正苦于以下问题:Python Elaboration.save方法的具体用法?Python Elaboration.save怎么用?Python Elaboration.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elaboration.models.Elaboration
的用法示例。
在下文中一共展示了Elaboration.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_elaborations
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def create_elaborations(self):
self.elaborations = []
for user in self.users:
elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test_text",
submission_time=datetime.now())
elaboration.save()
self.elaborations.append(elaboration)
示例2: test_get_elaborations
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_get_elaborations(self):
assert len(self.challenge.get_elaborations()) == 0
user = self.users[0]
elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test")
elaboration.save()
assert len(self.challenge.get_elaborations()) == 1
assert elaboration in self.challenge.get_elaborations()
示例3: test_notification_too_soon
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
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
示例4: test_submitted_by_user
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_submitted_by_user(self):
user = self.users[0]
elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test")
elaboration.save()
assert not self.challenge.submitted_by_user(user)
elaboration.submission_time = datetime.now()
elaboration.save()
assert self.challenge.submitted_by_user(user)
示例5: test_is_started
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_is_started(self):
user = self.users[0]
elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="")
elaboration.save()
assert self.challenge.is_started(user) is False
elaboration.elaboration_text="test"
elaboration.save()
assert self.challenge.is_started(user) is True
示例6: test_final_challenge_enabled
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_final_challenge_enabled(self):
challenge1 = self.challenge
self.create_challenge()
challenge2 = self.challenge
challenge2.prerequisite = challenge1
challenge2.save()
user1 = self.users[0]
user2 = self.users[1]
user3 = self.users[2]
user4 = self.users[3]
elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test",
submission_time=datetime.now())
elaboration1.save()
elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test",
submission_time=datetime.now())
elaboration2.save()
elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test",
submission_time=datetime.now())
elaboration3.save()
elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test",
submission_time=datetime.now())
elaboration4.save()
Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
assert not challenge2.is_enabled_for_user(user1)
Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2,
appraisal=Review.SUCCESS).save()
Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3,
appraisal=Review.SUCCESS).save()
assert challenge2.is_enabled_for_user(user1)
示例7: test_status_not_submitted
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_status_not_submitted(self):
challenge1 = self.challenge
self.create_challenge()
challenge2 = self.challenge
challenge2.prerequisite = challenge1
challenge2.save()
user = self.users[0]
assert challenge1.get_status(user) == Challenge.NOT_STARTED
elaboration = Elaboration(challenge=challenge1, user=user, elaboration_text="test")
elaboration.save()
assert challenge1.is_enabled_for_user(user)
assert challenge1.get_status(user) == Challenge.NOT_SUBMITTED
assert not challenge2.is_enabled_for_user(user)
assert challenge2.get_status(user) == Challenge.NOT_ENABLED
示例8: test_already_submitted_challenges_are_enabled
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_already_submitted_challenges_are_enabled(self):
challenge1 = self.challenge
self.create_challenge()
challenge2 = self.challenge
challenge2.prerequisite = challenge1
challenge2.save()
user = self.users[0]
assert not challenge2.is_enabled_for_user(user)
elaboration = Elaboration(challenge=challenge2, user=user, elaboration_text="test")
elaboration.save()
assert not challenge2.is_enabled_for_user(user)
elaboration.submission_time = datetime.now()
elaboration.save()
assert challenge2.is_enabled_for_user(user)
示例9: test_get_points
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_get_points(self):
user = self.users[0]
tutor = self.users[1]
tutor.staff = True
tutor.save()
assert self.stack.get_points_earned(user) == 0
elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test elaboration",
submission_time=datetime.now())
elaboration.save()
evaluation = Evaluation(submission=elaboration, tutor=tutor, evaluation_text="test_evaluation",
submission_time=datetime.now())
for points in range(10):
evaluation.evaluation_points = points
evaluation.save()
assert self.stack.get_points_earned(user) == points
示例10: test_is_evaluated
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_is_evaluated(self):
user = self.users[0]
tutor = self.users[1]
tutor.staff = True
tutor.save()
assert self.stack.is_evaluated(user) is False
elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test elaboration",
submission_time=datetime.now())
elaboration.save()
evaluation = Evaluation(submission=elaboration, tutor=tutor, evaluation_text="test_evaluation")
evaluation.save()
assert self.stack.is_evaluated(user) is False
evaluation.submission_time = datetime.now()
evaluation.evaluation_points = 10
evaluation.save()
assert self.stack.is_evaluated(user) is True
示例11: test_status_final_challenge
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_status_final_challenge(self):
challenge1 = self.challenge
self.create_challenge()
challenge2 = self.challenge
challenge2.prerequisite = challenge1
challenge2.save()
user1 = self.users[0]
elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test",
submission_time=datetime.now())
elaboration1.save()
user2 = self.users[1]
elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test",
submission_time=datetime.now())
elaboration2.save()
user3 = self.users[2]
elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test",
submission_time=datetime.now())
elaboration3.save()
user4 = self.users[3]
elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test",
submission_time=datetime.now())
elaboration4.save()
Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
assert challenge1.get_status(user1) == Challenge.DONE_MISSING_PEER_REVIEW
assert challenge2.get_status(user1) == Challenge.NOT_ENABLED
Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2,
appraisal=Review.SUCCESS).save()
Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3,
appraisal=Review.SUCCESS).save()
assert challenge1.get_status(user1) == Challenge.DONE_PEER_REVIEWED
assert challenge2.get_status(user1) == Challenge.NOT_STARTED
final_elaboration = Elaboration(challenge=challenge2, user=user1, elaboration_text="test",
submission_time=datetime.now())
final_elaboration.save()
assert challenge2.get_status(user1) == Challenge.WAITING_FOR_EVALUATION
tutor = user4
tutor.staff = True
tutor.save()
Evaluation(submission=final_elaboration, tutor=tutor, evaluation_text="test evaluation", evaluation_points=10,
submission_time=datetime.now()).save()
assert challenge2.get_status(user1) == Challenge.EVALUATED
示例12: test_status_blocked_bad_review_nothing
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_status_blocked_bad_review_nothing(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()
user1 = self.users[0]
user2 = self.users[1]
user3 = self.users[2]
user4 = self.users[3]
elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test",
submission_time=datetime.now())
elaboration1.save()
elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test",
submission_time=datetime.now())
elaboration2.save()
elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test",
submission_time=datetime.now())
elaboration3.save()
elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test",
submission_time=datetime.now())
elaboration4.save()
assert not challenge2.is_enabled_for_user(user1)
assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING
assert challenge2.get_status(user1) == Challenge.NOT_ENABLED
bad_review = Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2,
appraisal=Review.NOTHING)
bad_review.save()
assert not challenge2.is_enabled_for_user(user1)
assert challenge1.get_status(user1) == Challenge.BLOCKED_BAD_REVIEW
assert challenge2.get_status(user1) == Challenge.NOT_ENABLED
bad_review.appraisal = Review.SUCCESS
bad_review.save()
Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
assert challenge1.has_enough_user_reviews(user1)
assert challenge1.get_status(user1) == Challenge.DONE_MISSING_PEER_REVIEW
assert challenge2.is_enabled_for_user(user1)
assert challenge2.get_status(user1) == Challenge.NOT_STARTED
bad_review.appraisal = Review.NOTHING
bad_review.save()
assert challenge2.is_enabled_for_user(user1)
assert challenge2.get_status(user1) == Challenge.NOT_STARTED
示例13: test_get_review_written_by_user
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_get_review_written_by_user(self):
challenge1 = self.challenge
self.create_challenge()
challenge2 = self.challenge
challenge2.prerequisite = challenge1
challenge2.save()
user1 = self.users[0]
elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test",
submission_time=datetime.now())
elaboration1.save()
user2 = self.users[1]
elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test",
submission_time=datetime.now())
elaboration2.save()
user3 = self.users[2]
elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test",
submission_time=datetime.now())
elaboration3.save()
user4 = self.users[3]
elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test",
submission_time=datetime.now())
elaboration4.save()
assert len(challenge1.get_reviews_written_by_user(user1)) == 0
review1 = Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS)
review1.save()
assert len(challenge1.get_reviews_written_by_user(user1)) == 1
assert review1 in challenge1.get_reviews_written_by_user(user1)
review2 = Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS)
review2.save()
assert len(challenge1.get_reviews_written_by_user(user1)) == 2
assert review1 in challenge1.get_reviews_written_by_user(user1)
assert review2 in challenge1.get_reviews_written_by_user(user1)
review3 = Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS)
review3.save()
assert len(challenge1.get_reviews_written_by_user(user1)) == 3
assert review1 in challenge1.get_reviews_written_by_user(user1)
assert review2 in challenge1.get_reviews_written_by_user(user1)
assert review3 in challenge1.get_reviews_written_by_user(user1)
示例14: test_status_done_missing_peer_review
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_status_done_missing_peer_review(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()
user1 = self.users[0]
user2 = self.users[1]
user3 = self.users[2]
user4 = self.users[3]
elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test",
submission_time=datetime.now())
elaboration1.save()
elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test",
submission_time=datetime.now())
elaboration2.save()
elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test",
submission_time=datetime.now())
elaboration3.save()
elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test",
submission_time=datetime.now())
elaboration4.save()
Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
assert challenge1.get_status(user1) == Challenge.DONE_MISSING_PEER_REVIEW
Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2,
appraisal=Review.SUCCESS).save()
assert challenge1.get_status(user1) == Challenge.DONE_MISSING_PEER_REVIEW
Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3,
appraisal=Review.SUCCESS).save()
assert challenge1.get_status(user1) == Challenge.DONE_MISSING_PEER_REVIEW
示例15: test_if_stack_blocked_challenge_is_not_enabled_nothing
# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import save [as 别名]
def test_if_stack_blocked_challenge_is_not_enabled_nothing(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()
user1 = self.users[0]
user2 = self.users[1]
user3 = self.users[2]
user4 = self.users[3]
elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test",
submission_time=datetime.now())
elaboration1.save()
elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test",
submission_time=datetime.now())
elaboration2.save()
elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test",
submission_time=datetime.now())
elaboration3.save()
elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test",
submission_time=datetime.now())
elaboration4.save()
Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS).save()
assert challenge2.is_enabled_for_user(user1)
Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2,
appraisal=Review.NOTHING).save()
# nothing should not block a user from working
assert challenge2.is_enabled_for_user(user1)