Compare commits
No commits in common. '54bdbccdaa4d8f902edbc31fbddadc82e4a14b99' and 'a280b2c96b56d849231aac581638ec46ea1e7da3' have entirely different histories.
54bdbccdaa
...
a280b2c96b
@ -1,8 +1,8 @@
|
|||||||
# Default ignored files
|
# Default ignored files
|
||||||
/shelf/
|
/shelf/
|
||||||
/workspace.xml
|
/workspace.xml
|
||||||
# Datasource local storage ignored files
|
# Datasource local storage ignored files
|
||||||
/../../../../../../:\djangoProject\djangoProject\djangoProject\the_online_test_system\.idea/dataSources/
|
/../../../../../../:\djangoProject\djangoProject\djangoProject\the_online_test_system\.idea/dataSources/
|
||||||
/dataSources.local.xml
|
/dataSources.local.xml
|
||||||
# 基于编辑器的 HTTP 客户端请求
|
# 基于编辑器的 HTTP 客户端请求
|
||||||
/httpRequests/
|
/httpRequests/
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/the_online_test_system.iml" filepath="$PROJECT_DIR$/.idea/the_online_test_system.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/the_online_test_system.iml" filepath="$PROJECT_DIR$/.idea/the_online_test_system.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -1,28 +1,28 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="PYTHON_MODULE" version="4">
|
<module type="PYTHON_MODULE" version="4">
|
||||||
<component name="FacetManager">
|
<component name="FacetManager">
|
||||||
<facet type="django" name="Django">
|
<facet type="django" name="Django">
|
||||||
<configuration>
|
<configuration>
|
||||||
<option name="rootFolder" value="$MODULE_DIR$" />
|
<option name="rootFolder" value="$MODULE_DIR$" />
|
||||||
<option name="settingsModule" value="the_online_test_system/settings.py" />
|
<option name="settingsModule" value="the_online_test_system/settings.py" />
|
||||||
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
|
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
|
||||||
<option name="environment" value="<map/>" />
|
<option name="environment" value="<map/>" />
|
||||||
<option name="doNotUseTestRunner" value="false" />
|
<option name="doNotUseTestRunner" value="false" />
|
||||||
<option name="trackFilePattern" value="migrations" />
|
<option name="trackFilePattern" value="migrations" />
|
||||||
</configuration>
|
</configuration>
|
||||||
</facet>
|
</facet>
|
||||||
</component>
|
</component>
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$" />
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="TemplatesService">
|
<component name="TemplatesService">
|
||||||
<option name="TEMPLATE_CONFIGURATION" value="Django" />
|
<option name="TEMPLATE_CONFIGURATION" value="Django" />
|
||||||
<option name="TEMPLATE_FOLDERS">
|
<option name="TEMPLATE_FOLDERS">
|
||||||
<list>
|
<list>
|
||||||
<option value="$MODULE_DIR$/../the_online_test_system\templates" />
|
<option value="$MODULE_DIR$/../the_online_test_system\templates" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,3 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
class LoginConfig(AppConfig):
|
class LoginConfig(AppConfig):
|
||||||
name = 'login'
|
name = 'login'
|
||||||
|
@ -1,59 +1,59 @@
|
|||||||
import os
|
import os
|
||||||
from PIL import Image, ImageDraw, ImageFont, ImageFilter
|
from PIL import Image, ImageDraw, ImageFont, ImageFilter
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
|
||||||
def random_str(length=4):
|
def random_str(length=4):
|
||||||
""" 随机字符串 默认长度 4
|
""" 随机字符串 默认长度 4
|
||||||
|
|
||||||
:param length: 默认长度 4
|
:param length: 默认长度 4
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
return ''.join(random.sample(string.ascii_letters, length))
|
return ''.join(random.sample(string.ascii_letters, length))
|
||||||
|
|
||||||
|
|
||||||
def random_color(s=1, e=255):
|
def random_color(s=1, e=255):
|
||||||
""" 随机 RGB 颜色
|
""" 随机 RGB 颜色
|
||||||
|
|
||||||
:param s: 起始值, 0-255
|
:param s: 起始值, 0-255
|
||||||
:param e: 结束时, 0-255
|
:param e: 结束时, 0-255
|
||||||
:return: (r, g, b)
|
:return: (r, g, b)
|
||||||
"""
|
"""
|
||||||
return random.randint(s, e), random.randint(s, e), random.randint(s, e)
|
return random.randint(s, e), random.randint(s, e), random.randint(s, e)
|
||||||
|
|
||||||
|
|
||||||
def veri_code(length=4, width=160, height=40, size=28):
|
def veri_code(length=4, width=160, height=40, size=28):
|
||||||
""" 生成验证码图片
|
""" 生成验证码图片
|
||||||
|
|
||||||
:param length: 验证码字符串长度
|
:param length: 验证码字符串长度
|
||||||
:param width: 图片宽度
|
:param width: 图片宽度
|
||||||
:param height: 图片高度
|
:param height: 图片高度
|
||||||
:param size: 字体大小
|
:param size: 字体大小
|
||||||
:return: (验证码图片, 验证码字符串)
|
:return: (验证码图片, 验证码字符串)
|
||||||
"""
|
"""
|
||||||
# 创建Image对象
|
# 创建Image对象
|
||||||
image = Image.new('RGB', (width, height), (255, 255, 255))
|
image = Image.new('RGB', (width, height), (255, 255, 255))
|
||||||
# 创建Font对象
|
# 创建Font对象
|
||||||
file = os.path.dirname(os.path.abspath(__file__))
|
file = os.path.dirname(os.path.abspath(__file__))
|
||||||
font = ImageFont.truetype(f'{file}/FZSTK.ttf', size)
|
font = ImageFont.truetype(f'{file}/FZSTK.ttf', size)
|
||||||
# 创建Draw对象
|
# 创建Draw对象
|
||||||
draw = ImageDraw.Draw(image)
|
draw = ImageDraw.Draw(image)
|
||||||
# 随机颜色填充每个像素
|
# 随机颜色填充每个像素
|
||||||
for x in range(0, width, 2):
|
for x in range(0, width, 2):
|
||||||
for y in range(height):
|
for y in range(height):
|
||||||
draw.point((x, y), fill=random_color(64, 255))
|
draw.point((x, y), fill=random_color(64, 255))
|
||||||
# 验证码
|
# 验证码
|
||||||
code = random_str(length)
|
code = random_str(length)
|
||||||
# 随机颜色验证码写到图片上
|
# 随机颜色验证码写到图片上
|
||||||
for t in range(length):
|
for t in range(length):
|
||||||
draw.text((40 * t + 5, 5), code[t], font=font, fill=random_color(32, 127))
|
draw.text((40 * t + 5, 5), code[t], font=font, fill=random_color(32, 127))
|
||||||
# 模糊滤镜
|
# 模糊滤镜
|
||||||
# image = image.filter(ImageFilter.BLUR)
|
# image = image.filter(ImageFilter.BLUR)
|
||||||
return image, code
|
return image, code
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
img, code = veri_code()
|
img, code = veri_code()
|
||||||
with open('test.png', 'wb') as f:
|
with open('test.png', 'wb') as f:
|
||||||
img.save(f)
|
img.save(f)
|
@ -1,26 +1,26 @@
|
|||||||
# Generated by Django 3.1.4 on 2022-04-08 08:50
|
# Generated by Django 3.1.4 on 2022-04-08 08:50
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='UserInfo',
|
name='UserInfo',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('identity', models.CharField(max_length=4, verbose_name='身份')),
|
('identity', models.CharField(max_length=4, verbose_name='身份')),
|
||||||
('name', models.CharField(max_length=32, verbose_name='姓名')),
|
('name', models.CharField(max_length=32, verbose_name='姓名')),
|
||||||
('id_number', models.CharField(max_length=32, verbose_name='学号/教师编号')),
|
('id_number', models.CharField(max_length=32, verbose_name='学号/教师编号')),
|
||||||
('phone', models.CharField(max_length=32, unique=True, verbose_name='手机')),
|
('phone', models.CharField(max_length=32, unique=True, verbose_name='手机')),
|
||||||
('username', models.CharField(max_length=32, unique=True, verbose_name='账号')),
|
('username', models.CharField(max_length=32, unique=True, verbose_name='账号')),
|
||||||
('password', models.CharField(max_length=32, verbose_name='密码')),
|
('password', models.CharField(max_length=32, verbose_name='密码')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
class UserInfo(models.Model):
|
|
||||||
"""
|
class UserInfo(models.Model):
|
||||||
用户列表
|
"""
|
||||||
用于记录用户基本信息
|
用户列表
|
||||||
"""
|
用于记录用户基本信息
|
||||||
identity = models.CharField(max_length=4, verbose_name="身份", blank=False, null=False)
|
"""
|
||||||
name = models.CharField(max_length=32, verbose_name="姓名", blank=False, null=False)
|
identity = models.CharField(max_length=4, verbose_name="身份", blank=False, null=False)
|
||||||
id_number = models.CharField(max_length=32, verbose_name="学号/教师编号", blank=False, null=False)
|
name = models.CharField(max_length=32, verbose_name="姓名", blank=False, null=False)
|
||||||
phone = models.CharField(max_length=32, verbose_name="手机", unique=True, blank=False, null=False)
|
id_number = models.CharField(max_length=32, verbose_name="学号/教师编号", blank=False, null=False)
|
||||||
username = models.CharField(max_length=32, verbose_name="账号", unique=True, blank=False, null=False)
|
phone = models.CharField(max_length=32, verbose_name="手机", unique=True, blank=False, null=False)
|
||||||
password = models.CharField(max_length=32, verbose_name="密码", blank=False, null=False)
|
username = models.CharField(max_length=32, verbose_name="账号", unique=True, blank=False, null=False)
|
||||||
|
password = models.CharField(max_length=32, verbose_name="密码", blank=False, null=False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,252 +1,252 @@
|
|||||||
body .bgimg img{
|
body .bgimg img{
|
||||||
position:absolute;
|
position:absolute;
|
||||||
width: auto;
|
width: auto;
|
||||||
height: auto;
|
height: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
top: 5px;
|
top: 5px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
left:0%;
|
left:0%;
|
||||||
top: 0%;
|
top: 0%;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin:0;
|
margin:0;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
font-family: PingFang SC,HarmonyOS_Regular,Helvetica Neue,Microsoft YaHei,sans-serif!important;
|
font-family: PingFang SC,HarmonyOS_Regular,Helvetica Neue,Microsoft YaHei,sans-serif!important;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
background-color: var(--graph_bg_regular);
|
background-color: var(--graph_bg_regular);
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
/* font-size: 14px; */
|
/* font-size: 14px; */
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
/* -webkit-text-size-adjust: 100%; */
|
/* -webkit-text-size-adjust: 100%; */
|
||||||
-webkit-tap-highlight-color: transparent;
|
-webkit-tap-highlight-color: transparent;
|
||||||
color: #18191c;
|
color: #18191c;
|
||||||
background-color: #f6f7f8;
|
background-color: #f6f7f8;
|
||||||
/* min-width: 1100px; */
|
/* min-width: 1100px; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-bgimg {
|
.header-bgimg {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: auto;
|
width: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
top: 0;
|
top: 0;
|
||||||
left:0;
|
left:0;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
/* width: 1519.2px; */
|
/* width: 1519.2px; */
|
||||||
width: 1535px;
|
width: 1535px;
|
||||||
/* height: 155px; */
|
/* height: 155px; */
|
||||||
height: 120px;
|
height: 120px;
|
||||||
}
|
}
|
||||||
header .header_bar {
|
header .header_bar {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
z-index: 1002;
|
z-index: 1002;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
/* padding: 0 24px; */
|
/* padding: 0 24px; */
|
||||||
max-width: 2560px;
|
max-width: 2560px;
|
||||||
/* width: 100%; */
|
/* width: 100%; */
|
||||||
width: 1535px;
|
width: 1535px;
|
||||||
height: 64px;
|
height: 64px;
|
||||||
}
|
}
|
||||||
body ul {
|
body ul {
|
||||||
/* 取消小原点 */
|
/* 取消小原点 */
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
body ul li {
|
body ul li {
|
||||||
margin: 15px;
|
margin: 15px;
|
||||||
}
|
}
|
||||||
header .header_bar .left_entry {
|
header .header_bar .left_entry {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
margin-right: 30px;
|
margin-right: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
body a {
|
body a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
header span {
|
header span {
|
||||||
color: white;
|
color: white;
|
||||||
/* font:14px "PingFang SC",HarmonyOs_re */
|
/* font:14px "PingFang SC",HarmonyOs_re */
|
||||||
}
|
}
|
||||||
|
|
||||||
.header_center {
|
.header_center {
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 2px;
|
top: 2px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
width: 400px;
|
width: 400px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
border-radius: 13px;
|
border-radius: 13px;
|
||||||
}
|
}
|
||||||
.header_bar .header_center .reseach {
|
.header_bar .header_center .reseach {
|
||||||
position: relative;
|
position: relative;
|
||||||
/* display: inline; */
|
/* display: inline; */
|
||||||
top: -7px;
|
top: -7px;
|
||||||
/* left: 2px; */
|
/* left: 2px; */
|
||||||
|
|
||||||
width: 360px;
|
width: 360px;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
border-radius: 13px;
|
border-radius: 13px;
|
||||||
border-width: 0px;
|
border-width: 0px;
|
||||||
outline:none;
|
outline:none;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* header .header_bar .right_entry {
|
/* header .header_bar .right_entry {
|
||||||
position: relative;
|
position: relative;
|
||||||
left: 100px;
|
left: 100px;
|
||||||
} */
|
} */
|
||||||
header right_last {
|
header right_last {
|
||||||
position:absolute;
|
position:absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
header .header_bar .right_entry {
|
header .header_bar .right_entry {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
margin-right: 30px;
|
margin-right: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.right_last button {
|
.right_last button {
|
||||||
/* box-shadow: 5px 5px rgb(109, 247, 71); */
|
/* box-shadow: 5px 5px rgb(109, 247, 71); */
|
||||||
/* blur:5px; */
|
/* blur:5px; */
|
||||||
background:transparent;/*按钮背景透明 */
|
background:transparent;/*按钮背景透明 */
|
||||||
/* background-color: pink; */
|
/* background-color: pink; */
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
border-color: greenyellow;
|
border-color: greenyellow;
|
||||||
border: width 1px; /*边框透明*/
|
border: width 1px; /*边框透明*/
|
||||||
outline:none; /*点击后没边框*/
|
outline:none; /*点击后没边框*/
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
border-radius: 22px;
|
border-radius: 22px;
|
||||||
}
|
}
|
||||||
.mybody {
|
.mybody {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: auto;
|
width: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
left: -8px;
|
left: -8px;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
top: 60px;
|
top: 60px;
|
||||||
/* background: #000; */
|
/* background: #000; */
|
||||||
|
|
||||||
}
|
}
|
||||||
.body_left{
|
.body_left{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
|
|
||||||
}
|
}
|
||||||
.body_center {
|
.body_center {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: relative;
|
position: relative;
|
||||||
top: -220px;
|
top: -220px;
|
||||||
/* left: 900px; */
|
/* left: 900px; */
|
||||||
width: 200px;
|
width: 200px;
|
||||||
/* height: 600px; */
|
/* height: 600px; */
|
||||||
/* background-color: pink; */
|
/* background-color: pink; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.body_center ul {
|
.body_center ul {
|
||||||
/* position: absolute; */
|
/* position: absolute; */
|
||||||
/* top: -200px;
|
/* top: -200px;
|
||||||
left: 50px; */
|
left: 50px; */
|
||||||
position: relative;
|
position: relative;
|
||||||
left: 20px;
|
left: 20px;
|
||||||
display:inline-block;
|
display:inline-block;
|
||||||
|
|
||||||
}
|
}
|
||||||
.body_center ul li{
|
.body_center ul li{
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
|
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
/* font-style: italic; */
|
/* font-style: italic; */
|
||||||
font-size: 50px;
|
font-size: 50px;
|
||||||
position: center;
|
position: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.body_right {
|
.body_right {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
display: block;
|
display: block;
|
||||||
/* width: 100px;
|
/* width: 100px;
|
||||||
height: 100px; */
|
height: 100px; */
|
||||||
top: 70px;
|
top: 70px;
|
||||||
right: 0;
|
right: 0;
|
||||||
/* background-color: #fff; */
|
/* background-color: #fff; */
|
||||||
/* background: rgba(249, 246, 246, 0.3); */
|
/* background: rgba(249, 246, 246, 0.3); */
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
/* margin: 20px */
|
/* margin: 20px */
|
||||||
}
|
}
|
||||||
|
|
||||||
.body_right table tr{
|
.body_right table tr{
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
}
|
}
|
||||||
.body_right input {
|
.body_right input {
|
||||||
width: 250px;
|
width: 250px;
|
||||||
height: 23px;
|
height: 23px;
|
||||||
border-color: aqua;
|
border-color: aqua;
|
||||||
border-radius: 18px;
|
border-radius: 18px;
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
}
|
}
|
||||||
.body_right table .sign_ {
|
.body_right table .sign_ {
|
||||||
position:relative;
|
position:relative;
|
||||||
width: 220px;
|
width: 220px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
left: 50px;
|
left: 50px;
|
||||||
/*color: white;*/
|
/*color: white;*/
|
||||||
/*background:rgba(0,0,0, 0.3);*/
|
/*background:rgba(0,0,0, 0.3);*/
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
}
|
}
|
||||||
.body_right table span {
|
.body_right table span {
|
||||||
/* border: red; */
|
/* border: red; */
|
||||||
position: relative;
|
position: relative;
|
||||||
/*background-color:aqua;*/
|
/*background-color:aqua;*/
|
||||||
/*left: 150px;*/
|
/*left: 150px;*/
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
border-radius: 18px;
|
border-radius: 18px;
|
||||||
margin: 30px;
|
margin: 30px;
|
||||||
}
|
}
|
||||||
/*.body_right table {*/
|
/*.body_right table {*/
|
||||||
/* margin: 0px;*/
|
/* margin: 0px;*/
|
||||||
/* width: 50px;*/
|
/* width: 50px;*/
|
||||||
/*}*/
|
/*}*/
|
||||||
.body_right table .add input{
|
.body_right table .add input{
|
||||||
position: relative;
|
position: relative;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
width: 15px;
|
width: 15px;
|
||||||
top: 4px;
|
top: 4px;
|
||||||
/*left: 20px;*/
|
/*left: 20px;*/
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
/*color: aliceblue;*/
|
/*color: aliceblue;*/
|
||||||
}
|
}
|
||||||
.body_right table .add span {
|
.body_right table .add span {
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
border: 4px;
|
border: 4px;
|
||||||
border-color: aqua;
|
border-color: aqua;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
background-color:#aedab5;
|
background-color:#aedab5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.body_right table .add a {
|
.body_right table .add a {
|
||||||
width: 110px;
|
width: 110px;
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
|
|
||||||
background-color:#aedab5;
|
background-color:#aedab5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,102 +1,102 @@
|
|||||||
|
|
||||||
.mybody{padding: 0;margin: 0;}
|
.mybody{padding: 0;margin: 0;}
|
||||||
|
|
||||||
.body_left{
|
.body_left{
|
||||||
position: relative;
|
position: relative;
|
||||||
/* top: 40px; */
|
/* top: 40px; */
|
||||||
/* width: 100vw;
|
/* width: 100vw;
|
||||||
height: 100vh; */
|
height: 100vh; */
|
||||||
width: 750px;
|
width: 750px;
|
||||||
height: 600px;
|
height: 600px;
|
||||||
/* background: #82ccdd; */
|
/* background: #82ccdd; */
|
||||||
display:inline-block;
|
display:inline-block;
|
||||||
/* justify-content: center;
|
/* justify-content: center;
|
||||||
align-items: center; */
|
align-items: center; */
|
||||||
}
|
}
|
||||||
/* 显示框 */
|
/* 显示框 */
|
||||||
div.scroll-photo{
|
div.scroll-photo{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
/* width: 400px;
|
/* width: 400px;
|
||||||
height: 300px; */
|
height: 300px; */
|
||||||
/* width: 800px; */
|
/* width: 800px; */
|
||||||
width: 765px;
|
width: 765px;
|
||||||
height: 450px;
|
height: 450px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
/* 内置图片的排列总宽度 */
|
/* 内置图片的排列总宽度 */
|
||||||
div.photos{
|
div.photos{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
/* width: 1200px;
|
/* width: 1200px;
|
||||||
height: 300px; */
|
height: 300px; */
|
||||||
width: 22500px;
|
width: 22500px;
|
||||||
height: 450px;
|
height: 450px;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.photos img{
|
div.photos img{
|
||||||
position: relative;
|
position: relative;
|
||||||
/* width: 400px;
|
/* width: 400px;
|
||||||
height: 300px; */
|
height: 300px; */
|
||||||
width: 800px;
|
width: 800px;
|
||||||
height: 450px;
|
height: 450px;
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.index ul{
|
div.index ul{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
display: grid;
|
display: grid;
|
||||||
bottom: -10px;
|
bottom: -10px;
|
||||||
left: 40%;
|
left: 40%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
list-style: none;
|
list-style: none;
|
||||||
width: 150px;
|
width: 150px;
|
||||||
grid-template: 1fr/repeat(3,1fr);
|
grid-template: 1fr/repeat(3,1fr);
|
||||||
justify-items: center;
|
justify-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.index ul::after{
|
div.index ul::after{
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 15px;
|
top: 15px;
|
||||||
left: 55px;
|
left: 55px;
|
||||||
width: 25px;
|
width: 25px;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
/* background: #d63031; */
|
/* background: #d63031; */
|
||||||
background: rgb(0, 255, 255);
|
background: rgb(0, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
div.index ul li{
|
div.index ul li{
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 25px;
|
width: 25px;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
color: #FFF;
|
color: #FFF;
|
||||||
background: rgba(0,0,0,.5);
|
background: rgba(0,0,0,.5);
|
||||||
display: grid;
|
display: grid;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
div.photos{
|
div.photos{
|
||||||
animation:scroll 12s steps(3,end);
|
animation:scroll 12s steps(3,end);
|
||||||
animation-iteration-count: infinite;
|
animation-iteration-count: infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.index ul::after{
|
div.index ul::after{
|
||||||
animation:index-scroll 12s steps(3,end);
|
animation:index-scroll 12s steps(3,end);
|
||||||
animation-iteration-count: infinite;
|
animation-iteration-count: infinite;
|
||||||
}
|
}
|
||||||
/* 图片移动像素 */
|
/* 图片移动像素 */
|
||||||
@keyframes scroll{
|
@keyframes scroll{
|
||||||
to{
|
to{
|
||||||
transform: translateX(-2400px);
|
transform: translateX(-2400px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*下标移动像素 */
|
/*下标移动像素 */
|
||||||
@keyframes index-scroll{
|
@keyframes index-scroll{
|
||||||
to{
|
to{
|
||||||
transform: translateX(165px);
|
transform: translateX(165px);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,60 +1,60 @@
|
|||||||
body {
|
body {
|
||||||
background-image: url(img/zc3.png);
|
background-image: url(img/zc3.png);
|
||||||
/* background-repeat: repeat-x; */
|
/* background-repeat: repeat-x; */
|
||||||
position:relative;
|
position:relative;
|
||||||
background-position-y: -100px;
|
background-position-y: -100px;
|
||||||
/* background-position-x: 50px; */
|
/* background-position-x: 50px; */
|
||||||
/* top: -200px; */
|
/* top: -200px; */
|
||||||
}
|
}
|
||||||
div {
|
div {
|
||||||
position:relative;
|
position:relative;
|
||||||
top: 80px;
|
top: 80px;
|
||||||
left: 35%;
|
left: 35%;
|
||||||
width: 500px;
|
width: 500px;
|
||||||
border: 0ch;
|
border: 0ch;
|
||||||
border: 4px solid aqua;
|
border: 4px solid aqua;
|
||||||
background-color: rgba(255,255,255,0.6);
|
background-color: rgba(255,255,255,0.6);
|
||||||
}
|
}
|
||||||
div h4 {
|
div h4 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 36px;
|
font-size: 36px;
|
||||||
font-style: inherit;
|
font-style: inherit;
|
||||||
font-family:Georgia, 'Times New Roman', Times, serif
|
font-family:Georgia, 'Times New Roman', Times, serif
|
||||||
}
|
}
|
||||||
td {
|
td {
|
||||||
position:relative;
|
position:relative;
|
||||||
left: 15%;
|
left: 15%;
|
||||||
}
|
}
|
||||||
input {
|
input {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
border-radius: 18px;
|
border-radius: 18px;
|
||||||
border-color: aqua;
|
border-color: aqua;
|
||||||
position: relative;
|
position: relative;
|
||||||
/* left: 25%; */
|
/* left: 25%; */
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tk input{
|
.tk input{
|
||||||
position:relative;
|
position:relative;
|
||||||
width: 15px;
|
width: 15px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
/* height: 100%; */
|
/* height: 100%; */
|
||||||
/* margin:0px; */
|
/* margin:0px; */
|
||||||
/* line-height: 72px; */
|
/* line-height: 72px; */
|
||||||
/* right: 50%; */
|
/* right: 50%; */
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
border-radius: 18px;
|
border-radius: 18px;
|
||||||
border-color: aqua;
|
border-color: aqua;
|
||||||
position: relative;
|
position: relative;
|
||||||
/* left: 25%; */
|
/* left: 25%; */
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
}
|
}
|
||||||
a {
|
a {
|
||||||
position: relative;
|
position: relative;
|
||||||
left: 20%;
|
left: 20%;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
@ -1,92 +1,92 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
{% load static %}
|
{% load static %}
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>注册页面</title>
|
<title>注册页面</title>
|
||||||
<link rel="stylesheet" href="{% static 'css/zhuce.css' %}">
|
<link rel="stylesheet" href="{% static 'css/zhuce.css' %}">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
{%csrf_token%}
|
{%csrf_token%}
|
||||||
<div>
|
<div>
|
||||||
<h4>启航题库</h4>
|
<h4>启航题库</h4>
|
||||||
<table width="500">
|
<table width="500">
|
||||||
<!-- 第一行 -->
|
<!-- 第一行 -->
|
||||||
<!-- <tr>
|
<!-- <tr>
|
||||||
<td>
|
<td>
|
||||||
我是:
|
我是:
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label><input type="radio" name="id"><img src="../images/men.jpg" width="25">老师</label>
|
<label><input type="radio" name="id"><img src="../images/men.jpg" width="25">老师</label>
|
||||||
<label><input type="radio" name="id"> <img src="../images/women.jpg" width="25" >学生</label>
|
<label><input type="radio" name="id"> <img src="../images/women.jpg" width="25" >学生</label>
|
||||||
</td>
|
</td>
|
||||||
</tr> -->
|
</tr> -->
|
||||||
<!-- 第二行 -->
|
<!-- 第二行 -->
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<select name="identity" required="required">
|
<select name="identity" required="required">
|
||||||
<option>我的身份</option>
|
<option>我的身份</option>
|
||||||
<option name=identity" value="老师">老师</option>
|
<option name=identity" value="老师">老师</option>
|
||||||
<option name="identity" value="学生">学生</option>
|
<option name="identity" value="学生">学生</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- 第三行 -->
|
<!-- 第三行 -->
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="name" required="required" placeholder="我的姓名">
|
<input type="text" name="name" required="required" placeholder="我的姓名">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- 第四行 -->
|
<!-- 第四行 -->
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="id_number" required="required" placeholder="学号or工号">
|
<input type="text" name="id_number" required="required" placeholder="学号or工号">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- 第六行 -->
|
<!-- 第六行 -->
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="phone" required="required" placeholder="手机号码">
|
<input type="text" name="phone" required="required" placeholder="手机号码">
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="username" required="required" placeholder="用户名">
|
<input type="text" name="username" required="required" placeholder="用户名">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="password" name="password" required="required" placeholder="密码">
|
<input type="password" name="password" required="required" placeholder="密码">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- 第八行 -->
|
<!-- 第八行 -->
|
||||||
<br>
|
<br>
|
||||||
{% if error_msg %}<p><strong>{{ error_msg }}</strong></p>{% endif %}
|
{% if error_msg %}<p><strong>{{ error_msg }}</strong></p>{% endif %}
|
||||||
<br>
|
<br>
|
||||||
<tr>
|
<tr>
|
||||||
<td class>
|
<td class>
|
||||||
<input type="submit" value="注册">
|
<input type="submit" value="注册">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- 第九行 -->
|
<!-- 第九行 -->
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tk">
|
<td class="tk">
|
||||||
<input type="radio"> 我同意注册条款和会员加入标准
|
<input type="radio"> 我同意注册条款和会员加入标准
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- 第十行 -->
|
<!-- 第十行 -->
|
||||||
<tr>
|
<tr>
|
||||||
<td >
|
<td >
|
||||||
<a href="#"> 我是会员,立即登录</a>
|
<a href="#"> 我是会员,立即登录</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -1,3 +1,3 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
app_name = 'login'
|
app_name = 'login'
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
|
||||||
path('register/', views.register),
|
path('register/', views.register),
|
||||||
|
|
||||||
path('login/', views.login, name='login'),
|
path('login/', views.login, name='login'),
|
||||||
|
|
||||||
path('dologin/', views.dologin, name='dologin'),
|
path('dologin/', views.dologin, name='dologin'),
|
||||||
|
|
||||||
path('logout/', views.logout, name='logout'),
|
path('logout/', views.logout, name='logout'),
|
||||||
|
|
||||||
path('captcha_img/', views.captcha_img, name='captcha_img'),
|
path('captcha_img/', views.captcha_img, name='captcha_img'),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1,145 +1,140 @@
|
|||||||
from django.shortcuts import render, HttpResponse, redirect
|
from django.shortcuts import render, HttpResponse, redirect
|
||||||
from pymysql import IntegrityError
|
from pymysql import IntegrityError
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from login.models import UserInfo
|
from login.models import UserInfo
|
||||||
from django.core.paginator import Paginator, Page
|
from django.core.paginator import Paginator, Page
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from login.common import captcha
|
from login.common import captcha
|
||||||
|
|
||||||
|
|
||||||
def home(request):
|
def home(request):
|
||||||
return render(request, 'home.html')
|
return render(request, 'home.html')
|
||||||
|
|
||||||
|
|
||||||
def register(request):
|
def register(request):
|
||||||
"""
|
"""
|
||||||
注册模块
|
注册模块
|
||||||
:param request:
|
:param request:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
return render(request, 'zhuce.html')
|
return render(request, 'zhuce.html')
|
||||||
|
|
||||||
# 获取用户提交的数据
|
# 获取用户提交的数据
|
||||||
try:
|
try:
|
||||||
identity = request.POST.get("identity")
|
identity = request.POST.get("identity")
|
||||||
name = request.POST.get("name")
|
name = request.POST.get("name")
|
||||||
id_number = request.POST.get("id_number")
|
id_number = request.POST.get("id_number")
|
||||||
phone = request.POST.get("phone")
|
phone = request.POST.get("phone")
|
||||||
username = request.POST.get("username")
|
username = request.POST.get("username")
|
||||||
password = request.POST.get("password")
|
password = request.POST.get("password")
|
||||||
|
|
||||||
# 添加到数据库
|
# 添加到数据库
|
||||||
UserInfo.objects.create(identity=identity, name=name, id_number=id_number, phone=phone, username=username, password=password)
|
UserInfo.objects.create(identity=identity, name=name, id_number=id_number, phone=phone, username=username, password=password)
|
||||||
|
|
||||||
# 一个跳转
|
# 一个跳转
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# 之后跳转至登录界面
|
# 之后跳转至登录界面
|
||||||
#
|
#
|
||||||
return redirect('login:login')
|
return redirect('login:login')
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
error_msg = '该手机号或用户名已被注册!'
|
error_msg = '该手机号或用户名已被注册!'
|
||||||
return render(request, 'zhuce.html', {'error_msg': error_msg} )
|
return render(request, 'zhuce.html', {'error_msg': error_msg} )
|
||||||
|
|
||||||
|
|
||||||
def server_error(request):
|
def server_error(request):
|
||||||
error_msg = '该手机号或用户名已被注册!'
|
error_msg = '该手机号或用户名已被注册!'
|
||||||
return HttpResponse("")
|
return HttpResponse("asedfsdf")
|
||||||
|
|
||||||
|
|
||||||
# def login00(request):
|
def login00(request):
|
||||||
#
|
|
||||||
# if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
# return render(request, 'login.html')
|
return render(request, 'login.html')
|
||||||
#
|
|
||||||
# error_msg = ""
|
error_msg = ""
|
||||||
# user = request.POST.get('email')
|
user = request.POST.get('email')
|
||||||
# pwd = request.POST.get('password')
|
pwd = request.POST.get('password')
|
||||||
#
|
|
||||||
# temp_RawQuerySet = UserInfo.objects.raw('select * from app02_userfo')
|
temp_RawQuerySet = UserInfo.objects.raw('select * from app02_userfo')
|
||||||
#
|
|
||||||
# for temp in temp_RawQuerySet:
|
for temp in temp_RawQuerySet:
|
||||||
# if temp.username == user and temp.password == pwd:
|
if temp.username == user and temp.password == pwd:
|
||||||
# if temp.identity == '老师':
|
if temp.identity == '老师':
|
||||||
# return redirect('http://www.baidu.com')
|
return redirect('http://www.baidu.com')
|
||||||
# else:
|
else:
|
||||||
# return redirect('http://www.baidu.com')
|
return redirect('http://www.baidu.com')
|
||||||
# else:
|
else:
|
||||||
# # 用户密码不匹配
|
# 用户密码不匹配
|
||||||
# error_msg = '用户名或密码错误'
|
error_msg = '用户名或密码错误'
|
||||||
# return render(request, 'login.html', {'error_msg': error_msg})
|
return render(request, 'login.html', {'error_msg': error_msg})
|
||||||
|
|
||||||
|
|
||||||
def login(request):
|
def login(request):
|
||||||
# 从cookie中获取用户名和密码
|
# 从cookie中获取用户名和密码
|
||||||
username = request.COOKIES.get('username')
|
username = request.COOKIES.get('username')
|
||||||
password = request.get_signed_cookie('pwd', None, salt='pwdsalt')
|
password = request.get_signed_cookie('pwd', None, salt='pwdsalt')
|
||||||
if username and password:
|
if username and password:
|
||||||
return render(request, 'login.html', {'username': username, 'pwd': password})
|
return render(request, 'login.html', {'username': username, 'pwd': password})
|
||||||
else:
|
else:
|
||||||
return render(request, 'login.html')
|
return render(request, 'login.html')
|
||||||
|
|
||||||
|
|
||||||
def dologin(request):
|
def dologin(request):
|
||||||
|
|
||||||
# 获取表单中提交的验证码
|
# 获取表单中提交的验证码
|
||||||
check_code = request.POST.get('check_code')
|
check_code = request.POST.get('check_code')
|
||||||
# 获取session会话中保存的code
|
print(check_code)
|
||||||
session_checkcode = request.session.get('check_code')
|
# 获取session会话中保存的code
|
||||||
if check_code and check_code.lower() == session_checkcode.lower():
|
session_checkcode = request.session.get('check_code')
|
||||||
# 从登录表单中获取用户名和密码及是否勾选了记住密码
|
if check_code and check_code.lower() == session_checkcode.lower():
|
||||||
username = request.POST.get('username')
|
# 从登录表单中获取用户名和密码及是否勾选了记住密码
|
||||||
password = request.POST.get('password')
|
username = request.POST.get('username')
|
||||||
rember = request.POST.get('rember')
|
password = request.POST.get('password')
|
||||||
response = HttpResponse()
|
rember = request.POST.get('rember')
|
||||||
|
response = HttpResponse()
|
||||||
temp_RawQuerySet = UserInfo.objects.raw('select * from login_userinfo')
|
|
||||||
|
temp_RawQuerySet = UserInfo.objects.raw('select * from login_userinfo')
|
||||||
for temp in temp_RawQuerySet:
|
|
||||||
if temp.username == username and temp.password == password:
|
for temp in temp_RawQuerySet:
|
||||||
# ## 存入基本信息到session ## #
|
if temp.username == username and temp.password == password:
|
||||||
request.session['username'] = username
|
|
||||||
request.session['password'] = password
|
if rember == 'rember':
|
||||||
request.session['id_number'] = temp.id_number
|
# 勾选了记住用户名和密码
|
||||||
request.session['name'] = temp.name
|
# 将用户名和密码保存到cookie中
|
||||||
if rember == 'rember':
|
response.set_cookie('username', username, max_age=3 * 24 * 3600)
|
||||||
# 勾选了记住用户名和密码
|
response.set_signed_cookie('pwd', password, salt='pwdsalt', max_age=3 * 24 * 3600)
|
||||||
# 将用户名和密码保存到cookie中
|
else:
|
||||||
response.set_cookie('username', username, max_age=3 * 24 * 3600)
|
# 删除cookie中的之前保存用户名和密码
|
||||||
response.set_signed_cookie('pwd', password, salt='pwdsalt', max_age=3 * 24 * 3600)
|
response.delete_cookie('username')
|
||||||
else:
|
response.delete_cookie('pwd')
|
||||||
# 删除cookie中的之前保存用户名和密码
|
|
||||||
response.delete_cookie('username')
|
if temp.identity == '老师':
|
||||||
response.delete_cookie('pwd')
|
return render(request, 'teacher_client.html', {'username': temp.username})
|
||||||
|
else:
|
||||||
if temp.identity == '老师':
|
return redirect('http://www.baidu.com')
|
||||||
return redirect('teacher_client:teacher_client')
|
|
||||||
# return render(request, 'teacher_client.html', {'username': temp.username})
|
# 用户密码不匹配
|
||||||
else:
|
response.delete_cookie('username')
|
||||||
return redirect('student_client:student_client')
|
response.delete_cookie('pwd')
|
||||||
|
error_msg = '用户名或密码错误'
|
||||||
# 用户密码不匹配
|
return render(request, 'login.html', {'error_msg1': error_msg})
|
||||||
response.delete_cookie('username')
|
else:
|
||||||
response.delete_cookie('pwd')
|
error_msg = '验证码错误'
|
||||||
error_msg = '用户名或密码错误'
|
return render(request, 'login.html', {'error_msg': error_msg})
|
||||||
return render(request, 'login.html', {'error_msg1': error_msg})
|
|
||||||
else:
|
|
||||||
error_msg = '验证码错误'
|
def logout(request):
|
||||||
return render(request, 'login.html', {'error_msg': error_msg})
|
response = HttpResponse()
|
||||||
|
response.delete_cookie('username')
|
||||||
|
response.delete_cookie('pwd')
|
||||||
def logout(request):
|
return response and redirect('login:login')
|
||||||
response = HttpResponse()
|
|
||||||
response.delete_cookie('username')
|
|
||||||
response.delete_cookie('pwd')
|
def captcha_img(request):
|
||||||
request.session.flush()
|
stream = BytesIO()
|
||||||
return response and redirect('login:login')
|
img, code = captcha.veri_code()
|
||||||
|
img.save(stream, 'PNG')
|
||||||
|
request.session['check_code'] = code
|
||||||
def captcha_img(request):
|
|
||||||
stream = BytesIO()
|
|
||||||
img, code = captcha.veri_code()
|
|
||||||
img.save(stream, 'PNG')
|
|
||||||
request.session['check_code'] = code
|
|
||||||
return HttpResponse(stream.getvalue())
|
return HttpResponse(stream.getvalue())
|
@ -1,22 +1,22 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
"""Django's command-line utility for administrative tasks."""
|
"""Django's command-line utility for administrative tasks."""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Run administrative tasks."""
|
"""Run administrative tasks."""
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'the_online_test_system.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'the_online_test_system.settings')
|
||||||
try:
|
try:
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"Couldn't import Django. Are you sure it's installed and "
|
"Couldn't import Django. Are you sure it's installed and "
|
||||||
"available on your PYTHONPATH environment variable? Did you "
|
"available on your PYTHONPATH environment variable? Did you "
|
||||||
"forget to activate a virtual environment?"
|
"forget to activate a virtual environment?"
|
||||||
) from exc
|
) from exc
|
||||||
execute_from_command_line(sys.argv)
|
execute_from_command_line(sys.argv)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
@ -1,5 +0,0 @@
|
|||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class StudentClientConfig(AppConfig):
|
|
||||||
name = 'student_client'
|
|
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
@ -1,3 +0,0 @@
|
|||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
@ -1,11 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
from django.urls import path
|
|
||||||
from . import views
|
|
||||||
|
|
||||||
app_name = 'student_client'
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
|
|
||||||
path("student_client/", views.student_client, name = "student_client")
|
|
||||||
|
|
||||||
]
|
|
@ -1,7 +0,0 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
|
|
||||||
def student_client(request):
|
|
||||||
"""学生端口"""
|
|
||||||
if request.method == "GET":
|
|
||||||
return render(request, "student_client.html")
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,3 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
class TeacherClientConfig(AppConfig):
|
class TeacherClientConfig(AppConfig):
|
||||||
name = 'teacher_client'
|
name = 'teacher_client'
|
||||||
|
Binary file not shown.
@ -1,14 +0,0 @@
|
|||||||
import random
|
|
||||||
|
|
||||||
|
|
||||||
def random_num():
|
|
||||||
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
|
|
||||||
'a', 'b', 'c', 'd', 'e', 'f',
|
|
||||||
'g', 'h', 'i', 'j', 'k', 'l',
|
|
||||||
'm', 'n', 'o', 'p', 'q', 'r',
|
|
||||||
's', 't', 'u', 'v', 'w', 'x',
|
|
||||||
'y', 'z']
|
|
||||||
temp = random.sample(L, 5)
|
|
||||||
a, b, c, d, e = temp
|
|
||||||
code = str(a)+str(b)+str(c)+str(d)+str(e)
|
|
||||||
return code
|
|
Binary file not shown.
@ -1,17 +0,0 @@
|
|||||||
from django.utils.deprecation import MiddlewareMixin
|
|
||||||
from django.shortcuts import HttpResponse, redirect
|
|
||||||
|
|
||||||
|
|
||||||
class AuthMiddleware(MiddlewareMixin):
|
|
||||||
|
|
||||||
def process_request(self, request):
|
|
||||||
# 首先排除那些不需要登录的urls
|
|
||||||
if request.path_info == '/' or request.path_info == '/register/' or request.path_info == '/dologin/':
|
|
||||||
return None
|
|
||||||
# 获取当前访问用户登录时存入的session信息
|
|
||||||
username = request.session.get('username')
|
|
||||||
password = request.session.get('password')
|
|
||||||
# 若不为空,则已经登录
|
|
||||||
if username and password:
|
|
||||||
return None
|
|
||||||
return HttpResponse('请登录')
|
|
@ -1,20 +1,20 @@
|
|||||||
# Generated by Django 3.1.4 on 2022-04-09 08:54
|
# Generated by Django 3.1.4 on 2022-04-09 08:54
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='questionBank',
|
name='questionBank',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
# Generated by Django 3.1.4 on 2022-04-14 11:45
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('teacher_client', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='classTable',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('name', models.CharField(max_length=32, verbose_name='姓名')),
|
|
||||||
('id_number', models.CharField(max_length=32, verbose_name='学号/教师编号')),
|
|
||||||
('phone', models.CharField(max_length=32, unique=True, verbose_name='手机')),
|
|
||||||
('classCode', models.CharField(default='', max_length=6, verbose_name='加课码')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='teacherClass',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('name', models.CharField(max_length=32, verbose_name='姓名')),
|
|
||||||
('id_number', models.CharField(max_length=32, verbose_name='学号/教师编号')),
|
|
||||||
('classCode', models.CharField(default='', max_length=20, verbose_name='加课码')),
|
|
||||||
('classname', models.CharField(default='', max_length=20, verbose_name='课程名')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.DeleteModel(
|
|
||||||
name='questionBank',
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,26 +0,0 @@
|
|||||||
# Generated by Django 3.1.4 on 2022-04-15 09:36
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('teacher_client', '0002_auto_20220414_1945'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='questionBank',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('qus_imfomation', models.CharField(max_length=1000, verbose_name='题目信息')),
|
|
||||||
('qus_A', models.CharField(max_length=1000, verbose_name='选项A')),
|
|
||||||
('qus_B', models.CharField(max_length=1000, verbose_name='选项B')),
|
|
||||||
('qus_C', models.CharField(max_length=1000, verbose_name='选项C')),
|
|
||||||
('qus_D', models.CharField(max_length=1000, verbose_name='选项D')),
|
|
||||||
('qus_ans', models.CharField(max_length=100, verbose_name='答案')),
|
|
||||||
('que_classcode', models.CharField(max_length=10, verbose_name='所属班级')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,23 +0,0 @@
|
|||||||
# Generated by Django 3.1.4 on 2022-04-15 09:55
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('teacher_client', '0003_questionbank'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='questionbank',
|
|
||||||
name='que_classcode',
|
|
||||||
field=models.CharField(max_length=1000, verbose_name='所属班级'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='questionbank',
|
|
||||||
name='qus_ans',
|
|
||||||
field=models.CharField(max_length=1000, verbose_name='答案'),
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 3.1.4 on 2022-04-15 12:25
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('teacher_client', '0004_auto_20220415_1755'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='questionbank',
|
|
||||||
name='que_time',
|
|
||||||
field=models.CharField(default='', max_length=200, verbose_name='存入时间'),
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,26 +0,0 @@
|
|||||||
# Generated by Django 3.1.4 on 2022-04-15 14:51
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('teacher_client', '0005_questionbank_que_time'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='testQuestionBank',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('qus_imfomation', models.CharField(max_length=1000, verbose_name='题目信息')),
|
|
||||||
('qus_A', models.CharField(max_length=1000, verbose_name='选项A')),
|
|
||||||
('qus_B', models.CharField(max_length=1000, verbose_name='选项B')),
|
|
||||||
('qus_C', models.CharField(max_length=1000, verbose_name='选项C')),
|
|
||||||
('qus_D', models.CharField(max_length=1000, verbose_name='选项D')),
|
|
||||||
('qus_ans', models.CharField(max_length=1000, verbose_name='答案')),
|
|
||||||
('test_code', models.CharField(max_length=1000, verbose_name='所属班级')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 3.1.4 on 2022-04-16 02:52
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('teacher_client', '0006_testquestionbank'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='testquestionbank',
|
|
||||||
name='test_time',
|
|
||||||
field=models.CharField(default='', max_length=200, verbose_name='考试时间'),
|
|
||||||
),
|
|
||||||
]
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,45 +1,6 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
# class questionBank(models.Model):
|
class questionBank(models.Model):
|
||||||
# """用于存储题目数据"""
|
"""用于存储题目数据"""
|
||||||
|
|
||||||
|
|
||||||
class teacherClass(models.Model):
|
|
||||||
"""记录班级加课码"""
|
|
||||||
name = models.CharField(max_length=32, verbose_name="姓名", blank=False, null=False)
|
|
||||||
id_number = models.CharField(max_length=32, verbose_name="学号/教师编号", blank=False, null=False)
|
|
||||||
classCode = models.CharField(max_length=20, verbose_name="加课码", default='')
|
|
||||||
classname = models.CharField(max_length=20, verbose_name="课程名", default='')
|
|
||||||
|
|
||||||
|
|
||||||
class classTable(models.Model):
|
|
||||||
"""班级表"""
|
|
||||||
name = models.CharField(max_length=32, verbose_name="姓名", blank=False, null=False)
|
|
||||||
id_number = models.CharField(max_length=32, verbose_name="学号/教师编号", blank=False, null=False)
|
|
||||||
phone = models.CharField(max_length=32, verbose_name="手机", unique=True, blank=False, null=False)
|
|
||||||
classCode = models.CharField(max_length=6, verbose_name="加课码", default='')
|
|
||||||
|
|
||||||
|
|
||||||
class questionBank(models.Model):
|
|
||||||
"""用于保存用户上传提交的题目"""
|
|
||||||
qus_imfomation = models.CharField(max_length=1000, verbose_name="题目信息", blank=False, null=False)
|
|
||||||
qus_A = models.CharField(max_length=1000, verbose_name="选项A", blank=False, null=False)
|
|
||||||
qus_B = models.CharField(max_length=1000, verbose_name="选项B", blank=False, null=False)
|
|
||||||
qus_C = models.CharField(max_length=1000, verbose_name="选项C", blank=False, null=False)
|
|
||||||
qus_D = models.CharField(max_length=1000, verbose_name="选项D")
|
|
||||||
qus_ans = models.CharField(max_length=1000, verbose_name="答案", blank=False, null=False)
|
|
||||||
que_classcode = models.CharField(max_length=1000, verbose_name="所属班级", blank=False, null=False)
|
|
||||||
que_time = models.CharField(max_length=200, verbose_name="存入时间", default="")
|
|
||||||
|
|
||||||
|
|
||||||
class testQuestionBank(models.Model):
|
|
||||||
"""考试信息表"""
|
|
||||||
qus_imfomation = models.CharField(max_length=1000, verbose_name="题目信息", blank=False, null=False)
|
|
||||||
qus_A = models.CharField(max_length=1000, verbose_name="选项A", blank=False, null=False)
|
|
||||||
qus_B = models.CharField(max_length=1000, verbose_name="选项B", blank=False, null=False)
|
|
||||||
qus_C = models.CharField(max_length=1000, verbose_name="选项C", blank=False, null=False)
|
|
||||||
qus_D = models.CharField(max_length=1000, verbose_name="选项D")
|
|
||||||
qus_ans = models.CharField(max_length=1000, verbose_name="答案")
|
|
||||||
test_code = models.CharField(max_length=1000, verbose_name="所属班级", blank=False, null=False)
|
|
||||||
test_time = models.CharField(max_length=200, verbose_name="考试时间", default='')
|
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
*{
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
.page {
|
|
||||||
display: block;
|
|
||||||
position: relative;
|
|
||||||
/* top: 400px; */
|
|
||||||
left: 40px;
|
|
||||||
}
|
|
||||||
.all{
|
|
||||||
width: 100%;
|
|
||||||
/* width: 100px; */
|
|
||||||
height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
/* left: 30px; */
|
|
||||||
/* justify-content: center; */
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
/*偷懒才用的id*/
|
|
||||||
#inputs input{
|
|
||||||
display: inline-block;
|
|
||||||
width: 100px;
|
|
||||||
height: 50px;
|
|
||||||
background-color: white;
|
|
||||||
margin: 10px;
|
|
||||||
}
|
|
||||||
.info {
|
|
||||||
position: relative;
|
|
||||||
left: 100px;
|
|
||||||
}
|
|
||||||
#table{
|
|
||||||
display: inline-block;
|
|
||||||
width: 90%;
|
|
||||||
}
|
|
||||||
tr{
|
|
||||||
width: 100%;
|
|
||||||
margin: 10px;
|
|
||||||
}
|
|
||||||
td{
|
|
||||||
text-align: center;
|
|
||||||
/* width: 50%; */
|
|
||||||
width: 200px;
|
|
||||||
height: 10vh;
|
|
||||||
border: 1px solid black;
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
table
|
|
||||||
{
|
|
||||||
border-collapse: collapse;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
table td, table th
|
|
||||||
{
|
|
||||||
border: 1px solid #cad9ea;
|
|
||||||
color: #666;
|
|
||||||
height: 35px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table thead th
|
|
||||||
{
|
|
||||||
background-color: #CCE8EB;
|
|
||||||
width: 100px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table tr:nth-child(odd)
|
|
||||||
{
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
table tr:nth-child(even)
|
|
||||||
{
|
|
||||||
background: #F5FAFA;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*ul,li{ padding:0; margin:0;list-style:none}*/
|
|
||||||
/*.nav{border:1px solid #000; width:510px; overflow:hidden}*/
|
|
||||||
/*.nav li{ line-height:22px; float:left; padding:0 5px;}*/
|
|
||||||
/*.nav li a:hover{ color:#F00}*/
|
|
||||||
/*nav li{line-height:22px; float:left; padding:0 6px;}*/
|
|
||||||
/*nav li a{ color:#009900}*/
|
|
@ -1,120 +0,0 @@
|
|||||||
*{
|
|
||||||
margin: 0px;
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
/* 全局字体大小 */
|
|
||||||
font-size: 18px;
|
|
||||||
|
|
||||||
}
|
|
||||||
.page {
|
|
||||||
display: inline-block;
|
|
||||||
/*position: fixed;*/
|
|
||||||
display: block;
|
|
||||||
position: fixed;
|
|
||||||
width: 340px;
|
|
||||||
left: 8px;
|
|
||||||
top: 5px;
|
|
||||||
/* width: auto; */
|
|
||||||
height: auto;
|
|
||||||
/*border-style:solid;*/
|
|
||||||
/*border-width: 2px;*/
|
|
||||||
/*border-color:aqua;*/
|
|
||||||
padding-top: 5px;
|
|
||||||
padding: 5px;
|
|
||||||
/* background-color: red; */
|
|
||||||
}
|
|
||||||
/*.set_time {*/
|
|
||||||
/* display: flex;*/
|
|
||||||
/* display: block;*/
|
|
||||||
/* top: auto;*/
|
|
||||||
/* margin: 10px;*/
|
|
||||||
|
|
||||||
/*}*/
|
|
||||||
.set_time {
|
|
||||||
display: block;
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
.set_time input {
|
|
||||||
font-size: 20px;
|
|
||||||
width: 300px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: white;
|
|
||||||
border-bottom-color:black ;
|
|
||||||
/* 点击后无边框 */
|
|
||||||
outline:none;
|
|
||||||
}
|
|
||||||
.page1 {
|
|
||||||
border-style:solid;
|
|
||||||
border-width: 2px;
|
|
||||||
border-color:aqua;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.page a {
|
|
||||||
display: inline-block;
|
|
||||||
text-decoration: none;
|
|
||||||
font-size: 24px;
|
|
||||||
line-height: 50px;
|
|
||||||
text-align: center;
|
|
||||||
width: 50px;
|
|
||||||
height: 50px;
|
|
||||||
margin: 5px;
|
|
||||||
background-color: rgb(246, 224, 224);
|
|
||||||
border-style: solid;
|
|
||||||
border-width: 1px;
|
|
||||||
border-color: aquamarine
|
|
||||||
}
|
|
||||||
.page a:hover {
|
|
||||||
/* 鼠标移动到时的改变颜色 */
|
|
||||||
background-color: #5096f5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.line {
|
|
||||||
|
|
||||||
display: inline-block;
|
|
||||||
position: relative;
|
|
||||||
position: fixed;
|
|
||||||
left: 368px;
|
|
||||||
width: 6px;
|
|
||||||
height: 600px;
|
|
||||||
border-radius: 6px;
|
|
||||||
background-color:rgb(129, 122, 122);
|
|
||||||
}
|
|
||||||
.test {
|
|
||||||
display: inline-block;
|
|
||||||
position: relative;
|
|
||||||
/* position: fixed; */
|
|
||||||
left: 408px;
|
|
||||||
height: auto;
|
|
||||||
/* height: 1000px; */
|
|
||||||
/* background-color: pink;*/
|
|
||||||
}
|
|
||||||
ul {
|
|
||||||
list-style-type:armenian;
|
|
||||||
}
|
|
||||||
ul .ques {
|
|
||||||
position: relative;
|
|
||||||
left: 1px;
|
|
||||||
}
|
|
||||||
li {
|
|
||||||
position: relative;
|
|
||||||
left: 20px;
|
|
||||||
/* 取消小圆点 */
|
|
||||||
list-style-type: none;
|
|
||||||
}
|
|
||||||
.write {
|
|
||||||
/* 设置下划线 */
|
|
||||||
width: 300px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: white;
|
|
||||||
border-bottom-color:black ;
|
|
||||||
/* 点击后无边框 */
|
|
||||||
outline:none;
|
|
||||||
font-size: 24px;
|
|
||||||
}
|
|
||||||
/* .write:hover{
|
|
||||||
border-style: solid;
|
|
||||||
border-color: white;
|
|
||||||
border-bottom-color:black ;
|
|
||||||
} */
|
|
@ -1,24 +0,0 @@
|
|||||||
*{
|
|
||||||
margin: 0px;
|
|
||||||
padding: 0%;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
.img {
|
|
||||||
width: 1488px;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
position: relative;
|
|
||||||
top: -13px;
|
|
||||||
}
|
|
||||||
.class {
|
|
||||||
width: 400px;
|
|
||||||
height: 400px;
|
|
||||||
/* color: blue; */
|
|
||||||
/* background-color: red; */
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Title</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<form action="{% url 'teacher_client:classSet'%}" method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
班级名:<input type="text" name="classname" placeholder="班级名称">
|
|
||||||
<input type="submit" value="提交">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,110 +0,0 @@
|
|||||||
{% load static %}
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="zh-CN">
|
|
||||||
<!-- {% load static %} -->
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Title</title>
|
|
||||||
<!-- <link rel="stylesheet" href="{% static 'css/henyeqi.css' %}"> -->
|
|
||||||
<link rel="stylesheet" href="{% static 'css/stud.css' %}">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<div class="page">
|
|
||||||
<div class="page1">
|
|
||||||
{% if single_choice %}
|
|
||||||
单选题<br>
|
|
||||||
{% for counter in single_choice %}
|
|
||||||
<a href="#0{{ forloop.counter }}"><span>{{ forloop.counter }}</span></a>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% if multiple_choice %}
|
|
||||||
<br>多选题<br>
|
|
||||||
{% for counter in multiple_choice %}
|
|
||||||
<a href="#1{{ forloop.counter }}"><span>{{ forloop.counter }}</span></a>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% if gap_filling %}
|
|
||||||
<br>填空题<br>
|
|
||||||
{% for counter in gap_filling %}
|
|
||||||
<a href="#2{{ forloop.counter }}"><span>{{ forloop.counter }}</span></a>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<form method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
<span class="set_time">
|
|
||||||
时间:<input type="text" name="test_time" placeholder="输入考试时间,例如 2:30">
|
|
||||||
</span>
|
|
||||||
<span>是否决定发布测试?</span><br>
|
|
||||||
<input type="submit" value="发布测试">
|
|
||||||
{% if TEST_CODE %}
|
|
||||||
本场考试的考试码为:{{ TEST_CODE }}
|
|
||||||
{% endif %}
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="line"></div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="test">
|
|
||||||
<form action="">
|
|
||||||
<table >
|
|
||||||
|
|
||||||
<!-- 单选 -->
|
|
||||||
{# {% for student in student_page.object_list %} #}
|
|
||||||
{% if single_choice %}
|
|
||||||
一、单选<br><br>
|
|
||||||
{% for single in single_choice %}
|
|
||||||
<ul id="0{{ forloop.counter }}">
|
|
||||||
<li class="ques"><label>{{ forloop.counter }}、(单选){{ single.qus_imfomation }}</label></li>
|
|
||||||
<li><label><input type="radio" name="choose{{ forloop.counter }}" value="A">{{ single.qus_A }}</label></li>
|
|
||||||
<li><label><input type="radio" name="choose{{ forloop.counter }}" value="B">{{ single.qus_B }}</label></li>
|
|
||||||
<li><label><input type="radio" name="choose{{ forloop.counter }}" value="C">{{ single.qus_C }}</label></li>
|
|
||||||
<li><label><input type="radio" name="choose{{ forloop.counter }}" value="D">{{ single.qus_D }}</label></li>
|
|
||||||
</ul>
|
|
||||||
<br>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<!-- 多选 -->
|
|
||||||
{# {% for student in student_page.object_list %} #}
|
|
||||||
{% if multiple_choice %}
|
|
||||||
<br>二、多选<br><br>
|
|
||||||
{% for multiple in multiple_choice %}
|
|
||||||
<ul id="1{{ forloop.counter }}">
|
|
||||||
<li class="ques"><label>{{ forloop.counter }}、(多选){{ multiple.qus_imfomation }}</label></li>
|
|
||||||
<li><label><input type="checkbox" name="choose{{ forloop.counter }}" value="A">{{ multiple.qus_A }}</label></li>
|
|
||||||
<li><label><input type="checkbox" name="choose{{ forloop.counter }}" value="B">{{ multiple.qus_B }}</label></li>
|
|
||||||
<li><label><input type="checkbox" name="choose{{ forloop.counter }}" value="C">{{ multiple.qus_C }}</label></li>
|
|
||||||
<li><label><input type="checkbox" name="choose{{ forloop.counter }}" value="D">{{ multiple.qus_D }}</label></li>
|
|
||||||
</ul>
|
|
||||||
<br>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<!-- 填空 -->
|
|
||||||
{# {% for student in student_page.object_list %} #}
|
|
||||||
{% if gap_filling %}
|
|
||||||
<br>三、填空题<br><br>
|
|
||||||
{% for gap in gap_filling%}
|
|
||||||
<ul id="2{{ forloop.counter }}">
|
|
||||||
<li class="ques"><label>{{ forloop.counter }}、(填空){{ gap.qus_imfomation }}</label></li>
|
|
||||||
<!-- <li><label><input type="text" name="choose" value="dhsaujdh">A.jshduse</label></li> -->
|
|
||||||
<li><label><input type="text" class="write" name="choose" placeholder="在此处作答"></label></li>
|
|
||||||
</ul>
|
|
||||||
<br>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</table>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,3 +1,3 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
|
@ -1,20 +1,12 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
app_name = 'teacher_client'
|
urlpatterns = [
|
||||||
|
|
||||||
urlpatterns = [
|
path('admin/', admin.site.urls),
|
||||||
|
|
||||||
path('admin/', admin.site.urls),
|
path('teacher_client/', views.teacher_client),
|
||||||
|
|
||||||
path('teacher_client/', views.teacher_client, name="teacher_client"),
|
|
||||||
|
|
||||||
path('file_muti/', views.file_muti, name="file_muti"),
|
|
||||||
|
|
||||||
path('teacher_client/classSet/', views.classSet, name="classSet"),
|
|
||||||
|
|
||||||
path('teacher_client/test_release/', views.test_release, name="test_release")
|
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
@ -1,255 +1,7 @@
|
|||||||
from django.http import HttpResponse
|
from django.shortcuts import render
|
||||||
from django.shortcuts import render, redirect
|
|
||||||
from .models import teacherClass, classTable, questionBank, testQuestionBank
|
|
||||||
from .common import createCode
|
def teacher_client(request):
|
||||||
import json, time
|
"""教师服务端"""
|
||||||
from openpyxl import load_workbook
|
if request.method == 'GET':
|
||||||
|
return render(request, 'teacher_client.html')
|
||||||
TEST_CODE = 1000
|
|
||||||
|
|
||||||
|
|
||||||
def get_code():
|
|
||||||
code = createCode.random_num()
|
|
||||||
return code
|
|
||||||
|
|
||||||
|
|
||||||
def teacher_client(request):
|
|
||||||
"""教师服务端"""
|
|
||||||
if request.method == 'GET':
|
|
||||||
username = request.session.get('username')
|
|
||||||
password = request.session.get('password')
|
|
||||||
print(username, password)
|
|
||||||
|
|
||||||
if username and password:
|
|
||||||
|
|
||||||
teacherID = request.session.get('id_number')
|
|
||||||
classCODE = request.session.get('classcode')
|
|
||||||
|
|
||||||
classname = []
|
|
||||||
classcode = []
|
|
||||||
|
|
||||||
select_teacher_client_teacherclass = 'select id, id_number, classname, classcode ' \
|
|
||||||
'from teacher_client_teacherclass ' \
|
|
||||||
'where id_number = ' + str(teacherID)
|
|
||||||
|
|
||||||
temp_RawQuerySetClass = teacherClass.objects.raw(select_teacher_client_teacherclass)
|
|
||||||
|
|
||||||
for cc in temp_RawQuerySetClass:
|
|
||||||
classname.append(cc.classname)
|
|
||||||
classcode.append(cc.classcode)
|
|
||||||
|
|
||||||
classnum = len(classname)
|
|
||||||
|
|
||||||
str1 = '('
|
|
||||||
for temp in classcode:
|
|
||||||
str1 = str1 + "'" + temp + "'" + ","
|
|
||||||
str1 = str1.strip(',')
|
|
||||||
str1 += ')'
|
|
||||||
select_teacher_client_classtable = 'select id, name, id_number, phone, classcode ' \
|
|
||||||
'from teacher_client_classtable ' \
|
|
||||||
'where classcode in ' + str1
|
|
||||||
|
|
||||||
temp_RawQuerySetStudent = classTable.objects.raw(select_teacher_client_classtable)
|
|
||||||
Sname = []
|
|
||||||
Sno = []
|
|
||||||
Sphone = []
|
|
||||||
|
|
||||||
for ss in temp_RawQuerySetStudent:
|
|
||||||
Sname.append(ss.name)
|
|
||||||
Sno.append(ss.id_number)
|
|
||||||
Sphone.append(ss.phone)
|
|
||||||
res = []
|
|
||||||
for i in range(len(Sname)):
|
|
||||||
res.append([Sname[i], Sno[i], Sphone[i]])
|
|
||||||
|
|
||||||
return render(request, 'teacher_client.html',
|
|
||||||
{'classname': json.dumps(classname), 'res': json.dumps(res), 'classcode': classcode,
|
|
||||||
"student": temp_RawQuerySetStudent, 'username': username,
|
|
||||||
"class": temp_RawQuerySetClass}, )
|
|
||||||
else:
|
|
||||||
return redirect("http://127.0.0.1:8000/")
|
|
||||||
|
|
||||||
|
|
||||||
def classSet(request):
|
|
||||||
if request.method == "GET":
|
|
||||||
return render(request, "createClass.html")
|
|
||||||
classname = request.POST.get('classname')
|
|
||||||
request.session['classname'] = classname
|
|
||||||
if classname != '':
|
|
||||||
# global CLASS_ID
|
|
||||||
# CLASS_ID += 1
|
|
||||||
code = get_code()
|
|
||||||
request.session['code'] = code
|
|
||||||
username = request.session.get('username')
|
|
||||||
id_number = request.session.get('id_number')
|
|
||||||
teacherClass.objects.create(name=username, id_number=id_number, classCode=code, classname=classname)
|
|
||||||
return redirect("teacher_client:teacher_client")
|
|
||||||
else:
|
|
||||||
return HttpResponse("请输入班级名")
|
|
||||||
|
|
||||||
|
|
||||||
def file_muti(request):
|
|
||||||
"""用于教师端文件上传"""
|
|
||||||
file_object = request.FILES.get('exc')
|
|
||||||
now_time = time.time()
|
|
||||||
wb = load_workbook(file_object)
|
|
||||||
sheet = wb.worksheets[0]
|
|
||||||
|
|
||||||
for row in sheet.iter_rows(min_row=2):
|
|
||||||
# for temp in range(7):
|
|
||||||
# print(row[temp].value)
|
|
||||||
qus_imfomation = row[0].value
|
|
||||||
qus_A = row[1].value
|
|
||||||
qus_B = row[2].value
|
|
||||||
qus_C = row[3].value
|
|
||||||
qus_D = row[4].value
|
|
||||||
qus_ans = row[5].value
|
|
||||||
que_classcode = row[6].value
|
|
||||||
questionBank.objects.create(qus_imfomation=qus_imfomation, qus_A=qus_A, qus_B=qus_B, qus_C=qus_C, qus_D=qus_D, qus_ans=qus_ans, que_classcode=que_classcode, que_time=now_time)
|
|
||||||
return redirect('teacher_client:teacher_client')
|
|
||||||
|
|
||||||
|
|
||||||
def radix_sort(array):
|
|
||||||
"""基数排序"""
|
|
||||||
max_num = max(array)
|
|
||||||
place = 1
|
|
||||||
while max_num >= 10 ** place:
|
|
||||||
place += 1
|
|
||||||
for i in range(place):
|
|
||||||
buckets = [[] for _ in range(10)]
|
|
||||||
for num in array:
|
|
||||||
radix = int(num / (10 ** i) % 10)
|
|
||||||
buckets[radix].append(num)
|
|
||||||
j = 0
|
|
||||||
for k in range(10):
|
|
||||||
for num in buckets[k]:
|
|
||||||
array[j] = num
|
|
||||||
j += 1
|
|
||||||
return array
|
|
||||||
|
|
||||||
|
|
||||||
def binary_search(alist, data):
|
|
||||||
"""二分查找"""
|
|
||||||
n = len(alist)
|
|
||||||
first = 0
|
|
||||||
last = n - 1
|
|
||||||
if data > alist[-1]:
|
|
||||||
return alist[-1]
|
|
||||||
while first <= last:
|
|
||||||
mid = (last + first) // 2
|
|
||||||
if alist[mid] > data:
|
|
||||||
last = mid - 1
|
|
||||||
elif alist[mid] < data:
|
|
||||||
first = mid + 1
|
|
||||||
else:
|
|
||||||
return data
|
|
||||||
if abs(alist[first] - data) > abs(alist[first-1] - data):
|
|
||||||
return alist[first-1]
|
|
||||||
return alist[first]
|
|
||||||
|
|
||||||
|
|
||||||
def test_release(request):
|
|
||||||
"""用于习题发布"""
|
|
||||||
if request.method == "GET":
|
|
||||||
global TEST_CODE
|
|
||||||
TEST_CODE += 1
|
|
||||||
|
|
||||||
# 从前端获取一个考试时间 #
|
|
||||||
# test_time = request.POST.get('test_time')
|
|
||||||
|
|
||||||
time_list = []
|
|
||||||
time_select = "select id, que_time " \
|
|
||||||
"from teacher_client_questionbank"
|
|
||||||
time_res = questionBank.objects.raw(time_select)
|
|
||||||
|
|
||||||
for temp in time_res:
|
|
||||||
if temp.que_time not in time_list:
|
|
||||||
time_list.append(temp.que_time)
|
|
||||||
time_list = [float(x) for x in time_list]
|
|
||||||
time_list = radix_sort(time_list)
|
|
||||||
print(time_list)
|
|
||||||
target_time = binary_search(time_list, time.time())
|
|
||||||
questionSelect = "select id, qus_imfomation, " \
|
|
||||||
"qus_A, qus_B, qus_C, qus_D, " \
|
|
||||||
"qus_ans, " \
|
|
||||||
"que_classcode " \
|
|
||||||
"from teacher_client_questionbank " \
|
|
||||||
"where que_time =" + str(target_time)
|
|
||||||
temp_RawQuerySetquestion = questionBank.objects.raw(questionSelect)
|
|
||||||
single_choice = []
|
|
||||||
multiple_choice = []
|
|
||||||
gap_filling = []
|
|
||||||
for temp in temp_RawQuerySetquestion:
|
|
||||||
temp_classcode = temp.que_classcode
|
|
||||||
if temp.qus_ans is None:
|
|
||||||
gap_filling.append(temp)
|
|
||||||
elif len(temp.qus_ans) == 1:
|
|
||||||
single_choice.append(temp)
|
|
||||||
else:
|
|
||||||
multiple_choice.append(temp)
|
|
||||||
|
|
||||||
# testQuestionBank.objects.create(qus_imfomation=temp.qus_imfomation, qus_A=temp.qus_A, qus_B=temp.qus_B,
|
|
||||||
# qus_C=temp.qus_C, qus_D=temp.qus_D, qus_ans=temp.qus_ans,
|
|
||||||
# test_code=TEST_CODE, test_time=test_time)
|
|
||||||
|
|
||||||
total_number = len(gap_filling) + len(multiple_choice) + len(single_choice)
|
|
||||||
total_list = [x + 1 for x in range(total_number)]
|
|
||||||
single_choice_number = len(single_choice)
|
|
||||||
multiple_choice_number = len(multiple_choice)
|
|
||||||
gap_filling_number = len(gap_filling)
|
|
||||||
|
|
||||||
return render(request, "test.html", {"total_num": total_number,
|
|
||||||
"total_list": total_list,
|
|
||||||
"single_choice": single_choice,
|
|
||||||
"multiple_choice": multiple_choice,
|
|
||||||
"gap_filling": gap_filling,
|
|
||||||
"ClassCode": temp_classcode,
|
|
||||||
"TEST_CODE": TEST_CODE,
|
|
||||||
"single_choice_number": single_choice_number,
|
|
||||||
"multiple_choice_number": multiple_choice_number,
|
|
||||||
"gap_filling_number": gap_filling_number
|
|
||||||
})
|
|
||||||
|
|
||||||
# 从前端获取一个考试时间 #
|
|
||||||
test_time = request.POST.get('test_time')
|
|
||||||
#
|
|
||||||
time_list = []
|
|
||||||
time_select = "select id, que_time " \
|
|
||||||
"from teacher_client_questionbank"
|
|
||||||
time_res = questionBank.objects.raw(time_select)
|
|
||||||
|
|
||||||
for temp in time_res:
|
|
||||||
if temp.que_time not in time_list:
|
|
||||||
time_list.append(temp.que_time)
|
|
||||||
time_list = [float(x) for x in time_list]
|
|
||||||
time_list = radix_sort(time_list)
|
|
||||||
print(time_list)
|
|
||||||
target_time = binary_search(time_list, time.time())
|
|
||||||
questionSelect = "select id, qus_imfomation, " \
|
|
||||||
"qus_A, qus_B, qus_C, qus_D, " \
|
|
||||||
"qus_ans, " \
|
|
||||||
"que_classcode " \
|
|
||||||
"from teacher_client_questionbank " \
|
|
||||||
"where que_time =" + str(target_time)
|
|
||||||
temp_RawQuerySetquestion = questionBank.objects.raw(questionSelect)
|
|
||||||
for temp in temp_RawQuerySetquestion:
|
|
||||||
temp_classcode = temp.que_classcode
|
|
||||||
testQuestionBank.objects.create(qus_imfomation=temp.qus_imfomation,qus_A=temp.qus_A, qus_B=temp.qus_B, qus_C=temp.qus_C, qus_D=temp.qus_D,qus_ans=temp.qus_ans,test_code=TEST_CODE, test_time=test_time)
|
|
||||||
return HttpResponse("发布成功")
|
|
||||||
# total_number = len(gap_filling) + len(multiple_choice) + len(single_choice)
|
|
||||||
# total_list = [x+1 for x in range(total_number)]
|
|
||||||
# single_choice_number = len(single_choice)
|
|
||||||
# multiple_choice_number = len(multiple_choice)
|
|
||||||
# gap_filling_number = len(gap_filling)
|
|
||||||
#
|
|
||||||
# return render(request, "test.html", {"total_num": total_number,
|
|
||||||
# "total_list": total_list,
|
|
||||||
# "single_choice": single_choice,
|
|
||||||
# "multiple_choice": multiple_choice,
|
|
||||||
# "gap_filling": gap_filling,
|
|
||||||
# "ClassCode": temp_classcode,
|
|
||||||
# "test_time": test_time,
|
|
||||||
# "single_choice_number": single_choice_number,
|
|
||||||
# "multiple_choice_number": multiple_choice_number,
|
|
||||||
# "gap_filling_number": gap_filling_number
|
|
||||||
# })
|
|
Binary file not shown.
Binary file not shown.
@ -1,16 +1,16 @@
|
|||||||
"""
|
"""
|
||||||
ASGI config for the_online_test_system project.
|
ASGI config for the_online_test_system project.
|
||||||
|
|
||||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
For more information on this file, see
|
For more information on this file, see
|
||||||
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
|
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'the_online_test_system.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'the_online_test_system.settings')
|
||||||
|
|
||||||
application = get_asgi_application()
|
application = get_asgi_application()
|
||||||
|
@ -1,136 +1,134 @@
|
|||||||
"""
|
"""
|
||||||
Django settings for the_online_test_system project.
|
Django settings for the_online_test_system project.
|
||||||
|
|
||||||
Generated by 'django-admin startproject' using Django 3.1.4.
|
Generated by 'django-admin startproject' using Django 3.1.4.
|
||||||
|
|
||||||
For more information on this file, see
|
For more information on this file, see
|
||||||
https://docs.djangoproject.com/en/3.1/topics/settings/
|
https://docs.djangoproject.com/en/3.1/topics/settings/
|
||||||
|
|
||||||
For the full list of settings and their values, see
|
For the full list of settings and their values, see
|
||||||
https://docs.djangoproject.com/en/3.1/ref/settings/
|
https://docs.djangoproject.com/en/3.1/ref/settings/
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = '%_iwhh8=4=smi^)&tzfdu%v9n=elm*0p21dpd-df8pcjift#ve'
|
SECRET_KEY = '%_iwhh8=4=smi^)&tzfdu%v9n=elm*0p21dpd-df8pcjift#ve'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = []
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'login.apps.LoginConfig',
|
'login.apps.LoginConfig',
|
||||||
'teacher_client.apps.TeacherClientConfig',
|
'teacher_client.apps.TeacherClientConfig'
|
||||||
'student_client.apps.StudentClientConfig'
|
]
|
||||||
]
|
|
||||||
|
MIDDLEWARE = [
|
||||||
MIDDLEWARE = [
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
]
|
||||||
# 'teacher_client.middleware.auto.AuthMiddleware',
|
|
||||||
]
|
ROOT_URLCONF = 'the_online_test_system.urls'
|
||||||
|
|
||||||
ROOT_URLCONF = 'the_online_test_system.urls'
|
TEMPLATES = [
|
||||||
|
{
|
||||||
TEMPLATES = [
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
{
|
'DIRS': []
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
,
|
||||||
'DIRS': []
|
'APP_DIRS': True,
|
||||||
,
|
'OPTIONS': {
|
||||||
'APP_DIRS': True,
|
'context_processors': [
|
||||||
'OPTIONS': {
|
'django.template.context_processors.debug',
|
||||||
'context_processors': [
|
'django.template.context_processors.request',
|
||||||
'django.template.context_processors.debug',
|
'django.contrib.auth.context_processors.auth',
|
||||||
'django.template.context_processors.request',
|
'django.contrib.messages.context_processors.messages',
|
||||||
'django.contrib.auth.context_processors.auth',
|
],
|
||||||
'django.contrib.messages.context_processors.messages',
|
},
|
||||||
],
|
},
|
||||||
},
|
]
|
||||||
},
|
|
||||||
]
|
WSGI_APPLICATION = 'the_online_test_system.wsgi.application'
|
||||||
|
|
||||||
WSGI_APPLICATION = 'the_online_test_system.wsgi.application'
|
|
||||||
|
# Database
|
||||||
|
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
||||||
# Database
|
|
||||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
# DATABASES = {
|
||||||
|
# 'default': {
|
||||||
# DATABASES = {
|
# 'ENGINE': 'django.db.backends.sqlite3',
|
||||||
# 'default': {
|
# 'NAME': BASE_DIR / 'db.sqlite3',
|
||||||
# 'ENGINE': 'django.db.backends.sqlite3',
|
# }
|
||||||
# 'NAME': BASE_DIR / 'db.sqlite3',
|
# }
|
||||||
# }
|
|
||||||
# }
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
DATABASES = {
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'default': {
|
'NAME': 'superstar_1', # 数据库的名字
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
'USER': 'root', # MySQL账户名
|
||||||
'NAME': 'superstar_1', # 数据库的名字
|
'PASSWORD': '1234', # MySQL密码
|
||||||
'USER': 'root', # MySQL账户名
|
'HOST': 'localhost', # 哪台机器上的MySQL
|
||||||
'PASSWORD': '1234', # MySQL密码
|
'PORT': 3306, # 端口
|
||||||
'HOST': 'localhost', # 哪台机器上的MySQL
|
}
|
||||||
'PORT': 3306, # 端口
|
}
|
||||||
}
|
|
||||||
}
|
# Password validation
|
||||||
|
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
|
||||||
# Password validation
|
|
||||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
|
{
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||||
{
|
},
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
{
|
||||||
},
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||||
{
|
},
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
{
|
||||||
},
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||||
{
|
},
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
{
|
||||||
},
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||||
{
|
},
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
]
|
||||||
},
|
|
||||||
]
|
|
||||||
|
# Internationalization
|
||||||
|
# https://docs.djangoproject.com/en/3.1/topics/i18n/
|
||||||
# Internationalization
|
|
||||||
# https://docs.djangoproject.com/en/3.1/topics/i18n/
|
LANGUAGE_CODE = 'zh-Hans'
|
||||||
|
|
||||||
LANGUAGE_CODE = 'zh-Hans'
|
TIME_ZONE = 'UTC'
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
USE_I18N = True
|
||||||
|
|
||||||
USE_I18N = True
|
USE_L10N = True
|
||||||
|
|
||||||
USE_L10N = True
|
USE_TZ = True
|
||||||
|
|
||||||
USE_TZ = True
|
|
||||||
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
# https://docs.djangoproject.com/en/3.1/howto/static-files/
|
||||||
# Static files (CSS, JavaScript, Images)
|
|
||||||
# https://docs.djangoproject.com/en/3.1/howto/static-files/
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
|
||||||
|
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
"""the_online_test_system URL Configuration
|
"""the_online_test_system URL Configuration
|
||||||
|
|
||||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||||
https://docs.djangoproject.com/en/3.1/topics/http/urls/
|
https://docs.djangoproject.com/en/3.1/topics/http/urls/
|
||||||
Examples:
|
Examples:
|
||||||
Function views
|
Function views
|
||||||
1. Add an import: from my_app import views
|
1. Add an import: from my_app import views
|
||||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||||
Class-based views
|
Class-based views
|
||||||
1. Add an import: from other_app.views import Home
|
1. Add an import: from other_app.views import Home
|
||||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||||
Including another URLconf
|
Including another URLconf
|
||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from login import views
|
from login import views
|
||||||
import login
|
import login
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# admin后台界面
|
# admin后台界面
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
|
||||||
# 主界面home
|
# 主界面home
|
||||||
path('', views.login),
|
path('', views.login),
|
||||||
|
|
||||||
# 注册界面
|
# 注册界面
|
||||||
path('', include("login.urls")),
|
path('', include("login.urls")),
|
||||||
|
|
||||||
# 教师端口
|
# 教师端口
|
||||||
path('', include("teacher_client.urls")),
|
path('', include("teacher_client.urls")),
|
||||||
]
|
]
|
||||||
|
|
||||||
handler500 = login.views.server_error
|
handler500 = login.views.server_error
|
@ -1,16 +1,16 @@
|
|||||||
"""
|
"""
|
||||||
WSGI config for the_online_test_system project.
|
WSGI config for the_online_test_system project.
|
||||||
|
|
||||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
For more information on this file, see
|
For more information on this file, see
|
||||||
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
|
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'the_online_test_system.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'the_online_test_system.settings')
|
||||||
|
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
||||||
|
Loading…
Reference in new issue