示例#1
0
 def _get_rest(course: models.Course) -> t.Mapping[str, t.Any]:
     if request.args.get('extended') == 'true':
         return {
             'assignments': course.get_all_visible_assignments(),
             **course.__to_json__(),
         }
     return course.__to_json__()
示例#2
0
    def _get_rest(course: models.Course) -> t.Mapping[str, t.Any]:
        if helpers.extended_requested():
            snippets: t.Sequence[models.CourseSnippet] = []
            if (current_user.has_permission(GPerm.can_use_snippets)
                    and current_user.has_permission(
                        CPerm.can_view_course_snippets, course_id=course.id)):
                snippets = course.snippets

            return {
                'assignments': course.get_all_visible_assignments(),
                'group_sets': course.group_sets,
                'snippets': snippets,
                **course.__to_json__(),
            }
        return course.__to_json__()
示例#3
0
def test_max_submissions_invalid():
    course = Course(id=5)
    a = Assignment(deadline=None, is_lti=False, course=course)
    with pytest.raises(exceptions.APIException):
        a.max_submissions = 0

    with pytest.raises(exceptions.APIException):
        a.max_submissions = -1
示例#4
0
def test_update_amount_in_cool_off_period_invalid():
    course = Course(id=5)
    a = Assignment(deadline=None, is_lti=False, course=course)
    with pytest.raises(exceptions.APIException):
        a.amount_in_cool_off_period = 0

    with pytest.raises(exceptions.APIException):
        a.amount_in_cool_off_period = -1

    a.amount_in_cool_off_period = 1
示例#5
0
def test_update_cgignore_invalid():
    course = Course(id=5)
    a = Assignment(deadline=None, is_lti=False, course=course)
    with pytest.raises(exceptions.APIException):
        a.update_cgignore('invalid', 'err')

    with pytest.raises(exceptions.APIException):
        a.update_cgignore('IgnoreFilterManager', ['not a string'])

    with pytest.raises(exceptions.APIException):
        a.update_cgignore('SubmissionValidator', 'not a dict')
示例#6
0
def test_deadline_expired_property(monkeypatch):
    course = Course(id=5)
    a = Assignment(deadline=None, is_lti=False, course=course)
    assert not a.deadline_expired

    before = datetime.utcnow()
    monkeypatch.setattr(helpers, 'get_request_start_time', datetime.utcnow)

    a.deadline = before
    assert a.deadline_expired

    a.deadline = datetime.utcnow() + timedelta(hours=1)
    assert not a.deadline_expired
示例#7
0
 def make(id=None):
     course = Course(id=5)
     a = Assignment(course=course, is_lti=False)
     a.id = id
     return a