当前位置: 首页>>代码示例>>Python>>正文


Python Courses2.get_course方法代码示例

本文整理汇总了Python中oasis.lib.Courses2.get_course方法的典型用法代码示例。如果您正苦于以下问题:Python Courses2.get_course方法的具体用法?Python Courses2.get_course怎么用?Python Courses2.get_course使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oasis.lib.Courses2的用法示例。


在下文中一共展示了Courses2.get_course方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: admin_course_save

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def admin_course_save(course_id):
    """ accept saved settings """
    form = request.form
    cancel_edit = form.get("cancel_edit", False)
    if cancel_edit:
        flash("Course edits cancelled")
        return redirect(url_for("admin_courses"))

    changed = False
    course = Courses2.get_course(course_id)
    groups = Courses.get_groups(course_id)

    for g_id, group in groups.iteritems():
        if form.get('delgroup_%s' % g_id):
            changed = True
            flash("Removing group %s" % group.name, "info")
            Courses.del_group(int(g_id), course_id)

    if 'course_name' in form:
        name = form['course_name']
        if not name == course['name']:
            changed = True
            Courses.set_name(course_id, name)

    if 'course_title' in form:
        title = form['course_title']
        if not title == course['title']:
            changed = True
            Courses.set_title(course_id, title)

    if 'course_active' in form:
        active = form['course_active']
        if active == '1' or active == 1:
            active = True
        else:
            active = False
        if not (active == course['active']):
            changed = True
            Courses.set_active(course_id, active)

    addbtn = form.get('group_addbtn')
    if addbtn:
        newgroup = form.get('addgroup', None)
        if newgroup:
            Courses.add_group(newgroup, course_id)
            changed = True
            group = Groups.Group(newgroup)
            flash("Group %s added." % group.name)

    if changed:
        Courses2.reload_if_needed()
        flash("Course changes saved!")
        return redirect(url_for("admin_course", course_id=course_id))

    course = Courses2.get_course(course_id)
    course['size'] = len(Courses.get_users(course_id))
    return redirect(url_for("admin_courses"))
开发者ID:jamesdoherty,项目名称:oasisqe,代码行数:59,代码来源:views_admin.py

示例2: cadmin_top

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def cadmin_top(course_id):
    """ Present top level course admin page """
    course = Courses2.get_course(course_id)
    if not course:
        abort(404)

    user_id = session['user_id']
    is_sysadmin = check_perm(user_id, -1, 'sysadmin')

    topics = Courses2.get_topics_list(course_id)
    exams = [Exams.get_exam_struct(exam_id, course_id)
             for exam_id in Courses.get_exams(course_id, prev_years=False)]

    exams.sort(key=lambda y: y['start_epoch'], reverse=True)
    groups = Courses.get_groups(course_id)
    choosegroups = [group
                    for group in Groups.all_groups()
                    if group.id not in groups]
    return render_template(
        "courseadmin_top.html",
        course=course,
        topics=topics,
        exams=exams,
        choosegroups=choosegroups,
        groups=groups,
        is_sysadmin=is_sysadmin
    )
开发者ID:tkanesh,项目名称:oasisqe,代码行数:29,代码来源:views_cadmin.py

示例3: cadmin_edit_exam

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def cadmin_edit_exam(course_id, exam_id):
    """ Provide a form to edit an assessment """
    course = Courses2.get_course(course_id)
    if not course:
        abort(404)

    exam = Exams.get_exam_struct(exam_id, course_id)
    if not exam:
        abort(404)

    if not int(exam['cid']) == int(course_id):
        flash("Assessment %s does not belong to this course." % int(exam_id))
        return redirect(url_for('cadmin_top', course_id=course_id))

    exam['start_date'] = int(date_from_py2js(exam['start']))
    exam['end_date'] = int(date_from_py2js(exam['end']))
    exam['start_hour'] = int(exam['start'].hour)
    exam['end_hour'] = int(exam['end'].hour)
    exam['start_minute'] = int(exam['start'].minute)
    exam['end_minute'] = int(exam['end'].minute)

    return render_template(
        "exam_edit.html",
        course=course,
        exam=exam
    )
开发者ID:tkanesh,项目名称:oasisqe,代码行数:28,代码来源:views_cadmin.py

示例4: practice_choose_topic

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def practice_choose_topic(course_id):
    """ Present a list of topics for them to choose from the given course """
    user_id = session['user_id']
    try:
        course = Courses2.get_course(course_id)
    except KeyError:
        course = None
        abort(404)
    try:
        topics = Courses2.get_topics_list(course_id)
    except KeyError:
        topics = []
        abort(404)

    members = None
    for topic in topics:
        if topic['visibility'] == 2:  # course only
            if not members:
                members = Courses.get_users(course_id)
            if not user_id in members:
                topics.remove(topic)
    return render_template(
        "practicecourse.html",
        courses=Setup.get_sorted_courselist(),
        canpreview=check_perm(user_id, course_id, "questionpreview"),
        topics=topics,
        course=course
    )
开发者ID:jamesdoherty,项目名称:oasisqe,代码行数:30,代码来源:views_practice.py

示例5: cadmin_assign_coord

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def cadmin_assign_coord(course_id):
    """ Set someone as course coordinator
"""
    course = Courses2.get_course(course_id)
    if not course:
        abort(404)

    if not "coord" in request.form:
        abort(400)

    new_uname = request.form["coord"]
    # TODO: Sanitize username
    try:
        new_uid = Users2.uid_by_uname(new_uname)
    except KeyError:
        flash("User '%s' Not Found" % new_uname)
    else:
        if not new_uid:
            flash("User '%s' Not Found" % new_uname)
        else:
            Permissions.add_perm(new_uid, course_id, 3)  # courseadmin
            Permissions.add_perm(new_uid, course_id, 4)  # coursecoord
            flash("%s can now control the course." % (new_uname,))

    return redirect(url_for("cadmin_config", course_id=course_id))
开发者ID:jamesdoherty,项目名称:oasisqe,代码行数:27,代码来源:views_cadmin.py

示例6: cadmin_export_csv

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def cadmin_export_csv(course_id, exam_id, group_id):
    """ Send the group results as a CSV file """
    course = Courses2.get_course(course_id)
    if not course:
        abort(404)

    exam = Exams.get_exam_struct(exam_id, course_id)
    if not exam:
        abort(404)

    if not int(exam["cid"]) == int(course_id):
        flash("Assessment %s does not belong to this course." % int(exam_id))
        return redirect(url_for("cadmin_top", course_id=course_id))

    group = Groups.Group(g_id=group_id)
    output = Spreadsheets.exam_results_as_spreadsheet(course_id, group, exam_id)
    response = make_response(output)
    response.headers.add(
        "Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8"
    )
    response.headers.add(
        "Content-Disposition", 'attachment; filename="OASIS_%s_%s_Results.xlsx"' % (course["title"], exam["title"])
    )

    return response
开发者ID:jamesdoherty,项目名称:oasisqe,代码行数:27,代码来源:views_cadmin.py

示例7: cadmin_create_exam

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def cadmin_create_exam(course_id):
    """ Provide a form to create/edit a new assessment """
    course = Courses2.get_course(course_id)
    if not course:
        abort(404)

    topics = CourseAdmin.get_create_exam_q_list(course_id)

    today = datetime.now()
    return render_template(
        "exam_edit.html",
        course=course,
        topics=topics,
        #  defaults
        exam={
            'id': 0,
            'start_date': int(date_from_py2js(today)+86400000),  # tomorrow
            'end_date': int(date_from_py2js(today)+90000000),  # tomorrow + hour
            'start_hour': int(today.hour),
            'end_hour': int(today.hour + 1),
            'start_minute': int(today.minute),
            'end_minute': int(today.minute),
            'duration': 60,
            'title': "Assessment",
            'archived': 1,
        }
    )
开发者ID:tkanesh,项目名称:oasisqe,代码行数:29,代码来源:views_cadmin.py

示例8: cadmin_assign_coord

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def cadmin_assign_coord(course_id):
    """ Set someone as course coordinator
    """
    cur_user = session['user_id']
    course = Courses2.get_course(course_id)
    if not course:
        abort(404)

    if "coord" not in request.form:
        abort(400)

    new_uname = sanitize_username(request.form['coord'])
    try:
        new_uid = Users2.uid_by_uname(new_uname)
    except KeyError:
        flash("User '%s' Not Found" % new_uname)
    else:
        if not new_uid:
            flash("User '%s' Not Found" % new_uname)
        else:
            L.info("courseadmin: user %s assigned as coordinator to course %s by %s" % (new_uid, course_id, cur_user))
            Permissions.add_perm(new_uid, course_id, 3)  # courseadmin
            Permissions.add_perm(new_uid, course_id, 4)  # coursecoord
            flash("%s can now control the course." % (new_uname,))

    return redirect(url_for('cadmin_config', course_id=course_id))
开发者ID:ehchua,项目名称:oasisqe,代码行数:28,代码来源:views_cadmin.py

示例9: practice_do_question

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def practice_do_question(topic_id, qt_id):
    """ Show them a question and allow them to fill in some answers """
    user_id = session['user_id']
    try:
        course_id = Topics.get_course_id(topic_id)
    except KeyError:
        course_id = None
        abort(404)
    try:
        course = Courses2.get_course(course_id)
    except KeyError:
        course = None
        abort(404)
    topictitle = "UNKNOWN"
    try:
        topictitle = Topics.get_name(topic_id)
    except KeyError:
        abort(404)
    try:
        qtemplate = DB.get_qtemplate(qt_id)
    except KeyError:
        qtemplate = None
        abort(404)
    questions = Practice.get_sorted_questions(course_id, topic_id, user_id)
    q_title = qtemplate['title']
    q_pos = DB.get_qtemplate_topic_pos(qt_id, topic_id)

    blocked = Practice.is_q_blocked(user_id, course_id, topic_id, qt_id)
    if blocked:
        return render_template(
            "practicequestionblocked.html",
            mesg=blocked,
            topictitle=topictitle,
            topic_id=topic_id,
            qt_id=qt_id,
            course=course,
            q_title=q_title,
            questions=questions,
            q_pos=q_pos,
        )

    try:
        q_id = Practice.get_practice_q(qt_id, user_id)
    except (ValueError, TypeError), err:
        log(ERROR,
            "ERROR 1001  (%s,%s) %s" % (qt_id, user_id, err))
        return render_template(
            "practicequestionerror.html",
            mesg="Error generating question.",
            topictitle=topictitle,
            topic_id=topic_id,
            qt_id=qt_id,
            course=course,
            q_title=q_title,
            questions=questions,
            q_pos="?",
        )
开发者ID:jamesdoherty,项目名称:oasisqe,代码行数:59,代码来源:views_practice.py

示例10: practice_mark_question

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def practice_mark_question(topic_id, question_id):
    """ Mark the submitted question answersjust wa """
    user_id = session['user_id']

    course_id = Topics.get_course_id(topic_id)
    if not course_id:
        abort(404)

    course = Courses2.get_course(course_id)
    if not course:
        abort(404)

    topictitle = "UNKNOWN"
    try:
        topictitle = Topics.get_name(topic_id)
    except KeyError:
        abort(404)

    qt_id = DB.get_q_parent(question_id)

    q_title = DB.get_qt_name(qt_id)
    questions = Practice.get_sorted_questions(course_id, topic_id, user_id)
    q_pos = DB.get_qtemplate_topic_pos(qt_id, topic_id)

    blocked = Practice.is_q_blocked(user_id, course_id, topic_id, qt_id)
    if blocked:
        return render_template(
            "practicequestionblocked.html",
            mesg=blocked,
            topictitle=topictitle,
            topic_id=topic_id,
            qt_id=qt_id,
            course=course,
            q_title=q_title,
            questions=questions,
            q_pos=q_pos,
        )

    marking = Practice.mark_q(user_id, topic_id, question_id, request)
    prev_id, next_id = Practice.get_next_prev(qt_id, topic_id)

    return render_template(
        "practicemarkquestion.html",
        topictitle=topictitle,
        topic_id=topic_id,
        qt_id=qt_id,
        course=course,
        q_title=q_title,
        questions=questions,
        q_pos=q_pos,
        q_id=question_id,
        marking=marking,
        next_id=next_id,
        prev_id=prev_id
    )
开发者ID:jamesdoherty,项目名称:oasisqe,代码行数:57,代码来源:views_practice.py

示例11: cadmin_exam_viewmarked

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def cadmin_exam_viewmarked(course_id, exam_id, student_uid):
    """  Show a student's marked assessment results """

    course = Courses2.get_course(course_id)
    try:
        exam = Exams.get_exam_struct(exam_id, course_id)
    except KeyError:
        exam = {}
        abort(404)
    results, examtotal = Assess.render_own_marked_exam(student_uid, exam_id)

    if examtotal is False:
        status = 0
    else:
        status = 1
    marktime = Exams.get_mark_time(exam_id, student_uid)
    firstview = Exams.get_student_start_time(exam_id, student_uid)
    submittime = Exams.get_submit_time(exam_id, student_uid)

    try:
        datemarked = General.human_date(marktime)
    except AttributeError:
        datemarked = None
    try:
        datefirstview = General.human_date(firstview)
    except AttributeError:
        datefirstview = None
    try:
        datesubmit = General.human_date(submittime)
    except AttributeError:
        datesubmit = None

    user = Users2.get_user(student_uid)

    if submittime and firstview:
        taken = submittime-firstview
        takenmins = (taken.seconds/60)
    else:
        takenmins = None

    return render_template(
        "cadmin_markedresult.html",
        course=course,
        exam=exam,
        results=results,
        examtotal=examtotal,
        datesubmit=datesubmit,
        datemarked=datemarked,
        datefirstview=datefirstview,
        taken=takenmins,
        user=user,
        status=status
    )
开发者ID:tkanesh,项目名称:oasisqe,代码行数:55,代码来源:views_cadmin.py

示例12: cadmin_edittopics

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def cadmin_edittopics(course_id):
    """ Present a page to view and edit all topics, including hidden. """
    course = None
    try:
        course = Courses2.get_course(course_id)
    except KeyError:
        abort(404)

    if not course:
        abort(404)

    topics = Courses2.get_topics_list(course_id)
    return render_template("courseadmin_edittopics.html", course=course, topics=topics)
开发者ID:jamesdoherty,项目名称:oasisqe,代码行数:15,代码来源:views_cadmin.py

示例13: cadmin_exam_results

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def cadmin_exam_results(course_id, exam_id):
    """ View the results of an assessment """
    course = Courses2.get_course(course_id)
    if not course:
        abort(404)

    exam = Exams.get_exam_struct(exam_id, course_id)
    if not exam:
        abort(404)

    if not int(exam['cid']) == int(course_id):
        flash("Assessment %s does not belong to this course." % int(exam_id))
        return redirect(url_for('cadmin_top', course_id=course_id))

    exam['start_date'] = int(date_from_py2js(exam['start']))
    exam['end_date'] = int(date_from_py2js(exam['end']))
    exam['start_hour'] = int(exam['start'].hour)
    exam['end_hour'] = int(exam['end'].hour)
    exam['start_minute'] = int(exam['start'].minute)
    exam['end_minute'] = int(exam['end'].minute)

    groups = [Groups.Group(g_id=g_id)
              for g_id
              in Groups.active_by_course(course_id)]
    results = {}
    uids = set([])
    totals = {}
    for group in groups:
        results[group.id] = Exams.get_marks(group, exam_id)
        for user_id in results[group.id]:
            uids.add(user_id)
            if user_id not in totals:
                totals[user_id] = 0.0
            for qt, val in results[group.id][user_id].iteritems():
                totals[user_id] += val['score']

    questions = Exams.get_qts_list(exam_id)
    users = {}
    for uid in uids:
        users[uid] = Users2.get_user(uid)
    return render_template(
        "cadmin_examresults.html",
        course=course,
        exam=exam,
        results=results,
        groups=groups,
        users=users,
        questions=questions,
        when=datetime.now().strftime("%H:%m, %a %d %b %Y"),
        totals=totals
    )
开发者ID:tkanesh,项目名称:oasisqe,代码行数:53,代码来源:views_cadmin.py

示例14: setup_myprofile

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def setup_myprofile():
    """ Show an account summary for the current user account. """
    user_id = session['user_id']

    user = Users2.get_user(user_id)
    course_ids = Users2.get_courses(user_id)
    courses = []
    for course_id in course_ids:
        courses.append(Courses2.get_course(course_id))
    return render_template(
        'setup_myprofile.html',
        user=user,
        courses=courses
    )
开发者ID:tkanesh,项目名称:oasisqe,代码行数:16,代码来源:views_setup.py

示例15: cadmin_view_qtemplate_history

# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import get_course [as 别名]
def cadmin_view_qtemplate_history(course_id, topic_id, qt_id):
    """ Show the practice history of the question template. """
    if not course_id:
        abort(404)

    course = Courses2.get_course(course_id)
    topic = {"id": topic_id, "position": Topics.get_pos(topic_id), "name": Topics.get_name(topic_id)}
    qtemplate = DB.get_qtemplate(qt_id)
    year = datetime.now().year
    years = range(year, year - 6, -1)

    return render_template(
        "courseadmin_viewqtemplate.html", course=course, topic=topic, qtemplate=qtemplate, years=years
    )
开发者ID:jamesdoherty,项目名称:oasisqe,代码行数:16,代码来源:views_cadmin.py


注:本文中的oasis.lib.Courses2.get_course方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。