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


Python Task.is_shown方法代码示例

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


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

示例1: tasks_list_many_task_many_group

# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import is_shown [as 别名]
def tasks_list_many_task_many_group(request, course, get_context=False):
    user = request.user
    user_is_attended = False
    user_is_attended_special_course = False

    course.can_edit = course.user_can_edit_course(user)

    group_x_student_x_task_takens = OrderedDict()
    group_x_task_list = {}
    group_x_max_score = {}

    task = Task()
    task.is_shown = None
    task.is_hidden = None

    for group in course.groups.all().order_by('name'):
        student_x_task_x_task_takens = {}

        group_x_task_list[group] = Task.objects.filter(course=course).filter(group=group).order_by('weight')
        group_x_max_score.setdefault(group, 0)

        for task in group_x_task_list[group]:
            task.add_user_properties(user)

            if not task.is_hidden:
                group_x_max_score[group] += task.score_max
            if task.task_text is None:
                task.task_text = ''

        for student in group.students.filter(is_active=True):
            if user == student:
                user_is_attended = True

            task_list = group_x_task_list[group]

            student_task_takens = TaskTaken.objects.filter(task__in=group_x_task_list[group]).filter(user=student)

            task_x_task_taken = {}
            student_summ_scores = 0
            for task_taken in student_task_takens:
                task_x_task_taken[task_taken.task.id] = task_taken
                if not task_taken.task.is_hidden:
                    student_summ_scores += task_taken.score

            student_x_task_x_task_takens[student] = (task_x_task_taken, student_summ_scores)

        group_x_student_x_task_takens[group] = student_x_task_x_task_takens

    group_x_student_information = OrderedDict()
    for group,student_x_task_x_task_takens in group_x_student_x_task_takens.iteritems():
        group_x_student_information.setdefault(group, [])

        for student in sorted(student_x_task_x_task_takens.keys(), key=lambda x: u"{0} {1}".format(x.last_name, x.first_name)):
            if user == student:
                user_is_attended = True
            elif not course.user_can_see_transcript(user, student):
                continue

            group_x_student_information[group].append((student, student_x_task_x_task_takens[student][0], student_x_task_x_task_takens[student][1]))


    extern_max_score = 0
    extern_student_x_task_takens = {}

    extern_tasks = Task.objects.filter(course=course).filter(group=None).order_by('weight')
    for task in extern_tasks:
        task.add_user_properties(user)

        if not task.is_hidden:
            extern_max_score += task.score_max
        if task.task_text is None:
            task.task_text = ''


    task_takens = TaskTaken.objects.filter(task__in=extern_tasks)
    for student in course.students.all():
        if user == student:
            user_is_attended = True
            user_is_attended_special_course = True
        elif not course.user_can_see_transcript(user, student):
            continue

        task_x_task_taken = {}

        student_summ_scores = 0
        student_task_takens = filter(lambda x: x.user == student, task_takens)

        for task_taken in student_task_takens:
            task_x_task_taken[task_taken.task.id] = task_taken
            if not task_taken.task.is_hidden:
                student_summ_scores += task_taken.score

        extern_student_x_task_takens[student] = (task_x_task_taken, student_summ_scores)

    extern_student_information = []
    for student in sorted(extern_student_x_task_takens.keys(), key=lambda x: u"{0} {1}".format(x.last_name, x.first_name)):
        if user == student:
            user_is_attended = True

        extern_student_information.append((student, extern_student_x_task_takens[student][0], extern_student_x_task_takens[student][1]))
#.........这里部分代码省略.........
开发者ID:BooleT37,项目名称:anytask,代码行数:103,代码来源:views.py

示例2: tasklist_shad_cpp

# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import is_shown [as 别名]
def tasklist_shad_cpp(request, course):

    user = request.user
    user_is_attended = False
    user_is_attended_special_course = False

    course.can_edit = course.user_can_edit_course(user)
    if course.can_be_chosen_by_extern:
        course.groups.add(course.group_with_extern)

    group_x_student_x_task_takens = OrderedDict()
    group_x_task_list = {}
    group_x_max_score = {}

    task = Task()
    task.is_shown = None
    task.is_hidden = None

    events_with_mark = Event.objects.filter(field_id=8).filter(author__in=course.teachers.all()).order_by('issue','timestamp')
    marks_for_issues = {}
    for event in events_with_mark:
        marks_for_issues[event.issue.id] = event.value
    
    for group in course.groups.all().order_by('name'):
        student_x_task_x_task_takens = {}

        group_x_task_list[group] = Task.objects.filter(Q(course=course) & (Q(group=group) | Q(group=None))).order_by('weight')
        group_x_max_score.setdefault(group, 0)

        for task in group_x_task_list[group]:
            task.add_user_properties(user)

            if not task.is_hidden:
                group_x_max_score[group] += task.score_max
            if task.task_text is None:
                task.task_text = ''

        issues_students_in_group = Issue.objects.filter(task__in=group_x_task_list[group]).filter(student__group__in=[group]).order_by('student')

        from collections import defaultdict
        issues_x_student = defaultdict(list)
        for issue in issues_students_in_group.all():
            student_id = issue.student.id
            issues_x_student[student_id].append(issue)

        for student in group.students.filter(is_active=True):
            if user == student:
                user_is_attended = True
                user_is_attended_special_course = True

            task_list = group_x_task_list[group]

            student_task_takens = issues_x_student[student.id]

            task_x_task_taken = {}
            student_summ_scores = 0
            for task_taken in student_task_takens:
                task_x_task_taken[task_taken.task.id] = task_taken
                if not task_taken.task.is_hidden:
                    student_summ_scores += marks_for_issues[task_taken.id]

            student_x_task_x_task_takens[student] = (task_x_task_taken, student_summ_scores)

        group_x_student_x_task_takens[group] = student_x_task_x_task_takens

    group_x_student_information = OrderedDict()
    for group,student_x_task_x_task_takens in group_x_student_x_task_takens.iteritems():
        group_x_student_information.setdefault(group, [])

        for student in sorted(student_x_task_x_task_takens.keys(), key=lambda x: u"{0} {1}".format(x.last_name, x.first_name)):
            if user == student:
                user_is_attended = True
            elif not course.user_can_see_transcript(user, student):
                continue

            group_x_student_information[group].append((student, student_x_task_x_task_takens[student][0], student_x_task_x_task_takens[student][1]))


    extern_max_score = 0
    extern_student_x_task_takens = {}

    extern_tasks = Task.objects.filter(course=course).filter(group=None).order_by('weight')
    for task in extern_tasks:
        task.add_user_properties(user)

        if not task.is_hidden:
            extern_max_score += task.score_max
        if task.task_text is None:
            task.task_text = ''


    task_takens = TaskTaken.objects.filter(task__in=extern_tasks)
    for student in course.students.all():
        if user == student:
            user_is_attended = True
            user_is_attended_special_course = True
        elif not course.user_can_see_transcript(user, student):
            continue

        task_x_task_taken = {}
#.........这里部分代码省略.........
开发者ID:BooleT37,项目名称:anytask,代码行数:103,代码来源:views.py


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