main
lsh 2 months ago
parent 619191b829
commit 77584735d0

@ -0,0 +1,16 @@
"""
ASGI config for config project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
application = get_asgi_application()

@ -0,0 +1,134 @@
"""
Django settings for config project.
Generated by 'django-admin startproject' using Django 5.1.1.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-q4zt_!3q_l9bdtyzdaeqvf=gm)6^g+)h^h400+jugzvdeakvl5'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'user.apps.UserConfig'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
# 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'config.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'pages')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'config.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/5.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.1/howto/static-files/
# Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# settings.py
STATIC_URL = '/static/' # 静态文件访问路径
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static/')]#css问题加载这个
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

@ -0,0 +1,24 @@
"""
URL configuration for config project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path,include
urlpatterns = [
# path('admin/', admin.site.urls),
path('',include('user.urls')),
]

@ -0,0 +1,16 @@
"""
WSGI config for config project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
application = get_wsgi_application()

Binary file not shown.

@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

@ -0,0 +1,76 @@
<!-- <div class="container"></div>
<button id="toggleButton" class="close-button">
<i class="fas fa-times" aria-hidden="true"></i>
</button>
<div id="contentToHide">
<p>这是要隐藏的内容。</p>
<p>点击按钮后,这段文字将被隐藏。</p>
</div>
</div>
</div>
<script>
// 示例 JavaScript 代码,用于处理点击事件
document.getElementById('toggleButton').addEventListener('click', function() {
var contentToHide = document.getElementById('contentToHide');
contentToHide.classList.toggle('hidden');
});
</script> -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<span>nihap</span>
<p>sandw</p>
</body>
</html>
<div style="margin-left:15%;height:auto;padding: 120px 0 0 0;">
<div style="text-align: end;">
<form action="/zhuxiao/" id="zhuxiao" method="post">
<button class="shangchuang" type="submit" style="color: red;" >账户注销</button>
</form>
</div>
<script>
document.getElementById('zhuxiao').addEventListener('submit', function(event) {
// 阻止表单提交行为
event.preventDefault();
// 弹出确认对话框
if (confirm('您确定要注销吗?')) {
this.submit();
}else {
return;
}
});
</script>
<div class="sign-box">
<form action="/xiugai/" method="post" id="myform">
<div style="padding: 30px;font-size: 20px;">修改用户名和密码</div>
<div style="padding: 10px;">
<span>当前用户名:{{name}}</span>
<input type="text" placeholder="修改用户名" name="username">
</div>
<input type="password" placeholder="修改密码" name="password">
<div style="padding: 10px;">
<button class="shangchuang" type="submit" >修改提交</button>
</div>
</form>
</div>
<script>
document.getElementById('myform').addEventListener('submit', function(event) {
// 阻止表单提交行为
event.preventDefault();
// 弹出确认对话框
if (confirm('您确定要修改吗?')) {
this.submit();
}else {
return;
}
});
</script>
</div>

@ -0,0 +1,141 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>随机点名系统</title>
<style>
.biaoti {
font-size: 30px;/* 文字大小 */
position: fixed;
text-align: center;
background-color: #163874;
color: white;
width: 100%;
padding: 45px 0 45px 16px;/* 边框宽度 */
height: 120px;
box-sizing: border-box
}
body {
margin: 0px;
}
ul {
list-style-type: none;
margin: 120px 0 0 0;
border: 0px;
padding: 0;
width: 15%;
background-color: #163874;
position: fixed;
height: 100%;
}
li a {
display: block;
color: white;
font-size: 20px;
padding: 45px;
text-align: center;
text-decoration: none;
}
li a.active {
background-color: #7989E8;
color: white;
}
li a:hover:not(.active) {
background-color: #555;
color: white;
}
.buof {
font-size: 30px;/* 文字大小 */
text-align: center;
color: white;
box-sizing: border-box;
margin-left: 15%;
}
.button {
background-color: #1ab5dc;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
font-size: 20px;
}
.twospan {
font-size: 30px;
color: gold;
/* margin-left: ; */
}
</style>
</head>
<body>
<div class="biaoti">随机点名系统</div>
<ul>
<li><a class="active" href="#">点名提问</a></li>
<li><a href="/second/">学生名单</a></li>
<li><a href="/third/">积分排名</a></li>
<li><a href="/fourth/">账号设置</a></li>
</ul>
<!-- 随机事件触发 -->
<div style="margin-left:15%;padding:120px 0 0 16px;height:auto;">
<div style="padding: 50px 0 0 0;">
<div style="font-size: 70px;color: #163874;text-align: center;">天选之子</div>
<div style="font-size: 60px;text-align: center;margin-top: 50px;">{{ form }}</div>
<div style="margin:40px 0 20px 0;text-align: center;">
{% if sign == 'zhongkou' %}
<span class="twospan" style="text-align: center;">触发随机事件:双倍扣分</span>
{% elif sign == 'lucky' %}
<span class="twospan" style="text-align: center;">触发随机事件:可以寻求帮助</span>
{% endif %}
<span style="visibility: hidden;font-size: 30px;">占位</span>
</div>
</div>
</div>
<!-- 评分 -->
<div style="margin-left:15%;height:auto;text-align: center;">
<form action="/submitscore/" method="post" style="line-height: 30px;">
<input type="hidden" name="student_name" value="{{ form }}"></input>
<span style="font-size: 20px;color: #163874;">评分:</span>
<!-- 来没来 -->
<input type="radio" name="daoda" value="1" checked="checked">到达课堂(加1分)
{% if sign == 'zhongkou' %}
<input type="radio" name="daoda" value="22">没到(扣2分)</input><br>
{% else %}
<input type="radio" name="daoda" value="2">没到(扣1分)</input><br>
{% endif %}
<!-- 问题回复 -->
<input type="radio" name="score1" value="1" checked="checked">重复问题(加0.5分)
{% if sign == 'zhongkou' %}
<input type="radio" name="score1" value="22">不能重复问题(扣2分)</input><br>
{% else %}
<input type="radio" name="score1" value="2">不能重复问题(扣1分)</input><br>
{% endif %}
<span >回答问题得分:</span>
<input type="number" name="score2" step = "0.5" min="0" max="3" placeholder="0.5-3" value="0">
<button class="button" style="padding: 5px;" type="submit">确认</button>
</form>
</div>
<br>
<!-- 点名按钮 -->
<div class="buof">
<form action="/dianming/" method="get">
<button class="button">随机点名</button>
</form>
</div>
</body>
</html>

@ -0,0 +1,179 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>随机点名系统</title>
<style>
.biaoti {
font-size: 30px;/* 文字大小 */
position: fixed;
text-align: center;
background-color: #163874;
color: white;
width: 100%;
padding: 45px 0 45px 16px;/* 边框宽度 */
height: 120px;
box-sizing: border-box
}
body {
margin: 0px;
}
ul {
list-style-type: none;
margin: 120px 0 0 0;
border: 0px;
padding: 0;
width: 15%;
background-color: #163874;
position: fixed;
height: 100%;
}
li a {
display: block;
color: white;
font-size: 20px;
padding: 45px;
text-align: center;
text-decoration: none;
}
li a.active {
background-color: #7989E8;
color: white;
}
li a:hover:not(.active) {
background-color: #555;
color: white;
}
/* 表格样式 */
.biaoge {
width:100%;
margin:0;
border:0;
color:black;
background-color:#EEEEEE;
}
.biaoge,.biaoge th,.biaoge td {
font-size:26px;
text-align:center;
padding:4px;
border-collapse:collapse;
}
.biaoge th,.biaoge td {
border-width:1px 0 1px 0;
border:1px inset #D8D8D8;
}
.biaoge tr {
border: 1px solid #D8D8D8;
height: 20px;
}
.sign-box {
position: fixed;
top: 40%;
left: 45%;
width: 400px;
height: 320px;
z-index: 101;
background-color: ghostwhite;
border: 2px solid rgb(0, 0, 0);
padding: 20px;
text-align: center;
}
.sign-box input {
width: 300px;
height: 35px;
font-size: 17px;
background: transparent;
text-indent: 8px;
border: none;
border-bottom: 1px solid black;
margin: 15px;
outline: none;
color: black;
}
.shangchuang{
font-size: 15px;
width: 130px;
height: 45px;
margin: 5px auto 5px 5px;
border: none;
background-color: #d5e4f6;
color: #71c9eb;
border-radius: 8px;
font-weight: bold;
cursor: pointer;
transition: .5s;
}
</style>
<script>
var count=ref(0);
</script>
</head>
<body>
<div class="biaoti">随机点名系统</div>
<ul>
<li><a href="/first/">点名提问</a></li>
<li><a href="/second/">学生名单</a></li>
<li><a href="/third/">积分排名</a></li>
<li><a href="#" class="active">账号设置</a></li>
</ul>
<!-- 学生积分排名 -->
<div style="margin-left:15%;height:auto;padding: 120px 0 0 0;">
<div style="text-align: end;">
<form action="/zhuxiao/" id="zhuxiao" method="post">
<button class="shangchuang" type="submit" style="color: red;" >账户注销</button>
</form>
</div>
<script>
document.getElementById('zhuxiao').addEventListener('submit', function(event) {
// 阻止表单提交行为
event.preventDefault();
// 弹出确认对话框
if (confirm('您确定要注销吗?')) {
this.submit();
}else {
return;
}
});
</script>
<div class="sign-box">
<form action="/xiugai/" method="post" id="myform">
<div style="padding: 30px;font-size: 20px;">修改用户名和密码</div>
<div style="padding: 10px;">
<span>当前用户名:{{name}}</span>
<input type="text" placeholder="修改用户名" name="username">
</div>
<input type="password" placeholder="修改密码" name="password">
<div style="padding: 10px;">
<button class="shangchuang" type="submit" >修改提交</button>
</div>
</form>
</div>
<script>
document.getElementById('myform').addEventListener('submit', function(event) {
// 阻止表单提交行为
event.preventDefault();
// 弹出确认对话框
if (confirm('您确定要修改吗?')) {
this.submit();
}else {
return;
}
});
</script>
</div>
</body>
</html>

@ -0,0 +1,63 @@
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登陆界面</title>
<link rel="stylesheet" href="../static/login.css">
</head>
<body class="container2">
<!-- 按钮模块 -->
<input type="checkbox" id="a12" hidden>
<i class="indicator"></i>
<label class="c2" for="a12"></label>
<!-- 日月交替模块 -->
<div id="container" class="dark">
<div class="bg"></div>
<div class="moon-box">
<div class="moon"></div>
</div>
<div class="sun-box">
<div class="sun"></div>
</div>
<div class="sea"></div>
</div>
<!-- 登录模块 -->
<form action="/login/" method="post">
<div class="form-box">
<div class="tit">login</div>
<input type="text" placeholder="账号" name="username">
<input type="password" placeholder="密码" name="password">
<button>登录</button>
</div>
</form>
<!-- 注册模块 -->
<div class="sign">
<input type="checkbox" id="search_btn" hidden>
<label class="search-btn" for="search_btn">
<i class="search" aria-hidden="true">点我注册</i>
</label>
<label class="close-btn" for="search_btn">
<i class="close" aria-hidden="true">登录</i>
</label>
<div class="container3">
<h2 class="signin" ><span>sign in</span></h2>
<form action="/register/" method="post">
<div class="search-box s1 s2">
<input type="password" placeholder="请输入密码" name="password">
</div>
<div class="search-box s1 s3">
<input type="text" placeholder="请输入用户名" name="username">
<button class="sign-btn" type="submit">注册</button>
</div>
</form>
<div class="shade"></div>
</div>
</body>
</html>

@ -0,0 +1,144 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>随机点名系统</title>
<style>
.biaoti {
font-size: 30px;/* 文字大小 */
position: fixed;
text-align: center;
background-color: #163874;
color: white;
width: 100%;
padding: 45px 0 45px 16px;/* 边框宽度 */
height: 120px;
box-sizing: border-box
}
body {
margin: 0px;
}
ul {
list-style-type: none;
margin: 120px 0 0 0;
border: 0px;
padding: 0;
width: 15%;
background-color: #163874;
position: fixed;
height: 100%;
}
li a {
display: block;
color: white;
font-size: 20px;
padding: 45px;
text-align: center;
text-decoration: none;
}
li a.active {
background-color: #7989E8;
color: white;
}
li a:hover:not(.active) {
background-color: #555;
color: white;
}
</style>
<style>
.biaoge {
width:100%;
margin:0;
border:0;
color:black;
background-color:#EEEEEE;
}
.biaoge,.biaoge th,.biaoge td {
font-size:26px;
text-align:center;
padding:4px;
border-collapse:collapse;
}
.biaoge th,.biaoge td {
border-width:1px 0 1px 0;
border:1px inset #D8D8D8;
}
.biaoge tr {
border: 1px solid #D8D8D8;
height: 20px;
}
.shangchuang{
font-size: 15px;
width: 130px;
height: 45px;
margin: 5px auto 5px 5px;
border: none;
background-color: #d5e4f6;
color: #71c9eb;
border-radius: 8px;
font-weight: bold;
cursor: pointer;
transition: .5s;
}
</style>
</head>
<body>
<div class="biaoti">随机点名系统</div>
<ul>
<li><a href="/first/">点名提问</a></li>
<li><a class="active" href="#news">学生名单</a></li>
<li><a href="/third/">积分排名</a></li>
<li><a href="/fourth/">账号设置</a></li>
</ul>
<!-- 上传Excel文件 -->
<div style="margin-left:15%;padding:120px 0 0 0;height:auto;">
<div style="display: flex ;">
<form action="/upload_excel/" method="get">
<button class="shangchuang">上传名单</button>
</form>
<form action="/delete_excel/" method="get" id="delete">
<button class="shangchuang" >删除名单</button>
</form>
</div>
</div>
<script>
document.getElementById('delete').addEventListener('submit', function(event) {
// 阻止表单提交行为
event.preventDefault();
// 弹出确认对话框
if (confirm('您确定要删除吗?')) {
this.submit();
}else {
return;
}
});
</script>
<!-- 学生名单表格 -->
<div style="margin-left:15%;height:auto;">
<table class="biaoge">
<tr>
<th>学号</th><th>姓名</th><th>专业</th> <th>班级</th>
</tr>
{% for row in form %}
<tr>
<td>{{ row.student_xuehao }}</td>
<td>{{ row.student_name }}</td>
<td>{{ row.student_major }}</td>
<td>{{ row.student_class }}</td>
</tr>
{% endfor %}
</table>
</div>
</body>
</html>

@ -0,0 +1,110 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>随机点名系统</title>
<style>
.biaoti {
font-size: 30px;/* 文字大小 */
position: fixed;
text-align: center;
background-color: #163874;
color: white;
width: 100%;
padding: 45px 0 45px 16px;/* 边框宽度 */
height: 120px;
box-sizing: border-box
}
body {
margin: 0px;
}
ul {
list-style-type: none;
margin: 120px 0 0 0;
border: 0px;
padding: 0;
width: 15%;
background-color: #163874;
position: fixed;
height: 100%;
}
li a {
display: block;
color: white;
font-size: 20px;
padding: 45px;
text-align: center;
text-decoration: none;
}
li a.active {
background-color: #7989E8;
color: white;
}
li a:hover:not(.active) {
background-color: #555;
color: white;
}
/* 表格样式 */
.biaoge {
width:100%;
margin:0;
border:0;
color:black;
background-color:#EEEEEE;
}
.biaoge,.biaoge th,.biaoge td {
font-size:26px;
text-align:center;
padding:4px;
border-collapse:collapse;
}
.biaoge th,.biaoge td {
border-width:1px 0 1px 0;
border:1px inset #D8D8D8;
}
.biaoge tr {
border: 1px solid #D8D8D8;
height: 20px;
}
</style>
<script>
var count=ref(0);
</script>
</head>
<body>
<div class="biaoti">随机点名系统</div>
<ul>
<li><a href="/first/">点名提问</a></li>
<li><a href="/second/">学生名单</a></li>
<li><a class="active" href="#contact">积分排名</a></li>
<li><a href="/fourth/">账号设置</a></li>
</ul>
<!-- 学生积分排名 -->
<div style="margin-left:15%;height:auto;padding: 120px 0 0 0;">
<table class="biaoge">
<tr>
<th>排名</th><th>学号</th><th>姓名</th><th>积分</th>
</tr>
{% for row in form %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ row.student_xuehao }}</td>
<td>{{ row.student_name }}</td>
<td>{{ row.student_score }}</td>
</tr>
{% endfor %}
</table>
</div>
</body>
</html>

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>上传Excel文件</title>
<style>
.loadbox {
position: fixed;
top: 28%;
left: 30%;
width: 400px;
height: 250px;
z-index: 101;
background-color: ghostwhite;
border: 2px solid rgb(0, 0, 0);
padding: 20px;
}
</style>
</head>
<body>
<div class="loadbox">
<form action="/upload_file/" method="post" enctype="multipart/form-data">
<label for="file">选择文件:</label>
<input type="file" id="file" name="file">
<button type="submit">上传</button>
</form>
<p>提示请上传Excel文件(学号,姓名,班级,专业)(学号必须为数字,班级和专业可以为空)</p>
<img src="../static/excel上传格式.png" width="400">
</div>
</body>
</html>

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

@ -0,0 +1,722 @@
@font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot?1tb2pa');
src: url('fonts/icomoon.eot?1tb2pa#iefix') format('embedded-opentype'),
url('fonts/icomoon.ttf?1tb2pa') format('truetype'),
url('fonts/icomoon.woff?1tb2pa') format('woff'),
url('fonts/icomoon.svg?1tb2pa#icomoon') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
}
body {
/* 初始化 取消内外边距 */
margin: 0;
padding: 0;
overflow: hidden;
zoom: 85%;
}
button {
/* 去除按钮自带样式 */
border: none !important;
outline: none !important;
}
#container {
/* 100%窗口高度 */
height: 100vh;
}
.bg {
/* 绝对定位 */
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.sun {
margin: 0;
padding: 0;
/* 绝对定位 水平垂直居中 */
position: absolute;
top: 500px;
left: 48%;
transform: translate(-50%, -50%);
width: 600px;
height: 600px;
background: orange;
border-radius: 50%;
}
.moon {
margin: 0;
padding: 0;
position: absolute;
top: 54%;
left: 48%;
/* 计算得出月亮的位置 */
transform: translate(calc(-50% + -160px), calc(-50% + -180px));
width: 600px;
height: 600px;
/* 通过阴影绘制月亮 */
box-shadow: 160px 180px 0 cyan;
border-radius: 50%;
}
.sea {
position: absolute;
bottom: 0;
width: 100%;
height: 35%;
/* 背景模糊制造大海的感觉 */
backdrop-filter: blur(100px);
-webkit-backdrop-filter: blur(100px);
z-index: 100;
}
.sun,
.moon,
.sun-box,
.moon-box,
.bg {
/* 添加动画过渡 */
transition: all 1s ease-in-out;
}
.sun-box,
.moon-box {
/* 相对定位 */
position: relative;
/* 溢出隐藏 */
/* overflow: hidden; */
}
.light .bg {
background: #ffeea2;
}
/* 夜晚 */
.dark .sun-box {
height: 0;
}
.dark .moon-box {
height: 100%;
}
.dark .bg {
background: #040720;
}
/* ................................................. */
/* ....................按钮模块..................... */
/* ...... ..........................................*/
.container2 .c2 {
/* 相对定位 */
/* position: relative; */
transition: 1s;
z-index: 1;
float: left;
margin: 5px 0;
cursor: pointer;
position: relative;
display: block;
width: 80px;
height: 40px;
background-color: #222;
border-radius: 40px;
/* 内阴影 */
box-shadow: inset 0 2px 15px rgba(0, 0, 0, 0.2),
inset 0 2px 2px rgba(0, 0, 0, 0.2),
inset 0 -1px 1px rgba(0, 0, 0, 0.2);
}
/* 滑块 */
.container2 .indicator {
/* 绝对定位 */
position: absolute;
z-index: 2;
left: 0px;
top: 5px;
width: 40px;
height: 40px;
/* 渐变背景 */
background: linear-gradient(to bottom, #444, #222);
border-radius: 50%;
/* 阴影 */
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5),
inset 0 1px 1px rgba(255, 255, 255, 0.1);
/* 缩小 */
transform: scale(0.9);
/* 动画过渡 */
transition: 1s;
/* 鼠标事件取消 */
pointer-events: none;
}
/* 滑块中心发光点 */
.container2 .indicator::before {
content: "";
width: 5px;
height: 5px;
/* 绝对定位 居中 */
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background-color: #f00;
border-radius: 50%;
/* 阴影制造发光效果 */
box-shadow: 0 0 2px #f00,
0 0 5px #f00,
0 0 10px #f00,
0 0 15px #f00,
0 0 20px #f00,
0 0 25px #f00,
0 0 30px #f00,
0 0 35px #f00;
transition: 0.5s;
}
/* 勾选复选框后滑块的变化 */
.container2 input:checked~.indicator {
left: 40px;
}
.container2 input:checked~.indicator::before {
background-color: #0f0;
box-shadow: 0 0 2px #0f0,
0 0 5px #0f0,
0 0 10px #0f0,
0 0 15px #0f0,
0 0 20px #0f0,
0 0 25px #0f0,
0 0 30px #0f0,
0 0 35px #0f0;
}
.container2 input:checked~.dark .sun-box {
height: 100% !important;
}
.container2 input:checked~.dark .sun {
top: 62%;
}
.container2 input:checked~.dark .moon-box {
height: 0 !important;
transform-origin: -10px;
transform: rotate(-90deg);
}
.container2 input:checked~.dark .bg {
background: #ffeea2;
}
.container2 input:checked~label {
background-color: #ffeea2;
}
.container2 input:checked~.indicator {
background: #ffeea2;
box-shadow: 0 0 .5;
}
/* ................................................. */
/* ....................登录模块...................... */
/* ...... ..........................................*/
.form-box {
/* transform: scale(0.7, 0.7); */
/* zoom: 90%; */
position: fixed;
top: 28%;
left: 36%;
width: 400px;
height: 550px;
z-index: 101;
background-color: rgba(255, 255, 255, 0.1);
/* 背景模糊 */
backdrop-filter: blur(20px);
border-top: 1px solid rgba(255, 255, 255, 0.5);
border-left: 1px solid rgba(255, 255, 255, 0.5);
border-radius: 15px;
display: flex;
flex-direction: column;
align-items: center;
/* 阴影 */
box-shadow: 0px 20px 50px rgba(0, 0, 0, 0.5);
}
.form-box .tit {
cursor: default;
color: #fff;
font-size: 45px;
font-weight: bold;
/* 大写 */
text-transform: uppercase;
/* 字间距 */
letter-spacing: 10px;
text-indent: 10px;
margin: 90px auto 50px auto;
}
.form-box input {
width: 350px;
height: 35px;
font-size: 17px;
background: transparent;
text-indent: 8px;
border: none;
border-bottom: 1px solid rgba(255, 255, 255, 0.8);
margin: 15px auto;
outline: none;
color: #fff;
}
.form-box input::placeholder {
color: rgba(255, 255, 255, 0.8);
}
.form-box button {
font-size: 20px;
width: 350px;
height: 45px;
margin: 35px auto 40px auto;
border: none;
background: #00addd;
color: #fff;
letter-spacing: 20px;
text-indent: 20px;
border-radius: 8px;
font-weight: bold;
cursor: pointer;
}
.form-box button:hover {
transition: .5s;
background: #0098d4;
letter-spacing: 50px;
text-indent: 45px;
}
.form-box span {
font-size: 14px;
color: #fff;
}
.form-box a {
color: #00addd;
text-decoration: none;
}
/* .............................................. */
/* ....................注册特效................... */
/* ...............................................*/
.search,
.close {
font-family: 'icomoon';
white-space: nowrap;
font-style: normal;
text-align: center;
}
.search:hover {
text-decoration: underline;
}
.close {
transition: .3s;
}
.close:hover {
color: #f55858;
}
.search {
font-size: 14px;
color: #33b7eb;
}
/* 注册按钮 */
.search-btn {
pointer-events: all;
z-index: 301;
font-style: normal;
position: absolute;
top: 79.2%;
left: 59%;
width: 50px;
height: 50px;
line-height: 60px;
text-align: center;
cursor: pointer;
}
/* 关闭按钮 */
.close-btn {
background: none !important;
pointer-events: all;
position: absolute;
top: -238px;
right: -600px;
z-index: 302;
font-size: 25px;
color: #fff;
cursor: pointer;
display: none;
}
.container3 {
/* zoom: 80%; */
z-index: 301;
position: absolute;
background: linear-gradient(200deg, #e7f0fd, #accbee);
top: -97%;
left: -180%;
width: 2000px;
height: 2000px;
/* background-color: darkgrey; */
/* 渐变背景 */
/* background: linear-gradient(200deg, #6e86ee, #453c90); */
/* 将元素剪切为一个圆形 【25px表示圆的半径】 【50% 50%表示圆心位置】 */
clip-path: circle(40px at 50% 50%);
/* clip-path: inset(975px 975px round 15px); */
/* 设置过渡 */
transition: .9s;
opacity: 0;
}
.search-box {
z-index: 303;
/* 默认宽度为0隐藏 */
position: fixed;
top: 0%;
left: 0%;
width: 0;
height: 50px;
border-bottom: 3px solid #fff;
transition: 0.3s;
}
.search-box input {
width: 100%;
height: 50px;
background: none;
border: none;
outline: none;
color: #fff;
font-size: 22px;
font-weight: 500;
/* 请输入前的缩进 */
text-indent: 8px;
}
.search-box input::placeholder {
color: rgba(255, 255, 255, 0.7);
}
.search-box .fa {
width: 50px;
height: 50px;
line-height: 50px;
color: #fff;
font-size: 22px;
text-align: center;
cursor: pointer;
}
#search_btn:checked~.search-btn {
display: none;
}
#search_btn:checked~.container3 .shade {
pointer-events: all;
position: fixed;
top: 28%;
left: 36%;
width: 400px;
height: 550px;
z-index: 120;
}
#search_btn:checked~.close-btn {
display: block;
}
#search_btn:checked~.container3 {
opacity: 1;
clip-path: circle(100%);
}
#search_btn:checked~.container3 .search-box {
width: 400px;
}
.sign {
pointer-events: none;
position: fixed;
top: 28%;
left: 37%;
width: 400px;
height: 550px;
z-index: 300;
/* 100%窗口高度 */
/* 弹性布局 水平+垂直居中 */
/* display: flex;
justify-content: center;
align-items: center; */
}
/* ................................................. */
/* ....................注册界面...................... */
/* ...... ..........................................*/
.signin {
pointer-events: all;
position: fixed;
top: 20%;
left: 37%;
z-index: 330;
font-size: 96px;
color: #393838;
font-weight: bold;
letter-spacing: 5px;
cursor: pointer;
}
.signin span {
/* 动画过渡 */
transition: 0.5s;
}
.signin:hover span {
margin-right: 10px;
}
.signin:hover span::after {
font-size: 20px;
content: " us";
}
.signin:hover span {
color: #fff;
/* 文字阴影 */
text-shadow: 0 0 10px #fff,
0 0 20px #fff,
0 0 40px #fff,
0 0 80px #fff,
0 0 120px #fff,
0 0 160px #fff;
}
.s1 {
pointer-events: all;
position: fixed;
float: left;
top: 45%;
left: 36%;
}
.s2 {
top: 52%;
}
.s3 {
width: 250px !important;
top: 59%;
}
.s3 button {
position: fixed;
pointer-events: all !important;
font-style: normal;
top: 56.5%;
left: 51%;
font-size: 15px;
width: 130px;
height: 45px;
margin: 35px auto 40px auto;
border: none;
background-color: #d5e4f6;
color: #71c9eb;
/* letter-spacing: 20px;
text-indent: 20px; */
border-radius: 8px;
font-weight: bold;
cursor: pointer;
transition: .5s;
}
.s3 .verification-code:hover {
background-color: #5abce6;
color: #d5e4f6;
}
.sign-btn-box {
overflow: hidden;
color: #00aeff;
border: 2px solid #00aeff;
}
.s3 .sign-btn {
font-size: 20px;
position: fixed;
top: 65%;
left: 36%;
width: 400px;
background: #00addd;
color: #fff;
letter-spacing: 20px;
text-indent: 20px;
border-radius: 8px;
font-weight: bold;
cursor: pointer;
}
.s3 .sign-btn:hover {
transition: .5s;
background: #0098d4;
letter-spacing: 50px;
text-indent: 45px;
}
/* 流星特效 */
.container4 span {
position: absolute;
top: 50%;
left: 50%;
width: 4px;
height: 4px;
background-color: #fff;
border-radius: 50%;
/* 发光效果 */
box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1),
0 0 0 8px rgba(255, 255, 255, 0.1),
0 0 20px rgba(255, 255, 255, 1);
/* 执行动画 */
animation: animate 3s linear infinite;
}
/* 拖尾效果 */
.container4 span::before {
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 300px;
height: 3px;
background: linear-gradient(90deg, #fff, transparent);
}
/* 分别为每一个流星设置位置、动画延迟时间、动画时长 */
.container4 span:nth-child(1) {
top: 0;
right: 0;
/* initial关键字用于设置CSS属性为它的默认值 */
/* 这个东西可以用来强制覆盖前面设置的属性 */
/* left的初始值为auto所以就相当于left:auto */
left: initial;
/* 动画延迟时间 */
animation-delay: 0s;
/* 动画时长 */
animation-duration: 1s;
}
.container4 span:nth-child(2) {
top: 0;
right: 80px;
left: initial;
animation-delay: 0.2s;
animation-duration: 3s;
}
.container4 span:nth-child(3) {
top: 80px;
right: 0;
left: initial;
animation-delay: 0.4s;
animation-duration: 2s;
}
.container4 span:nth-child(4) {
top: 0;
right: 180px;
left: initial;
animation-delay: 0.6s;
animation-duration: 1.5s;
}
.container4 span:nth-child(5) {
top: 0;
right: 400px;
left: initial;
animation-delay: 0.8s;
animation-duration: 2.5s;
}
.container4 span:nth-child(6) {
top: 0;
right: 600px;
left: initial;
animation-delay: 1s;
animation-duration: 3s;
}
.container4 span:nth-child(7) {
top: 300px;
right: 0;
left: initial;
animation-delay: 1.2s;
animation-duration: 1.75s;
}
.container4 span:nth-child(8) {
top: 0;
right: 700px;
left: initial;
animation-delay: 1.4s;
animation-duration: 1.25s;
}
.container4 span:nth-child(9) {
top: 0;
right: 1000px;
left: initial;
animation-delay: 0.75s;
animation-duration: 2.25s;
}
.container4 span:nth-child(10) {
top: 0;
right: 450px;
left: initial;
animation-delay: 2.75s;
animation-duration: 2.25s;
}
/* 流星坠落动画 */
@keyframes animate {
0% {
transform: rotate(315deg) translateX(0);
opacity: 1;
}
90% {
opacity: 1;
}
100% {
transform: rotate(315deg) translateX(-1000px);
opacity: 0;
}
}

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

@ -0,0 +1,6 @@
from django.apps import AppConfig
class UserConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'user'

@ -0,0 +1,35 @@
# Generated by Django 5.1.1 on 2024-09-30 11:58
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='user',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=200, unique=True)),
('password', models.CharField(max_length=200)),
],
),
migrations.CreateModel(
name='student',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('student_xuehao', models.IntegerField(default=0)),
('student_name', models.CharField(blank=True, max_length=200, null=True)),
('student_major', models.CharField(blank=True, max_length=200, null=True)),
('student_class', models.CharField(blank=True, max_length=200, null=True)),
('student_score', models.IntegerField(default=0)),
('teather', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='user.user')),
],
),
]

@ -0,0 +1,18 @@
# Generated by Django 5.1.1 on 2024-10-01 13:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('user', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='student',
name='student_score',
field=models.FloatField(default=0),
),
]

@ -0,0 +1,16 @@
from django.db import models
# Create your models here.
#用户表
class user(models.Model):
username = models.CharField(max_length=200,unique=True)
password = models.CharField(max_length=200)
#学生表
class student(models.Model):
student_xuehao=models.IntegerField(default=0)
student_name = models.CharField(max_length=200,null=True, blank=True)
student_major = models.CharField(max_length=200,null=True, blank=True)
student_class = models.CharField(max_length=200,null=True, blank=True)
student_score = models.FloatField(default=0)
teather=models.ForeignKey(to='user',to_field='id',on_delete=models.CASCADE)

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

@ -0,0 +1,19 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.loginpage),
path('first/', views.firstpage,name='first'),#随机点名界面
path('second/',views.secondpage,name='second'),#学生名单
path('third/',views.thirdpage,name='third'),#积分排名
path('login/', views.Loginadmit,name='login'),#登录验证
path('register/', views.Register,name='register'),#注册
path('upload_excel/', views.upload_excel, name='upload_excel'),#上传文件页面
path('upload_file/', views.upload_file, name='upload_file'),#上传execl文件
path('delete_excel/',views.delete_excel,name='delete_excel'),#删除学生名单
path('dianming/',views.dianming,name='dianming'),#随机点名和特殊规则
path('submitscore/',views.submitscore,name='submitscore'),#提交积分
path('fourth/',views.fourthpage,name='fourth'),#用户信息
path('xiugai/',views.xiugai,name='xiugai'),#账号和密码修改
path('zhuxiao/',views.zhuxiao,name='zhuxiao'),#账户注销
]

@ -0,0 +1,217 @@
from django.shortcuts import render
from django.http import HttpResponse, JsonResponse
from user.models import user
from user.models import student
import pandas as pd
import random
# Create your views here.
def loginpage(request):
return render(request, 'login.html')
def Loginadmit(request):
if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('password')
print(username,password)
if user.objects.filter(username=username).exists():
if user.objects.filter(username=username,password=password).exists():
request.session["info"]=username
return render(request, 'firstpage.html')
else:
return HttpResponse("密码错误")
else:
return HttpResponse("用户名不存在")
def Register(request):
sign=0
if request.method == 'POST':#判断是否登录
username = request.POST.get('username')
password = request.POST.get('password')
qs = user.objects.values
if user.objects.filter(username=username).exists():
return HttpResponse("用户名已存在")
else:
user.objects.create(username=username,password=password)
return render(request, 'login.html',{'success':'注册成功'})
# 第一页
def firstpage(request):
if request.session.get("info"):#判断是否登录
return render(request, 'firstpage.html')
else:
return render(request, 'login.html')
#随机点名
def dianming(request):
if request.session.get("info"):#判断是否登录
User=user.objects.filter(username=request.session.get("info")).first()#获取当前用户
studentlist=student.objects.filter(teather_id=User.id)#获取当前用户的学生表
if len(studentlist)==0:#判断学生表是否为空
return render(request, 'firstpage.html',{'form':'暂无学生'})
#权重随机点名算法
form=weights_random_choice(studentlist)
#随机事件
random_number = random.randint(1, 11)#随机数
if random_number ==5:#触发事件双倍扣分
fair='zhongkou'
return render(request,'firstpage.html',{'form':form.student_name,'sign':fair})
elif random_number ==6:#触发事件可以指定同学帮忙回答
fair='lucky'
return render(request,'firstpage.html',{'form':form.student_name,'sign':fair})
else:
return render(request,'firstpage.html',{'form':form.student_name,'sign':'none'})
else:
return render(request, 'login.html')
#权重随机点名算法
def weights_random_choice(studentlist):
# 偏移所有分数
offset = max(1, abs(min(student.student_score for student in studentlist)))#计算最小值的绝对值
adjusted_points = [student.student_score + offset for student in studentlist]#添加偏移
# 计算逆向权重
inverse_weights = [1 / (point+1) for point in adjusted_points]
# 归一化逆向权重
total_inverse_weight = sum(inverse_weights)
normalized_inverse_weights = [w / total_inverse_weight for w in inverse_weights]
# 选择一个学生
selected_student = random.choices(studentlist, weights=normalized_inverse_weights, k=1)[0]
print(selected_student)
return selected_student
# 分数写入
def submitscore(request):
teather=request.session.get("info")#获取当前用户
if teather:#判断是否登录
if request.method == 'POST':
print(request.POST)
User=user.objects.filter(username=teather).first()#获取当前用户的id
STdname=request.POST.get('student_name','')#获取被点到的学生姓名
print(STdname)
STudent=student.objects.filter(teather_id=User.id,student_name=STdname ).first()#获取被点到的学生
print(request.POST)
#{'student_name': ['才需困'], 'daoda': ['1'], 'score1': ['1'], 'score2': ['0.5']}>
daoda=request.POST.get('daoda','')
score1=request.POST.get('score1','')
score2=request.POST.get('score2','')
if daoda=='1':#到课堂加1分
STudent.student_score+=1
elif daoda=='2':#没到扣1分
STudent.student_score-=1
elif daoda=='22':#没到扣2分双倍扣分
STudent.student_score-=2
#重复问题
if score1=='1':#重复问题加0.5分
STudent.student_score+=0.5
elif score1=='2':#重复不了问题扣1分
STudent.student_score-=1
elif score1=='22':#重复不了问题扣2分双倍扣分
STudent.student_score-=2
#回答问题
STudent.student_score+=float(score2)
print(STudent.student_score)
#写入数据库
STudent.save()
return render(request, 'firstpage.html')
else:
return render(request, 'login.html')
# 第二页
def secondpage(request):
teather=request.session.get("info")#获取用户信息
if teather:#判断是否登录
User=user.objects.filter(username=teather).first()#获取用户
form=student.objects.filter(teather_id=User.id)
return render(request, 'secondpage.html',{'form':form})#返回学生数据
else:
return render(request, 'login.html')
# 第三页
def thirdpage(request):
teather=request.session.get("info")#获取用户session信息
if teather:
User=user.objects.filter(username=teather).first()#获取当前用户的id
form=student.objects.filter(teather_id=User.id).order_by('-student_score')
return render(request, 'thirdpage.html',{"form":form})
else:
return render(request, 'login.html')
#上传Excel文件
def upload_excel(request):
if request.session.get("info"):
return render(request, 'upload.html')
else:
return render(request, 'login.html')
#接收文件
def upload_file(request):
teather=request.session.get("info")#获取session中的用户名
if teather:
User=user.objects.filter(username=teather).first()#获取用户
if request.method == 'POST':
excel_file = request.FILES.get('file')#获取excel表格文件
df=pd.read_excel(excel_file)#读取excel表格
for index, row in df.iterrows():
if student.objects.filter(student_xuehao=row['学号'],teather_id=User.id).exists():#判断是否已经存在当前老师的学生表中
continue
student.objects.create(student_xuehao=row['学号'],student_name=row['姓名'],student_major=row['专业'],student_class=row['班级'],teather_id=User.id)#写入学生表
form=student.objects.filter(teather_id=User.id)#返回当前老师的学生表
return render(request, 'secondpage.html',{'form':form})
else:
return render(request, 'login.html')
#删除表格
def delete_excel(request):
teather=request.session.get("info")#获取session中的用户名
if teather:
User=user.objects.filter(username=teather).first()#获取用户
print("删除当前老师的所有学生")
student.objects.filter(teather_id=User.id).delete()
return render(request, 'secondpage.html')
else:
return render(request, 'login.html')
#第四页
def fourthpage(request):
teather=request.session.get("info")#获取当前用户
if teather:#判断是否登录
User=user.objects.filter(username=teather).first()#获取当前用户的id
return render(request, 'fourthpage.html',{'name':User.username})
else:
return render(request, 'login.html')
#账号和密码修改
def xiugai(request):
teather=request.session.get("info")#获取当前用户名
if teather:#判断是否登录
User=user.objects.filter(username=teather).first()#获取当前用户
if request.method == 'POST':
username=request.POST.get('username','')
password=request.POST.get('password','')
print(username,password)
if username=='' and password=='':
return render(request, 'fourthpage.html',{'name':User.username})
else:
if username!='':
User.username=username
if password!='':
User.password=password
User.save()
return render(request, 'login.html')
else:
return render(request, 'login.html')
#账户注销
def zhuxiao(request):
teather=request.session.get("info")#获取当前用户名
if teather:#判断是否登录
User=user.objects.filter(username=teather).first()#获取当前用户
if request.method == 'POST':
User.delete()
return render(request, 'login.html')
else:
return render(request, 'login.html')
Loading…
Cancel
Save