批阅论文和作业Python程序助手

Posted 卓晴

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了批阅论文和作业Python程序助手相关的知识,希望对你有一定的参考价值。

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

关键词 EXCEL成绩作业

批阅作业
文章目录
背景介绍
处理程序
使用环境
处理程序
总 结

 

§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',ret

    ret = inforsub.setexcelcellstring(inforsub.shzhfile, idstr, hwstr, score)
    if ret >= 0: return 'SHZH',ret

    return ' ', -1

#------------------------------------------------------------
def appendscore(idstr, hwstr, score):
    ret = inforsub.appendexcelcellstring(inforsub.tshfile, idstr, hwstr, score)
    if ret >= 0:
        return 'TS',ret

    ret = inforsub.appendexcelcellstring(inforsub.shzhfile, idstr, hwstr, score)
    if ret >= 0:
        return 'SHZH',ret

    return ' ', -1

def showscore(idstr):
    ret = inforsub.showexcelinfor(inforsub.tshfile, idstr)
    if ret >= 0: return 'TS', ret

    ret = inforsub.showexcelinfor(inforsub.shzhfile, idstr)
    if ret >=0: return 'SHZH', ret

    return ' ', -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"%hwstr

        if 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',ret

    ret = inforsub.setexcelcellstring(inforsub.shzhfile, idstr, hwstr, score)
    if ret >= 0: return 'SHZH',ret

    return ' ', -1

#------------------------------------------------------------
def appendscore(idstr, hwstr, score):
    ret = inforsub.appendexcelcellstring(inforsub.tshfile, idstr, hwstr, score)
    if ret >= 0:
        return 'TS',ret

    ret = inforsub.appendexcelcellstring(inforsub.shzhfile, idstr, hwstr, score)
    if ret >= 0:
        return 'SHZH',ret

    return ' ', -1

def showscore(idstr):
    ret = inforsub.showexcelinfor(inforsub.tshfile, idstr)
    if ret >= 0: return 'TS', ret

    ret = inforsub.showexcelinfor(inforsub.shzhfile, idstr)
    if ret >=0: return 'SHZH', ret

    return ' ', -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"%hwstr

        if 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 -*-
#============================================

以上是关于批阅论文和作业Python程序助手的主要内容,如果未能解决你的问题,请参考以下文章

Python课设:作业统计管理系统,源码+实验报告+论文需要自取

清华大一Python作业太难上热榜!只上3节课,手撸AI算法,网友:离本科毕设只差一篇万字论文...

代码之间-论文修改助手v1.0版本发布

两分钟站在数据可视化前沿!让导师审阅论文不要那么累了!

清华大一Python作业太难上热榜!手撸AI算法,网友:离本科毕设只差一篇万字论文...

数据库课程设计 在线考试管理系统 大作业论文+源程序+数据库