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


Python Elaboration.get_awesome_challenge方法代码示例

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


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

示例1: awesome

# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import get_awesome_challenge [as 别名]
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,代码行数:34,代码来源:views.py

示例2: awesome

# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import get_awesome_challenge [as 别名]
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:flozzone,项目名称:aurora,代码行数:38,代码来源:views.py


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