database_tools中新增生成备课草稿功能

This commit is contained in:
weiye.wang 2023-07-08 17:06:03 +08:00
parent ac1590b26e
commit a5c4a697c7
2 changed files with 81 additions and 0 deletions

View File

@ -836,5 +836,41 @@ def generate_lessonid_list(lessonidstr,lessonsdict): #根据lessonidstr的条件
break
return lessons_list # 返回课时代码列表
def GenerateLessonPreparationDraft(notetitle, outputdir, adict, prodict, objdict, lessonsdict, topandbottomusagestuple = (3,3), showobjs = True, showtags = True, showans = True, showsolution = True, showusages = True, showorigin = True, showremark = True): #根据adict中课时与题号的对应生成每一课时的备课草稿
output = "\\tableofcontents\n\\newpage\n\n"
outputfilepath = os.path.join(outputdir,notetitle+".tex")
for lid in adict:
output += "\\section{%s \ %s}\n\n"%(lid,lessonsdict[lid]["name"])
output += "\\subsection{课时目标}\n\n"
output += "\\begin{enumerate}\n\n"
for objid in objdict:
if objid.startswith(lid):
output += "\\item %s \\ %s \n\n"%(objid,objdict[objid]["content"])
output += "\\end{enumerate}\n\n"
output += GenerateTeacherBodyString([adict[lid]],["参考题目资源"],prodict,objdict,sectionname = "subsection",topandbottomusagestuple= topandbottomusagestuple, showobjs = showobjs, showtags = showtags, showans = showans, showsolution = showsolution, showusages = showusages, showorigin = showorigin, showremark = showremark)
output += "\\newpage\n\n"
latex_raw = ReadTextFile("模板文件/讲义模板.txt")
latex_raw = latex_raw.replace(r"学号\blank{50} \ 姓名\blank{80}","上海市控江中学") #替换掉模板中的姓名学号
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)
latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,(notetitle,output)) #替换标题和bodystring
SaveTextFile(latex_data,outputfilepath) #保存.tex文件
if XeLaTeXCompile(outputdir,notetitle+".tex"):
print("编译成功")
return 0 # 返回0
else:
print("编译失败")
return latex_data # 返回有错误的latex源代码
if __name__ == "__main__":
print("数据库工具, import用.")

View File

@ -0,0 +1,45 @@
{
"K0101": "011739:011745,011750:011752,009426:009427,010019,010026,000019,020001:020004,020009,020010,020012:020015,020020",
"K0102": "011746:011749,009428:009430,010017:010018,000001:000002,020005:020008,020011",
"K0103": "011753:011757,009431:009433,010020:010022,010027:010028,000009,000011,000014,000016,020009,020016:020041",
"K0104": "011758:011765,009434:009436,010023:010025,010029,000004:000007,000013:000015,020042:020069",
"K0105": "011766:011771,011783,009437:009439,010030:010032,010036,020070:020075,020090",
"K0106": "011772:011775,009440:009441,010033:010035,010037:010039,000003,000008:000009,000012,020076:020086,020091,030001",
"K0107": "011776:011782,009442:009444,000010,000017:000018,020087:020089,020092:020096",
"K0201": "011856:011859,011864,009469:009471,010105,010106,010112,020352,020358:020360,020362,020366,020370",
"K0202": "011860,011861,009472,009473,010107:010110,010113,020353:020356,020363,020364,020367",
"K0203": "011862:011863,009474,009475,010111,010114,000050,000051,000057,000058,020357,020361,020365,020368,020371",
"K0204": "011865:011870,009476:009478,010115:010118,010123,000049,000074,020373:020377,020380,020381,020382,020390",
"K0205": "011871:011873,011875,009479:009481,010119,010120,010124,010125,000052,000056,020379,020383:020389,020391",
"K0206": "011874,011876:011881,009482:009484,010121,010122,010126:010128,000048,000053:000055,000059,000060,020378,020392:020403,20476",
"K0207": "11882:11886,9485:9487,65,10129:10131,10135,20404:20411,20413:20416,20422",
"K0208": "11887:11891,9488:9490,10132:10134,10136:10139,20417:20421,20425:20426,20605:20611",
"K0209": "11892:11896,11899,9491:9493,69,72,10140:10142,10154,20427:20429,20431:20434,20440:20442,20457:20458",
"K0210": "11897,11900:11901,9494:9495,10143:10145,10152,20430,20435:20437,20439,20443:20444,20448,20450,20453",
"K0211": "11898,11902:11906,9496:9498,68,10146:10151,10153,20438,20445:20447,20449,20452,20454:20456",
"K0212": "11907:11912,9499:9501,61:63,10155:10157,10163,20459,20461,20462:20467,20470,20474,20477:20478",
"K0213": "11913:11917,9502:9504,64,66,70,73,10158:10162,10164,20460,20468:20469,20417,20472:20473,20480,20487:20488,20493",
"K0214": "11918:11923,9505:9506,67,71,75,10165:10167,20475,20479,20481:20483,20485:20486,20489:20491",
"K0215": "11924:11930,9507:9509,10168:10169,10171,76,81,20451,20484,20492,20494:20495,20498,20500,20502,20504:20506,20509,20511:20513,20517:20519,20575,20578,20580",
"K0216": "11931:11937,9510:9511,10170,10172,90,20501,20503,20507:20508,20510,20514:20516,20612:20613",
"K0217": "11938:11942,9512:9514,10173:10175,10182,78,85,93,20424,20521:20526,20529,20531,20533:20538,20543:20544,20588,20592,20615",
"K0218": "11943:11947,9515:9516,10176,10183,77,88,20527:20528,20530,20532,20539:20542,20545",
"K0219": "11947:11951,9517:9519,10177,10187,20547:20551,20554:20556,20560:20561,20563,20566,20573,20587,20589,20591,20593:20595",
"K0220": "11952:11958,9520:9522,10178,10184,79:80,89,91:92,20496,20546,20552:20553,20557:20559,20562,20564:20565,20567,20568:20572,20584:20586,20590,20596,20616,20618,20621,20628",
"K0221": "11959:11963,9523:9525,10179:10181,10185:10186,10188,82,84,86:87,20497,20574,20576:20577,20579,20581:20583,20597:20604,20614,20617,20619:20620,20622:20627,20629:20636",
"K0222": "11964:11968,9526:9528,10189:10190,10193:10195,83,20520,20637:20643",
"K0223": "11969:11972,9529:9530,10196:10197,20650:20674,20676",
"K0224": "11973:11977,9531:9532,10191:10192,20675,20677:20683",
"K0225": "11978:11981,9533:9535,10198:10201,94",
"K0226": "11982:11987,9536:9538,10202",
"K0401": "18258:18262,9875:9877,10742:10744,10748,10750,10755,20684:20706",
"K0402": "18263:18266,9878:9880,10745:10747,10749,10751:10754,20707:20729,308:312,318,321",
"K0403": "18267:18272,9881:9883,10756:10761,10765,10768,20730:20749,306,313:314,317,319",
"K0404": "18273:18278,18312:18313,9884:9886,10762:10763,10766:10767,20750:20763",
"K0405": "18279:18284,18311,9887:9889,10764,10769,20764:20779",
"K0406": "18286:18290,9890:9892,10770:10773,10775,10777:10778,10780,20780:20793",
"K0407": "18291:18294,9893:9895,10774,10776,10779,10781,20794:20808,20834:20849,307,320,324:325",
"K0408": "18295:18299,9896:9898,10782:10786,20809:20818,315,322",
"K0409": "18300:18306,18314,9899:9901,10787:10788,20819:20833,316,323",
"K0410": "18307:18309,9902:9904"
}