コード例 #1
0
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
    )
コード例 #2
0
ファイル: views_cadmin.py プロジェクト: ehchua/oasisqe
def cadmin_topic_save(course_id, topic_id):
    """ Receive the page from cadmin_edit_topic and process any changes. """
    L.debug("cadmin_topic_save(%s, %s), REQUEST=%s" %
            (course_id, topic_id, repr(request)))

    user_id = session['user_id']

    if not course_id:
        abort(404)

    if "cancel_edit" in request.form:
        flash("Topic Changes Cancelled!")
        return redirect(url_for('cadmin_top', course_id=course_id))

    if "save_changes" in request.form:
        (what, result) = Setup.do_topic_page_commands(request, topic_id,
                                                      user_id)

        if what == 1:
            # flash(result['mesg'])
            return redirect(
                url_for('cadmin_edit_topic',
                        course_id=course_id,
                        topic_id=topic_id))
        if what == 2:
            return result

    flash("Error saving Topic Information!")
    L.error("Error saving Topic Information " % repr(request.form))
    return redirect(
        url_for('cadmin_edit_topic', course_id=course_id, topic_id=topic_id))
コード例 #3
0
ファイル: views_cadmin.py プロジェクト: tkanesh/oasisqe
def cadmin_topic_save(course_id, topic_id):
    """ Receive the page from cadmin_edit_topic and process any changes. """
    user_id = session['user_id']

    if not course_id:
        abort(404)

    if "cancel_edit" in request.form:
        flash("Topic Changes Cancelled!")
        return redirect(url_for('cadmin_top', course_id=course_id))

    if "save_changes" in request.form:
        (what, result) = Setup.do_topic_page_commands(request, topic_id, user_id)

        if what == 1:
            # flash(result['mesg'])
            return redirect(url_for('cadmin_edit_topic',
                                    course_id=course_id,
                                    topic_id=topic_id))
        if what == 2:
            return result

    flash("Error saving Topic Information!")
    L.error( "Error saving Topic Information " % repr(request.form))
    return redirect(url_for('cadmin_edit_topic',
                            course_id=course_id,
                            topic_id=topic_id))
コード例 #4
0
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 user_id not 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
    )
コード例 #5
0
ファイル: views_admin.py プロジェクト: jamesdoherty/oasisqe
def admin_top():
    """ Present the top level admin page """
    db_version = DB.get_db_version()
    return render_template(
        "admintop.html",
        courses=Setup.get_sorted_courselist(),
        db_version=db_version
    )
コード例 #6
0
ファイル: views_admin.py プロジェクト: ehchua/oasisqe
def admin_top():
    """ Present the top level admin page """
    db_version = DB.get_db_version()
    return render_template(
        "admintop.html",
        courses=Setup.get_sorted_courselist(),
        db_version=db_version
    )
コード例 #7
0
def setup_courses():
    """ Let the user choose a course to administer """
    user_id = session['user_id']
    is_sysadmin = check_perm(user_id, -1, 'sysadmin')

    return render_template(
        "setupchoosecourse.html",
        courses=Setup.get_sorted_courselist(only_active=False),
        is_sysadmin=is_sysadmin)
コード例 #8
0
ファイル: views_setup.py プロジェクト: colincoghill/oasisqe
def setup_courses():
    """ Let the user choose a course to administer """
    user_id = session['user_id']
    is_sysadmin = check_perm(user_id, -1, 'sysadmin')

    return render_template(
        "setupchoosecourse.html",
        courses=Setup.get_sorted_courselist(only_active=False),
        is_sysadmin=is_sysadmin
    )
コード例 #9
0
ファイル: views_admin.py プロジェクト: jamesdoherty/oasisqe
def admin_sysstats():
    """ Present the top level admin page """
    db_version = DB.get_db_version()
    db_sizes = DB.get_db_size()
    return render_template(
        "admin_sysstats.html",
        courses=Setup.get_sorted_courselist(),
        db_version=db_version,
        db_sizes=db_sizes
    )
コード例 #10
0
ファイル: views_admin.py プロジェクト: colincoghill/oasisqe
def admin_sysstats():
    """ Present the top level admin page """
    db_version = DB.get_db_version()
    db_sizes = DB.get_db_size()
    db_queue_size = DB.dbpool.total()
    db_queue_free = len(DB.dbpool)
    if OaConfig.memcache_enable:
        mc_queue_size = DB.MC.total()
        mc_queue_free = len(DB.MC)
    else:
        mc_queue_free = 0
        mc_queue_size = 0
    return render_template(
        "admin_sysstats.html",
        courses=Setup.get_sorted_courselist(),
        db_version=db_version,
        db_sizes=db_sizes,
        db_queue_size=db_queue_size,
        db_queue_free=db_queue_free,
        mc_enable=OaConfig.memcache_enable,
        mc_queue_size=mc_queue_size,
        mc_queue_free=mc_queue_free
    )
コード例 #11
0
ファイル: views_admin.py プロジェクト: ehchua/oasisqe
def admin_sysstats():
    """ Present the top level admin page """
    db_version = DB.get_db_version()
    db_sizes = DB.get_db_size()
    db_queue_size = DB.dbpool.total()
    db_queue_free = len(DB.dbpool)
    if OaConfig.memcache_enable:
        mc_queue_size = DB.MC.total()
        mc_queue_free = len(DB.MC)
    else:
        mc_queue_free = 0
        mc_queue_size = 0
    return render_template(
        "admin_sysstats.html",
        courses=Setup.get_sorted_courselist(),
        db_version=db_version,
        db_sizes=db_sizes,
        db_queue_size=db_queue_size,
        db_queue_free=db_queue_free,
        mc_enable=OaConfig.memcache_enable,
        mc_queue_size=mc_queue_size,
        mc_queue_free=mc_queue_free
    )
コード例 #12
0
def practice_top():
    """ Present the top level practice page - let them choose a course """
    return render_template(
        "practicetop.html",
        courses=Setup.get_sorted_courselist()
    )
コード例 #13
0
def practice_top():
    """ Present the top level practice page - let them choose a course """
    return render_template(
        "practicetop.html",
        courses=Setup.get_sorted_courselist()
    )