예제 #1
0
'''TODO

'''
import logging

from larc.rest import (
    IdResourceEndpoint, get_id_resources, new_id_resource,
)

from .course import (
    course_resource_docstring, create_course_resource_docstring,
)


log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())

rubrics = get_id_resources(
    'rubrics', form_key='rubric', memo=True,
    help=course_resource_docstring('rubrics'),
)

new_rubric = new_id_resource(
    'rubrics', form_key='rubric',
    post_unpack_f=lambda d: d['rubric'],
    help=create_course_resource_docstring(
        'rubric', {'name': 'Module Name', 'position': 1}
    ),
)
예제 #2
0
)

log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())

modules = get_id_resources(
    'modules',
    form_key='module',
    memo=True,
    help=course_resource_docstring('modules'),
)

new_module = new_id_resource(
    'modules',
    form_key='module',
    help=create_course_resource_docstring('module', {
        'name': 'Module Name',
        'position': 1
    }),
)

ITEM_TYPES = [
    "File",
    "Page",
    "Discussion",
    "Assignment",
    "Quiz",
    "SubHeader",
    "ExternalUrl",
    "ExternalTool",
]
예제 #3
0
파일: page.py 프로젝트: dogwynn/coursework
log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())

pages = get_id_resources(
    'pages',
    form_key='wiki_page',
    id_key='url',
    memo=True,
    help=course_resource_docstring('pages'),
)

new_page = new_id_resource(
    'pages',
    form_key='wiki_page',
    id_key='url',
    help=create_course_resource_docstring('page', {
        'title': 'A New Page',
        'body': '<p>Some HTML content.</p>'
    }),
)


@curry
def find_page(course: IdResourceEndpoint, title: str):
    for p in pages(course):
        if p.data['title'] == title:
            return p.refresh()


@curry
def sync_page_from_path(course: IdResourceEndpoint, course_root: str,
예제 #4
0
# ----------------------------------------------------------------------
#
# AssignmentGroup functionality
#
# ----------------------------------------------------------------------

assignment_groups = get_id_resources(
    'assignment_groups',
    memo=True,
)

new_assignment_group = new_id_resource('assignment_groups',
                                       help=create_course_resource_docstring(
                                           'assignment_group',
                                           {
                                               'name': 'Assignment Group X',
                                               'group_weight': 30
                                           },
                                       ))


@curry
def find_assignment_group(course: IdResourceEndpoint, name: str):
    groups = pipe(
        assignment_groups(course),
        filter(lambda g: g.data['name'].lower().startswith(name)),
        tuple,
    )
    if len(groups):
        if len(groups) == 1:
            return groups[0]
예제 #5
0
}

Quiz = IdResourceEndpoint

quizzes = get_id_resources(
    'quizzes',
    form_key='quiz',
    memo=True,
    help=course_resource_docstring('quizzes'),
)

new_quiz = new_id_resource(
    'quizzes',
    form_key='quiz',
    help=create_course_resource_docstring(
        'quiz', {
            'title': 'Quiz About Something',
            'time_limit': 30,
            'description': '<p>Some HTML content.</p>'
        }),
)

Question = IdResourceEndpoint

questions = get_id_resources(
    'questions',
    form_key='question',
    # data={'include[]': ['content_details']},
    help='''For a given quiz endpoint, return a tuple of its question endpoints

    Example: