예제 #1
0
def get_ep_comment(uc,
                   object_id,
                   ver='2.3',
                   **kwargs):
    """
    Return the comments for an ePortfolio object identified by its ID.

    Parameters:
        uc: user context, from d2lvalence.auth.fashion_user_context
        object_id: an ePortfolio object's unique identifier
        ver (optional): ePortfolio API version as a String

    Return data includes two properties:

    PagingInfo: dict containing:
        Bookmark: number (int) of last item of PagedResultSet returned for
         passing to get remaining items in PagedResultSet
        HasMoreItems: boolean,  True if more items in PagedResultSet to return

    Items: list containing dictionaries of the following properties for each
     comment:
        ObjectId: unique int ePortfolio identifier
        CommentId: unique int ePortfolio comment identifier
        UserId: unique int D2L user identifier
        CreatedDate: string containing creation date of comment
        Body: string containing the comment body in HTML
    """
    route = '/d2l/api/eP/{0}/object/{1}/comments/'.format(ver, object_id)
    r = d2l_service._get(route, uc, **kwargs)
    return d2l_data.PagedResultSet(r)
예제 #2
0
def get_ep_object_content(uc,
                          object_id,
                          ver='2.3',
                          **kwargs):
    """
    Return the associated file(s) of an ePortfolio object as a file stream.

    Parameters:
        uc: user context, from d2lvalence.auth.fashion_user_context
        object_id: an ePortfolio object's unique identifier
        ver (optional): ePortfolio API version as a String
    """
    route = '/d2l/api/eP/{0}/object/{1}/content'.format(ver, object_id)
    return d2l_service._get(route, uc, **kwargs)
예제 #3
0
def get_ep_tag(uc,
               object_id,
               ver='2.3',
               **kwargs):
    """
    Return the tags for an ePortfolio object identified by its ID.

    Parameters:
        uc: user context, from d2lvalence.auth.fashion_user_context
        object_id: an ePortfolio object's unique identifier
        ver (optional): ePortfolio API version as a String

    Return data is a list of dictionaries. Each dictionary contains:
        Type: int value 0 for public tags, 1 for private tags
        Text: string containing tag text
    """
    route = '/d2l/api/eP/{0}/object/{1}/tags/'.format(ver, object_id)
    r = d2l_service._get(route, uc, **kwargs)
    return r
예제 #4
0
def get_ep_presentation(uc,
                        object_id,
                        ver='2.3',
                        c=False,
                        **kwargs):
    """
    Return an ePortfolio presentation by ID.

    Parameters:
        uc: user context, from d2lvalence.auth.fashion_user_context
        object_id: an ePortfolio object's unique identifier
        ver (optional): ePortfolio API version as a String
        c (optional): include comments attached to object if true
    """
    kwargs.setdefault('params', {})
    if c:
        kwargs['params'].update({'c': c})
    route = '/d2l/api/eP/{0}/presentation/{1}'.format(ver, object_id)
    r = d2l_service._get(route, uc, **kwargs)
    return epPresentation(r)
예제 #5
0
def get_ep_objects(uc,
                   ver='2.3',
                   c=False,
                   q='',
                   bookmark='',
                   pagesize=None,
                   **kwargs):
    """
    Return all ePortfolio objects owned by the current user context.

    Parameters:
        uc: user context, from d2lvalence.auth.fashion_user_context
        ver (optional): ePortfolio API version as a String
        c (optional): set to True to include comments
        q (optional): query filter expression as a String to filter results,
         (docs.valence.desire2learn.com/res/epobject.html#object-query-filters)
        bookmark (optional): ObjectId of last item in data segment, passed to
         start the next data segment with the following ObjectId
        pagesize (optional): int number of entries to return per data segment

    Return data includes two properties:
    PagingInfo (dict):
        Bookmark: number (int) of last item of PagedResultSet returned for
         passing to get remaining items in PagedResultSet
        HasMoreItems: boolean,  True if more items in PagedResultSet to return
    Items: list containing all of the relevant ePortfolio object properties
     for each item.
    """
    route = '/d2l/api/eP/{0}/objects/my/'.format(ver)
    kwargs.setdefault('params', {})
    if c:
        kwargs['params'].update({'c': c})
    if q:
        kwargs['params'].update({'q': q})
    if bookmark:
        kwargs['params'].update({'bookmark': bookmark})
    if pagesize:
        kwargs['params'].update({'pagesize': pagesize})
    r = d2l_service._get(route, uc, **kwargs)
    return d2l_data.PagedResultSet(r)
예제 #6
0
def get_ep_object_properties(uc,
                             object_id,
                             ver='2.3',
                             c=False,
                             **kwargs):
    """
    Return an ePortfolio object by ID. Checks whether this is a specific type
    of ePortfolio object and return appropriate data corresponding to type.

    Parameters:
        uc: user context, from d2lvalence.auth.fashion_user_context
        object_id: an ePortfolio object's unique identifier
        ver (optional): ePortfolio API version as a String
        c (optional): include comments attached to object if true
    """
    kwargs.setdefault('params', {})
    if c:
        kwargs['params'].update({'c': c})
    route = '/d2l/api/eP/{0}/object/{1}'.format(ver, object_id)
    # Gets generic ePortfolio object properties
    r = d2l_service._get(route, uc, **kwargs)

    # Gets specific object properties for unique epObject types
    if r['ObjectTypeId'] == EPOBJ_T.get('file_artifact'):
        return get_ep_file_artifact(uc, object_id, ver, c, **kwargs)

    elif r['ObjectTypeId'] == EPOBJ_T.get('url_artifact'):
        return get_ep_url_artifact(uc, object_id, ver, c, **kwargs)

    elif r['ObjectTypeId'] == EPOBJ_T.get('collection'):
        return get_ep_collection(uc, object_id, ver, c, **kwargs)

    elif r['ObjectTypeId'] == EPOBJ_T.get('presentation'):
        return get_ep_presentation(uc, object_id, ver, c, **kwargs)

    else:
        return epObject(r)