当前位置: 首页>>代码示例>>Python>>正文


Python models.Elaboration类代码示例

本文整理汇总了Python中Elaboration.models.Elaboration的典型用法代码示例。如果您正苦于以下问题:Python Elaboration类的具体用法?Python Elaboration怎么用?Python Elaboration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Elaboration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_elaborations

 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()
开发者ID:Bernhard---H,项目名称:aurora,代码行数:7,代码来源:tests.py

示例2: create_elaborations

 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)
开发者ID:Bernhard---H,项目名称:aurora,代码行数:7,代码来源:tests.py

示例3: 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
开发者ID:Bernhard---H,项目名称:aurora,代码行数:28,代码来源:tests.py

示例4: awesome

def awesome(request, course_short_title=None):
    course = Course.get_or_raise_404(short_title=course_short_title)
    selected_challenge = request.session.get('selected_challenge', 'task...')
    if selected_challenge != 'task...':
        selected_challenge = selected_challenge[:(selected_challenge.rindex('(') - 1)]
        challenge = Challenge.objects.get(title=selected_challenge, course=course)
        elaborations = Elaboration.get_awesome_challenge(course, challenge)
    else:
        elaborations = Elaboration.get_awesome(course)

    # sort elaborations by submission time
    if type(elaborations) == list:
        elaborations.sort(key=lambda elaboration: elaboration.submission_time)
    else:
        elaborations = elaborations.order_by('submission_time')

    # store selected elaborations in session
    request.session['elaborations'] = serializers.serialize('json', elaborations)
    request.session['selection'] = 'awesome'
    request.session['selected_challenge'] = 'task...'
    request.session['count'] = len(elaborations)

    return render_to_response('evaluation.html',
                              {'overview': render_to_string('overview.html', {'elaborations': elaborations, 'course': course},
                                                            RequestContext(request)),
                               'count_awesome': request.session.get('count', '0'),
                               'selected_task': selected_challenge,
                               'stabilosiert_awesome': 'stabilosiert',
                               'selection': request.session['selection'],
                               'course': course
                              },
                              context_instance=RequestContext(request))
开发者ID:Bernhard---H,项目名称:aurora,代码行数:32,代码来源:views.py

示例5: test_status_not_submitted

 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
开发者ID:Bernhard---H,项目名称:aurora,代码行数:14,代码来源:tests.py

示例6: test_get_points

 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
开发者ID:Bernhard---H,项目名称:aurora,代码行数:15,代码来源:tests.py

示例7: final_evaluation_new

def final_evaluation_new(request, course_short_title=None):
    course = Course.get_or_raise_404(short_title=course_short_title)
    elaborations = Elaboration.get_final_evaluation_top_level_tasks(course)

    # sort elaborations by submission time
    if type(elaborations) == list:
        elaborations.sort(key=lambda elaboration: elaboration.submission_time)
    else:
        elaborations = elaborations.order_by('submission_time')

    # store selected elaborations in session
    request.session['elaborations'] = serializers.serialize(
        'json', elaborations)
    request.session['selection'] = 'final_evaluation_new'
    request.session['final_evaluation_count'] = len(elaborations)

    return render_to_response('evaluation.html',
                              {'overview': render_to_string('overview_new.html', {'elaborations': elaborations, 'course': course},
                                                            RequestContext(request)),
                               'count_final_evaluation_new': request.session.get('final_evaluation_count', '0'),
                               'stabilosiert_final_evaluation_new': 'stabilosiert',
                               'selection': request.session['selection'],
                               'course': course
                               },
                              context_instance=RequestContext(request))
开发者ID:martflu,项目名称:aurora,代码行数:25,代码来源:views.py

示例8: create_context_review

def create_context_review(request):
    data = {}
    if 'id' in request.GET:
        user = request.user
        challenge = Challenge.objects.get(pk=request.GET.get('id'))
        if not challenge.is_enabled_for_user(user):
            raise Http404
        if challenge.has_enough_user_reviews(user):
            raise Http404
        if not challenge.submitted_by_user(user):
            raise Http404
        review = Review.get_open_review(challenge, user)
        if not review:
            review_candidate = Elaboration.get_review_candidate(challenge, user)
            if review_candidate:
                review = Review(elaboration=review_candidate['candidate'], reviewer=user, chosen_by=review_candidate['chosen_by'])
                review.save()
            else:
                return data
        data['review'] = review
        data['stack_id'] = challenge.get_stack().id
        review_questions = ReviewQuestion.objects.filter(challenge=challenge).order_by("order")

        author_questions = [question for question in review_questions if question.visible_to_author == True]
        staff_questions  = [question for question in review_questions if question.visible_to_author == False]

        data['questions'] = review_questions
        data['author_questions'] = author_questions
        data['staff_questions'] = staff_questions

        extra_review_question_present = len(review.elaboration.extra_review_question) > 0
        data['extra_review_question_present'] = extra_review_question_present


    return data
开发者ID:martflu,项目名称:aurora,代码行数:35,代码来源:views.py

示例9: missing_reviews

def missing_reviews(request, course_short_title=None):
    course = Course.get_or_raise_404(short_title=course_short_title)
    elaborations = Elaboration.get_missing_reviews(course)

    # sort elaborations by submission time
    if type(elaborations) == list:
        elaborations.sort(key=lambda elaboration: elaboration.submission_time)
    else:
        elaborations = elaborations.order_by("submission_time")

    # store selected elaborations in session
    request.session["elaborations"] = serializers.serialize("json", elaborations)
    request.session["selection"] = "missing_reviews"
    request.session["count"] = len(elaborations)

    return render_to_response(
        "evaluation.html",
        {
            "overview": render_to_string(
                "overview.html", {"elaborations": elaborations, "course": course}, RequestContext(request)
            ),
            "count_missing_reviews": request.session.get("count", "0"),
            "stabilosiert_missing_reviews": "stabilosiert",
            "selection": request.session["selection"],
            "course": course,
        },
        context_instance=RequestContext(request),
    )
开发者ID:flozzone,项目名称:aurora,代码行数:28,代码来源:views.py

示例10: complaints

def complaints(request, course_short_title=None):
    course = Course.get_or_raise_404(short_title=course_short_title)
    elaborations = list(Elaboration.get_complaints(course))

    # sort elaborations by last comment time
    elaborations.sort(key=lambda elaboration: elaboration.get_last_post_date())

    # store selected elaborations in session
    request.session["elaborations"] = serializers.serialize("json", elaborations)
    request.session["selection"] = "complaints"
    request.session["count"] = len(elaborations)

    return render_to_response(
        "evaluation.html",
        {
            "overview": render_to_string(
                "overview.html",
                {"elaborations": elaborations, "course": course, "complaints": "true"},
                RequestContext(request),
            ),
            "count_complaints": request.session.get("count", "0"),
            "stabilosiert_complaints": "stabilosiert",
            "selection": request.session["selection"],
            "course": course,
        },
        context_instance=RequestContext(request),
    )
开发者ID:flozzone,项目名称:aurora,代码行数:27,代码来源:views.py

示例11: 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
开发者ID:martflu,项目名称:aurora,代码行数:28,代码来源:views.py

示例12: create_context_review

def create_context_review(request):
    data = {}
    if "id" in request.GET:
        user = RequestContext(request)["user"]
        challenge = Challenge.objects.get(pk=request.GET.get("id"))
        if not challenge.is_enabled_for_user(user):
            raise Http404
        if challenge.has_enough_user_reviews(user):
            raise Http404
        if not challenge.submitted_by_user(user):
            raise Http404
        review = Review.get_open_review(challenge, user)
        if not review:
            # number of hours needed to pass until elaboration is applicable as candidate
            offset = randint(ReviewConfig.get_candidate_offset_min(), ReviewConfig.get_candidate_offset_max())
            review_candidate = Elaboration.get_review_candidate(challenge, user, offset)
            if review_candidate:
                review = Review(elaboration=review_candidate, reviewer=user)
                review.save()
            else:
                return data
        data["review"] = review
        data["stack_id"] = challenge.get_stack().id
        review_questions = ReviewQuestion.objects.filter(challenge=challenge).order_by("order")
        data["questions"] = review_questions
    return data
开发者ID:flozzone,项目名称:aurora,代码行数:26,代码来源:views.py

示例13: test_is_evaluated

 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
开发者ID:Bernhard---H,项目名称:aurora,代码行数:16,代码来源:tests.py

示例14: search

def search(request, course_short_title=None):
    course = Course.get_or_raise_404(short_title=course_short_title)

    selected_challenge = request.POST['selected_challenge']
    selected_user = request.POST['selected_user'].split()[0]
    selected_tag = request.POST['selected_tag']

    challenges = []
    if(selected_challenge != 'task...'):
        challenges = Challenge.objects.filter(title=selected_challenge[:(
            request.POST['selected_challenge'].rindex('(') - 1)], course=course)
    else:
        challenges = Challenge.objects.filter(course=course)

    user = []
    if(selected_user != 'user...'):
        user = AuroraUser.objects.filter(username=selected_user)
        request.session['display_points'] = "true"
    else:
        user = AuroraUser.objects.all()
        request.session['display_points'] = "false"

    if(selected_tag != 'tag...'):
        aurorauser_ct = ContentType.objects.get_for_model(AuroraUser)
        tagged_items = TaggedItem.objects.filter(
            content_type=aurorauser_ct, tag__name=selected_tag)
        tagged_user_ids = []
        for ti in tagged_items:
            if not tagged_user_ids.__contains__(ti.content_object):
                tagged_user_ids.append(ti.content_object.id)

        tagged_user = AuroraUser.objects.filter(id__in=tagged_user_ids)
        user = user & tagged_user

    elaborations = []
    if Elaboration.search(challenges, user):
        elaborations = list(Elaboration.search(challenges, user))

    # store selected elaborations in session
    request.session['elaborations'] = serializers.serialize(
        'json', elaborations)
    request.session['selection'] = 'search'
    request.session['selected_challenge'] = selected_challenge
    request.session['selected_user'] = selected_user
    request.session['selected_tag'] = selected_tag

    return evaluation(request, course_short_title)
开发者ID:martflu,项目名称:aurora,代码行数:47,代码来源:views.py

示例15: back

def back(request, course_short_title=None):
    selection = request.session.get('selection', 'error')
    course = Course.get_or_raise_404(short_title=course_short_title)

    if selection == "search":
        return HttpResponse()
    if selection == "missing_reviews":
        elaborations = Elaboration.get_missing_reviews(course)
    if selection == "top_level_tasks":
        elaborations = Elaboration.get_top_level_tasks(course)
    if selection == "non_adequate_work":
        elaborations = Elaboration.get_non_adequate_work(course)
    if selection == "complaints":
        elaborations = Elaboration.get_complaints(course)
    if selection == "awesome":
        elaborations = Elaboration.get_awesome(course)
    if selection == "evaluated_non_adequate_work":
        elaborations = Elaboration.get_evaluated_non_adequate_work(course)

    # update overview
    if type(elaborations) == list:
        elaborations.sort(key=lambda elaboration: elaboration.submission_time)
    else:
        elaborations = elaborations.order_by('submission_time')
    request.session['elaborations'] = serializers.serialize('json', elaborations)

    return evaluation(request, course_short_title)
开发者ID:bobschi,项目名称:aurora,代码行数:27,代码来源:views.py


注:本文中的Elaboration.models.Elaboration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。