简 介: 利用网络学堂下载的作业文件中包含学号的信息,通过Python程序,可以自动定位EXCEL表中记录表格,使得成绩记录精确可靠。

关键词EXCEL成绩作业

#mermaid-svg-GnpfhAaFKFf7Hosw {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-GnpfhAaFKFf7Hosw .error-icon{fill:#552222;}#mermaid-svg-GnpfhAaFKFf7Hosw .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-GnpfhAaFKFf7Hosw .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-GnpfhAaFKFf7Hosw .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-GnpfhAaFKFf7Hosw .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-GnpfhAaFKFf7Hosw .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-GnpfhAaFKFf7Hosw .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-GnpfhAaFKFf7Hosw .marker{fill:#333333;stroke:#333333;}#mermaid-svg-GnpfhAaFKFf7Hosw .marker.cross{stroke:#333333;}#mermaid-svg-GnpfhAaFKFf7Hosw svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-GnpfhAaFKFf7Hosw .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-GnpfhAaFKFf7Hosw .cluster-label text{fill:#333;}#mermaid-svg-GnpfhAaFKFf7Hosw .cluster-label span{color:#333;}#mermaid-svg-GnpfhAaFKFf7Hosw .label text,#mermaid-svg-GnpfhAaFKFf7Hosw span{fill:#333;color:#333;}#mermaid-svg-GnpfhAaFKFf7Hosw .node rect,#mermaid-svg-GnpfhAaFKFf7Hosw .node circle,#mermaid-svg-GnpfhAaFKFf7Hosw .node ellipse,#mermaid-svg-GnpfhAaFKFf7Hosw .node polygon,#mermaid-svg-GnpfhAaFKFf7Hosw .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-GnpfhAaFKFf7Hosw .node .label{text-align:center;}#mermaid-svg-GnpfhAaFKFf7Hosw .node.clickable{cursor:pointer;}#mermaid-svg-GnpfhAaFKFf7Hosw .arrowheadPath{fill:#333333;}#mermaid-svg-GnpfhAaFKFf7Hosw .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-GnpfhAaFKFf7Hosw .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-GnpfhAaFKFf7Hosw .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-svg-GnpfhAaFKFf7Hosw .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-svg-GnpfhAaFKFf7Hosw .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-GnpfhAaFKFf7Hosw .cluster text{fill:#333;}#mermaid-svg-GnpfhAaFKFf7Hosw .cluster span{color:#333;}#mermaid-svg-GnpfhAaFKFf7Hosw div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-GnpfhAaFKFf7Hosw :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}

批阅作业
目 录
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程序助手相关推荐

  1. CMU发布船新「论文评审」Python程序,淘汰人工审核,自动给arXiv打分

    晓查 发自 凹非寺  量子位 报道 | 公众号 QbitAI 什么?同行评审已经可以被AI程序取代了? 就在4月1日,CMU提出了最新的评审标准算法--State-Of-the-Art Review, ...

  2. python作业题目用户输入行数、输出倒的等腰三角形_Python爬虫作业 | Python 程序逻辑训练3题...

    操作环境:Python版本,2.7.13:PyCharm版本,2017.1:电脑:Win 10 1703 1. 打印三角形 分为三角形,倒三角形和等腰三角形 #coding:utf-8 rows = ...

  3. python实验报告代写价格_代写OS python程序作业、代写代写OS作业、代写OS实验报告...

    代写OS python程序作业.代写代写OS作业.代写OS实验报告 日期:2018-06-11 03:21 CSE 304 - Operating Systems DUE: June 11. Subm ...

  4. Python代写CSSE1001/7030 python程序作业、代做python CSSE1001/7030程序作业、 代写CSSE1001/7030 python 作业...

    Python代写CSSE1001/7030 python程序作业.代做python CSSE1001/7030程序作业. 代写CSSE1001/7030 python 作业 Uno++ Assignm ...

  5. python实验报告代写_TensorFlow作业代写、代做Python程序语言作业、代写github课程作业、Python实验作业代写...

    TensorFlow作业代写.代做Python程序语言作业.代写github课程作业.Python实验作业代写 日期:2019-07-10 10:34 Python Practical Examine ...

  6. Springboot旅游助手系统wp1hv计算机毕业设计-课程设计-期末作业-毕设程序代做

    Springboot旅游助手系统wp1hv计算机毕业设计-课程设计-期末作业-毕设程序代做 [免费赠送源码]Springboot旅游助手系统wp1hv计算机毕业设计-课程设计-期末作业-毕设程序代做 ...

  7. python代写学生作业_代做python程序作业、代写 tree Tpython留学生作业

    代做python程序作业.代写 tree Tpython留学生作业 日期:2018-05-27 02:10 Exercise 2 We are again interested in lists of ...

  8. 代写python期末作业价格_代写program留学生作业、代做Python程序语言作业、代写Python课程设计作业...

    代写program留学生作业.代做Python程序语言作业.代写Python课程设计作业 日期:2019-11-29 12:55 Completing the Final Project - Pyth ...

  9. 全球最年轻的Python程序员;13 岁创建 RISC-V 内核,后浪程序员有多恐怖?

    [CSDN 编者按]前不久,英国一位仅 6 岁多的孩子获得了 IBM AI 认证,创下新的吉尼斯记录,成为全球最年轻程序员.前有 AI 编程掀餐桌,后有 6 岁娃娃抢饭碗,程序员们真的太难了.别慌,今 ...

最新文章

  1. 配置集群Nginx+Memcached+Tomcat集群配置
  2. Hadoop Hive概念学习系列之hive的数据压缩(七)
  3. Leetcode--424. 替换后的最长重复字符
  4. 计算机系统军训口号,霸气的军训口号大全
  5. PT短网址缩短还原网站源码,php版+html版
  6. Java会话技术之 —— cookie与session
  7. jzoj3736. 【NOI2014模拟7.11】数学题
  8. 创业,如果条件允许,你最想开一个什么店?
  9. matlab cg steihaug,截断共轭梯度法
  10. solaris 系统信息查看
  11. 计算机化学博士点,2017年新增博士硕士授予单位公布!各高校博士、硕士学位授权点建设的总体情况如何?...
  12. android wear刷机,1分钟搞定刷机 百度DuWear手表系统公测版上线
  13. 用 Telegram bot 搭个消息提醒服务
  14. linux下c使用lzma_linux 编译lzma
  15. 计算机文档翻页怎么设置,PDF文档翻页设置
  16. brctl 使用说明
  17. 计算机系统实验三——buflab(缓冲区实验)
  18. 阿里云基于区块链服务构建企业业务系统实践总结
  19. 360n4s高通版卡刷包
  20. 牛客小白月赛5 D.阶乘(factorial)

热门文章

  1. SIGIR阿里论文 | 可视化理解深度神经网络CTR预估模型
  2. Linux下du加强版,灵活快速定位硬盘使用情况,无需安装
  3. (四)Thymeleaf标准表达式之——[3-6] 操作符(文本、算术、布尔、比较及相等)...
  4. oracle的用户账号密码设置
  5. SCCM2012R2之二安装SQL Server
  6. Linux下查看/修改系统时区、时间
  7. LYNC2013部署系列PART2:后端部署
  8. 获取SQL Server 2000数据库和表空间使用信息
  9. Maven在windows下的安装
  10. java远程调用笔记