From 5933adeb5b7201c719b9213d801da0c65039f039 Mon Sep 17 00:00:00 2001 From: Lyanling <1736289433@qq.com> Date: Tue, 8 Oct 2024 13:13:02 +0800 Subject: [PATCH] first commit --- .../polls/__pycache__/models.cpython-37.pyc | Bin 928 -> 1006 bytes .../polls/__pycache__/urls.cpython-37.pyc | Bin 547 -> 605 bytes .../polls/__pycache__/views.cpython-37.pyc | Bin 3010 -> 3331 bytes .../migrations/0003_student_called_count.py | 18 ++++++++++++ .../migrations/0004_student_protected.py | 18 ++++++++++++ .../0003_student_called_count.cpython-37.pyc | Bin 0 -> 601 bytes .../0004_student_protected.cpython-37.pyc | Bin 0 -> 604 bytes pythonProject03/mysite10_7/polls/models.py | 2 ++ .../polls/templates/leaderboard.html | 27 ++++++++++++++++++ pythonProject03/mysite10_7/polls/urls.py | 1 + pythonProject03/mysite10_7/polls/views.py | 9 +++++- 11 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 pythonProject03/mysite10_7/polls/migrations/0003_student_called_count.py create mode 100644 pythonProject03/mysite10_7/polls/migrations/0004_student_protected.py create mode 100644 pythonProject03/mysite10_7/polls/migrations/__pycache__/0003_student_called_count.cpython-37.pyc create mode 100644 pythonProject03/mysite10_7/polls/migrations/__pycache__/0004_student_protected.cpython-37.pyc create mode 100644 pythonProject03/mysite10_7/polls/templates/leaderboard.html diff --git a/pythonProject03/mysite10_7/polls/__pycache__/models.cpython-37.pyc b/pythonProject03/mysite10_7/polls/__pycache__/models.cpython-37.pyc index 88751921f26ad3d1aec85ae56021e10eaee74f6e..ef9a4d812c0fa29a3f4fb322a3affe4ca7d9a1b8 100644 GIT binary patch delta 184 zcmZ3${*Il`iILw2{xBk?908UVY+ B7hC`U diff --git a/pythonProject03/mysite10_7/polls/__pycache__/urls.cpython-37.pyc b/pythonProject03/mysite10_7/polls/__pycache__/urls.cpython-37.pyc index 2205bd279e104980e4647b3e2e3218ba1d825be1..4c7d1684e97d17a3c8e97a3104cad5723af8253b 100644 GIT binary patch delta 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1018 zcmZ8g-)qxQ6z)yB^e#=(u50JkPRGXFRwlB}{ghdTL)0-56dx=?D7ontNSkt!I`L(K zKFVNR-}S{OAN>Oa{V#&(lmCLK58^rLMAtyRbMMJH=R4=SH_yu-&so<^Q%~XZ`pRiCHgZ-IzH*@qNgW zU*8M%y^j6Za}N#Nhk1k)vzVoDR%D!UMOUCApQ$@Fsxz3Livn=>y)beisWCw{PU$CQ zeRx8e=|_tuWm*I|gjipyEnit#U0dJStg5jVMm^gTK+G^AU!}LR1zL_06y?|S^lrjD zPJ61~P%&e$5%WwN=P@iK!ekU2qdyAF$lalLtRTM+UC?InD_oRiZB^s6EXW7i1}n*9 zZE7zeoJVg%cb_<}Z?`<(jTO;~nH{ST96~>v@&*LW^}2r06gKuK+)fl$Epn>nbQP5Py8`KX~2w7c~ia)BQ&T%yV)gjj9*J}l5SQDusJ8RsDI95;kn`Grs1 zq;4DhFCko|;5CA?EHH<@I=-ieth2OQR4mlSz+;9vZ1J19f#0jFKVCsD>GzH(>*<&i zbXp#?Z3ukdcCe?*2T|LH6$&@t8k+urWoVUj|F7p|^u_sR6uBMI>^QFN1iela54BLJ z2&O4RBcOXzO+zAnqAyi11GPLj$|m~m$Vzrzqg8cO{?2Y4kv0vj+eDTS7IA|V0klI% z&X=w?R0t*sW(aBoG$2r!|40($k{^U`wFA-f-8#dFu#8}kUZ*$8P`JWPp5_KGDLnTF D%r46V diff --git a/pythonProject03/mysite10_7/polls/migrations/0003_student_called_count.py b/pythonProject03/mysite10_7/polls/migrations/0003_student_called_count.py new file mode 100644 index 0000000..61d762d --- /dev/null +++ b/pythonProject03/mysite10_7/polls/migrations/0003_student_called_count.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.25 on 2024-10-07 16:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('polls', '0002_student'), + ] + + operations = [ + migrations.AddField( + model_name='student', + name='called_count', + field=models.IntegerField(default=0), + ), + ] diff --git a/pythonProject03/mysite10_7/polls/migrations/0004_student_protected.py b/pythonProject03/mysite10_7/polls/migrations/0004_student_protected.py new file mode 100644 index 0000000..d0a8e4b --- /dev/null +++ b/pythonProject03/mysite10_7/polls/migrations/0004_student_protected.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.25 on 2024-10-07 16:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('polls', '0003_student_called_count'), + ] + + operations = [ + migrations.AddField( + model_name='student', + name='protected', + field=models.BooleanField(default=False), + ), + ] diff --git a/pythonProject03/mysite10_7/polls/migrations/__pycache__/0003_student_called_count.cpython-37.pyc b/pythonProject03/mysite10_7/polls/migrations/__pycache__/0003_student_called_count.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9f2499384e249bd0750c2584b2db161a38f71356 GIT binary patch literal 601 zcmYjO&5G1O5bjRrZ-!a$psyeVWQnuFqKK>_iU$|LTL?5URhvodq+@r2%vq1_V|ehD z`s&G7@MLv%!&;$>`uS2nU%fgx*)o!!N!a}0jQ#e`Dj^vc^z1`Yz*@A1A)8~-$WrG{K&HC4`EprxNYAyrkYwkSQqyiP}$n2R*A{Dpl2VELRN5KMF70v zg}|_jd~uAs1VV_eImFk3GASg~B6XYhYi(*2jan(|c6pxfrJZKLVRFf8?CMG>1X=5O zm<(;mGVT( z4%D-5(VBqjyYwZ%8(+f+@9y3W6EaTkJtQ?QiK@a$%OXqiZsHs30sZgN=QrfM@cUZN!9DR0%b=q{ literal 0 HcmV?d00001 diff --git a/pythonProject03/mysite10_7/polls/migrations/__pycache__/0004_student_protected.cpython-37.pyc b/pythonProject03/mysite10_7/polls/migrations/__pycache__/0004_student_protected.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..16135c516b4670c4dcc3579bf90afa37d4361977 GIT binary patch literal 604 zcmYLG&2H2%5Vm6{n_abt0~~k(q)4a=ZKVo?P^r*zqC(;pMY2L>x|`s{!A^ws4A;H@ zZ@?@0%86It#5mn;C-P|iGBe*dSI5UIMzVe+H@`Sze}Z!mNya5T_nZ_k;F@*3;9XQi zoPA&rf%wTlAaBJFQ3#NqSr-4LT9!qA)ioPijg9G@PdWprT^&*fNyxaQ=U$LPR&ZcN z1bo8_fwGN5b4=O=NQiGaB)5VxDJ*D2>X#o6y=hQ97_FUumgo7Ia^nQpkE*V;Mo_hx z`q3};QNJ9l8L=J_)*1H;z?*8)Vul*$HOH0mE2XGz(n$7^ zQs1UZhuYu)4%pM=xG2}*uec01RM_%c@)K!&0~hX}ibP5t(KpAhGwGMmR{h4Dz?T`%jABkctb1oYrT=~U=8l=S0jvuI HJQn`}(<-IQ literal 0 HcmV?d00001 diff --git a/pythonProject03/mysite10_7/polls/models.py b/pythonProject03/mysite10_7/polls/models.py index d6563c0..c5011aa 100644 --- a/pythonProject03/mysite10_7/polls/models.py +++ b/pythonProject03/mysite10_7/polls/models.py @@ -17,6 +17,8 @@ class Student(models.Model): student_id = models.CharField(max_length=100, unique=True) # 学号设为唯一 score = models.FloatField(default=0) # 积分允许为小数 attendance_count = models.IntegerField(default=0) # 到课次数 + called_count = models.IntegerField(default=0) # 被点名次数 + protected = models.BooleanField(default=False) # 是否有保护权 def __str__(self): return self.name diff --git a/pythonProject03/mysite10_7/polls/templates/leaderboard.html b/pythonProject03/mysite10_7/polls/templates/leaderboard.html new file mode 100644 index 0000000..997ce63 --- /dev/null +++ b/pythonProject03/mysite10_7/polls/templates/leaderboard.html @@ -0,0 +1,27 @@ + + + + 积分排行榜 + + +

积分排行榜

+ + + + + + + + + {% for student in students %} + + + + + + + + {% endfor %} +
排名学号姓名积分到课次数
{{ forloop.counter }} {{ student.student_id }}{{ student.name }}{{ student.score }}{{ student.attendance_count }}
+ + \ No newline at end of file diff --git a/pythonProject03/mysite10_7/polls/urls.py b/pythonProject03/mysite10_7/polls/urls.py index e9d2e41..49c7c78 100644 --- a/pythonProject03/mysite10_7/polls/urls.py +++ b/pythonProject03/mysite10_7/polls/urls.py @@ -8,4 +8,5 @@ urlpatterns = [ path('upload/', views.upload_students, name='upload_students'), path('roll_call/', views.roll_call, name='roll_call'), path('confirm_roll_call/', views.confirm_roll_call, name='confirm_roll_call'), # 确认点名 + path('leaderboard/', views.leaderboard, name='leaderboard'), ] \ No newline at end of file diff --git a/pythonProject03/mysite10_7/polls/views.py b/pythonProject03/mysite10_7/polls/views.py index 9c8f2df..c040159 100644 --- a/pythonProject03/mysite10_7/polls/views.py +++ b/pythonProject03/mysite10_7/polls/views.py @@ -4,6 +4,8 @@ from .models import * from django.shortcuts import render, redirect, get_object_or_404 import random import pandas as pd +from django.db.models import Window, F +from django.db.models.functions import Rank # 导入表单 from .forms import UploadFileForm # Create your views here. @@ -100,4 +102,9 @@ def confirm_roll_call(request): student.save() # 保存更新后的学生信息 return redirect('roll_call') # 返回点名页面,进行下一轮点名 - return render(request, 'confirm_roll_call.html', {'student': student}) # 渲染确认点名页面 \ No newline at end of file + return render(request, 'confirm_roll_call.html', {'student': student}) # 渲染确认点名页面 + +# 积分排行榜 +def leaderboard(request): + students = Student.objects.all().order_by('-score') # 按分数降序排列 + return render(request, 'leaderboard.html', {'students': students}) \ No newline at end of file