Merge branch 'master' of ssh://wwylss.asuscomm.com:30001/wangweiye/mathdeptv2
This commit is contained in:
commit
60fbb77be4
|
|
@ -743,7 +743,20 @@ def GenerateStudentBodyString(problems,sectiontitles,pro_dict,consecutivenumberi
|
|||
return bodystring #返回主题内容字符串
|
||||
|
||||
|
||||
def TeachersGetAfterContent(id,prodict,objdict,topandbottomusagestuple = (3,3), showobjs = True, showtags = True, showans = True, showsolution = True, showusages = True, showorigin = True, showremark = True): #生成教师版讲义后的答案及空格, topandbottomusagestuple表示保留得分率最高的使用记录与最低的使用记录的个数, 有负数表示不排列
|
||||
def TeachersGetAfterContentColored(id,prodict,objdict,topandbottomusagestuple = (3,3), showobjs = True, showtags = True, showans = True, showsolution = True, showusages = True, showorigin = True, showremark = True): #生成教师版讲义后的答案及空格, topandbottomusagestuple表示保留得分率最高的使用记录与最低的使用记录的个数, 有负数表示不排列, 彩色背景
|
||||
string = ""
|
||||
objs = GenerateObjTexCode(id,prodict,objdict) if showobjs else ""
|
||||
tags = ("\\begin{tcolorbox}[colback = orange!10!white, colframe = orange!10!white, breakable]\n标签: %s\n\n\\end{tcolorbox}\n"%("; ".join(prodict[id]["tags"]))) if showtags else ""
|
||||
ans = ("\\begin{tcolorbox}[colback = red!10!white, colframe = red!10!white, breakable]\n答案: %s\n\n\\end{tcolorbox}\n"%(prodict[id]["ans"] if prodict[id]["ans"] != "" else "暂无答案")) if showans else ""
|
||||
solution = ("\\begin{tcolorbox}[colback = green!10!white, colframe = green!10!white, breakable]\n解答或提示: %s\n\n\\end{tcolorbox}\n"%(prodict[id]["solution"] if prodict[id]["solution"] != "" else "暂无解答")) if showsolution else ""
|
||||
# solution = ("解答或提示: \\textcolor{magenta}{%s}\n\n"%(prodict[id]["solution"] if prodict[id]["solution"] != "" else "暂无解答")) if showsolution else ""
|
||||
origin = ("\\begin{tcolorbox}[colback = yellow!30!white, colframe = yellow!30!white, breakable]\n来源: %s\n\n\\end{tcolorbox}\n"%prodict[id]["origin"]) if showorigin else ""
|
||||
remark = ("\\begin{tcolorbox}[colback = cyan!30!white, colframe = cyan!30!white, breakable]\n备注: %s\n\n\\end{tcolorbox}\n"%(prodict[id]["remark"] if prodict[id]["remark"] != "" else "暂无备注")) if showremark else ""
|
||||
usages = ("\\begin{tcolorbox}[colback = lime!10!white, colframe = lime!10!white, breakable]\n使用记录(%s):\n\n%s\n\n\\end{tcolorbox}\n"%(str(topandbottomusagestuple),GenerateUsageTexCode(id,prodict,topandbottomusagestuple))) if showusages else ""
|
||||
string += objs + tags + ans + solution + usages + origin + remark
|
||||
return string #生成教师版讲义后的答案及空格
|
||||
|
||||
def TeachersGetAfterContentPlain(id,prodict,objdict,topandbottomusagestuple = (3,3), showobjs = True, showtags = True, showans = True, showsolution = True, showusages = True, showorigin = True, showremark = True): #生成教师版讲义后的答案及空格, topandbottomusagestuple表示保留得分率最高的使用记录与最低的使用记录的个数, 有负数表示不排列
|
||||
string = ""
|
||||
objs = ("目标:\n\n%s\n\n"%GenerateObjTexCode(id,prodict,objdict)) if showobjs else ""
|
||||
tags = ("标签: \\textcolor[rgb]{0.5,0.6,0.8}{%s}\n\n"%("; ".join(prodict[id]["tags"])) if not prodict[id]["tags"] == [] else "标签: \n\n") if showtags else ""
|
||||
|
|
@ -755,14 +768,19 @@ def TeachersGetAfterContent(id,prodict,objdict,topandbottomusagestuple = (3,3),
|
|||
string += objs + tags + ans + solution + usages + origin + remark
|
||||
return string #生成教师版讲义后的答案及空格
|
||||
|
||||
|
||||
def GenerateObjTexCode(id,prodict,objdict): #生成目标代号对应的学习目标字符串(含蓝色编码)
|
||||
string = ""
|
||||
if prodict[id]["objs"] != []:
|
||||
for objid in prodict[id]["objs"]:
|
||||
if objid.upper() == "KNONE":
|
||||
string += "\\textcolor{blue}{%s\t%s}\n\n"%(objid,"无当前有效关联目标")
|
||||
else:
|
||||
string += "\\textcolor{blue}{%s\t%s}\n\n"%(objid,objdict[objid]["content"])
|
||||
# string = ""
|
||||
# if prodict[id]["objs"] != []:
|
||||
string = "\n\\begin{tcolorbox}[colback = blue!10!white, colframe = blue!10!white, breakable]\n目标:"
|
||||
for objid in prodict[id]["objs"]:
|
||||
if objid.upper() == "KNONE":
|
||||
string += "\n\n%s\t%s"%(objid,"无当前有效关联目标")
|
||||
else:
|
||||
string += "\n\n%s\t%s"%(objid,objdict[objid]["content"])
|
||||
if prodict[id]["objs"] == []:
|
||||
string += "暂未关联\n"
|
||||
string += "\n\n\\end{tcolorbox}\n"
|
||||
return string #返回目标代码字符串
|
||||
|
||||
def ChooseUsage(usages,topandbottomusagestuple): #生成题号对应的题目的使用记录, topandbottomusagestuple表示保留得分率最高的使用记录与最低的使用记录的个数, 有负数表示不排列, 两数之和大于记录数则从高到低排列后全部展示
|
||||
|
|
@ -780,8 +798,9 @@ def GenerateUsageTexCode(id,prodict,topandbottomusagestuple): #根据topandbotto
|
|||
usagecode = re.sub("\\t([\d]\.[\d]{0,10})",GenerateValueColorCode,"\n\n".join(usages))
|
||||
return usagecode #返回缩减后的使用记录列表
|
||||
|
||||
def GenerateTeacherBodyString(problems,sectiontitles,prodict,objdict,consecutivenumbering = True,topandbottomusagestuple = (3,3),sectionname = "section", showobjs = True, showtags = True, showans = True, showsolution = True, showusages = True, showorigin = True, showremark = True): #生成教师版的.tex文件的主体内容, 各项是否显示为可选
|
||||
def GenerateTeacherBodyString(problems,sectiontitles,prodict,objdict,consecutivenumbering = True,topandbottomusagestuple = (3,3),sectionname = "section", showobjs = True, showtags = True, showans = True, showsolution = True, showusages = True, showorigin = True, showremark = True, colored = False): #生成教师版的.tex文件的主体内容, 各项是否显示为可选
|
||||
bodystring = ""
|
||||
GetAfterContent = TeachersGetAfterContentPlain if not colored else TeachersGetAfterContentColored
|
||||
if len(problems) == len(sectiontitles):
|
||||
count = 0
|
||||
for i in range(len(problems)):
|
||||
|
|
@ -789,7 +808,7 @@ def GenerateTeacherBodyString(problems,sectiontitles,prodict,objdict,consecutive
|
|||
sectionstring = "\\%s{%s}\n\\begin{enumerate}\n\\setcounter{enumi}{%d}\n\n"%(sectionname,sectiontitles[i],count if consecutivenumbering else 0)
|
||||
for id in idlist:
|
||||
count += 1
|
||||
aftercontent = TeachersGetAfterContent(id,prodict,objdict,topandbottomusagestuple = topandbottomusagestuple, showobjs = showobjs, showtags = showtags, showans = showans, showsolution = showsolution, showusages = showusages, showorigin = showorigin, showremark = showremark)
|
||||
aftercontent = GetAfterContent(id,prodict,objdict,topandbottomusagestuple = topandbottomusagestuple, showobjs = showobjs, showtags = showtags, showans = showans, showsolution = showsolution, showusages = showusages, showorigin = showorigin, showremark = showremark)
|
||||
sectionstring += "\\item (%s) %s\n\n%s"%(id,prodict[id]["content"],aftercontent)
|
||||
sectionstring += "\\end{enumerate}\n\n"
|
||||
bodystring += sectionstring
|
||||
|
|
@ -798,7 +817,7 @@ def GenerateTeacherBodyString(problems,sectiontitles,prodict,objdict,consecutive
|
|||
idlist = generate_number_set(idstring,prodict)
|
||||
sectionstring = "\\begin{enumerate}\n\n"
|
||||
for id in idlist:
|
||||
aftercontent = TeachersGetAfterContent(id,prodict,objdict,topandbottomusagestuple = topandbottomusagestuple, showobjs = showobjs, showtags = showtags, showans = showans, showsolution = showsolution, showusages = showusages, showorigin = showorigin, showremark = showremark)
|
||||
aftercontent = GetAfterContent(id,prodict,objdict,topandbottomusagestuple = topandbottomusagestuple, showobjs = showobjs, showtags = showtags, showans = showans, showsolution = showsolution, showusages = showusages, showorigin = showorigin, showremark = showremark)
|
||||
sectionstring += "\\item (%s) %s\n\n%s"%(id,prodict[id]["content"],aftercontent)
|
||||
sectionstring += "\\end{enumerate}\n\n"
|
||||
bodystring += sectionstring
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
problems = ["1:5","10:15"] #题号列表, 每个字符串表示一个分块的题目
|
||||
problems = ["1:600"] #题号列表, 每个字符串表示一个分块的题目
|
||||
notetitle = "测试讲义教师版" #讲义标题, 也是文件标题
|
||||
sectiontitles = ["课前","课后"] #小节标题列表, 如果与题号列表长度不符则作为不设小节处理
|
||||
sectiontitles = ["课前","课后","测试"] #小节标题列表, 如果与题号列表长度不符则作为不设小节处理
|
||||
|
||||
colored = False #是否使用背景色块
|
||||
|
||||
consecutivenumbering = True #不同小节是否连续编号, True表示连续编号, False表示每小节从1开始编号
|
||||
topandbottomusagestuple = (3,3) #表示保留得分率最高的使用记录与最低的使用记录的个数, 有负数表示不排列
|
||||
|
||||
|
|
@ -15,6 +18,7 @@ sectionname = "section" #按何种名称分组, 可选section, subsection, chapt
|
|||
|
||||
|
||||
from database_tools import *
|
||||
import time
|
||||
|
||||
prodictpath = "../题库0.3/problems.json"
|
||||
objdictpath = "../题库0.3/lessonobj.json"
|
||||
|
|
@ -32,9 +36,9 @@ if sys.platform != "win32": #非win系统用默认字体
|
|||
latex_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",latex_raw)
|
||||
latex_raw = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",latex_raw)
|
||||
|
||||
starttime = time.time()
|
||||
|
||||
|
||||
bodystring = GenerateTeacherBodyString(problems,sectiontitles,pro_dict,obj_dict,sectionname=sectionname, consecutivenumbering=consecutivenumbering, topandbottomusagestuple = topandbottomusagestuple, showobjs = showobjs, showtags = showtags, showans = showans, showsolution = showsolution, showusages = showusages, showorigin = showorigin, showremark = showremark) #生成.tex中的内容主体字符串, 用于替换模板中的相应部分
|
||||
bodystring = GenerateTeacherBodyString(problems,sectiontitles,pro_dict,obj_dict,sectionname=sectionname, consecutivenumbering=consecutivenumbering, topandbottomusagestuple = topandbottomusagestuple, showobjs = showobjs, showtags = showtags, showans = showans, showsolution = showsolution, showusages = showusages, showorigin = showorigin, showremark = showremark, colored = colored) #生成.tex中的内容主体字符串, 用于替换模板中的相应部分
|
||||
|
||||
latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,(notetitle,bodystring)) #替换标题和bodystring
|
||||
SaveTextFile(latex_data,outputfilepath) #保存.tex文件
|
||||
|
|
@ -44,5 +48,9 @@ if XeLaTeXCompile(outputdir,notetitle+".tex"):
|
|||
else:
|
||||
print("编译失败")
|
||||
|
||||
endtime = time.time()
|
||||
|
||||
print("总处理时间: %.3f秒"%(endtime-starttime))
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
\usepackage{longtable}
|
||||
\usepackage{diagbox}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{tcolorbox}
|
||||
\usepackage[top=1in, bottom=1in,left=0.8in,right=0.8in]{geometry}
|
||||
\usepackage{fancyhdr}
|
||||
\fancyhf{}
|
||||
|
|
@ -56,7 +57,7 @@ A.~#1 &B.~#2& C.~#3& D.~#4
|
|||
(1)~#1 &(2)~#2& (3)~#3& (4)~#4
|
||||
\end{tabular}}
|
||||
|
||||
|
||||
\tcbuselibrary{breakable}
|
||||
\newcommand{\papername}{<<待替换1>>}
|
||||
|
||||
\begin{document}
|
||||
|
|
|
|||
11966
题库0.3/Problems.json
11966
题库0.3/Problems.json
File diff suppressed because it is too large
Load Diff
Reference in New Issue