コード例 #1
0
def new_lesson(content):
    """
    create a new lesson and return the lesson id
    """
    unit_id = content['unit']
    unit = get_content_by_id(unit_id)
    if unit is None:
        raise Exception("invalid unit id: that unit does not exist")

    if 'title' not in content:
        content['title'] = ''
    if 'body' not in content:
        content['body'] = ''

    content['private'] = unit.content['private']
    content['teacher'] = unit.content['teacher']
    content['course'] = unit.content['course']

    key = Curriculum(content_type = 'lesson', content = content).put()
    
    # add this lesson to the parent unit's lesson list
    unit.content['lessons'].append(int(key.id()))
    unit.put()

    return int(key.id())
コード例 #2
0
ファイル: new_unit.py プロジェクト: qdonnellan/lessonwell
def new_unit(content):
    """
    create a new unit entity; return the id of the new unit
    """
    course_id = content["course"]
    course = get_content_by_id(course_id)
    if course is None:
        raise Exception("invalid course id: that course does not exist")

    if "title" not in content:
        content["title"] = ""
    if "body" not in content:
        content["body"] = ""

    content["private"] = course.content["private"]
    content["teacher"] = course.content["teacher"]
    content["course"] = course_id
    content["lessons"] = []
    key = Curriculum(content_type="unit", content=content).put()

    # add this unit to the parent course's unit list
    course.content["units"].append(int(key.id()))
    course.put()

    return int(key.id())
コード例 #3
0
def new_unit(content):
    """
    create a new unit entity; return the id of the new unit
    """
    course_id = content['course']
    course = get_content_by_id(course_id)
    if course is None:
        raise Exception("invalid course id: that course does not exist")

    if 'title' not in content:
        content['title'] = ''
    if 'body' not in content:
        content['body'] = ''

    content['private'] = course.content['private']
    content['teacher'] = course.content['teacher']
    content['course'] = course_id
    content['lessons'] = []
    key = Curriculum(content_type='unit', content=content).put()

    # add this unit to the parent course's unit list
    course.content['units'].append(int(key.id()))
    course.put()

    return int(key.id())