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


Python Topics.get_pos方法代码示例

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


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

示例1: test_create_topic

# 需要导入模块: from oasis.lib import Topics [as 别名]
# 或者: from oasis.lib.Topics import get_pos [as 别名]
    def test_create_topic(self):
        """ Fetch a topic back and check it
        """

        course_id = Courses.create("TEST101", "Test topic position logic", 1, 1)

        self.assertDictContainsSubset(
            {course_id:
                 {'active': 1,
                  'assess_visibility': 'enrol',
                  'id': course_id,
                  'name': 'TEST101',
                  'owner': 1,
                  'practice_visibility': 'all',
                  'title': 'Test topic position logic',
                  'type': 1
                  }
             },
            Courses.get_courses_dict(),
        )

        topic1_id = Topics.create(course_id, "TESTTOPIC1", 1, 2)
        topic2_id = Topics.create(course_id, "TESTTOPIC2", 3, 3)

        self.assertGreater(topic1_id, 0)
        self.assertIsInstance(topic1_id, int)

        self.assertGreater(topic2_id, 0)
        self.assertIsInstance(topic2_id, int)

        self.assertNotEqual(topic1_id, topic2_id)

        topic1 = Topics.get_topic(topic1_id)
        topic2 = Topics.get_topic(topic2_id)

        self.assertEqual(topic1['id'], topic1_id)
        self.assertEqual(topic2['id'], topic2_id)
        self.assertEqual(topic1['title'], "TESTTOPIC1")
        self.assertEqual(topic2['title'], "TESTTOPIC2")
        self.assertEqual(topic1['visibility'], 1)
        self.assertEqual(topic2['visibility'], 3)

        self.assertEqual(Topics.get_name(topic1_id), topic1['title'])

        Topics.set_name(topic1_id, "NEWNAME1")
        self.assertEqual(Topics.get_name(topic1_id), "NEWNAME1")

        self.assertEqual(Topics.get_num_qs(topic1_id), 0)

        self.assertEqual(Topics.get_pos(topic1_id), 2)

        Topics.set_pos(topic1_id, 8)
        self.assertEqual(Topics.get_pos(topic1_id), 8)
开发者ID:colincoghill,项目名称:oasisqe,代码行数:55,代码来源:test_topics.py

示例2: cadmin_view_qtemplate_history

# 需要导入模块: from oasis.lib import Topics [as 别名]
# 或者: from oasis.lib.Topics import get_pos [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

示例3: cadmin_edit_topic

# 需要导入模块: from oasis.lib import Topics [as 别名]
# 或者: from oasis.lib.Topics import get_pos [as 别名]
def cadmin_edit_topic(course_id, topic_id):
    """ Present a page to view and edit a topic, including adding/editing
        questions and setting some parameters.
    """
    user_id = session['user_id']

    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)
    }
    questions = [question
                 for question in Topics.get_qts(topic_id).values()]
    for question in questions:
        question['embed_id'] = DB.get_qt_embedid(question['id'])
        if question['embed_id']:
            question['embed_url'] = "%s/embed/question/%s/question.html" % \
                                    (OaConfig.parentURL, question['embed_id'])
        else:
            question['embed_url'] = None
        question['editor'] = DB.get_qt_editor(question['id'])

    all_courses = Courses2.get_course_list()
    all_courses = [crse
                   for crse in all_courses
                   if satisfy_perms(user_id, int(crse['id']),
                                    ("questionedit", "courseadmin",
                                    "sysadmin"))]
    all_courses.sort(lambda f, s: cmp(f['name'], s['name']))

    all_course_topics = []
    for crse in all_courses:
        topics = Courses.get_topics_all(crse['id'], numq=False)
        if topics:
            all_course_topics.append({'course': crse['name'], 'topics': topics})

    questions.sort(key=lambda k: k['position'])
    return render_template(
        "courseadmin_edittopic.html",
        course=course,
        topic=topic,
        questions=questions,
        all_course_topics=all_course_topics
    )
开发者ID:tkanesh,项目名称:oasisqe,代码行数:50,代码来源:views_cadmin.py

示例4: cadmin_view_topic

# 需要导入模块: from oasis.lib import Topics [as 别名]
# 或者: from oasis.lib.Topics import get_pos [as 别名]
def cadmin_view_topic(course_id, topic_id):
    """ Present a page to view a topic, including basic stats """
    user_id = session["user_id"]

    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)}
    questions = [question for question in Topics.get_qts(topic_id).values()]
    for question in questions:
        question["embed_id"] = DB.get_qt_embedid(question["id"])
        if question["embed_id"]:
            question["embed_url"] = "%s/embed/question/%s/question.html" % (OaConfig.parentURL, question["embed_id"])
        else:
            question["embed_url"] = None
        question["editor"] = DB.get_qt_editor(question["id"])

    all_courses = Courses2.get_course_list()
    all_courses = [
        crse
        for crse in all_courses
        if satisfy_perms(user_id, int(crse["id"]), ("questionedit", "courseadmin", "sysadmin"))
    ]
    all_courses.sort(lambda f, s: cmp(f["name"], s["name"]))

    all_course_topics = []
    for crse in all_courses:
        topics = Courses.get_topics_all(crse["id"], numq=False)
        if topics:
            all_course_topics.append({"course": crse["name"], "topics": topics})

    questions.sort(key=lambda k: k["position"])
    return render_template(
        "courseadmin_viewtopic.html",
        course=course,
        topic=topic,
        questions=questions,
        all_course_topics=all_course_topics,
    )
开发者ID:jamesdoherty,项目名称:oasisqe,代码行数:42,代码来源:views_cadmin.py


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