diff --git a/工具/备课草稿生成.py b/工具/备课草稿生成.py new file mode 100644 index 00000000..d89b9414 --- /dev/null +++ b/工具/备课草稿生成.py @@ -0,0 +1,91 @@ +import os,re,json,time,sys + + + +"""---设置目标及题块编号---""" + +lessonid = "K0103" +title = "集合的关系" +problems = "15:30" + +"""---设置结束---""" + + +template_file = "模板文件/备课草稿模板.txt" #设置模板文件名 +exec_list = [("标题替换",lessonid+title)] #设置讲义标题 +destination_file = "临时文件/"+lessonid+title # 设置输出文件名 + + + +#生成数码列表, 逗号分隔每个区块, 区块内部用:表示整数闭区间 +def generate_number_set(string): + string = re.sub(r"[\n\s]","",string) + string_list = string.split(",") + numbers_list = [] + for s in string_list: + if not ":" in s: + numbers_list.append(s.zfill(6)) + else: + start,end = s.split(":") + for ind in range(int(start),int(end)+1): + numbers_list.append(str(ind).zfill(6)) + return numbers_list + + +#读取题库json文件并转化为字典 +with open(r"../题库0.3/Problems.json","r",encoding = "utf8") as f: + database = f.read() +pro_dict = json.loads(database) + +#读取目标数据库json并转化为字典 +with open(r"../题库0.3/LessonObj.json","r",encoding = "utf8") as f: + database = f.read() +obj_dict = json.loads(database) + +#读取系统日期 +current_time = time.localtime() +time_string = "_"+str(current_time.tm_year).zfill(4)+str(current_time.tm_mon).zfill(2)+str(current_time.tm_mday).zfill(2) + +#生成目标文件名和目标文件目录 +latex_file = destination_file + time_string + ".tex" +d = re.search("/[^/]*$",destination_file).span()[0] +destination_dir = destination_file[:d] + +#读取模板 +with open(template_file,"r",encoding="utf8") as f: + latex_raw = f.read() + +#识别操作系统 +if sys.platform != "win32": + latex_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",latex_raw) + latex_raw = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",latex_raw) + +#预处理 +for command in exec_list: + latex_raw = re.sub(command[0],command[1],latex_raw) + +data_output = latex_raw + +obj_data = "" +for id in obj_dict: + if lessonid in id: + obj_data += "\n\\item %s: %s\n"%(id,obj_dict[id]["content"]) + +problems_data = "" +for id in generate_number_set(problems): + if id in pro_dict: + problems_data += "\n\\item (%s) %s\\\\\n来源: %s\\\\\n参考答案: %s\\\\\n关联目标: %s\\\\\n"%(id,pro_dict[id]["content"],pro_dict[id]["origin"],pro_dict[id]["ans"],",".join(pro_dict[id]["objs"])) + + + +data_output = data_output.replace("目标待替换",obj_data) +print("目标生成完毕.") +data_output = data_output.replace("题目待替换",problems_data) +print("题目生成完毕.") + +#保存和编译latex文件 +with open(latex_file,"w",encoding = "utf8") as f: + f.write(data_output) +print("开始编译pdf文件: ", latex_file) +os.system("xelatex -interaction=batchmode -output-directory=" + destination_dir + " "+ latex_file) +print(os.system("xelatex -interaction=batchmode -output-directory=" + destination_dir + " "+ latex_file)) diff --git a/工具/工具面板.py b/工具/工具面板.py index b1fa339d..d4b7b3dc 100644 --- a/工具/工具面板.py +++ b/工具/工具面板.py @@ -112,6 +112,8 @@ def run_command1(): call(["python","../文本处理工具/单选变为多选.py"]) elif selectedtool == "分类题号字典生成": call(["python","分类题号字典生成.py"]) + elif selectedtool == "备课草稿生成": + call(["python","备课草稿生成.py"]) LabelTool.config(text = selectedtool+"STEP1命令执行完毕") button1.place_forget() @@ -185,6 +187,8 @@ BKZMenu.add_command(label = "题号清单生成", command = lambda: SetButton(" BKZMenu.add_command(label = "已用题号剔除", command = lambda: SetButton("已用题号剔除",1,["已用题号剔除.py"])) BKZMenu.add_command(label = "寻找未赋答案题目", command = lambda: SetButton("寻找未赋答案题目",1,["寻找未赋答案题目.py"])) BKZMenu.add_command(label = "错题重做来源清点", command = lambda: SetButton("错题重做来源清点",1,["错题重做来源清点.py"])) +BKZMenu.add_separator() +BKZMenu.add_command(label = "备课草稿生成", command = lambda: SetButton("备课草稿生成",1,["备课草稿生成.py"])) # 设置 目标及标签 菜单项 ObjTagMenu = Menu(menubar, tearoff = False) diff --git a/工具/批量生成题目pdf.py b/工具/批量生成题目pdf.py index 9ce96a12..5d07b1be 100644 --- a/工具/批量生成题目pdf.py +++ b/工具/批量生成题目pdf.py @@ -11,40 +11,21 @@ answered = False #目录和文件的分隔务必用/ directory = "临时文件/" # filename = "高三二模前易错题" -filename = "统计单元作业无答案" +filename = "新高一例题习题材料" """---设置文件名结束---""" """---设置题目列表---""" #字典字段为文件名, 之后为内容的题号 problems_dict = { -"高中数学质量测试与监控单元知识测试01集合与逻辑单元测试": "017551:017567", -"高中数学质量测试与监控单元知识测试02等式与不等式单元测试": "017568:017582", -"高中数学质量测试与监控单元知识测试03幂函数指数函数和对数函数单元测试": "017583:017596", -"高中数学质量测试与监控单元知识测试04函数的基本性质单元测试": "017597:017610", -"高中数学质量测试与监控单元知识测试05三角单元测试": "017611:017624", -"高中数学质量测试与监控单元知识测试06三角函数单元测试": "017625:017638", -"高中数学质量测试与监控单元知识测试07平面向量单元测试": "017639:017655", -"高中数学质量测试与监控单元知识测试08复数单元测试": "017656:017671", -"高中数学质量测试与监控单元知识测试09空间直线与平面单元测试": "017672:017684", -"高中数学质量测试与监控单元知识测试10简单几何体单元测试": "017685:017697", -"高中数学质量测试与监控单元知识测试11概率初步单元测试": "017698:017715", -"高中数学质量测试与监控单元知识测试12概率与统计初步单元测试": "017716:017733", -"高中数学质量测试与监控单元知识测试13坐标平面上的直线单元测试": "017734:017749", -"高中数学质量测试与监控单元知识测试14圆锥曲线单元测试": "017750:017764", -"高中数学质量测试与监控单元知识测试15空间向量及其应用一单元测试": "017765:017782", -"高中数学质量测试与监控单元知识测试16空间向量及其应用二单元测试": "017783:017798", -"高中数学质量测试与监控单元知识测试17数列和数学归纳法单元测试": "017799:017812", -"高中数学质量测试与监控单元知识测试18导数及其应用单元测试": "017813:017829", -"高中数学质量测试与监控单元知识测试19计数原理单元测试": "017830:017847", -"高中数学质量测试与监控单元知识测试20概率初步续单元测试": "017848:017864", -"高中数学质量测试综合测试01集合函数不等式": "017865:017887", -"高中数学质量测试综合测试02三角与平面向量": "017888:017909", -"高中数学质量测试综合测试03数列": "017910:017931", -"高中数学质量测试综合测试04解析几何直线和圆": "017932:017952", -"高中数学质量测试综合测试05解析几何圆锥曲线": "017953:017971", -"高中数学质量测试综合测试06空间直线与平面多面体与旋转体及空间向量": "017972:018001", -"高中数学质量测试综合测试07排列组合二项式定理概率与复数": "018002:018019", -"高中数学质量测试综合测试08导数及其应用": "018020:018038" +"空中课堂必修第一册例题与习题": "011739:011987", +"新教材必修第一册课堂练习": "009426:009538", +"新教材必修第一册习题": "010017:010202", +"2025届高一校本作业必修第一章": "020001:020096,030001", +"2025届高一校本作业必修第二章": "020097:020351", +"2025届高一校本作业必修第三章": "020352:020403", +"2025届高一校本作业必修第四章": "020404:020497", +"2025届高一校本作业必修第五章": "020498:020683", +"2025届高一校本作业选择性必修第四章": "020684:020849" } # problems_dict = { diff --git a/工具/模板文件/备课草稿模板.txt b/工具/模板文件/备课草稿模板.txt new file mode 100644 index 00000000..dec01b79 --- /dev/null +++ b/工具/模板文件/备课草稿模板.txt @@ -0,0 +1,91 @@ +\documentclass[10pt,a4paper,twoside]{article} +\usepackage[UTF8, fontset = none, heading = true]{ctex} +\setCJKmainfont[BoldFont=黑体,ItalicFont=楷体]{华文中宋} +\usepackage{amssymb,amsmath,amsfonts,amsthm,mathrsfs,dsfont,graphicx} +\usepackage{ifthen,indentfirst,enumerate,color,lastpage} +\usepackage{tikz} +\usepackage{multicol} +\usepackage{multirow} +\usepackage{makecell} +\usepackage{longtable} +\usepackage{diagbox} +\usepackage[top=1in, bottom=1in,left=0.8in,right=0.8in]{geometry} +\usepackage{fancyhdr} +\fancyhf{} +\rhead{--\ \thepage\ of \pageref{LastPage} \ --} +\pagestyle{fancy} +\ctexset{section={ +name={}, +number=\chinese{section}, +}} +\CTEXsetup[format={\bfseries\raggedright}]{section} +\usetikzlibrary{arrows,calc,intersections,patterns,decorations.pathreplacing,3d,angles,quotes,positioning,shapes.geometric} + +\renewcommand{\baselinestretch}{1.5} +\newtheorem{defi}{定义~} +\newtheorem{eg}{例~} +\newtheorem{ex}{~} +\newtheorem{rem}{注~} +\newtheorem{thm}{定理~} +\newtheorem{coro}{推论~} +\newtheorem{axiom}{公理~} +\newtheorem{prop}{性质~} +\newcommand{\blank}[1]{\underline{\hbox to #1pt{}}} +\newcommand{\bracket}[1]{(\hbox to #1pt{})} +\newcommand{\onech}[4]{\par\begin{tabular}{p{.9\linewidth}} +A.~#1\\ +B.~#2\\ +C.~#3\\ +D.~#4 +\end{tabular}} +\newcommand{\twoch}[4]{\par\begin{tabular}{p{.46\linewidth}p{.46\linewidth}} +A.~#1& B.~#2\\ +C.~#3& D.~#4 +\end{tabular}} +\newcommand{\vartwoch}[4]{\par\begin{tabular}{p{.46\linewidth}p{.46\linewidth}} +(1)~#1& (2)~#2\\ +(3)~#3& (4)~#4 +\end{tabular}} +\newcommand{\fourch}[4]{\par\begin{tabular}{p{.23\linewidth}p{.23\linewidth}p{.23\linewidth}p{.23\linewidth}} +A.~#1 &B.~#2& C.~#3& D.~#4 +\end{tabular}} +\newcommand{\varfourch}[4]{\par\begin{tabular}{p{.23\linewidth}p{.23\linewidth}p{.23\linewidth}p{.23\linewidth}} +(1)~#1 &(2)~#2& (3)~#3& (4)~#4 +\end{tabular}} + + +\newcommand{\papername}{标题替换} + +\begin{document} +\begin{center} +{\bf\large \papername(备课用资源)}\\ +\today{} +\end{center} + + +\section{学习目标} + +\begin{enumerate}[1.] +目标待替换 +\end{enumerate} + + +\section{备选例题} + +\vspace*{6em} + +\section{备选课堂练习} + +\vspace*{6em} + +\section{备选作业} + +\vspace*{6em} + +\section{资源列表} + +\begin{enumerate}[1.] +题目待替换 +\end{enumerate} + +\end{document} \ No newline at end of file