當前位置: 首頁>>代碼示例>>Python>>正文


Python Course.createCourse方法代碼示例

本文整理匯總了Python中course.Course.createCourse方法的典型用法代碼示例。如果您正苦於以下問題:Python Course.createCourse方法的具體用法?Python Course.createCourse怎麽用?Python Course.createCourse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在course.Course的用法示例。


在下文中一共展示了Course.createCourse方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: process_courses

# 需要導入模塊: from course import Course [as 別名]
# 或者: from course.Course import createCourse [as 別名]
def process_courses(req_number, index, output_file, rest):
    print ("PROCESSING COURSES")
    indx = int(index)
    if rest:
        print("WRITING DATA FILE and PROCESSING via REST, this will take a minute or so...")
    else:
        print("WRITING DATA FILE ONLY - you must process via SIS Framework...")
    with open(output_file+"_COURSES-"+datetime.datetime.now().strftime('%Y%m%d-%H%M%S')+".txt", "w") as text_file:
        text_file.write("\n##### DELETE THIS LINE....THE FOLLOWING IS A COURSE SNAPSHOT FLAT FILE FOR STORE OR DELETE #####\n")
        text_file.write("##### DELETE THIS LINE.... DATASOURCEKEY %s #####\n" % DSKEXTERNALID)
        text_file.write("COURSE_ID|EXTERNAL_COURSE_KEY|COURSE_NAME\n")
        for num in range( 0, int(req_number)):
            json_payload = {}
            externalId = "%s_%d" % (COURSEEXTERNALIDSTEM, indx)
            text_file.write("%s|%s|%s\n" % (externalId, externalId, externalId))
            if rest:
                externalId = "%s_%d" % (COURSEEXTERNALIDSTEM, indx)
                dataSourceId = "externalId:%s" % DSKEXTERNALID
                courseId = "%s_%d" % (COURSEEXTERNALIDSTEM, indx)
                name = "%s_%d" % (COURSEEXTERNALIDSTEM, indx)
                description = "Course created by LearnObjGen"
                allowGuests = "true"
                readOnly = "false"
                availability = { "duration":"continuous"}

                json_payload["externalId"] = externalId
                json_payload["dataSourceId"] = dataSourceId
                json_payload["courseId"] = courseId
                json_payload["name"] = name
                json_payload["description"] = description
                json_payload["allowGuests"] = allowGuests
                json_payload["readOnly"] = readOnly
                json_payload["availability"] = availability

                #print (json.dumps(json_payload, indent=4, separators=(',', ': ')))
                global authorized_session
                course_session = Course(rest, authorized_session.getToken())
                course_session.createCourse(DSKEXTERNALID, json.dumps(json_payload), authorized_session.getToken())

            indx = indx+1
開發者ID:blackboard,項目名稱:BBDN-LearnObjectGen_Python,代碼行數:42,代碼來源:learnObjectGen.py

示例2: main

# 需要導入模塊: from course import Course [as 別名]
# 或者: from course.Course import createCourse [as 別名]

#.........這裏部分代碼省略.........
                    print("[main] datasource_PK1: " + datasource_PK1)
                    if (datasource_PK1 is None):
                        print ("[main] data source not found, creating for demo...")
                        datasource_session.createDataSource(authorized_session.getToken())
                        datasource_PK1 = datasource_session.datasource_PK1

                term_session.execute(COMMAND, datasource_PK1, authorized_session.getToken())
            else:
                #term_session.getTerms(authorized_session.getToken())
                term_session.createTerm(datasource_PK1, authorized_session.getToken())
                term_session.getTerm(authorized_session.getToken())
                term_session.updateTerm(datasource_PK1, authorized_session.getToken())

        if COURSE or ALL:
            course_session = Course(target_url, authorized_session.getToken())
            #process course command
            print("\n[main] Run course command: " + ('ALL' if ALL else COMMAND) + '...')
            if 'course' in COMMAND:
                if (('delete' in COMMAND) or ('read' in COMMAND)):
                    print ("[main] Deleting or getting does not require a datasource.")
                else:
                    print("[main] datasource_PK1:  not known... searching...")
                    datasource_session = DataSource(target_url, authorized_session.getToken())
                    datasource_session.getDataSource(authorized_session.getToken())
                    datasource_PK1 = datasource_session.datasource_PK1
                    print("[main] datasource_PK1: " + datasource_PK1)
                    if (datasource_PK1 is None):
                        print ("[main] data source not found, creating for demo...")
                        datasource_session.createDataSource(authorized_session.getToken())
                        datasource_PK1 = datasource_session.datasource_PK1
                course_session.execute(COMMAND, datasource_PK1, authorized_session.getToken())
            else:
                #course_session.getCourses(authorized_session.getToken())
                course_session.createCourse(datasource_PK1, authorized_session.getToken())
                course_session.getCourse(authorized_session.getToken())
                course_session.updateCourse(datasource_PK1, authorized_session.getToken())

        if USER or ALL:
            user_session = User(target_url, authorized_session.getToken())
            #process user command
            print("\n[main] Run user command: " + ('ALL' if ALL else COMMAND) + '...')
            if 'user' in COMMAND:
                if (('delete' in COMMAND) or ('read' in COMMAND)):
                    print ("[main] Deleting or getting does not require a datasource.")
                else:
                    print("[main] datasource_PK1:  not known... searching...")
                    datasource_session = DataSource(target_url, authorized_session.getToken())
                    datasource_session.getDataSource(authorized_session.getToken())
                    datasource_PK1 = datasource_session.datasource_PK1
                    print("[main] datasource_PK1: " + datasource_PK1)
                    if (datasource_PK1 is None):
                        print ("[main] data source not found, creating for demo...")
                    datasource_session.createDataSource(authorized_session.getToken())
                    datasource_PK1 = datasource_session.datasource_PK1
                    user_session.execute(COMMAND, datasource_PK1, authorized_session.getToken())
            else:
                #user_session.getUsers(authorized_session.getToken())
                user_session.createUser(datasource_PK1, authorized_session.getToken())
                user_session.getUser(authorized_session.getToken())
                user_session.updateUser(datasource_PK1, authorized_session.getToken())

        if MEMBERSHIP or ALL:
            membership_session = Membership(target_url, authorized_session.getToken())

            #process membership command
            print("\n[main] Run membership command: " + ('ALL' if ALL else COMMAND) + '...')
開發者ID:hanleybrand,項目名稱:BBDN-REST-DEMO_Python,代碼行數:70,代碼來源:restdemo.py


注:本文中的course.Course.createCourse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。