|
|
|
@ -17,37 +17,32 @@ def TakeRoll():
|
|
|
|
|
ins_sheet.cell(row=i, column=3).value = 0
|
|
|
|
|
i += 1
|
|
|
|
|
book.save(filename='sample.xlsx')
|
|
|
|
|
else:
|
|
|
|
|
return stu, idx
|
|
|
|
|
else: #学生表中含有已创建的SCredit列
|
|
|
|
|
max = 0
|
|
|
|
|
credit = ins_sheet['C']
|
|
|
|
|
credit = ins_sheet['C'] #将SCredit列存入redit数组
|
|
|
|
|
i = 1
|
|
|
|
|
while i <= sheet.nrows-1:
|
|
|
|
|
credit[i].value *= 2
|
|
|
|
|
credit[i].value *= 2 #将所有积分值整数化(所有非整数积分值小数部分均为0.5)
|
|
|
|
|
i += 1
|
|
|
|
|
i = 1
|
|
|
|
|
while i <= sheet.nrows-1:
|
|
|
|
|
if credit[i].value > max:
|
|
|
|
|
max = credit[i].value
|
|
|
|
|
i += 1
|
|
|
|
|
'''
|
|
|
|
|
while i<=sheet.nrows:
|
|
|
|
|
if ins_sheet.cell(row=i, column=3).value > max:
|
|
|
|
|
max = ins_sheet.cell(row=i, column=3).value
|
|
|
|
|
i += 1
|
|
|
|
|
'''
|
|
|
|
|
max += 1
|
|
|
|
|
max += 1 #求出最大积分值并加1
|
|
|
|
|
slct = []
|
|
|
|
|
i = 1
|
|
|
|
|
while i <= sheet.nrows-1:
|
|
|
|
|
credit[i].value = max - credit[i].value
|
|
|
|
|
credit[i].value = max - credit[i].value #倒转积分值,将最大的积分值置为1,其余积分依次增大
|
|
|
|
|
r = 1
|
|
|
|
|
while r <= int(credit[i].value):
|
|
|
|
|
slct.append(i)
|
|
|
|
|
r += 1
|
|
|
|
|
r += 1 #第i个学生倒转后的积分值即为slct数组中对应第i个学生的元素个数,和该生被选中的概率呈负相关
|
|
|
|
|
i += 1
|
|
|
|
|
idx = random.randint(0, len(slct)-1)
|
|
|
|
|
stu = str(ins_sheet.cell(row=slct[idx]+1, column=1).value) + ins_sheet.cell(row=slct[idx]+1, column=2).value
|
|
|
|
|
return stu, slct[idx]+1
|
|
|
|
|
return stu, slct[idx]+1
|
|
|
|
|
|
|
|
|
|
def CreditUpdate(stu, isInc, point):
|
|
|
|
|
book = openpyxl.load_workbook(filename='sample.xlsx')
|
|
|
|
@ -142,3 +137,4 @@ while True:
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
window.close()
|
|
|
|
|
|
|
|
|
|