批阅论文和作业Python程序助手
简 介: 利用网络学堂下载的作业文件中包含学号的信息,通过Python程序,可以自动定位EXCEL表中记录表格,使得成绩记录精确可靠。
关键词
: EXCEL,成绩,作业
Contents
§01 批阅作业
1.1 背景介绍
每到学期末,批阅课程学生提交的作业和论文的工作量很大。对于作业和论文成绩的等级也许需要做到精确可靠。
从网络学堂上可以下载到如下文件:
- 学生信息表格,前两列为学号和姓名;
- 作业和论文的打包文件;
在作业和论文文件下载时,网络学堂自动会在文件名称前增加了学号,因此可以以此为索引完成成绩在EXCEL表格中的记录。
本文下面给出的程序,通过几个学期的使用,验证了它的高效与可靠性。
1.2 处理程序
1.2.1 使用环境
- TEASOFT辅助程序。并在当前DOP中建立起EXCEL索引文件名称。
SHZH:
H:\Teaching\NN2021A\Homework\SZH.xls
TSH:
H:\Teaching\NN2021A\Homework\TSH.xls
EXCEL表格中的抬头应该与setscore中对应:
▲ 图1.2.1 EXCEL表格信息
1.2.2 处理程序
(1)记录所有提交文件
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# SETALLSCORE.PY -- by Dr. ZhuoQing 2021-12-27
#
# Note:
#============================================================from headm import * # =#------------------------------------------------------------
import inforsub#------------------------------------------------------------
def dropfile2studentid():tspdropfile2pastetext()pastestr = clipboard.paste()strsect = pastestr.split('\\')printf(strsect)for s in strsect[-1:0:-1]:if s.count('_') >= 1:if s.split('_')[0].isdigit():return s.split('_')[0]if s.split('_')[0][0] == 'P':return s.split('_')[0]return "ERROR"#------------------------------------------------------------
def setscore(idstr, hwstr, score):ret = inforsub.setexcelcellstring(inforsub.tshfile, idstr, hwstr, score)if ret >= 0: return 'TS',retret = inforsub.setexcelcellstring(inforsub.shzhfile, idstr, hwstr, score)if ret >= 0: return 'SHZH',retreturn ' ', -1#------------------------------------------------------------
def appendscore(idstr, hwstr, score):ret = inforsub.appendexcelcellstring(inforsub.tshfile, idstr, hwstr, score)if ret >= 0:return 'TS',retret = inforsub.appendexcelcellstring(inforsub.shzhfile, idstr, hwstr, score)if ret >= 0:return 'SHZH',retreturn ' ', -1def showscore(idstr):ret = inforsub.showexcelinfor(inforsub.tshfile, idstr)if ret >= 0: return 'TS', retret = inforsub.showexcelinfor(inforsub.shzhfile, idstr)if ret >=0: return 'SHZH', retreturn ' ', -1#------------------------------------------------------------
tspdropfile2pastetext()
pastestr = clipboard.paste().split('\n')#------------------------------------------------------------
id = []for ps in pastestr:pss = ps.split('\\')[-1]pss = pss.split('_')[0]if len(pss) > 0:id.append(pss)id = list(set(id))
printf(id, len(id))#------------------------------------------------------------
if __name__ == "__main__":hwstr = ''scorestr = ''if len(sys.argv) < 3:printf("Usage: setallscore hw score\a")exit()#--------------------------------------------------------if len(sys.argv) > 1:hwstr = sys.argv[1]if hwstr in "hw1 hw2 hw3 hw4".split():hwstr = hwstr.upper()if hwstr in "1 2 3 4".split():hwstr = "HW%s"%hwstrif hwstr == 'note':hwstr = 'NOTE'if hwstr == 'n':hwstr = 'NOTE'if hwstr == 'paper':hwstr = 'PAPER'if hwstr == 'p':hwstr = 'PAPER'if not hwstr in 'HW1 HW2 HW3 HW4 PAPER NOTE'.split():printf('HW string error[%s].\a'%hwstr)exit()if len(sys.argv) > 2:scorestr = sys.argv[2]for idstr in id:
# printf('Begin Modified:')
# showscore(idstr)if len(hwstr) > 0:if hwstr == 'NOTE':appendscore(idstr, 'NOTE', scorestr)else: setscore(idstr, hwstr, scorestr)# printf("After Modified:")
# showscore(idstr)id = list(set(id))
printf(id, len(id))
printf('\a')#------------------------------------------------------------
# END OF FILE : SETALLSCORE.PY
#============================================================
(2)登记单个文件成绩
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# SETSCORE.PY -- by Dr. ZhuoQing 2021-01-02
#
# Note:
#============================================================from head import *
import inforsub#------------------------------------------------------------
def dropfile2studentid():tspdropfile2pastetext()pastestr = clipboard.paste()strsect = pastestr.split('\\')printf(strsect)for s in strsect[-1:0:-1]:if s.count('_') >= 1:if s.split('_')[0].isdigit():return s.split('_')[0]if s.split('_')[0][0] == 'P':return s.split('_')[0]return "ERROR"#------------------------------------------------------------
def setscore(idstr, hwstr, score):ret = inforsub.setexcelcellstring(inforsub.tshfile, idstr, hwstr, score)if ret >= 0: return 'TS',retret = inforsub.setexcelcellstring(inforsub.shzhfile, idstr, hwstr, score)if ret >= 0: return 'SHZH',retreturn ' ', -1#------------------------------------------------------------
def appendscore(idstr, hwstr, score):ret = inforsub.appendexcelcellstring(inforsub.tshfile, idstr, hwstr, score)if ret >= 0:return 'TS',retret = inforsub.appendexcelcellstring(inforsub.shzhfile, idstr, hwstr, score)if ret >= 0:return 'SHZH',retreturn ' ', -1def showscore(idstr):ret = inforsub.showexcelinfor(inforsub.tshfile, idstr)if ret >= 0: return 'TS', retret = inforsub.showexcelinfor(inforsub.shzhfile, idstr)if ret >=0: return 'SHZH', retreturn ' ', -1#------------------------------------------------------------
if __name__ == "__main__":idstr = dropfile2studentid()if idstr == 'ERROR':printf("No student id is found by drop file !\a")exit()printf('ID : %s\a'%idstr)#--------------------------------------------------------hwstr = ''scorestr = ''printf('Begin Modified:')x, y = showscore(idstr)printff(x,y)if len(sys.argv) > 1:hwstr = sys.argv[1]if hwstr in "hw1 hw2 hw3 hw4".split():hwstr = hwstr.upper()if hwstr in "1 2 3 4".split():hwstr = "HW%s"%hwstrif hwstr == 'note':hwstr = 'NOTE'if hwstr == 'n':hwstr = 'NOTE'if hwstr == 'paper':hwstr = 'PAPER'if hwstr == 'p':hwstr = 'PAPER'if not hwstr in 'HW1 HW2 HW3 HW4 PAPER NOTE'.split():printf('HW string error[%s].\a'%hwstr)exit()if len(sys.argv) > 2:scorestr = sys.argv[2]if len(hwstr) > 0:if hwstr == 'NOTE':appendscore(idstr, 'NOTE', scorestr)else: setscore(idstr, hwstr, scorestr)#--------------------------------------------------------printf("After Modified:")showscore(idstr)printf(' \a')#------------------------------------------------------------
# END OF FILE : SETSCORE.PY
#============================================================
(3)辅助程序
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# INFORSUB.PY -- by Dr. ZhuoQing 2020-06-18
#
# Note:
#============================================================from headm import * # =
import pandas as pd#------------------------------------------------------------
tshfile = tspstring2text('TSH')
shzhfile = tspstring2text('SHZH')HOMEWORK_SHEET = 'homework'#------------------------------------------------------------
def showexcel(filename):excelfile = pd.read_excel(filename, sheet_name=HOMEWORK_SHEET)listdata = excelfile.values.tolist()for id,l in enumerate(listdata):printff(id, l)def showexcelinfor(filename, sid):excelfile = pd.read_excel(filename, sheet_name=HOMEWORK_SHEET)rowid = -1for id, content in excelfile.items():if id == '学号':content = [str(s) for s in content]if str(sid) in content:rowid = content.index(str(sid))breakif rowid < 0:return rowidprintf(excelfile.values.tolist()[rowid])return rowid#------------------------------------------------------------
def setexcelcellstring(filename, sid, col, num):excelfile = pd.read_excel(filename, sheet_name=HOMEWORK_SHEET)rowid = -1for id, content in excelfile.items():if id == '学号':content = [str(s) for s in content]if str(sid) in content:rowid = content.index(str(sid))breakif rowid < 0:return rowidprintff(rowid, col)excelfile[col] = excelfile[col].astype(str)excelfile.at[rowid, col] = numexcelfile.to_excel(filename, sheet_name=HOMEWORK_SHEET, index=False)return rowid#------------------------------------------------------------
def appendexcelcellstring(filename, sid, col, num):excelfile = pd.read_excel(filename, sheet_name=HOMEWORK_SHEET)rowid = -1for id, content in excelfile.items():if id == '学号':content = [str(s) for s in content]if str(sid) in content:rowid = content.index(str(sid))breakif rowid < 0:return rowidprintff(rowid, col)excelfile[col] = excelfile[col].astype(str)if excelfile.at[rowid, col] != 'nan':excelfile.at[rowid, col] = num + ', ' + excelfile.at[rowid, col]else: excelfile.at[rowid, col] = numif len(num) == 0: excelfile.at[rowid, col] = ''excelfile.to_excel(filename, sheet_name=HOMEWORK_SHEET, index=False)return rowid#------------------------------------------------------------
def getexcelcellstring(filename, sid, col):excelfile = pd.read_excel(filename, sheet_name=HOMEWORK_SHEET)rowid = -1for id, content in excelfile.items():if id == '学号':content = [str(s) for s in content]if str(sid) in content:rowid = content.index(str(sid))breakif rowid < 0:return rowid# printff(rowid, col)
# excelfile[col] = excelfile[col].astype(str)return excelfile.at[rowid, col]#------------------------------------------------------------
if __name__ == "__main__":
# setexcelcellstring(tshfile, '2020210975', 'HW1', 88)
# s = getexcelcellstring(tshfile, '2020210975', 'HW1')
# printf(s)
# showexcel(shzhfile)x=showexcelinfor(shzhfile, '2020280355')printf(x)#------------------------------------------------------------
# END OF FILE : INFORSUB.PY
#============================================================
(4)统计缺少信息
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# NOWORK.PY -- by Dr. ZhuoQing 2021-12-27
#
# Note:
#============================================================from headm import * # =strid = 14tspgetdopstring(-strid)
allstr = [s for s in clipboard.paste().split("\r\n") if len(s) > 0]printf(allstr)#------------------------------------------------------------infordim = []for s in allstr:ss = s.split('\t')printf(ss)flag = 0str = ss[0] + ':'for id,sss in enumerate(ss[2:]):if not sss.replace('.', '').isdigit():flag = 1str = str + 'HW%d,'%(id+1)if flag > 0:infordim.append(str)printf(infordim)
#------------------------------------------------------------for s in infordim:printf(s)#------------------------------------------------------------
# END OF FILE : NOWORK.PY
#============================================================
※ 总 结 ※
利用网络学堂下载的作业文件中包含学号的信息,通过Python程序,可以自动定位EXCEL表中记录表格,使得成绩记录精确可靠。
● 相关图表链接:
- 图1.2.1 EXCEL表格信息
批阅论文和作业Python程序助手相关推荐
- CMU发布船新「论文评审」Python程序,淘汰人工审核,自动给arXiv打分
晓查 发自 凹非寺 量子位 报道 | 公众号 QbitAI 什么?同行评审已经可以被AI程序取代了? 就在4月1日,CMU提出了最新的评审标准算法--State-Of-the-Art Review, ...
- python作业题目用户输入行数、输出倒的等腰三角形_Python爬虫作业 | Python 程序逻辑训练3题...
操作环境:Python版本,2.7.13:PyCharm版本,2017.1:电脑:Win 10 1703 1. 打印三角形 分为三角形,倒三角形和等腰三角形 #coding:utf-8 rows = ...
- python实验报告代写价格_代写OS python程序作业、代写代写OS作业、代写OS实验报告...
代写OS python程序作业.代写代写OS作业.代写OS实验报告 日期:2018-06-11 03:21 CSE 304 - Operating Systems DUE: June 11. Subm ...
- Python代写CSSE1001/7030 python程序作业、代做python CSSE1001/7030程序作业、 代写CSSE1001/7030 python 作业...
Python代写CSSE1001/7030 python程序作业.代做python CSSE1001/7030程序作业. 代写CSSE1001/7030 python 作业 Uno++ Assignm ...
- python实验报告代写_TensorFlow作业代写、代做Python程序语言作业、代写github课程作业、Python实验作业代写...
TensorFlow作业代写.代做Python程序语言作业.代写github课程作业.Python实验作业代写 日期:2019-07-10 10:34 Python Practical Examine ...
- Springboot旅游助手系统wp1hv计算机毕业设计-课程设计-期末作业-毕设程序代做
Springboot旅游助手系统wp1hv计算机毕业设计-课程设计-期末作业-毕设程序代做 [免费赠送源码]Springboot旅游助手系统wp1hv计算机毕业设计-课程设计-期末作业-毕设程序代做 ...
- python代写学生作业_代做python程序作业、代写 tree Tpython留学生作业
代做python程序作业.代写 tree Tpython留学生作业 日期:2018-05-27 02:10 Exercise 2 We are again interested in lists of ...
- 代写python期末作业价格_代写program留学生作业、代做Python程序语言作业、代写Python课程设计作业...
代写program留学生作业.代做Python程序语言作业.代写Python课程设计作业 日期:2019-11-29 12:55 Completing the Final Project - Pyth ...
- 全球最年轻的Python程序员;13 岁创建 RISC-V 内核,后浪程序员有多恐怖?
[CSDN 编者按]前不久,英国一位仅 6 岁多的孩子获得了 IBM AI 认证,创下新的吉尼斯记录,成为全球最年轻程序员.前有 AI 编程掀餐桌,后有 6 岁娃娃抢饭碗,程序员们真的太难了.别慌,今 ...
最新文章
- 配置集群Nginx+Memcached+Tomcat集群配置
- Hadoop Hive概念学习系列之hive的数据压缩(七)
- Leetcode--424. 替换后的最长重复字符
- 计算机系统军训口号,霸气的军训口号大全
- PT短网址缩短还原网站源码,php版+html版
- Java会话技术之 —— cookie与session
- jzoj3736. 【NOI2014模拟7.11】数学题
- 创业,如果条件允许,你最想开一个什么店?
- matlab cg steihaug,截断共轭梯度法
- solaris 系统信息查看
- 计算机化学博士点,2017年新增博士硕士授予单位公布!各高校博士、硕士学位授权点建设的总体情况如何?...
- android wear刷机,1分钟搞定刷机 百度DuWear手表系统公测版上线
- 用 Telegram bot 搭个消息提醒服务
- linux下c使用lzma_linux 编译lzma
- 计算机文档翻页怎么设置,PDF文档翻页设置
- brctl 使用说明
- 计算机系统实验三——buflab(缓冲区实验)
- 阿里云基于区块链服务构建企业业务系统实践总结
- 360n4s高通版卡刷包
- 牛客小白月赛5 D.阶乘(factorial)