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


Python lib.Courses类代码示例

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


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

示例1: practice_choose_topic

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 = Courses.get_course(course_id)
    except KeyError:
        course = None
        abort(404)
    try:
        topics = Courses.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
    )
开发者ID:colincoghill,项目名称:oasisqe,代码行数:28,代码来源:views_practice.py

示例2: cadmin_top

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,代码行数:27,代码来源:views_cadmin.py

示例3: test_assess_create

    def test_assess_create(self):
        """ Create an empty assessment"""

        course_id = Courses.create("TESTCOURSE5", "unit tests for assessment", 1, 1)
        Courses.create_config(course_id, "casual", 1)
        Courses.set_active(course_id, True)
        Courses.set_prac_vis(course_id, "none")
        Courses.set_assess_vis(course_id, "none")

        title = "Test Assessment 1"
        atype = 2  # assignment
        duration = 60
        code = "123456"
        instant = 1
        instructions = "These are the instructions"
        astart = datetime.datetime.utcnow()
        aend = astart + datetime.timedelta(hours=2)

        exam_id = Exams.create(course_id, 1, title, atype, duration, astart,
                               aend, instructions, code=code, instant=instant)
        self.assertGreater(exam_id, 0)

        topic1_id = Topics.create(course_id, "TESTASSESS1", 1, 1)
        self.assertGreater(topic1_id, 0)

        data = open(self.test_question_fname).read()
        numread = External.import_qts_from_zip(data, topic1_id)
        self.assertEqual(numread, 3)
开发者ID:colincoghill,项目名称:oasisqe,代码行数:28,代码来源:test_assess.py

示例4: get_exam_list_sorted

def get_exam_list_sorted(user_id, prev_years=False):
    """ Return a list of exams for the given user. """
    courses = Courses.get_all()
    exams = []
    for cid in courses:
        try:
            exams += [Exams.get_exam_struct(e, user_id)
                      for e in Courses.get_exams(cid, prev_years=prev_years)]
        except KeyError, err:
            L.error("Failed fetching exam list for user %s: %s" %
                    (user_id, err))
开发者ID:colincoghill,项目名称:oasisqe,代码行数:11,代码来源:Assess.py

示例5: cadmin_course_add_group

def cadmin_course_add_group(course_id):
    """ We've been asked to add a group to the course.
    """
    group_id = int(request.form.get("addgroup", "0"))
    if not group_id:
        flash("No group selected")
        return redirect(url_for('cadmin_config', course_id=course_id))

    Courses.add_group(group_id, course_id)
    group = Groups.Group(group_id)
    flash("Group %s added" % (group.name,))
    return redirect(url_for('cadmin_config', course_id=course_id))
开发者ID:tkanesh,项目名称:oasisqe,代码行数:12,代码来源:views_cadmin.py

示例6: test_create_topic

    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,代码行数:53,代码来源:test_topics.py

示例7: admin_course

def admin_course(course_id):
    """ Present page to administer settings for a given course"""

    course = Courses2.get_course(course_id)
    course['size'] = len(Courses.get_users(course_id))
    groups = Courses.get_groups(course_id)
    choosegroups = [group
                    for g_id, group in Groups.enrolment_groups().iteritems()
                    if not g_id in groups]
    return render_template(
        "cadmin_course.html",
        course=course,
        groups=groups,
        choosegroups=choosegroups
    )
开发者ID:jamesdoherty,项目名称:oasisqe,代码行数:15,代码来源:views_admin.py

示例8: get_sorted_courselist

def get_sorted_courselist(with_stats=False, only_active=True):
    """Return a list of courses suitable for choosing one to edit
         [  ('example101', { coursedict }),  ('sorted302', { coursedict } )  ]
    """

    courses = Courses.get_courses_dict(only_active=only_active)

    inorder = []
    for cid, course in courses.iteritems():
        if with_stats:
            course['students'] = Courses.get_users(cid)
            course['size'] = len(course['students'])
        inorder.append((course['name'], course))
    inorder.sort()
    return inorder
开发者ID:colincoghill,项目名称:oasisqe,代码行数:15,代码来源:Setup.py

示例9: cadmin_edittopics

def cadmin_edittopics(course_id):
    """ Present a page to view and edit all topics, including hidden. """
    course = None
    try:
        course = Courses.get_course(course_id)
    except KeyError:
        abort(404)

    if not course:
        abort(404)

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

示例10: cadmin_activate

def cadmin_activate(course_id):
    """ Mark the course as active
    """
    course = None
    try:
        course = Courses2.get_course(course_id)
    except KeyError:
        abort(404)

    if not course:
        abort(404)

    Courses.set_active(course_id, True)
    flash("Course %s marked as active" % (course['name']))
    return redirect(url_for("cadmin_config", course_id=course_id))
开发者ID:tkanesh,项目名称:oasisqe,代码行数:15,代码来源:views_cadmin.py

示例11: test_create_qtemplate

    def test_create_qtemplate(self):
        """ Test qtemplates creation
        """

        qt1_id = DB.create_qt(1, "TESTQ1", "Test question 1", 0, 5.0, 1)
        qt2_id = DB.create_qt(1, "TESTQ2", "Test question 2", 0, 4.1, 2)

        self.assertIsInstance(qt1_id, int)
        self.assertIsInstance(qt2_id, int)

        qt1 = DB.get_qtemplate(qt1_id)
        qt2 = DB.get_qtemplate(qt2_id)

        self.assertEqual(qt1['title'], "TESTQ1")
        self.assertEqual(qt2['title'], "TESTQ2")
        self.assertEqual(qt1['description'], "Test question 1")
        self.assertEqual(qt2['description'], "Test question 2")

        course_id = Courses.create("TEST107", "Test create qtemplate", 1, 1)
        topic1_id = Topics.create(course_id, "TESTTOPIC9", 1, 2)

        qt3_id = DB.create_qt(1, "TESTQ3", "Test question 3", 0, 5.0, 1, topic1_id)

        self.assertIsInstance(qt3_id, int)

        qt3 = DB.get_qtemplate(qt3_id)
        self.assertEqual(qt3['title'], "TESTQ3")
        self.assertEqual(qt3['description'], "Test question 3")
        self.assertEqual(DB.get_topic_for_qtemplate(qt3_id), topic1_id)
开发者ID:colincoghill,项目名称:oasisqe,代码行数:29,代码来源:test_topics.py

示例12: test_do_question

    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,代码行数:35,代码来源:test_topics.py

示例13: cadmin_assign_coord

def cadmin_assign_coord(course_id):
    """ Set someone as course coordinator
    """
    cur_user = session['user_id']
    course = Courses.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:colincoghill,项目名称:oasisqe,代码行数:26,代码来源:views_cadmin.py

示例14: cadmin_edit_exam

def cadmin_edit_exam(course_id, exam_id):
    """ Provide a form to edit an assessment """
    course = Courses.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:colincoghill,项目名称:oasisqe,代码行数:26,代码来源:views_cadmin.py

示例15: cadmin_group_detach

def cadmin_group_detach(course_id, group_id):
    """ Mark the course as inactive
    """
    course = None
    try:
        course = Courses2.get_course(course_id)
    except KeyError:
        abort(404)

    if not course:
        abort(404)

    group = Groups.Group(g_id=group_id)
    Courses.del_group(group_id, course_id)
    flash("Group %s removed from course" % (group.name,))
    return redirect(url_for("cadmin_config", course_id=course_id))
开发者ID:tkanesh,项目名称:oasisqe,代码行数:16,代码来源:views_cadmin.py


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