教师版讲义可选是否用背景色块
This commit is contained in:
parent
ec3dba93f6
commit
72511bf885
|
|
@ -743,7 +743,7 @@ def GenerateStudentBodyString(problems,sectiontitles,pro_dict,consecutivenumberi
|
||||||
return bodystring #返回主题内容字符串
|
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 = ""
|
string = ""
|
||||||
objs = GenerateObjTexCode(id,prodict,objdict) if showobjs else ""
|
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 ""
|
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 ""
|
||||||
|
|
@ -756,6 +756,19 @@ def TeachersGetAfterContent(id,prodict,objdict,topandbottomusagestuple = (3,3),
|
||||||
string += objs + tags + ans + solution + usages + origin + remark
|
string += objs + tags + ans + solution + usages + origin + remark
|
||||||
return string #生成教师版讲义后的答案及空格
|
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 ""
|
||||||
|
ans = ("答案: \\textcolor{red}{%s}\n\n"%(prodict[id]["ans"] if prodict[id]["ans"] != "" else "暂无答案")) if showans else ""
|
||||||
|
solution = ("解答或提示: \\textcolor{magenta}{%s}\n\n"%(prodict[id]["solution"] if prodict[id]["solution"] != "" else "暂无解答")) if showsolution else ""
|
||||||
|
origin = ("来源: %s\n\n"%prodict[id]["origin"]) if showorigin else ""
|
||||||
|
remark = ("备注: \\textcolor[rgb]{0,0.5,0.2}{%s}\n\n"%(prodict[id]["remark"] if prodict[id]["remark"] != "" else "暂无备注")) if showremark else ""
|
||||||
|
usages = ("使用记录:\n\n%s\n\n"%GenerateUsageTexCode(id,prodict,topandbottomusagestuple)) if showusages else ""
|
||||||
|
string += objs + tags + ans + solution + usages + origin + remark
|
||||||
|
return string #生成教师版讲义后的答案及空格
|
||||||
|
|
||||||
|
|
||||||
def GenerateObjTexCode(id,prodict,objdict): #生成目标代号对应的学习目标字符串(含蓝色编码)
|
def GenerateObjTexCode(id,prodict,objdict): #生成目标代号对应的学习目标字符串(含蓝色编码)
|
||||||
# string = ""
|
# string = ""
|
||||||
# if prodict[id]["objs"] != []:
|
# if prodict[id]["objs"] != []:
|
||||||
|
|
@ -785,8 +798,9 @@ def GenerateUsageTexCode(id,prodict,topandbottomusagestuple): #根据topandbotto
|
||||||
usagecode = re.sub("\\t([\d]\.[\d]{0,10})",GenerateValueColorCode,"\n\n".join(usages))
|
usagecode = re.sub("\\t([\d]\.[\d]{0,10})",GenerateValueColorCode,"\n\n".join(usages))
|
||||||
return usagecode #返回缩减后的使用记录列表
|
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 = ""
|
bodystring = ""
|
||||||
|
GetAfterContent = TeachersGetAfterContentPlain if not colored else TeachersGetAfterContentColored
|
||||||
if len(problems) == len(sectiontitles):
|
if len(problems) == len(sectiontitles):
|
||||||
count = 0
|
count = 0
|
||||||
for i in range(len(problems)):
|
for i in range(len(problems)):
|
||||||
|
|
@ -794,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)
|
sectionstring = "\\%s{%s}\n\\begin{enumerate}\n\\setcounter{enumi}{%d}\n\n"%(sectionname,sectiontitles[i],count if consecutivenumbering else 0)
|
||||||
for id in idlist:
|
for id in idlist:
|
||||||
count += 1
|
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 += "\\item (%s) %s\n\n%s"%(id,prodict[id]["content"],aftercontent)
|
||||||
sectionstring += "\\end{enumerate}\n\n"
|
sectionstring += "\\end{enumerate}\n\n"
|
||||||
bodystring += sectionstring
|
bodystring += sectionstring
|
||||||
|
|
@ -803,7 +817,7 @@ def GenerateTeacherBodyString(problems,sectiontitles,prodict,objdict,consecutive
|
||||||
idlist = generate_number_set(idstring,prodict)
|
idlist = generate_number_set(idstring,prodict)
|
||||||
sectionstring = "\\begin{enumerate}\n\n"
|
sectionstring = "\\begin{enumerate}\n\n"
|
||||||
for id in idlist:
|
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 += "\\item (%s) %s\n\n%s"%(id,prodict[id]["content"],aftercontent)
|
||||||
sectionstring += "\\end{enumerate}\n\n"
|
sectionstring += "\\end{enumerate}\n\n"
|
||||||
bodystring += sectionstring
|
bodystring += sectionstring
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
problems = ["20001:60000"] #题号列表, 每个字符串表示一个分块的题目
|
problems = ["1:600"] #题号列表, 每个字符串表示一个分块的题目
|
||||||
notetitle = "测试讲义教师版20001toend" #讲义标题, 也是文件标题
|
notetitle = "测试讲义教师版" #讲义标题, 也是文件标题
|
||||||
sectiontitles = ["课前","课后","测试"] #小节标题列表, 如果与题号列表长度不符则作为不设小节处理
|
sectiontitles = ["课前","课后","测试"] #小节标题列表, 如果与题号列表长度不符则作为不设小节处理
|
||||||
|
|
||||||
|
colored = False #是否使用背景色块
|
||||||
|
|
||||||
consecutivenumbering = True #不同小节是否连续编号, True表示连续编号, False表示每小节从1开始编号
|
consecutivenumbering = True #不同小节是否连续编号, True表示连续编号, False表示每小节从1开始编号
|
||||||
topandbottomusagestuple = (3,3) #表示保留得分率最高的使用记录与最低的使用记录的个数, 有负数表示不排列
|
topandbottomusagestuple = (3,3) #表示保留得分率最高的使用记录与最低的使用记录的个数, 有负数表示不排列
|
||||||
|
|
||||||
|
|
@ -35,7 +38,7 @@ if sys.platform != "win32": #非win系统用默认字体
|
||||||
|
|
||||||
starttime = time.time()
|
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
|
latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,(notetitle,bodystring)) #替换标题和bodystring
|
||||||
SaveTextFile(latex_data,outputfilepath) #保存.tex文件
|
SaveTextFile(latex_data,outputfilepath) #保存.tex文件
|
||||||
|
|
@ -47,7 +50,7 @@ else:
|
||||||
|
|
||||||
endtime = time.time()
|
endtime = time.time()
|
||||||
|
|
||||||
print("总处理时间: %.3f秒"%endtime-starttime)
|
print("总处理时间: %.3f秒"%(endtime-starttime))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Reference in New Issue