當前位置: 首頁>>代碼示例>>Python>>正文


Python models.Course方法代碼示例

本文整理匯總了Python中courses.models.Course方法的典型用法代碼示例。如果您正苦於以下問題:Python models.Course方法的具體用法?Python models.Course怎麽用?Python models.Course使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在courses.models的用法示例。


在下文中一共展示了models.Course方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: schedule_create_page

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def schedule_create_page(request, course_id):
    course = get_object_or_404(Course, id=course_id)

    if not course.user_is_teacher(request.user):
        return HttpResponseForbidden()

    if request.method == 'POST':
        return lesson_create(request, course)

    schools = course.school_set.all()

    context = {
        'is_create': True,
        'course': course,
        'period_types': Lesson().PERIOD_CHOICES,
        'school': schools[0] if schools else '',
        'user_location': request.user.profile.location,
        'geo_suggest_url': settings.GEO_SUGGEST_URL
    }

    return render(request, 'lesson_create.html', context) 
開發者ID:znick,項目名稱:anytask,代碼行數:23,代碼來源:views.py

示例2: task_import_page

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def task_import_page(request, course_id):
    course = get_object_or_404(Course, id=course_id)

    if not course.user_is_teacher(request.user):
        return HttpResponseForbidden()

    schools = course.school_set.all()

    seminar_tasks = Task.objects.filter(type=Task().TYPE_SEMINAR).filter(course=course)

    context = {
        'is_create': True,
        'course': course,
        'rb_integrated': course.rb_integrated,
        'school': schools[0] if schools else '',
        'seminar_tasks': seminar_tasks,
        'user_location': request.user.profile.location,
        'geo_suggest_url': settings.GEO_SUGGEST_URL
    }

    return render(request, 'task_import.html', context) 
開發者ID:znick,項目名稱:anytask,代碼行數:23,代碼來源:views.py

示例3: contest_import_page

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def contest_import_page(request, course_id):
    course = get_object_or_404(Course, id=course_id)

    if not course.user_is_teacher(request.user):
        return HttpResponseForbidden()

    schools = course.school_set.all()

    seminar_tasks = Task.objects.filter(type=Task().TYPE_SEMINAR).filter(course=course)

    context = {
        'is_create': True,
        'course': course,
        'rb_integrated': course.rb_integrated,
        'seminar_tasks': seminar_tasks,
        'school': schools[0] if schools else '',
        'contest_import': True,
        'user_location': request.user.profile.location,
        'geo_suggest_url': settings.GEO_SUGGEST_URL
    }

    return render(request, 'contest_import.html', context) 
開發者ID:znick,項目名稱:anytask,代碼行數:24,代碼來源:views.py

示例4: edit_course_information

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def edit_course_information(request):
    user = request.user

    for key in ['course_id', 'course_information']:
        if key not in request.POST:
            raise PermissionDenied

    try:
        course_id = int(request.POST['course_id'])
        course_information = request.POST['course_information'].strip()
    except ValueError:  # not int
        raise PermissionDenied

    course = get_object_or_404(Course, id=course_id)

    if not course.user_can_edit_course(user):
        raise PermissionDenied

    if course_information and not course_information.startswith(u'<div class="not-sanitize">'):
        course_information = u'<div class="not-sanitize">' + course_information + u'</div>'
    course.information = course_information
    course.save()

    return HttpResponse(json.dumps({'info': course_information}),
                        content_type="application/json") 
開發者ID:znick,項目名稱:anytask,代碼行數:27,代碼來源:views.py

示例5: set_spectial_course_attend

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def set_spectial_course_attend(request):
    user = request.user

    try:
        course_id = int(request.POST['course_id'])
        action = request.POST['action']
    except ValueError:  # not int
        raise PermissionDenied

    course = get_object_or_404(Course, id=course_id)

    if action == "add":
        course.add_user_to_group_with_extern(user)

    if action == "remove":
        course.remove_user_from_group_with_extern(user)

    return HttpResponse("OK") 
開發者ID:znick,項目名稱:anytask,代碼行數:20,代碼來源:views.py

示例6: get_issues

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def get_issues(request, course_id):
    course = get_object_or_404(Course, id=course_id)
    user = request.user
    if not course.user_is_teacher(user):
        return HttpResponseForbidden()

    add_events = bool(request.GET.get("add_events", False))
    filter_args = get_issue_filter(request.GET)

    ret = []
    issues = Issue.objects \
        .filter(task__course=course, **filter_args) \
        .select_related("task") \
        .prefetch_related("followers")
    lang = request.GET.get('lang', settings.API_LANGUAGE_CODE)
    for issue in issues:
        ret.append(unpack_issue(issue, add_events=add_events, request=request, lang=lang))

    return HttpResponse(json.dumps(ret),
                        content_type="application/json") 
開發者ID:znick,項目名稱:anytask,代碼行數:22,代碼來源:views.py

示例7: has_paid

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def has_paid(self, edx_course_key):
        """
        Returns true if user paid for a course run.

        Args:
            edx_course_key (str): an edX course run key

        Returns:
            bool: whether the user is paid
        """
        # financial aid programs need to have a paid entry for the course
        if self.financial_aid_available:
            # get the course associated with the course key
            course = Course.objects.get(courserun__edx_course_key=edx_course_key)
            return self.paid_course_fa.get(course.id, False)

        # normal programs need to have paid_on_edx in the final grades or a verified enrollment
        if self.has_final_grade(edx_course_key):
            return self.has_final_grade_paid_on_edx(edx_course_key)
        return self.has_verified_enrollment(edx_course_key) 
開發者ID:mitodl,項目名稱:micromasters,代碼行數:22,代碼來源:utils.py

示例8: get_overall_final_grade_for_course

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def get_overall_final_grade_for_course(self, course):
        """
        Calculate overall grade for course

        Args:
           course (courses.models.Course): A course
        Returns:
           str: the overall final grade
        """
        best_grade = self.get_best_final_grade_for_course(course)
        if best_grade is None:
            return ""
        if not course.has_exam:
            return str(round(best_grade.grade_percent))

        combined_grade = CombinedFinalGrade.objects.filter(user=self.user, course=course)
        if combined_grade.exists():
            return str(round(combined_grade.first().grade))
        return "" 
開發者ID:mitodl,項目名稱:micromasters,代碼行數:21,代碼來源:utils.py

示例9: clear_dashboard_data

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def clear_dashboard_data(user, course=None, course_run=None, models=None):
    """
    Clears all of a User's final grade data and all cached edX data for a Course/CourseRun
    (or just the cached data for specific models)
    """
    # Delete all cached edX data for the associated edX models (or all of them if no model is specified)
    if models:
        handlers = [CACHED_HANDLERS[model] for model in models]
    else:
        handlers = CACHED_HANDLERS.values()
    for cached_model_handler in handlers:
        cached_model_handler(user).clear_all(course=course, course_run=course_run)
    # Delete FinalGrade records
    final_grade_params = dict(user=user)
    if course:
        final_grade_params['course_run__course'] = course
    if course_run:
        final_grade_params['course_run'] = course_run
    FinalGrade.objects.filter(**final_grade_params).delete()
    # Delete course payment records (if the associated program is FA-enabled)
    clear_course_payment_data(user, course=course, course_run=course_run) 
開發者ID:mitodl,項目名稱:micromasters,代碼行數:23,代碼來源:lib.py

示例10: task_create_page

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def task_create_page(request, course_id):
    course = get_object_or_404(Course, id=course_id)

    if not course.user_is_teacher(request.user):
        return HttpResponseForbidden()

    if request.method == 'POST':
        return task_create_or_edit(request, course)

    schools = course.school_set.all()
    seminar_tasks = Task.objects.filter(type=Task().TYPE_SEMINAR).filter(course=course)
    not_seminar_tasks = Task.objects.filter(~Q(type=Task().TYPE_SEMINAR)).filter(course=course)
    has_seminar = course.issue_status_system.statuses.filter(tag=IssueStatus.STATUS_SEMINAR).count()

    task_types = Task.TASK_TYPE_CHOICES
    if not has_seminar:
        task_types = filter(lambda x: not x[0] == Task.TYPE_SEMINAR, task_types)

    context = {
        'is_create': True,
        'course': course,
        'task_types': task_types,
        'seminar_tasks': seminar_tasks,
        'not_seminar_tasks': not_seminar_tasks,
        'contest_integrated': course.contest_integrated,
        'rb_integrated': course.rb_integrated,
        'hide_contest_settings': True if not course.contest_integrated else False,
        'school': schools[0] if schools else '',
        'user_location': request.user.profile.location,
        'geo_suggest_url': settings.GEO_SUGGEST_URL
    }

    return render(request, 'task_create.html', context) 
開發者ID:znick,項目名稱:anytask,代碼行數:35,代碼來源:views.py

示例11: queue_page

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def queue_page(request, course_id):
    user = request.user
    course = get_object_or_404(Course, id=course_id)

    if not course.user_can_see_queue(user):
        raise PermissionDenied

    f = IssueFilter(request.GET, {})
    f.set_course(course, user)
    session_key = '_'.join([QUEUE_SESSION_PREFIX, str(course_id)])
    if request.GET:
        request.session[session_key] = f.form.data
    elif session_key in request.session:
        f.form.data = request.session.get(session_key)
    f.form.helper = FormHelper(f.form)
    f.form.helper.form_method = 'get'
    f.form.helper.layout.append(
        HTML(
            u"""
            <div class="form-group row">
            <button id="button_clear" class="btn btn-secondary" type="button">{0}</button>
            </div>
            <div class="form-group row">
            <button id="button_filter" class="btn btn-primary" type="button">{1}</button>
            </div>
            """.format(_(u'ochistit'), _(u'primenit'))
        )
    )

    schools = course.school_set.all()

    context = {
        'course': course,
        'user_is_teacher': course.user_is_teacher(user),
        'visible_attendance_log': course.user_can_see_attendance_log(user),
        'filter': f,
        'school': schools[0] if schools else '',
        'full_width_page': True,
        'timezone': user.profile.time_zone
    }
    return render(request, 'courses/queue.html', context) 
開發者ID:znick,項目名稱:anytask,代碼行數:43,代碼來源:views.py

示例12: ajax_get_queue

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def ajax_get_queue(request):
    user = request.user

    if "draw" not in request.POST or "course_id" not in request.POST:
        raise PermissionDenied

    course = get_object_or_404(Course, id=request.POST['course_id'])

    if not course.user_can_see_queue(user):
        raise PermissionDenied

    issues = Issue.objects.filter(
        Q(task__course=course)
        & (Q(student__profile__user_status__tag='active') | Q(student__profile__user_status__tag=None))
        & Q(student__group__course=course)
    ).exclude(
        task__type=Task.TYPE_SEMINAR,
    ).exclude(
        task__type=Task.TYPE_MATERIAL,
    ).distinct().select_related('student', 'task', 'responsible', 'status_field')

    order = []
    for order_info in json.loads(request.POST.get("order", "[]")):
        order.extend(set_order_direction(QUEUE_COLUMN_ORDER.get(str(order_info.get("column"))), order_info.get("dir")))
    issues = issues.order_by(*order)

    f = IssueFilter(QueryDict(request.POST["filter"]), issues)
    f.set_course(course, user)
    f.set_data(request.POST)
    session_key = '_'.join([QUEUE_SESSION_PREFIX, str(course.id)])
    if f.form.data:
        request.session[session_key] = f.form.data
    f.count()

    return HttpResponse(json.dumps(f.response), content_type="application/json") 
開發者ID:znick,項目名稱:anytask,代碼行數:37,代碼來源:views.py

示例13: change_visibility_hidden_tasks

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def change_visibility_hidden_tasks(request):
    course = get_object_or_404(Course, id=int(request.POST['course_id']))
    if not course.user_is_teacher(request.user):
        raise PermissionDenied

    session_var_name = str(request.user.id) + '_' + request.POST['course_id'] + '_show_hidden_tasks'
    request.session[session_var_name] = not request.session.get(session_var_name, False)

    return HttpResponse("OK") 
開發者ID:znick,項目名稱:anytask,代碼行數:11,代碼來源:views.py

示例14: change_visibility_academ_users

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def change_visibility_academ_users(request):
    course = get_object_or_404(Course, id=int(request.POST['course_id']))
    if not course.user_is_teacher(request.user):
        raise PermissionDenied

    session_var_name = str(request.user.id) + '_' + request.POST['course_id'] + '_show_academ_users'
    request.session[session_var_name] = not request.session.get(session_var_name, True)

    return HttpResponse("OK") 
開發者ID:znick,項目名稱:anytask,代碼行數:11,代碼來源:views.py

示例15: set_course_mark

# 需要導入模塊: from courses import models [as 別名]
# 或者: from courses.models import Course [as 別名]
def set_course_mark(request):
    user = request.user

    course = get_object_or_404(Course, id=request.POST['course_id'])
    if not course.user_is_teacher(user):
        raise PermissionDenied

    student = get_object_or_404(User, id=request.POST['student_id'])
    if request.POST['mark_id'] != '-1':
        mark = get_object_or_404(MarkField, id=request.POST['mark_id'])
    else:
        mark = MarkField()

    student_course_mark = StudentCourseMark()
    try:
        student_course_mark = StudentCourseMark.objects.get(course=course, student=student)
    except StudentCourseMark.DoesNotExist:
        student_course_mark.course = course
        student_course_mark.student = student

    student_course_mark.teacher = user
    student_course_mark.update_time = datetime.datetime.now()
    student_course_mark.mark = mark
    student_course_mark.save()
    return HttpResponse(json.dumps({'mark': unicode(mark), 'mark_id': mark.id, 'mark_int': mark.name_int}),
                        content_type="application/json") 
開發者ID:znick,項目名稱:anytask,代碼行數:28,代碼來源:views.py


注:本文中的courses.models.Course方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。