Ejemplo n.º 1
0
def main():
    cm = CourseMySql(host=MYSQL_HOST,
                     user=MYSQL_USER,
                     passwd=MYSQL_PWD,
                     port=MYSQL_PORT,
                     db=MYSQL_DB,
                     charset=MYSQL_CHARSET,
                     table=MYSQL_TABLE)

    c = Course(cm, DEBUG_MODEL, 'huaxue.xlsx', Course_HuaXue_Map,
               Chapter_Level, KeyPoint_Level)
    courses = c.get_course_path(798)
    print(courses)
    cm.close()
Ejemplo n.º 2
0
def key_point_handle(file, sheet, level, course_id):
    db = CourseMySql(host=MYSQL_HOST,
                     user=MYSQL_USER,
                     passwd=MYSQL_PWD,
                     port=MYSQL_PORT,
                     db=MYSQL_DB,
                     charset=MYSQL_CHARSET,
                     table='tb_course_structure_tree')

    book = xlrd.open_workbook(file)
    sheet = book.sheet_by_index(sheet)
    rows = sheet.get_rows()
    total = 0
    success = 0
    i = 0

    if rows:
        for row in rows:
            if i > 0:
                if row[0].value and row[1].value and row[2].value:
                    total += 1
                    chapter = db.query_course_by_name_level(
                        row[0].value, level + 1, course_id)
                    if chapter:
                        point = db.query_course_by_name_level(
                            row[2].value, level + 2, chapter[0])
                        if point is None:
                            data = {
                                'name': row[2].value,
                                'fid': chapter[0],
                                'term': chapter[5],
                                'node_level': level + 2,
                                'path_info': '',
                                'name_remark': row[1].value,
                                'status': 1,
                                'sort': 800
                            }
                            id = db.add_course_detail(data)
                            if id:
                                path = chapter[4] + ',' + str(id)
                                db.update_course_path_by_id(id, path)
                                success += 1
                    else:
                        course = db.query_course_by_id(course_id)
                        if course:
                            data = {
                                'name': row[0].value,
                                'fid': course_id,
                                'term': course[5],
                                'node_level': level + 1,
                                'path_info': '',
                                'name_remark': '',
                                'status': 1,
                                'sort': 800
                            }
                        id = db.add_course_detail(data)
                        if id:
                            path = course[4] + ',' + str(id)
                            db.update_course_path_by_id(id, path)
                            section = {
                                'name': row[2].value,
                                'fid': id,
                                'term': course[5],
                                'node_level': level + 2,
                                'path_info': '',
                                'name_remark': row[1].value,
                                'status': 1,
                                'sort': 800
                            }
                            id = db.add_course_detail(section)
                            if id:
                                path = chapter[4] + str(id)
                                db.update_course_path_by_id(id, path)
                                success += 1
            i += 1
    return (total, success)
Ejemplo n.º 3
0
            lists = string.split("&")
            result = lists[0]
        elif string.find(" ", 0) > 0:
            lists = string.split(" ")
            result = lists[0]
        elif string.find("(", 0) > 0:
            lists = string.split("(")
            result = lists[0]
        return result


if __name__ == '__main__':
    couse = CourseMySql(host=MYSQL_HOST,
                        user=MYSQL_USER,
                        passwd=MYSQL_PWD,
                        port=MYSQL_PORT,
                        db=MYSQL_DB,
                        charset=MYSQL_CHARSET,
                        table='tb_temp_course_structure_tree')

    video = VideoMySql(host=MYSQL_HOST,
                       user=MYSQL_USER,
                       passwd=MYSQL_PWD,
                       port=MYSQL_PORT,
                       db=MYSQL_DB,
                       charset=MYSQL_CHARSET,
                       table='tb_temp_course_video_detail')

    teacher = TeacherMySql(host=MYSQL_HOST,
                           user=MYSQL_USER,
                           passwd=MYSQL_PWD,
Ejemplo n.º 4
0
from config.config import *
from lib.mysql import CourseMySql

course_db = CourseMySql(host=MYSQL_HOST,
                        user=MYSQL_USER,
                        passwd=MYSQL_PWD,
                        port=MYSQL_PORT,
                        db=MYSQL_DB,
                        charset=MYSQL_CHARSET,
                        table='tb_course_structure_tree')
grade_courses = course_db.query_course_by_level(5)
chapter_courses = course_db.query_course_by_level(6)

for chapter in chapter_courses:
    # print(chapter)
    id = chapter[0]
    fid = chapter[2]
    term = chapter[4]
    new_fid = 0
    name = ''
    for grade in grade_courses:
        if fid == grade[0] and term != grade[4]:
            name = grade[1]
    if len(name) > 0:
        for grade in grade_courses:
            if name == grade[1] and term == grade[4]:
                new_fid = grade[0]
    if new_fid > 0 and len(name) > 0:
        course_db.update_course_fid(id, new_fid)
Ejemplo n.º 5
0
                    'title': title + default_course,
                    'term': 0
                }
        else:
            grade = int(row[1].value)
            title = GradeMap.get(str(grade))
            kdict = {
                'course': default_course,
                'grade': int(row[1].value),
                'value': row[0].value,
                'title': title+default_course,
                'term': int(row[3].value) if row[3].value else 0
            }
        return kdict

if __name__ == '__main__':
    db = CourseMySql(host=MYSQL_HOST, user=MYSQL_USER, passwd=MYSQL_PWD, port=MYSQL_PORT, db=MYSQL_DB,
                     charset=MYSQL_CHARSET, table=MYSQL_TABLE)
    key = Keypoint(db, True, KeyPoint_Level)
    file = '20190712.xlsx'
    # chinese_key_point = key.read(file, 0)
    # key.insert_keypoint(chinese_key_point)

    # math_key_point = key.read(file, 2)
    # key.insert_keypoint(math_key_point)
    # english_key_point = key.read(file, 1)
    # key.insert_keypoint(english_key_point)
    # wuli_key_point = key.read(file, 3)
    # key.insert_keypoint(wuli_key_point)
    huaxue_key_point = key.read(file, 4)
    # key.insert_keypoint(huaxue_key_point)
Ejemplo n.º 6
0
def main():
    course_table = 'tb_course_structure_tree'
    video_table = 'tb_course_video_detail'
    chapter_table = 'tb_hsd_chapter'
    question_table = 'tb_hsd_question'

    video_db = VideoMySql(host=MYSQL_HOST,
                          user=MYSQL_USER,
                          passwd=MYSQL_PWD,
                          port=MYSQL_PORT,
                          db=MYSQL_DB,
                          charset=MYSQL_CHARSET,
                          table=video_table)

    chapter_db = ChapterMySql(host=MYSQL_HOST,
                              user=MYSQL_USER,
                              passwd=MYSQL_PWD,
                              port=MYSQL_PORT,
                              db=MYSQL_DB,
                              charset=MYSQL_CHARSET,
                              table=chapter_table)

    question_db = QuestionMySql(host=MYSQL_HOST,
                                user=MYSQL_USER,
                                passwd=MYSQL_PWD,
                                port=MYSQL_PORT,
                                db=MYSQL_DB,
                                charset=MYSQL_CHARSET,
                                table=question_table)

    course_db = CourseMySql(host=MYSQL_HOST,
                            user=MYSQL_USER,
                            passwd=MYSQL_PWD,
                            port=MYSQL_PORT,
                            db=MYSQL_DB,
                            charset=MYSQL_CHARSET,
                            table=course_table)

    fields = ('章ID', '节ID', '年级课程', '章名称', '节名称', '视频统计')
    excel = xlwt.Workbook(encoding='utf-8')
    term_dict = {'0': '', '1': '上学期', '2': '下学期', '3': '拓展上', '4': '拓展下'}

    sheet_name = '课程视频统计'
    sheet = excel.add_sheet(sheet_name, cell_overwrite_ok=True)
    # init first row
    for field in range(0, len(fields)):
        sheet.write(0, field, fields[field])

    data = course_db.query_course_by_node_level(str(5))
    j = 1
    for item in data:
        name = item[1]
        path_info = item[2]
        term = term_dict.get(str(item[3]))
        class_name = name + term
        data = course_db.query_course_structure_by_path(path_info=path_info)

        for i in data:
            stat = video_db.stat_video_data(str(i[1]))
            course = course_db.query_course_by_id(i[1])
            if stat == 0 and course[7] == 1:
                course_db.update_status_by_id(i[1], 0)
                sheet.write(j, 0, i[0])
                sheet.write(j, 1, i[1])
                sheet.write(j, 2, class_name)
                sheet.write(j, 3, i[3])
                sheet.write(j, 4, i[4])
                sheet.write(j, 5, stat)
                j += 1

    excel.save(DATA_PATH + '/course_no_video.xls')
Ejemplo n.º 7
0
import string
from config.config import *
from lib.mysql import ChapterMySql
from lib.mysql import VideoMySql
from lib.mysql import CourseMySql

course_db = CourseMySql(host=MYSQL_HOST,
                        user=MYSQL_USER,
                        passwd=MYSQL_PWD,
                        port=MYSQL_PORT,
                        db=MYSQL_DB,
                        charset=MYSQL_CHARSET,
                        table='tb_tmp_course_structure_tree')

chapter_db = ChapterMySql(host=MYSQL_HOST,
                          user=MYSQL_USER,
                          passwd=MYSQL_PWD,
                          port=MYSQL_PORT,
                          db=MYSQL_DB,
                          charset=MYSQL_CHARSET,
                          table='tb_hsd_chapter')

video_db = VideoMySql(host=MYSQL_HOST,
                      user=MYSQL_USER,
                      passwd=MYSQL_PWD,
                      port=MYSQL_PORT,
                      db=MYSQL_DB,
                      charset=MYSQL_CHARSET,
                      table='tb_tmp_course_video_detail_bak')

videos = video_db.query_data(5000)