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


Python General.gen_q方法代码示例

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


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

示例1: test_do_question

# 需要导入模块: from oasis.lib import General [as 别名]
# 或者: from oasis.lib.General import gen_q [as 别名]
    def test_do_question(self):
        """ Do a question"""

        course_id = Courses.create("TEST102", "Test question logic", 1, 1)
        self.assertGreater(course_id, 0)
        topic1_id = Topics.create(course_id, "TESTQUESTIONS1", 1, 2)
        self.assertGreater(topic1_id, 0)

        qt1_id = DB.create_qt(1, "TESTQ9", "Test question 9", 0, 5.0, 1, topic_id=topic1_id)
        self.assertIsNotNone(qt1_id)

        ver = DB.get_qt_version(qt1_id)
        self.assertGreater(ver, 0)

        data = "2\n|1\n|2\n"
        qvars = [{'A1': "2"}, {'A1': "3"}]
        for row in range(0, len(qvars)):
            DB.add_qt_variation(qt1_id, row + 1, qvars[row], ver)
        DB.create_qt_att(qt1_id, "datfile.dat", "text/plain", data , ver)
        DB.create_qt_att(qt1_id, "qtemplate.html", "text/html", "What is <VAL A1>? <ANSWER 1>", ver)

        q_id = DB.get_q_by_qt_student(qt1_id, 1)
        self.assertFalse(q_id)  # Not generated yet

        q_id = General.gen_q(qt1_id, 1)
        self.assertGreater(q_id, 0)

        q_id = DB.get_q_by_qt_student(qt1_id, 1)
        self.assertTrue(qt1_id)  # Better be there now

        DB.update_qt_maxscore(qt1_id, 7.0)
        score = DB.get_qt_maxscore(qt1_id)
        self.assertEqual(score, 7.0)
        DB.set_q_viewtime(q_id)
        self.assertIsNotNone(DB.get_q_viewtime(q_id))
开发者ID:colincoghill,项目名称:oasisqe,代码行数:37,代码来源:test_topics.py

示例2: get_practice_q

# 需要导入模块: from oasis.lib import General [as 别名]
# 或者: from oasis.lib.General import gen_q [as 别名]
def get_practice_q(qt_id, user_id):
    """ Find an existing, or create a new, practice question
        for the given user."""
    try:
        qt_id = int(qt_id)
        assert qt_id > 0
    except (ValueError, TypeError, AssertionError):
        L.warn("Called with bad qtid %s?" % qt_id)
    qid = DB.get_q_by_qt_student(qt_id, user_id)
    if qid is not False:
        return int(qid)
    qid = General.gen_q(qt_id, user_id)
    try:
        qid = int(qid)
    except (ValueError, TypeError):
        L.warn("generateQuestion(%s,%s) Fail: returned %s" % (qt_id, user_id, qid))
    else:
        DB.set_q_viewtime(qid)
    return qid
开发者ID:colincoghill,项目名称:oasisqe,代码行数:21,代码来源:Practice.py


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