我新加了一个文件

master
张舜尧 3 years ago
parent 54bdbccdaa
commit e8aa21d4c1

@ -1,3 +1,11 @@
from django.contrib import admin from django.contrib import admin
from .models import UserInfo
# Register your models here.
class UserInfoAdmin(admin.ModelAdmin):
list_display = ['identity', 'name', 'id_number', 'phone', 'username', 'password']
list_filter = ['identity']
admin.site.register(UserInfo, UserInfoAdmin)

@ -13,6 +13,16 @@ class UserInfo(models.Model):
username = models.CharField(max_length=32, verbose_name="账号", unique=True, 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) password = models.CharField(max_length=32, verbose_name="密码", blank=False, null=False)
class Meta:
# 表详细备注
verbose_name = '用户列表'
# 设置排序
ordering = ['id']
# 表复数形式
verbose_name_plural = verbose_name

@ -125,7 +125,7 @@ header .header_bar .right_entry {
/* 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;
@ -178,12 +178,14 @@ header .header_bar .right_entry {
.body_right { .body_right {
position: absolute; /*position: absolute;*/
position: fixed;
display: block; display: block;
/* width: 100px; /* width: 100px;
height: 100px; */ height: 100px; */
top: 70px; top: 70px;
right: 0; right: 0;
z-index: 1;
/* 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;

@ -0,0 +1,290 @@
/*body .bgimg img{*/
/* position:absolute;*/
/* width: auto;*/
/* height: auto;*/
/* width: 100%;*/
/* top: 5px;*/
/* height: 100%;*/
/* left:0%;*/
/* top: 0%;*/
/* padding: 0;*/
/* margin:0;*/
/* z-index: 0;*/
/*}*/
body {
font-family: PingFang SC,HarmonyOS_Regular,Helvetica Neue,Microsoft YaHei,sans-serif!important;
font-weight: 400;
overflow-x: auto;
background-color: var(--graph_bg_regular);
}
body {
/* font-size: 14px; */
font-size: 24px;
line-height: 1.6;
/* -webkit-text-size-adjust: 100%; */
-webkit-tap-highlight-color: transparent;
color: #18191c;
background-color: #f6f7f8;
/* min-width: 1100px; */
}
.header-bgimg {
/*font-size: 24px;*/
position: absolute;
width: auto;
width: 100%;
top: 0;
left:0;
z-index: 100;
/* width: 1519.2px; */
width: 1535px;
/* height: 155px; */
height: 120px;
}
header .header_bar {
position: absolute;
top: 0;
left: 0px;
z-index: 1002;
display: flex;
align-items: center;
justify-content: space-between;
/* padding: 0 24px; */
max-width: 2560px;
/* width: 100%; */
width: 1535px;
height: 64px;
}
body ul {
/* 取消小原点 */
list-style-type: none;
font-size: 18px;
}
body ul li {
margin: 15px;
}
header .header_bar .left_entry {
display: flex;
align-items: center;
flex-shrink: 0;
margin-right: 30px;
}
body a {
text-decoration: none;
background-color: transparent;
color: inherit;
}
header span {
color: white;
/* font:14px "PingFang SC",HarmonyOs_re */
}
.header_center {
position: relative;
top: 2px;
background-color: #fff;
width: 400px;
height: 32px;
border-radius: 13px;
}
.header_bar .header_center .reseach {
position: relative;
/* display: inline; */
top: -7px;
/* left: 2px; */
width: 360px;
height: 25px;
line-height: 30px;
border-radius: 13px;
border-width: 0px;
outline:none;
}
/* header .header_bar .right_entry {
position: relative;
left: 100px;
} */
header right_last {
position:absolute;
}
header .header_bar .right_entry {
display: flex;
align-items: center;
flex-shrink: 0;
margin-right: 30px;
}
.right_last button {
/* box-shadow: 5px 5px rgb(109, 247, 71); */
/* blur:5px; */
background:transparent;/*按钮背景透明 */
/* background-color: pink; */
border-radius: 14px;
border-color: greenyellow;
border: width 1px; /*边框透明*/
outline:none; /*点击后没边框*/
font-size: 24px;
border-radius: 22px;
}
.mybody {
position: relative;
/*position: fixed;*/
width: auto;
width: 100%;
left: -8px;
padding: 0px;
margin: 0px;
top: 60px;
/*padding: 10px;*/
/* background: #000; */
}
.body_left{
display: inline-block;
position: relative;
padding: 0px;
margin: 0px;
}
.body_center {
display: inline-block;
position: relative;
/*top: -220px;*/
/* left: 900px; */
/*width: 200px;*/
width: auto;
left: 39%;
top: 20px;
z-index: 1;
/* height: 600px; */
/* background-color: pink; */
}
.body_center ul {
/* position: absolute; */
/* top: -200px;
left: 50px; */
position: relative;
/*width: 190px;*/
/*height: 30px;*/
left: 20px;
top: 10%;
display:inline-block;
}
.body_center ul li{
display: inline-block;
margin: 10px;
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
font-weight: 700;
/* font-style: italic; */
font-size: 50px;
position: center;
}
.body_right {
/*position: absolute;*/
position: fixed;
/* position: relative; */
/* left: 50%; */
/*display: inline-block;*/
display: flex;
z-index: 1;
top: 30%;
left: 38%;
/*top: 30px;*/
/* width: 100px;
height: 100px; */
/*top: 70px;*/
/*right: 50%;*/
/* background-color: #fff;*/
background: rgba(249, 246, 246, 0.3);
font-size: 20px;
/* margin: 20px */
}
.body_right .sign{
width: auto;
}
.body table {
width: auto;
}
.body_right table tr{
margin: 20px;
}
.body_right input {
width: 250px;
height: 23px;
border-color: aqua;
border-radius: 18px;
margin: 20px;
}
.body_right table .sign_ {
/*position:relative;*/
/*width: 60px;*/
/*height: 30px;*/
/*left: 130px;*/
/*background:rgba(0,0,0, 0)*/
position:relative;
width: 220px;
height: 40px;
left: 50px;
/*color: white;*/
/*background:rgba(0,0,0, 0.3);*/
font-size: 24px;
}
.body_right table span {
/* border: red; */
position: relative;
/*background-color:aqua;*/
left: 150px;
width: 100px;
height: 100px;
border-radius: 18px;
}
.body_right table .add .rmb {
position: relative;
left: -3px;
}
.body_right table .add input{
position: relative;
margin: 10px;
width: 15px;
top: -1px;
/*left: -20px;*/
font-size: 16px;
/*color: aliceblue;*/
}
/*.body_right table .add span {*/
/* border-radius: 16px;*/
/* border: 4px;*/
/* border-color: aqua;*/
/* width: 100px;*/
/* height: 100px;*/
/* background-color:#aedab5;*/
/*}*/
.body_right table .add a {
width: 110px;
border-radius: 16px;
margin-left: 100px;
/*background-color:#aedab5;*/
}

@ -0,0 +1,100 @@
/* =============================================================================
HTML5 CSS Reset Minified - Eric Meyer
========================================================================== */
html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,abbr,address,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,var,b,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background: #c49b9b00;}
body{line-height:1}
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}
nav ul{list-style:none}
blockquote,q{quotes:none}
blockquote:before,blockquote:after,q:before,q:after{content:none}
a{margin:0;padding:0;font-size:100%;vertical-align:baseline;background:transparent;text-decoration:none}
mark{background-color:#ff9;color:#000;font-style:italic;font-weight:bold}
del{text-decoration:line-through}
abbr[title],dfn[title]{border-bottom:1px dotted;cursor:help}
table{border-collapse:collapse;border-spacing:0}
hr{display:block;height:1px;border:0;border-top:1px solid #ccc;margin:1em 0;padding:0}
input,select{vertical-align:middle}
li{list-style:none}
/* =============================================================================
My CSS
========================================================================== */
/* ---- base ---- */
html,body{
width:100%;
height:100%;
background:#111;
}
html{
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
body{
font:normal 75% Arial, Helvetica, sans-serif;
}
canvas{
display:block;
/* vertical-align:bottom; */
}
/* ---- stats.js ---- */
.count-particles{
background: #000022;
position: absolute;
top: 48px;
left: 0;
width: 80px;
color: #13E8E9;
font-size: .8em;
text-align: left;
text-indent: 4px;
line-height: 14px;
padding-bottom: 2px;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
}
.js-count-particles{
font-size: 1.1em;
}
#stats,
.count-particles{
/* -webkit-user-select: none; */
margin-top: 5px;
margin-left: 5px;
}
#stats{
border-radius: 3px 3px 0 0;
overflow: hidden;
}
.count-particles{
border-radius: 0 0 3px 3px;
}
/* ---- particles.js container ---- */
#particles-js{
position: fixed;
/* position: absolute; */
z-index: 1;
width: 100%;
height: 100%;
/* 全屏背景颜色 */
background-color: rgb(211, 209, 209);
background-image: url('');
background-size: cover;
background-position: 50% 50%;
background-repeat: no-repeat;
}

@ -1,11 +1,17 @@
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; */
} }
#particles-js {
position: fixed;
left: 0%;
top: 0%;
}
div { div {
position:relative; position:relative;
top: 80px; top: 80px;
@ -13,13 +19,22 @@ div {
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,1);*/
}
.home {
position: fixed;
z-index: 1;
background: rgba(249, 246, 246, 0.3);
top: 0%;
bottom: 0px;
} }
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;
padding-top:35px;
} }
td { td {
position:relative; position:relative;

@ -0,0 +1,131 @@
/* -----------------------------------------------
/* How to use? : Check the GitHub README
/* ----------------------------------------------- */
/* To load a config file (particles.json) you need to host this demo (MAMP/WAMP/local)... */
/*
particlesJS.load('particles-js', 'particles.json', function() {
console.log('particles.js loaded - callback');
});
*/
/* Otherwise just put the config content (json): */
particlesJS('particles-js',
{
"particles": {
"number": {
"value": 80,
"density": {
"enable": true,
"value_area": 250
}
},
"color": {
"value": "#000000"
},
"shape": {
"type": "circle",
"stroke": {
"width": 0,
"color": "#000000"
},
"polygon": {
"nb_sides": 5
},
"image": {
"src": "img/github.svg",
"width": 100,
"height": 100
}
},
"opacity": {
"value": 0.5,
"random": false,
"anim": {
"enable": false,
"speed": 1,
"opacity_min": 0.1,
"sync": false
}
},
"size": {
"value": 5,
"random": true,
"anim": {
"enable": false,
"speed": 40,
"size_min": 0.1,
"sync": false
}
},
"line_linked": {
"enable": true,
"distance": 150,
"color": "#000000",
"opacity": 0.4,
"width": 1
},
"move": {
"enable": true,
"speed": 6,
"direction": "none",
"random": false,
"straight": false,
"out_mode": "out",
"attract": {
"enable": false,
"rotateX": 600,
"rotateY": 1200
}
}
},
"interactivity": {
"detect_on": "canvas",
"events": {
"onhover": {
"enable": true,
"mode": "repulse"
},
"onclick": {
"enable": true,
"mode": "push"
},
"resize": true
},
"modes": {
"grab": {
"distance": 400,
"line_linked": {
"opacity": 1
}
},
"bubble": {
"distance": 400,
"size": 40,
"duration": 2,
"opacity": 8,
"speed": 3
},
"repulse": {
"distance": 200
},
"push": {
"particles_nb": 4
},
"remove": {
"particles_nb": 2
}
}
},
"retina_detect": true,
"config_demo": {
"hide_card": false,
"background_color": "#b61924",
"background_image": "",
"background_position": "50% 50%",
"background_repeat": "no-repeat",
"background_size": "cover"
}
}
);

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -0,0 +1,149 @@
{% load static %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>ll</title>
<meta name="description" content="particles.js is a lightweight JavaScript library for creating particles.">
<meta name="author" content="Vincent Garreau" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="{% static 'css/myhome6.css'%}">
<link rel="stylesheet" media="screen" href="{% static 'css/style6.css' %}">
<script src="{% static 'js/particles.min.js' %}"></script>
{# <script src="https://cdnjs.cloudflare.com/ajax/libs/particlesjs/2.2.2/particles.min.js"></script>#}
</head>
<body>
<!-- particles.js container -->
<div id="particles-js"></div>
<!-- scripts -->
<script src="{% static 'js/particles.js' %}"></script>
<script src="{% static 'js/app2.js' %}"></script>
<!-- stats.js -->
<!-- <script src="js/lib/stats.js"></script> -->
<script>
var count_particles, stats, update;
stats = new Stats;
stats.setMode(0);
stats.domElement.style.position = 'absolute';
stats.domElement.style.left = '0px';
stats.domElement.style.top = '0px';
document.body.appendChild(stats.domElement);
count_particles = document.querySelector('.js-count-particles');
update = function() {
stats.begin();
stats.end();
if (window.pJSDom[0].pJS.particles && window.pJSDom[0].pJS.particles.array) {
count_particles.innerText = window.pJSDom[0].pJS.particles.array.length;
}
requestAnimationFrame(update);
};
requestAnimationFrame(update);
</script>
<!-- 主页开始 -->
<div class="bgimg">
<img src="img/主页1.png" alt="">
</div>
<header>
<!-- <img src="img/bilis.png" alt="" class="header-bgimg"> -->
<div class="header_bar">
<ul class="left_entry">
<li>
<a href="{% url 'login:home' %}">
<img src="{% static 'img/首页1.jpg' %}" alt="首页", width="18px">
<span>首页</span>
</a>
</li>
<li>
<a href="">
<span>
我的
</span>
</a>
</li>
</ul>
<div class="header_center">
<form action="">
<div>
<input type="text" class="reseach">
<a href="">
<img src="{% static 'img/rch.png' %}" alt="搜索" style="position: relative; width: 30px; line-height: 30px; border-radius: 13px; top:3px">
</a>
</div>
</form>
</div>
<ul class="right_entry">
<!-- <li>注册</li> -->
<li class="right_last">
<a href="http://127.0.0.1:8000/admin/" target="_blank">
<button>
<span>后台管理</span>
</button>
</a>
</li>
</ul>
</div>
</header>
<div class="mybody">
<div class="body_center">
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
<div class="body_right">
<form action="{%url 'login:dologin' %}" class="sign" method="post">
{% csrf_token %}
<table>
<tr>
<!-- <td>账号:</td> -->
<td>
账号:&nbsp;&nbsp;<input type="text" name="username" placeholder="账号" value="{{ username }}">
</td>
</tr>
<tr>
<!-- <td>密码:</td> -->
<td>
密码:&nbsp;&nbsp;<input type="password" name="password" {% if error_msg1 %} placeholder="{{ error_msg1 }}" {% endif %} placeholder="密码" placehol value="{{ pwd }}">
</td>
</tr>
<tr>
<td>
验证码:<input type="text" name="check_code" {% if error_msg %} placeholder="{{ error_msg }}" {% endif %} placeholder="请输入验证码" style="width: 150px;margin: 0px;">
<img src="{% url 'login:captcha_img' %}" onclick="changeCheckCode(this);" style="height:30px; position:relative ;top:5px">
</td>
</tr>
<tr class="add">
<td>
{# <lable><input class="rember" type="radio" name="rember" {% if username %}checked{%endif%}/> 记住密码<lable>#}
<span class="rmb">
<input type="checkbox" name="rember" value="rember" {% if username %}checked{%endif%}/>记住密码
</span>
<a href="http://127.0.0.1:8000/register/" target="_blank">注册
<span class="zc"></span>
</a>
</td>
</tr>
<tr>
<td>
<input class="sign_" type="submit" value="登录">
</td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>

@ -110,14 +110,7 @@
<td> <td>
密码:&nbsp;&nbsp;<input type="password" name="password" {% if error_msg1 %} placeholder="{{ error_msg1 }}" {% endif %} placeholder="密码" placehol value="{{ pwd }}"> 密码:&nbsp;&nbsp;<input type="password" name="password" {% if error_msg1 %} placeholder="{{ error_msg1 }}" {% endif %} placeholder="密码" placehol value="{{ pwd }}">
</td> </td>
{# <span style="color: red;font-size: 10px">{% if error_msg %}{{ error_msg }}{% endif %}</span>#}
</tr> </tr>
{# <tr class="Error">#}
{# <td>#}
{# #}
{# </td>#}
{# </tr>#}
<tr> <tr>
<td> <td>
验证码:<input type="text" name="check_code" {% if error_msg %} placeholder="{{ error_msg }}" {% endif %} placeholder="请输入验证码" style="width: 150px;margin: 0px;"> 验证码:<input type="text" name="check_code" {% if error_msg %} placeholder="{{ error_msg }}" {% endif %} placeholder="请输入验证码" style="width: 150px;margin: 0px;">

@ -8,24 +8,43 @@
<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' %}">
<link rel="stylesheet" media="screen" href="{% static 'css/style6.css' %}">
<script src="{% static 'js/particles.min.js' %}"></script>
</head> </head>
<body> <body>
<div id="particles-js"></div>
<!-- scripts -->
<script src="{% static 'js/particles.js' %}"></script>
<script src="{% static 'js/app2.js' %}"></script>
<!-- stats.js -->
<!-- <script src="js/lib/stats.js"></script> -->
<script>
var count_particles, stats, update;
stats = new Stats;
stats.setMode(0);
stats.domElement.style.position = 'absolute';
stats.domElement.style.left = '0px';
stats.domElement.style.top = '0px';
document.body.appendChild(stats.domElement);
count_particles = document.querySelector('.js-count-particles');
update = function() {
stats.begin();
stats.end();
if (window.pJSDom[0].pJS.particles && window.pJSDom[0].pJS.particles.array) {
count_particles.innerText = window.pJSDom[0].pJS.particles.array.length;
}
requestAnimationFrame(update);
};
requestAnimationFrame(update);
</script>
<form method="post"> <form method="post">
{%csrf_token%} {%csrf_token%}
<div> <div class="home">
<h4>启航题库</h4> <h4>灯塔测试</h4>
<table width="500"> <table width="500">
<!-- 第一行 -->
<!-- <tr>
<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/women.jpg" width="25" >学生</label>
</td>
</tr> -->
<!-- 第二行 -->
<tr> <tr>
<td> <td>
<select name="identity" required="required"> <select name="identity" required="required">
@ -82,7 +101,7 @@
<!-- 第十行 --> <!-- 第十行 -->
<tr> <tr>
<td > <td >
<a href="#"> 我是会员,立即登录</a> <a href="{% url 'login:home' %}"> 我是会员,立即登录</a>
</td> </td>
</tr> </tr>
</table> </table>

@ -9,6 +9,8 @@ urlpatterns = [
path('register/', views.register), path('register/', views.register),
path('home/', views.home, name='home'),
path('login/', views.login, name='login'), path('login/', views.login, name='login'),
path('dologin/', views.dologin, name='dologin'), path('dologin/', views.dologin, name='dologin'),

@ -8,7 +8,7 @@ from login.common import captcha
def home(request): def home(request):
return render(request, 'home.html') return render(request, 'laba.html')
def register(request): def register(request):
@ -48,37 +48,14 @@ def server_error(request):
return HttpResponse("") return HttpResponse("")
# def login00(request):
#
# if request.method == 'GET':
# return render(request, 'login.html')
#
# error_msg = ""
# user = request.POST.get('email')
# pwd = request.POST.get('password')
#
# temp_RawQuerySet = UserInfo.objects.raw('select * from app02_userfo')
#
# for temp in temp_RawQuerySet:
# if temp.username == user and temp.password == pwd:
# if temp.identity == '老师':
# return redirect('http://www.baidu.com')
# else:
# return redirect('http://www.baidu.com')
# else:
# # 用户密码不匹配
# 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, 'laba.html', {'username': username, 'pwd': password})
else: else:
return render(request, 'login.html') return render(request, 'laba.html')
def dologin(request): def dologin(request):
@ -93,9 +70,8 @@ def dologin(request):
password = request.POST.get('password') password = request.POST.get('password')
rember = request.POST.get('rember') rember = request.POST.get('rember')
response = HttpResponse() response = HttpResponse()
selectStr = "select * from login_userinfo"
temp_RawQuerySet = UserInfo.objects.raw('select * from login_userinfo') temp_RawQuerySet = UserInfo.objects.raw(selectStr)
for temp in temp_RawQuerySet: for temp in temp_RawQuerySet:
if temp.username == username and temp.password == password: if temp.username == username and temp.password == password:
# ## 存入基本信息到session ## # # ## 存入基本信息到session ## #
@ -103,6 +79,7 @@ def dologin(request):
request.session['password'] = password request.session['password'] = password
request.session['id_number'] = temp.id_number request.session['id_number'] = temp.id_number
request.session['name'] = temp.name request.session['name'] = temp.name
request.session['phone'] = temp.phone
if rember == 'rember': if rember == 'rember':
# 勾选了记住用户名和密码 # 勾选了记住用户名和密码
# 将用户名和密码保存到cookie中 # 将用户名和密码保存到cookie中
@ -123,10 +100,10 @@ def dologin(request):
response.delete_cookie('username') response.delete_cookie('username')
response.delete_cookie('pwd') response.delete_cookie('pwd')
error_msg = '用户名或密码错误' error_msg = '用户名或密码错误'
return render(request, 'login.html', {'error_msg1': error_msg}) return render(request, 'laba.html', {'error_msg1': error_msg})
else: else:
error_msg = '验证码错误' error_msg = '验证码错误'
return render(request, 'login.html', {'error_msg': error_msg}) return render(request, 'laba.html', {'error_msg': error_msg})
def logout(request): def logout(request):

@ -0,0 +1,30 @@
N = 13
DAY = 13
NOW_DAY = 0
COUNTER = 0
TEAM = ["A", "B", "C", "D", "E",
"F", "G", "H", "I", "J",
"K", "L"]
NO_CONTEST = []
DAILY_SCHEDULE = []
def NContest(N):
"""判断哪个队伍不需要比赛"""
global COUNTER
NO_CONTEST.append(TEAM[COUNTER])
if COUNTER+1 == N:
return False
else:
COUNTER += 1
def arrangement(N):
"""比赛安排"""
NContest(N)
NO_CONTEST[::-1]
if __name__ == '__main__':
a = [1, 2, 3, 4]
print(a[::-1])

@ -0,0 +1,37 @@
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]

@ -0,0 +1,50 @@
button {
position: relative;
position: absolute;
bottom: -30px;
padding: 20px;
width: 250px;
height: 35px;
padding: 1.3em 3em;
font-size: 17px;
font-weight: bold;
letter-spacing: 10px;
/* vertical-align:middle;
text-align: center; */
line-height: 35px;
/* font-weight: bold; */
/* text-transform: uppercase; */
letter-spacing: 2.5px;
font-weight: 4px;
color: #000;
background-color: #fff;
border: none;
/* border-bottom-width: 1px; */
border-style: solid;
border-width: 1px;
border-radius: 45px;
box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease 0s;
cursor: pointer;
outline: none;
}
button:hover {
background-color: #2EE59D;
box-shadow: 0px 15px 20px rgba(46, 229, 157, 0.4);
color: #fff;
transform: translateY(-7px);
}
button:active {
transform: translateY(-1px);
}
button span {
position: relative;
top: -25px;
height: 35px;
line-height: 50px;
}
.but {
height: 30px;
}

@ -0,0 +1,35 @@
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}*/

@ -0,0 +1,166 @@
*{
margin: 0px;
padding: 0px;
}
body {
/* 全局字体大小 */
font-size: 18px;
}
.head {
position: fixed;
width: 100%;
z-index: 100;
}
.page {
display: inline-block;
/*position: fixed;*/
display: block;
position: fixed;
width: 340px;
left: 8px;
top: 10%;
/* 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;
}
.target-fix {
position: relative;
top: -80px;
display: block;
height: 0;
/*overflow: hidden;*/
}
.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(241, 221, 221);
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; */
top: 80px;
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: 400px;
border-style: solid;
border-color: white;
border-bottom-color:black ;
/* 点击后无边框 */
outline:none;
font-size: 15px;
}
/* .write:hover{
border-style: solid;
border-color: white;
border-bottom-color:black ;
} */
.count-time {
position: fixed;
display:flex;
top: 10px;
width: 300px;
/* left: 1000px; */
}
.count-time .time1 {
position: fixed;
display:flex;
top: 30px;
line-height:atou;
left: 1220px;
/* left: 20px; */
z-index: 1px;
background-color: rgba(251,251,251,0);
}
.count-time .imga {
display: flex;
position: fixed;
/* background-image: url(./img/旋转_橙.gif); */
width: 300px;
left: 1200px;
object-fit: cover;
/* background-color:rgba(red, , , alpha); */
}
.count-time .imga:hover {
content: url(../img/_2.gif);
}

@ -0,0 +1,171 @@
*{
margin: 0px;
padding: 0px;
}
body {
/* 全局字体大小 */
font-size: 18px;
/*top: 50px;*/
}
.head {
position: fixed;
width: 100%;
z-index: 100;
}
.page {
display: inline-block;
/*position: fixed;*/
display: block;
position: fixed;
width: 340px;
left: 8px;
top: 10%;
/* 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;
}
.target-fix {
position: relative;
top: -80px;
display: block;
height: 0;
/*overflow: hidden;*/
}
.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(241,241,241);*/
/*rgb(246, 224, 224)*/
background-color:rgb(241,241,241);
border-style: solid;
border-width: 1px;
border-color: aquamarine;
color: black;
}
.page a:hover {
/* 鼠标移动到时的改变颜色 */
background-color: gray;
/*#5096f5*/
}
.line {
display: inline-block;
position: relative;
top: 10%;
position: fixed;
left: 368px;
width: 6px;
height: 600px;
border-radius: 6px;
background-color:rgb(129, 122, 122);
}
.test {
display: inline-block;
position: relative;
/*position: absolute;*/
top: 80px;
/* position: fixed; */
left: 408px;
height: auto;
}
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: 16px;
}
/* .write:hover{
border-style: solid;
border-color: white;
border-bottom-color:black ;
} */
.count-time {
position: fixed;
display:flex;
top: 7%;
width: 300px;
/* left: 1000px; */
}
.count-time .time1 {
position: fixed;
display:flex;
top: 10.3%;
line-height: atou;
left: 1220px;
/* left: 20px; */
z-index: 1px;
background-color: rgba(251,251,251,0);
}
.count-time .imga {
display: flex;
position: fixed;
/* background-image: url(./img/旋转_橙.gif); */
width: 300px;
left: 1200px;
object-fit: cover;
/* background-color:rgba(red, , , alpha); */
}
.count-time .imga:hover {
content: url(../img/_2.gif);
}

@ -0,0 +1,24 @@
*{
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; */
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 KiB

@ -25,6 +25,33 @@
<script src="https://fastly.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script> <script src="https://fastly.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script> <script src="https://fastly.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]--> <![endif]-->
<script type="text/javascript">
function disp_alert()
{
var code = {{ code|safe }};
var a=$("#a").val()
for(var i = 0;i<code.length;i++){
if (code[i] == a){
alert("加入课堂成功!");
return 0;
}
}
alert("加入失败!(课堂不存在或已经加入)");
}
</script>
<script type="text/javascript">
function disp_alert1()
{
var ttcode = {{ test_code|safe }};
var b=$("#b").val()
for(var i = 0;i<ttcode.length;i++){
if (ttcode[i] == b){
return 0;
}
}
alert("该测试不存在!");
}
</script>
</head> </head>
<body> <body>
<nav class="navbar navbar-default"> <nav class="navbar navbar-default">
@ -44,30 +71,35 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
{# <li><a>#}
{# <button type="button" onclick="F_Open_dialog()" style="border: 0px; background-color: rgba(0,0,0,0); font-size: 14px;">#}
{# <input type="file" id="btn_file" style="display:none">上传题目#}
{# </button >#}
{# </a></li>#}
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">上传文件<span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">加入测试<span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li> <li>
<form method="post" enctype="multipart/form-data" action="{% url 'teacher_client:file_muti' %}"> <form method="post" enctype="multipart/form-data" action="{% url 'student_client:test_join' %}">
{% csrf_token %} {% csrf_token %}
<div class="form-group"> <div class="form-group">
<input type="file" name="exc"> <input type="text" id="b" name="testcode" placeholder="输入测试号">
</div> </div>
<input type="submit" value="上传" class="btn btn-info btn-sm"> <input type="submit" value="确定" class="btn btn-info btn-sm" onclick="disp_alert1()">
</form> </form>
</li> </li>
</ul> </ul>
</li> </li>
<li><a href="{% url 'teacher_client:classSet' %}">我的课堂</a></li>
<li><a href="{% url 'teacher_client:test_release' %}">发布测试</a></li>
<li><a href="#">测试情况</a></li> <li><a href="#">测试情况</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">加入课堂<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<form method="post" enctype="multipart/form-data" action="{% url 'student_client:join_class' %}">
{% csrf_token %}
<div class="form-group">
<input type="text" id="a" name="Ccode" placeholder="输入加课码">
</div>
<input type="submit" value="确定" class="btn btn-info btn-sm" onclick="disp_alert()">
</form>
</li>
</ul>
</li>
</ul> </ul>
@ -84,12 +116,12 @@
</div> </div>
</nav> </nav>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery所以必须放在前边) --> <!-- jQuery -->
<script src="https://fastly.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script> <script src="https://fastly.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 --> <!-- 加载 Bootstrap 的所有 JavaScript 插件。 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
<div class="img"> <div class="img">
<img src="img/头哥.png" alt="灯塔测试" title="灯塔测试" style="position: relative; top: -10px;"> <img src="{% static 'img/头哥.png' %}" alt="灯塔测试" title="灯塔测试" style="position: relative; top: -10px;">
</div> </div>

@ -0,0 +1,237 @@
{% 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/stud3.css' %}">
<link rel="stylesheet" href="{% static 'css/button.css' %}">
<script type="text/javascript">
function F_Open_dialog()
{document.getElementById("btn_file").click();}
</script>
<script type="text/javascript">
</script>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'css/teacher.css' %}">
<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询media queries功能 -->
<!-- 警告:通过 file:// 协议(就是直接将 html 页面拖拽到浏览器中)访问页面时 Respond.js 不起作用 -->
<!--[if lt IE 9]>
<script src="https://fastly.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
function disp_alert()
{
var right = {{ right_num|safe }};
var wrong = {{ wrong_num|safe}}
alert("提交成功")
alert("正确题数:"+right+'\n'+'错误题数: '+wrong);
}
</script>
</head>
<body>
{##}
<div class="head">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar">434534534354</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{% url 'student_client:student_client' %}">灯塔</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">加入测试<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<form method="post" enctype="multipart/form-data" action="{% url 'student_client:test_join' %}">
{% csrf_token %}
<div class="form-group">
<input type="text" name="testcode" placeholder="输入测试号">
</div>
<input type="submit" value="确定" class="btn btn-info btn-sm">
</form>
</li>
</ul>
</li>
<li><a href="#">测试情况</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">加入课堂<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<div class="form-group">
<input type="text" name="Ccode" placeholder="输入加课码">
</div>
<input type="submit" value="确定" class="btn btn-info btn-sm">
</form>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">欢迎, {{ username }}<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{% url 'login:logout' %}">退出登录</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery所以必须放在前边) -->
<script src="https://fastly.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</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>
</div>
<div class="line"></div>
</div>
<div class="test">
<form id="frm" method="post">
{% csrf_token %}
<table >
<!-- 单选 -->
{# {% for student in student_page.object_list %} #}
{% if single_choice %}
一、单选<br><br>
{% for single in single_choice %}
<a id="0{{ forloop.counter }}" class="target-fix"></a>
<ul >
<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 %}
<a id="0{{ forloop.counter }}" class="target-fix"></a>
<ul >
<li class="ques" ><label>{{ forloop.counter }}、(多选){{ multiple.qus_imfomation }}</label></li>
<li><label><input type="checkbox" name="chooseA{{ forloop.counter }}" value="A">{{ multiple.qus_A }}</label></li>
<li><label><input type="checkbox" name="chooseA{{ forloop.counter }}" value="B">{{ multiple.qus_B }}</label></li>
<li><label><input type="checkbox" name="chooseA{{ forloop.counter }}" value="C">{{ multiple.qus_C }}</label></li>
<li><label><input type="checkbox" name="chooseA{{ 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%}
<a id="0{{ forloop.counter }}" class="target-fix"></a>
<ul>
<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="chooseB{{ forloop.counter }}" placeholder="在此处作答,多个答案请用分号隔开"></label></li>
</ul>
<br>
{% endfor %}
{% endif %}
</table>
{% if now_time %}
<div class="count-time">
<a href="#" class="imga"><img class="imga" src="{% static 'img/旋转_2.gif' %}" alt=""></a>
<div class="time1">考试还剩余:<div id="time" style="background-color: rgba(251,251,251,0)"></div></div>
</div>
{% endif %}
{# <input type="submit" value="提交试卷">#}
{# <button class="submit" type="submit">提交</button>#}
<div class="but">
<button class="" type="submit" onclick="disp_alert()" ><span>&nbsp交</span></button>
</div>
<script>
var times = {{ now_time|safe}};
var timeDiv = document.getElementById("time");
var timeObj = null;
var tim = 99
function timer(){
if(tim < 1){
//倒计时结束,提交表单
document.getElementById("frm").submit();
window.clearInterval(timeObj);
return;
}
var date = new Date();
var now = date.getTime();//转化成毫秒
tim = times- now/1000;
var t = Math.floor(tim/60) +"分"+Math.floor(tim%60)+"秒";
temp = Math.floor(tim%60)
timeDiv.innerHTML = t;
{#w --;#}
}
timeObj = window.setInterval(timer,1000);
</script>
</form>
</div>
</div>
</body>
</html>

@ -0,0 +1,213 @@
{% 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/stud3.css' %}">
<link rel="stylesheet" href="{% static 'css/button.css' %}">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<script type="text/javascript">
var right = {{ right_num|safe }};
var wrong = {{ wrong_num|safe}}
alert("提交成功")
alert("正确题数:"+right+'\n'+'错误题数: '+wrong);
</script>
</head>
<body>
<div class="head">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar">434534534354</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{% url 'student_client:student_client' %}">灯塔</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">加入测试<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<form method="post" enctype="multipart/form-data" action="{% url 'student_client:test_join' %}">
{% csrf_token %}
<div class="form-group">
<input type="text" name="testcode" placeholder="输入测试号">
</div>
<input type="submit" value="确定" class="btn btn-info btn-sm">
</form>
</li>
</ul>
</li>
<li><a href="#">测试情况</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">加入课堂<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<div class="form-group">
<input type="text" name="Ccode" placeholder="输入加课码">
</div>
<input type="submit" value="确定" class="btn btn-info btn-sm">
</form>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">欢迎, {{ username }}<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{% url 'login:logout' %}">退出登录</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery所以必须放在前边) -->
<script src="https://fastly.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</div>
<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>
</div>
<div class="line"></div>
</div>
<div class="test">
<form id="frm" method="post">
{% csrf_token %}
<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="chooseA{{ forloop.counter }}" value="A">{{ multiple.qus_A }}</label></li>
<li><label><input type="checkbox" name="chooseA{{ forloop.counter }}" value="B">{{ multiple.qus_B }}</label></li>
<li><label><input type="checkbox" name="chooseA{{ forloop.counter }}" value="C">{{ multiple.qus_C }}</label></li>
<li><label><input type="checkbox" name="chooseA{{ 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="chooseB{{ forloop.counter }}" placeholder="在此处作答,多个答案请用分号隔开"></label></li>
</ul>
<br>
{% endfor %}
{% endif %}
</table>
{% if now_time %}
<div class="count-time">
<a href="#" class="imga"><img class="imga" src="{% static 'img/旋转_2.gif' %}" alt=""></a>
<div class="time1">考试还剩余:<div id="time" style="background-color: rgba(251,251,251,0)"></div></div>
</div>
{% endif %}
<button class="" type="submit" onclick="disp_alert()" >提交</button>
<script>
var times = {{ now_time|safe}};
var timeDiv = document.getElementById("time");
var timeObj = null;
var tim = 99
function timer(){
if(tim < 1){
//倒计时结束,提交表单
document.getElementById("frm").submit();
window.clearInterval(timeObj);
return;
}
var date = new Date();
var now = date.getTime();//转化成毫秒
tim = times- now/1000;
var t = Math.floor(tim/60) +"分"+Math.floor(tim%60)+"秒";
temp = Math.floor(tim%60)
timeDiv.innerHTML = t;
{#w --;#}
}
timeObj = window.setInterval(timer,1000);
</script>
</form>
</div>
</div>
</body>
</html>

@ -6,6 +6,15 @@ app_name = 'student_client'
urlpatterns = [ urlpatterns = [
path("student_client/", views.student_client, name = "student_client") path('admin/', admin.site.urls),
path("student_client/", views.student_client, name="student_client"),
path("join_class/", views.join_class, name="join_class"),
path("test_join/", views.test_join, name="test_join"),
path("test_client/", views.test_client, name="test_client"),
path("panti/", views.panti, name="panti"),
] ]

@ -1,7 +1,266 @@
from django.shortcuts import render from django.shortcuts import render, redirect, HttpResponse
from .common import Ssearch
from teacher_client import models
import time
total_number = 0 # 总题目数
ans = []
single_choice_number = 0 # 单选题题目数
multiple_choice_number = 0 # 多选题题目数
gap_filling_number = 0 # 填空题题目数
single_choice_ans = [] # 单选题标准答案
multiple_choice_ans = [] # 多选题标准答案
gap_filling_ans = [] # 填空题标准答案
right_num = 0 # 正确的题目数量
wrong_num = 0 # 错误的题目数量
single_choice = [] # 单选题
multiple_choice = [] # 多选题
gap_filling = [] # 填空题
time_flag = 0
now_time = 0
test_time = 0 # 考试时间
single_choiceT = []
multiple_choiceT = []
gap_fillingT = []
def student_client(request): def student_client(request):
"""学生端口""" """学生端口"""
if request.method == "GET": if request.method == "GET":
return render(request, "student_client.html") username = request.session.get('username')
password = request.session.get('password')
if username and password:
StudentID = request.session.get('id_number')
StudentName = request.session.get('classcode')
code = []
Ccode = models.questionBank.objects.raw("select id, classcode from teacher_client_teacherclass")
for temp in Ccode:
code.append(temp.classcode)
selectTcode = "select id, test_code from teacher_client_testquestionbank"
temp_RawQuerySetT = models.teacherClass.objects.raw(selectTcode)
ttcode = []
for temp in temp_RawQuerySetT:
ttcode.append(temp.test_code)
return render(request, "student_client.html", {"username": username, "code": code, "test_code": ttcode})
else:
return redirect("http://127.0.0.1:8000/")
def join_class(request):
Ccode = request.POST.get("Ccode")
selectCcode = "select id, classcode from teacher_client_teacherclass where classcode = " + '\"'+ Ccode + '\"'
temp_RawQuerySetC = models.teacherClass.objects.raw(selectCcode)
if temp_RawQuerySetC:
flag = True
StudentID = request.session.get('id_number')
StudentPhone = request.session.get('phone')
name = request.session.get('name')
username = request.session.get('username')
models.classTable.objects.create(name=name, id_number=StudentID, phone=StudentPhone, classCode=Ccode)
return render(request, "student_client.html", {"username": username, "flag": flag})
else:
username = request.session.get('username')
flag = False
return render(request, "student_client.html", {"username": username, "flag": flag})
def test_join(request):
"""加入测试"""
if request.method == "GET":
username = request.session.get('username')
password = request.session.get('password')
if username and password:
StudentID= request.session.get('id_number')
StudentName = request.session.get('classcode')
else:
return redirect("http://127.0.0.1:8000/")
test_code = request.POST.get("testcode")
selectTcode = "select id, test_code from teacher_client_testquestionbank"
temp_RawQuerySetT = models.teacherClass.objects.raw(selectTcode)
ttcode = []
for temp in temp_RawQuerySetT:
ttcode.append(temp.test_code)
if test_code in ttcode:
request.session['test_code'] = test_code
return redirect("student_client:test_client")
else:
username = request.session.get('username')
return render(request, "student_client.html", {"username": username})
def test_client(request):
"""考试页面"""
if request.method == "GET":
test_code = request.session.get("test_code")
questionSelect = "select id, qus_imfomation, " \
"qus_A, qus_B, qus_C, qus_D, " \
"qus_ans," \
"test_time " \
"from teacher_client_testquestionbank " \
"where test_code = " + str(test_code)
temp_RawQuerySetquestion = models.questionBank.objects.raw(questionSelect)
global ans, single_choice_ans, multiple_choice_ans, gap_filling_ans
global single_choice, multiple_choice, gap_filling, test_time
global single_choiceT, multiple_choiceT, gap_fillingT
single_choiceT = []
multiple_choiceT = []
gap_fillingT = []
for temp in temp_RawQuerySetquestion:
temp_testtime = temp.test_time
test_time = temp_testtime
if temp.qus_ans is None:
gap_filling.append(temp)
gap_fillingT.append(temp)
gap_filling_ans.append(temp.qus_A)
elif len(temp.qus_ans) == 1:
single_choice.append(temp)
single_choiceT.append(temp)
single_choice_ans.append(temp.qus_ans)
else:
multiple_choice.append(temp)
multiple_choiceT.append(temp)
multiple_choice_ans.append(temp.qus_ans)
global total_number, single_choice_number, multiple_choice_number, gap_filling_number
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)
global time_flag, now_time
if ":" in test_time:
ttime = test_time.split(":")
else:
ttime = test_time.split("")
hour = int(ttime[0])
min = int(ttime[1])
second = hour * 60 * 60 + min * 60
if time_flag == 0:
now_time = time.time() + second
time_flag = 1
username = request.session.get("username")
return render(request, "test1.html", {"total_num": total_number,
"total_list": total_list,
"single_choice": single_choiceT,
"multiple_choice": multiple_choiceT,
"gap_filling": gap_fillingT,
"test_time": temp_testtime,
'now_time': now_time,
"single_choice_number": single_choice_number,
"multiple_choice_number": multiple_choice_number,
"gap_filling_number": gap_filling_number,
"username": username
})
else:
single_choice_answer = [] # 用户输入的单选题答案
multiple_choice_answer = [] # 用户输入的多选题答案
gap_filling_answer = [] # 用户输入的填空题答案
for temp in range(total_number):
pass
# 获取前端传递的单选题答案
for temp in range(1, single_choice_number + 1):
single_str = "choose" + str(temp)
temp_single_choice_answer = request.POST.get(single_str)
single_choice_answer.append(temp_single_choice_answer)
# 获取前端传递的多选题答案
for temp in range(1, multiple_choice_number + 1):
multiple_str = "chooseA" + str(temp)
temp_multiple_choice_answer = request.POST.getlist(multiple_str)
multiple_choice_answer.append(temp_multiple_choice_answer)
# 获取前端传递的填空题答案
for temp in range(1, gap_filling_number + 1):
gap_filling_str = "chooseB" + str(temp)
temp_gap_filling_answer = request.POST.getlist(gap_filling_str)
gap_filling_answer.append(temp_gap_filling_answer)
# 开始判题
global wrong_num, right_num
wrong_num = 0
right_num = 0 # 初始化
# 判断单选题 ans:标准答案 answer:用户答案
for ans, answer in zip(single_choice_ans, single_choice_answer):
if answer == ans:
right_num += 1
else:
wrong_num += 1
# 判断多选题 ans:标准答案 answer:用户答案
for ans, answer in zip(multiple_choice_ans, multiple_choice_answer):
answer_str = ""
for temp_answer in answer:
answer_str += temp_answer
if answer_str == ans:
right_num += 1
else:
wrong_num += 1
# 判断填空题 ans:标准答案 answer:用户答案
for ans, answer in zip(gap_filling_ans, gap_filling_answer):
ans_str = ans.split(";")
print("ans_str", ans_str)
print("用户答案", answer)
if answer[0] in ans_str:
right_num += 1
else:
wrong_num += 1
username = request.session.get("username")
return render(request, "test2.html", {"single_choice": single_choiceT,
"multiple_choice": multiple_choiceT,
"gap_filling": gap_fillingT,
"right_num": right_num,
"wrong_num": wrong_num,
"username": username,
})
def panti(request):
single_choice_answer = [] # 用户输入的单选题答案
multiple_choice_answer = [] # 用户输入的多选题答案
gap_filling_answer = [] # 用户输入的填空题答案
for temp in range(total_number):
pass
# 获取前端传递的单选题答案
for temp in range(1, single_choice_number+1):
single_str = "choose" + str(temp)
temp_single_choice_answer = request.POST.get(single_str)
single_choice_answer.append(temp_single_choice_answer)
# 获取前端传递的多选题答案
for temp in range(1, multiple_choice_number+1):
multiple_str = "chooseA" + str(temp)
temp_multiple_choice_answer = request.POST.getlist(multiple_str)
multiple_choice_answer.append(temp_multiple_choice_answer)
# 获取前端传递的填空题答案
for temp in range(1, gap_filling_number+1):
gap_filling_str = "chooseB" + str(temp)
temp_gap_filling_answer = request.POST.getlist(gap_filling_str)
gap_filling_answer.append(temp_gap_filling_answer)
# 开始判题
global wrong_num, right_num
wrong_num = 0
right_num = 0 # 初始化
# 判断单选题 ans:标准答案 answer:用户答案
for ans, answer in zip(single_choice_ans, single_choice_answer):
if answer == ans:
right_num += 1
else:
wrong_num += 1
# 判断多选题 ans:标准答案 answer:用户答案
for ans, answer in zip(multiple_choice_ans, multiple_choice_answer):
answer_str = ""
for temp_answer in answer:
answer_str += temp_answer
if answer_str == ans:
right_num += 1
else:
wrong_num += 1
# 判断填空题 ans:标准答案 answer:用户答案
for ans, answer in zip(gap_filling_ans, gap_filling_answer):
ans_str = ans.split(";")
print("ans_str", ans_str)
print("用户答案", answer)
if answer[0] in ans_str:
right_num += 1
else:
wrong_num += 1

@ -1,3 +1,31 @@
from django.contrib import admin from django.contrib import admin
from .models import classTable, teacherClass, questionBank, testQuestionBank
# Register your models here.
class classTableAdmin(admin.ModelAdmin):
list_display = ['name', 'id_number', 'phone', 'classCode']
list_filter = ['classCode']
class teacherClassAdmin(admin.ModelAdmin):
list_display = ['name', 'id_number', 'classCode', 'classname']
list_filter = ['name']
class questionBankAdmin(admin.ModelAdmin):
list_display = ['qus_imfomation', 'qus_A', 'qus_D', 'qus_C', 'qus_D', 'qus_ans', 'que_classcode', 'que_time']
class testQuestionBankAdmin(admin.ModelAdmin):
list_display = ['qus_imfomation', 'qus_A', 'qus_D', 'qus_C', 'qus_D', 'qus_ans', 'test_code', 'test_time']
admin.site.register(classTable, classTableAdmin)
admin.site.register(teacherClass, teacherClassAdmin)
admin.site.register(questionBank, questionBankAdmin)
admin.site.register(testQuestionBank, testQuestionBankAdmin)

@ -1,10 +1,6 @@
from django.db import models from django.db import models
# class questionBank(models.Model):
# """用于存储题目数据"""
class teacherClass(models.Model): class teacherClass(models.Model):
"""记录班级加课码""" """记录班级加课码"""
name = models.CharField(max_length=32, verbose_name="姓名", blank=False, null=False) name = models.CharField(max_length=32, verbose_name="姓名", blank=False, null=False)
@ -12,6 +8,16 @@ class teacherClass(models.Model):
classCode = models.CharField(max_length=20, verbose_name="加课码", default='') classCode = models.CharField(max_length=20, verbose_name="加课码", default='')
classname = models.CharField(max_length=20, verbose_name="课程名", default='') classname = models.CharField(max_length=20, verbose_name="课程名", default='')
class Meta:
# 表详细备注
verbose_name = '教师班级'
# 设置排序
ordering = ['id']
# 表复数形式
verbose_name_plural = verbose_name
class classTable(models.Model): class classTable(models.Model):
"""班级表""" """班级表"""
@ -21,6 +27,17 @@ class classTable(models.Model):
classCode = models.CharField(max_length=6, verbose_name="加课码", default='') classCode = models.CharField(max_length=6, verbose_name="加课码", default='')
class Meta:
# 表详细备注
verbose_name = '班级表'
# 设置排序
ordering = ['id']
# 表复数形式
verbose_name_plural = verbose_name
class questionBank(models.Model): class questionBank(models.Model):
"""用于保存用户上传提交的题目""" """用于保存用户上传提交的题目"""
qus_imfomation = models.CharField(max_length=1000, verbose_name="题目信息", blank=False, null=False) qus_imfomation = models.CharField(max_length=1000, verbose_name="题目信息", blank=False, null=False)
@ -32,6 +49,16 @@ class questionBank(models.Model):
que_classcode = 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="") que_time = models.CharField(max_length=200, verbose_name="存入时间", default="")
class Meta:
# 表详细备注
verbose_name = '题库'
# 设置排序
ordering = ['id']
# 表复数形式
verbose_name_plural = verbose_name
class testQuestionBank(models.Model): class testQuestionBank(models.Model):
"""考试信息表""" """考试信息表"""
@ -43,3 +70,13 @@ class testQuestionBank(models.Model):
qus_ans = models.CharField(max_length=1000, verbose_name="答案") qus_ans = models.CharField(max_length=1000, verbose_name="答案")
test_code = models.CharField(max_length=1000, verbose_name="所属班级", blank=False, null=False) test_code = models.CharField(max_length=1000, verbose_name="所属班级", blank=False, null=False)
test_time = models.CharField(max_length=200, verbose_name="考试时间", default='') test_time = models.CharField(max_length=200, verbose_name="考试时间", default='')
class Meta:
# 表详细备注
verbose_name = '测试详细信息'
# 设置排序
ordering = ['id']
# 表复数形式
verbose_name_plural = verbose_name

@ -0,0 +1,58 @@
*{
padding: 0;
margin: 0;
font-size: 20px;
}
.page {
display: block;
position: relative;
top: 100px;
/*top: 400px;*/
/*left: 90px;*/
}
.all{
/*width: 100%;*/
/* width: 100px; */
height: 100vh;
display: flex;
left: 60px;
/* justify-content: center; */
flex-wrap: wrap;
}
/*偷懒才用的id*/
#inputs input{
display: inline-block;
position: relative;
width: 100px;
height: 50px;
background-color: white;
margin: 10px;
left: 90px;
/*top: 100px;*/
}
.info {
position: relative;
left: 200px;
width: 600px;
}
/*#table{*/
/* position: relative;*/
/* !*top: 100px;*!*/
/* left: 90px;*/
/* !*left: -60px;*!*/
/* display: inline-block;*/
/* width: 600px;*/
/* !*width: 90%;*!*/
/*}*/
/*tr{*/
/* width: 100%;*/
/* margin: 10px;*/
/*}*/
/*td{*/
/* text-align: center;*/
/* !* width: 50%; *!*/
/* width: 200px;*/
/* height: 10vh;*/
/* border: 1px solid black;*/
/*}*/

@ -5,7 +5,12 @@
body { body {
/* 全局字体大小 */ /* 全局字体大小 */
font-size: 18px; font-size: 18px;
/*top: 50px;*/
}
.head {
position: fixed;
width: 100%;
z-index: 100;
} }
.page { .page {
display: inline-block; display: inline-block;
@ -14,13 +19,13 @@ body {
position: fixed; position: fixed;
width: 340px; width: 340px;
left: 8px; left: 8px;
top: 5px; top: 10%;
/* width: auto; */ /* width: auto; */
height: auto; height: auto;
/*border-style:solid;*/ /*border-style:solid;*/
/*border-width: 2px;*/ /*border-width: 2px;*/
/*border-color:aqua;*/ /*border-color:aqua;*/
padding-top: 5px; /*padding-top: 5px;*/
padding: 5px; padding: 5px;
/* background-color: red; */ /* background-color: red; */
} }
@ -50,7 +55,13 @@ body {
border-color:aqua; border-color:aqua;
} }
.target-fix {
position: relative;
top: -80px;
display: block;
height: 0;
/*overflow: hidden;*/
}
.page a { .page a {
display: inline-block; display: inline-block;
text-decoration: none; text-decoration: none;
@ -60,14 +71,18 @@ body {
width: 50px; width: 50px;
height: 50px; height: 50px;
margin: 5px; margin: 5px;
background-color: rgb(246, 224, 224); /*background-color: rgb(241,241,241);*/
/*rgb(246, 224, 224)*/
background-color:rgb(241,241,241);
border-style: solid; border-style: solid;
border-width: 1px; border-width: 1px;
border-color: aquamarine border-color: aquamarine;
color: black;
} }
.page a:hover { .page a:hover {
/* 鼠标移动到时的改变颜色 */ /* 鼠标移动到时的改变颜色 */
background-color: #5096f5; background-color: gray;
/*#5096f5*/
} }
.line { .line {
@ -84,11 +99,11 @@ body {
.test { .test {
display: inline-block; display: inline-block;
position: relative; position: relative;
/*position: absolute;*/
top: 80px;
/* position: fixed; */ /* position: fixed; */
left: 408px; left: 408px;
height: auto; height: auto;
/* height: 1000px; */
/* background-color: pink;*/
} }
ul { ul {
list-style-type:armenian; list-style-type:armenian;
@ -118,3 +133,5 @@ li {
border-color: white; border-color: white;
border-bottom-color:black ; border-bottom-color:black ;
} */ } */

@ -4,13 +4,21 @@
font-size: 14px; font-size: 14px;
} }
.head .af {
position: relative;
left: 100px;
font-size: 24px;
display: inline-block;
border-width: 1px;
}
nav { nav {
margin: 0; margin: 0;
padding: 0; padding: 0;
font-size: 14px; font-size: 14px;
} }
.img { .img {
width: 1488px; /*width: 1000px;*/
width: auto;
margin: 0; margin: 0;
padding: 0; padding: 0;
position: relative; position: relative;

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

@ -0,0 +1,260 @@
{% load static %}
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
<title>教师端口</title>
<link rel="stylesheet" href="{% static 'css/css1.css' %}">
<script type="text/javascript">
function F_Open_dialog()
{document.getElementById("btn_file").click();}
</script>
<script type="text/javascript">
</script>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'css/teacher.css' %}">
<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询media queries功能 -->
<!-- 警告:通过 file:// 协议(就是直接将 html 页面拖拽到浏览器中)访问页面时 Respond.js 不起作用 -->
<!--[if lt IE 9]>
<script src="https://fastly.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->
<style>
.main {
position: fixed;
top: 200px;
left: 20% ;
}
ul {
margin: 0;
padding: 0;
}
.clearfloat {
zoom: 1;
}
.clearfloat::after {
display: block;
clear: both;
content: "";
visibility: hidden;
height: 0;
}
.tab-list {
position: relative;
width: auto;
}
.tab-list .tab-itom {
float: left;
list-style: none;
margin-right: 4px;
width: auto;
}
.tab-itom .test-label {
position: relative;
display: block;
width: 85px;
height: 27px;
border: 1px solid transparent;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
line-height: 27px;
text-align: center;
background: #e7e8eb;
}
.tab-itom .tab-box {
/* 设置绝对定位方便定位相对于tab-list栏的位置同时为了可以使用z-index属性 */
position: absolute;
left: 0;
top: 28px;
width: 800px;
{#width: 488px;#}
height: 448px;
border: 1px solid #cbcccc;
border-radius: 5px;
border-top-left-radius: 0px;
background: #fff;
/* 设置层级最低方便选中状态遮挡 */
z-index: 0;
}
{#td{#}
{# width: 500px;#}
{#}#}
/* 用绝对定位使按钮脱离文档流透明度设置为0将其隐藏 */
input[type="radio"] {
position: absolute;
opacity: 0;
}
/* 利用选择器实现 tab切换 */
/* 当radio为选中状态时设置它的test-label兄弟元素的属性 */
input[type="radio"]:checked + .test-label {
/* 为了修饰存在的边框背景属性 */
border-color: #cbcccc;
border-bottom-color: #fff;
background: #fff;
/* 为了修饰存在的层级使下边框遮挡下方div的上边框 */
z-index: 10;
}
/* 当radio为选中状态时设置与它同级的tab-box元素的显示层级 */
input[type="radio"]:checked ~ .tab-box {
/* 选中时提升层级遮挡其他tab页达到选中切换的效果 */
z-index: 5;
}
.head {
{#font-size: 30px;#}
font-weight: bolder;
}
</style>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar">434534534354</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">灯塔</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
{# <li><a>#}
{# <button type="button" onclick="F_Open_dialog()" style="border: 0px; background-color: rgba(0,0,0,0); font-size: 14px;">#}
{# <input type="file" id="btn_file" style="display:none">上传题目#}
{# </button >#}
{# </a></li>#}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">上传文件<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<form method="post" enctype="multipart/form-data" action="{% url 'teacher_client:file_muti' %}">
{% csrf_token %}
<div class="form-group">
<input type="file" name="exc">
</div>
<input type="submit" value="上传" class="btn btn-info btn-sm">
</form>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">我的课堂<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<form method="post" enctype="multipart/form-data" action="{% url 'teacher_client:classSet' %}">
{% csrf_token %}
<div class="form-group">
<input type="text" name="classname" placeholder="输入班级名称">
</div>
<input type="submit" value="创建" class="btn btn-info btn-sm">
</form>
</li>
</ul>
</li>
<li><a href="{% url 'teacher_client:test_release' %}">发布测试</a></li>
<li><a href="#">测试情况</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">欢迎, {{ username }}<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{% url 'login:logout' %}">退出登录</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="img">
<img src="{% static 'img/头哥.png' %}" alt="灯塔测试" title="灯塔测试" style="position: relative; top: -10px;width: 1519.2px">
</div>
<div class="main">
<div class="clearfloat">
<ul class="tab-list clearfloat">
{% for tempC,tempc in classcode1 %}
<li class="tab-itom">
<input type="radio" id="testTabRadio{{ forloop.counter }}" class="test-radio" name="tab" checked="checked">
<label class="test-label" for="testTabRadio{{ forloop.counter }}">{{ tempc }}</label>
<div class="tab-box">
<table class="table table-hover">
<tr class="head">
<td>#</td>
<td>学号</td>
<td>姓名</td>
<td>联系方式</td>
</tr>
{% for tempS in student%}
{% if tempS.classcode == tempC %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ tempS.id_number }}</td>
<td>{{ tempS.name }}</td>
<td>{{ tempS.phone }}</td>
</tr>
{% endif %}
{% endfor %}
</table>
<span>加课码: {{ tempC }}</span>
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
</body>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery所以必须放在前边) -->
<script src="https://fastly.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</body>
</html>

@ -0,0 +1,220 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
{# <link rel="stylesheet" href="{% static 'css/css1.css' %}">#}
<title>CSS实现Tab切换效果</title>
<script type="text/javascript">
function F_Open_dialog()
{document.getElementById("btn_file").click();}
</script>
<script type="text/javascript">
</script>
{# <!-- Bootstrap -->#}
{# <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">#}
{# <link rel="stylesheet" href="{% static 'css/teacher.css' %}">#}
{# <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询media queries功能 -->#}
{# <!-- 警告:通过 file:// 协议(就是直接将 html 页面拖拽到浏览器中)访问页面时 Respond.js 不起作用 -->#}
{# <!--[if lt IE 9]>#}
{# <script src="https://fastly.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>#}
{# <script src="https://fastly.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>#}
{# <![endif]-->#}
<style>
.main {
position: fixed;
top: 10%;
left: 30% ;
}
ul {
margin: 0;
padding: 0;
}
.clearfloat {
zoom: 1;
}
.clearfloat::after {
display: block;
clear: both;
content: "";
visibility: hidden;
height: 0;
}
.tab-list {
position: relative;
}
.tab-list .tab-itom {
float: left;
list-style: none;
margin-right: 4px;
}
.tab-itom .test-label {
position: relative;
display: block;
width: 85px;
height: 27px;
border: 1px solid transparent;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
line-height: 27px;
text-align: center;
background: #e7e8eb;
}
.tab-itom .tab-box {
/* 设置绝对定位方便定位相对于tab-list栏的位置同时为了可以使用z-index属性 */
position: absolute;
left: 0;
top: 28px;
width: 488px;
height: 448px;
border: 1px solid #cbcccc;
border-radius: 5px;
border-top-left-radius: 0px;
background: #fff;
/* 设置层级最低方便选中状态遮挡 */
z-index: 0;
}
/* 用绝对定位使按钮脱离文档流透明度设置为0将其隐藏 */
input[type="radio"] {
position: absolute;
opacity: 0;
}
/* 利用选择器实现 tab切换 */
/* 当radio为选中状态时设置它的test-label兄弟元素的属性 */
input[type="radio"]:checked + .test-label {
/* 为了修饰存在的边框背景属性 */
border-color: #cbcccc;
border-bottom-color: #fff;
background: #fff;
/* 为了修饰存在的层级使下边框遮挡下方div的上边框 */
z-index: 10;
}
/* 当radio为选中状态时设置与它同级的tab-box元素的显示层级 */
input[type="radio"]:checked ~ .tab-box {
/* 选中时提升层级遮挡其他tab页达到选中切换的效果 */
z-index: 5;
}
</style>
</head>
<body >
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar">434534534354</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">灯塔</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
{# <li><a>#}
{# <button type="button" onclick="F_Open_dialog()" style="border: 0px; background-color: rgba(0,0,0,0); font-size: 14px;">#}
{# <input type="file" id="btn_file" style="display:none">上传题目#}
{# </button >#}
{# </a></li>#}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">上传文件<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<form method="post" enctype="multipart/form-data" action="{% url 'teacher_client:file_muti' %}">
{% csrf_token %}
<div class="form-group">
<input type="file" name="exc">
</div>
<input type="submit" value="上传" class="btn btn-info btn-sm">
</form>
</li>
</ul>
</li>
<li><a href="{% url 'teacher_client:classSet' %}">我的课堂</a></li>
<li><a href="{% url 'teacher_client:test_release' %}">发布测试</a></li>
<li><a href="#">测试情况</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">欢迎, {{ username }}<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{% url 'login:logout' %}">退出登录</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery所以必须放在前边) -->
<script src="https://fastly.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
{#<div class="img">#}
{# <img src="{% static 'img/头哥.png' %}" alt="灯塔测试" title="灯塔测试" style="position: relative; top: -10px;width: 1519.2px">#}
{#</div>#}
<div class="main">
<div class="clearfloat">
<ul class="tab-list clearfloat">
{% for tempC,tempc in classcode1 %}
<li class="tab-itom">
<input type="radio" id="testTabRadio{{ forloop.counter }}" class="test-radio" name="tab" checked="checked">
<label class="test-label" for="testTabRadio{{ forloop.counter }}">{{ tempc }}</label>
<div class="tab-box">
<table class="table table-hover">
<tr>
<td>#</td>
<td>学号</td>
<td>姓名</td>
<td>联系方式</td>
</tr>
{% for tempS in student%}
{% if tempS.classcode == tempC %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ tempS.id_number }}</td>
<td>{{ tempS.name }}</td>
<td>{{ tempS.phone }}</td>
</tr>
{% endif %}
{% endfor %}
</table>
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
</body>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery所以必须放在前边) -->
<script src="https://fastly.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</html>

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --> <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
<title>教师端口</title> <title>教师端口</title>
<link rel="stylesheet" href="{% static 'css/css.css' %}"> <link rel="stylesheet" href="{% static 'css/css1.css' %}">
<script type="text/javascript"> <script type="text/javascript">
function F_Open_dialog() function F_Open_dialog()
@ -89,11 +89,16 @@
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 --> <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
<div class="img"> <div class="img">
<img src="img/头哥.png" alt="灯塔测试" title="灯塔测试" style="position: relative; top: -10px;"> <img src="{% static 'img/头哥.png' %}" alt="灯塔测试" title="灯塔测试" style="position: relative; top: -10px;width: 1519.2px">
</div> </div>
{# <div class="head" style="display: inline-block; position: relative; left:200px; margin: 20px">#}
{# <div style="display: inline-block;margin-inline: 60px;font-size:25px;left: 100px; border-width: 2px;border-color: #18191c">姓名</div>#}
{# <div style="display: inline-block;margin-inline: 60px;font-size:25px;">学号</div>#}
{# <div style="display: inline-block;margin-inline: 60px;font-size:25px;">联系方式</div>#}
{# </div>#}
<div class="page"> <div class="page">
<div class="all"> <div class="all">
<!-- 导航 --> <!-- 导航 -->
<div id="inputs"> <div id="inputs">
@ -111,12 +116,14 @@
<script> <script>
var head = ['122','bbb','ccc'];
var classname = {{ classname|safe}}; var classname = {{ classname|safe}};
var strs = {{ res|safe}}; var strs = {{ res|safe}};
//假设规定每页显示长度为3 //假设规定每页显示长度为3
var len = 3; var len = 3;
{#var ids = classname#}
//确认该集合会被分成几页,分成几页就代表需要几个页面按钮,封装封装方便多次运用 //确认该集合会被分成几页,分成几页就代表需要几个页面按钮,封装封装方便多次运用
function limits(){ function limits(){
var countLim = Math.ceil(strs.length/len);//余数也算是一页,这里用向上取整 var countLim = Math.ceil(strs.length/len);//余数也算是一页,这里用向上取整
@ -124,23 +131,37 @@ function limits(){
document.getElementById("inputs").innerHTML='';//清空一下 document.getElementById("inputs").innerHTML='';//清空一下
// 导航内容每个内容需要保定一个value // 导航内容每个内容需要保定一个value
for(var i=1;i<=countLim;i++){ for(var i=1;i<=countLim;i++){
document.getElementById("inputs").innerHTML+='<input type="button" value="'+ i +'" onclick="limitinput(this)"/ style="display: block;">';//每个页面按钮都绑定上一个点击事件 document.getElementById("inputs").innerHTML+='<input type="button" value="'+ i +'" onclick="limitinput(this)"/ style="display: block;">';//每个页面按钮都绑定上一个点击事件
} }
} }
var choose = 0;//创建一个全局变量用来保存当前处于第几个页面 var choose = 0;//创建一个全局变量用来保存当前处于第几个页面
//点击按钮获取当前按钮的值进行选择当前table是第几页数据 //点击按钮获取当前按钮的值进行选择当前table是第几页数据
function limitinput(ids){ function limitinput(ids){
choose = ids.value; choose =ids.value;
tablestr(choose);//刷新table数据 tablestr(choose);//刷新table数据
limits();//刷新页面按钮 limits();//刷新页面按钮
ids.style.backgroundColor='red';//当前点击的页面按钮背景颜色改变为红色 choose.style.backgroundColor='red';//当前点击的页面按钮背景颜色改变为红色
liminputcolor(choose);//页面按钮变色 liminputcolor(choose);//页面按钮变色
} }
function hd(){
}
//通过当前页面按钮和页面数据长度将数据放进table内封装封装必须封装 //通过当前页面按钮和页面数据长度将数据放进table内封装封装必须封装
function tablestr(num){//num是指当前哪个页面 function tablestr(num){//num是指当前哪个页面
var num1 = (num-1)*len;//确定循环开始的集合下标 var num1 = (num-1)*len;//确定循环开始的集合下标
var num2 = num*len;//确定循环结束的结束下标 var num2 = num*len;//确定循环结束的结束下标
document.getElementById("table").innerHTML='';//清空一下 document.getElementById("table").innerHTML='';//清空一下
{#for(var i=1;i<2;i++) {//#}
{# var str = '';#}
{# for (var h in head) {//遍历集合#}
var str = '';
str += '<td>' +'姓名'+ '</td>';
str += '<td>' +'学号' + '</td>';
str += '<td>' +'联系方式' + '</td>';
document.getElementById("table").innerHTML += '<tr>' + str + '</tr>';//每循环一次添加一条数据
for(var i=num1;i<num2;i++){// for(var i=num1;i<num2;i++){//
var str = ''; var str = '';
for(var h in strs[i]){//遍历集合 for(var h in strs[i]){//遍历集合
@ -156,10 +177,7 @@ function liminputcolor(choose){
limits();//页面按钮生成 limits();//页面按钮生成
document.getElementById("inputs").childNodes[0].style.backgroundColor="red";//第一个按钮的背景颜色为红色 document.getElementById("inputs").childNodes[0].style.backgroundColor="red";//第一个按钮的背景颜色为红色
tablestr(1);//table数据显示 tablestr(1);//table数据显示
/*
到这里就结束了,但是!!!这些都是被封装好了的,意思就是说,在最开始的时候这就是通用的做法;
最开始的数据就是在模拟后端的集合,也就是说,不论你后端传递给前端什么集合都可以实现分页功能
*/
</script> </script>
</div> </div>

@ -0,0 +1,45 @@
{% 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">
{% for temp in classcode %}
{% if temp_RawQuerySetClass.classcode == temp %}
<a href="{{ forloop.counter }}">{{ temp_RawQuerySetStudent.name }}</a>
{% endif %}
{% endfor %}
</div>
</div>
<div class="line"></div>
</div>
<div class="test">
<table>
<tr>
<td>姓名</td>
<td>学号</td>
<td>联系方式</td>
<td>操作</td>
</tr>
{# {% if temp_RawQuerySetStudent.classcode = %}#}
{# {% endif %}#}
</table>
</div>
</div>
</body>
</html>

@ -6,12 +6,102 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Title</title> <title>Title</title>
<!-- <link rel="stylesheet" href="{% static 'css/henyeqi.css' %}"> --> <!-- <link rel="stylesheet" href="{% static 'css/henyeqi.css' %}"> -->
<link rel="stylesheet" href="{% static 'css/stud.css' %}"> <link rel="stylesheet" href="{% static 'css/stud1.css' %}">
<script type="text/javascript">
function F_Open_dialog()
{document.getElementById("btn_file").click();}
</script>
<script type="text/javascript">
</script>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'css/teacher.css' %}">
<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询media queries功能 -->
<!-- 警告:通过 file:// 协议(就是直接将 html 页面拖拽到浏览器中)访问页面时 Respond.js 不起作用 -->
<!--[if lt IE 9]>
<script src="https://fastly.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
function disp_alert()
{
alert("发布成功")
}
</script>
</head> </head>
<body> <body>
<div> {##}
<div class="page">
<div class="head">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar">434534534354</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{% url 'teacher_client:teacher_client' %}">灯塔</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
{# <li><a>#}
{# <button type="button" onclick="F_Open_dialog()" style="border: 0px; background-color: rgba(0,0,0,0); font-size: 14px;">#}
{# <input type="file" id="btn_file" style="display:none">上传题目#}
{# </button >#}
{# </a></li>#}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">上传文件<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<form method="post" enctype="multipart/form-data" action="{% url 'teacher_client:file_muti' %}">
{% csrf_token %}
<div class="form-group">
<input type="file" name="exc">
</div>
<input type="submit" value="上传" class="btn btn-info btn-sm">
</form>
</li>
</ul>
</li>
<li><a href="{% url 'teacher_client:classSet' %}">我的课堂</a></li>
<li><a href="{% url 'teacher_client:test_release' %}">发布测试</a></li>
<li><a href="#">测试情况</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">欢迎, {{ username }}<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{% url 'login:logout' %}">退出登录</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery所以必须放在前边) -->
<script src="https://fastly.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</div>
{#内容页开始#}
<div class="page" >
<div class="page1"> <div class="page1">
{% if single_choice %} {% if single_choice %}
单选题<br> 单选题<br>
@ -32,25 +122,27 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</div> </div>
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
<span class="set_time"> <span class="set_time">
时间:<input type="text" name="test_time" placeholder="输入考试时间,例如 2:30"> 时间:<input type="text" name="test_time" placeholder="输入考试时间,例如 2:30">
</span> </span>
<span>是否决定发布测试?</span><br> <span>是否决定发布测试?</span><br>
<input type="submit" value="发布测试"> <input type="submit" value="发布测试" onclick="disp_alert()">
{% if TEST_CODE %} {% if TEST_CODE %}
本场考试的考试码为:{{ TEST_CODE }} 本场考试的考试码为:{{ TEST_CODE }}
{% endif %} {% endif %}
</form> </form>
</div>
</div>
<div class="line"></div> <div class="line"></div>
</div> </div>
<div class="test">
<form action=""> <div class="test" >
<form action="" >
<table > <table >
<!-- 单选 --> <!-- 单选 -->
@ -58,7 +150,8 @@
{% if single_choice %} {% if single_choice %}
一、单选<br><br> 一、单选<br><br>
{% for single in single_choice %} {% for single in single_choice %}
<ul id="0{{ forloop.counter }}"> <a id="0{{ forloop.counter }}" class="target-fix"></a>
<ul >
<li class="ques"><label>{{ forloop.counter }}、(单选){{ single.qus_imfomation }}</label></li> <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="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="B">{{ single.qus_B }}</label></li>
@ -74,7 +167,8 @@
{% if multiple_choice %} {% if multiple_choice %}
<br>二、多选<br><br> <br>二、多选<br><br>
{% for multiple in multiple_choice %} {% for multiple in multiple_choice %}
<ul id="1{{ forloop.counter }}"> <a id="1{{ forloop.counter }}" class="target-fix"></a>
<ul >
<li class="ques"><label>{{ forloop.counter }}、(多选){{ multiple.qus_imfomation }}</label></li> <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="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="B">{{ multiple.qus_B }}</label></li>
@ -90,7 +184,8 @@
{% if gap_filling %} {% if gap_filling %}
<br>三、填空题<br><br> <br>三、填空题<br><br>
{% for gap in gap_filling%} {% for gap in gap_filling%}
<ul id="2{{ forloop.counter }}"> <a id="2{{ forloop.counter }}" class="target-fix"></a>
<ul >
<li class="ques"><label>{{ forloop.counter }}、(填空){{ gap.qus_imfomation }}</label></li> <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" name="choose" value="dhsaujdh">A.jshduse</label></li> -->
<li><label><input type="text" class="write" name="choose" placeholder="在此处作答"></label></li> <li><label><input type="text" class="write" name="choose" placeholder="在此处作答"></label></li>

@ -18,7 +18,6 @@ def teacher_client(request):
if request.method == 'GET': if request.method == 'GET':
username = request.session.get('username') username = request.session.get('username')
password = request.session.get('password') password = request.session.get('password')
print(username, password)
if username and password: if username and password:
@ -45,6 +44,9 @@ def teacher_client(request):
str1 = str1 + "'" + temp + "'" + "," str1 = str1 + "'" + temp + "'" + ","
str1 = str1.strip(',') str1 = str1.strip(',')
str1 += ')' str1 += ')'
print("str1: ", str1)
if str1 == "()":
return render(request, '111.html',{"username": username})
select_teacher_client_classtable = 'select id, name, id_number, phone, classcode ' \ select_teacher_client_classtable = 'select id, name, id_number, phone, classcode ' \
'from teacher_client_classtable ' \ 'from teacher_client_classtable ' \
'where classcode in ' + str1 'where classcode in ' + str1
@ -53,19 +55,21 @@ def teacher_client(request):
Sname = [] Sname = []
Sno = [] Sno = []
Sphone = [] Sphone = []
Sclasscode = []
for ss in temp_RawQuerySetStudent: for ss in temp_RawQuerySetStudent:
Sname.append(ss.name) Sname.append(ss.name)
Sno.append(ss.id_number) Sno.append(ss.id_number)
Sphone.append(ss.phone) Sphone.append(ss.phone)
Sclasscode.append(ss.classcode)
res = [] res = []
for i in range(len(Sname)): for i in range(len(Sname)):
res.append([Sname[i], Sno[i], Sphone[i]]) res.append([Sname[i], Sno[i], Sphone[i], Sclasscode[i]])
classcode1 = zip(classcode, classname)
return render(request, 'teacher_client.html', return render(request, '111.html',
{'classname': json.dumps(classname), 'res': json.dumps(res), 'classcode': classcode, {'classname': classname, 'res': res, 'classcode': classcode,
"student": temp_RawQuerySetStudent, 'username': username, "student": temp_RawQuerySetStudent, 'username': username,
"class": temp_RawQuerySetClass}, ) "class": temp_RawQuerySetClass, "classcode1": classcode1},)
else: else:
return redirect("http://127.0.0.1:8000/") return redirect("http://127.0.0.1:8000/")
@ -188,16 +192,12 @@ def test_release(request):
else: else:
multiple_choice.append(temp) 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_number = len(gap_filling) + len(multiple_choice) + len(single_choice)
total_list = [x + 1 for x in range(total_number)] total_list = [x + 1 for x in range(total_number)]
single_choice_number = len(single_choice) single_choice_number = len(single_choice)
multiple_choice_number = len(multiple_choice) multiple_choice_number = len(multiple_choice)
gap_filling_number = len(gap_filling) gap_filling_number = len(gap_filling)
username = request.session.get("username")
return render(request, "test.html", {"total_num": total_number, return render(request, "test.html", {"total_num": total_number,
"total_list": total_list, "total_list": total_list,
"single_choice": single_choice, "single_choice": single_choice,
@ -207,7 +207,8 @@ def test_release(request):
"TEST_CODE": TEST_CODE, "TEST_CODE": TEST_CODE,
"single_choice_number": single_choice_number, "single_choice_number": single_choice_number,
"multiple_choice_number": multiple_choice_number, "multiple_choice_number": multiple_choice_number,
"gap_filling_number": gap_filling_number "gap_filling_number": gap_filling_number,
"username": username,
}) })
# 从前端获取一个考试时间 # # 从前端获取一个考试时间 #
@ -235,21 +236,4 @@ def test_release(request):
for temp in temp_RawQuerySetquestion: for temp in temp_RawQuerySetquestion:
temp_classcode = temp.que_classcode 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) 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("发布成功") return redirect("teacher_client:teacher_client")
# 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
# })

@ -38,8 +38,9 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'login.apps.LoginConfig', 'login.apps.LoginConfig',
'student_client.apps.StudentClientConfig',
'teacher_client.apps.TeacherClientConfig', 'teacher_client.apps.TeacherClientConfig',
'student_client.apps.StudentClientConfig'
] ]
MIDDLEWARE = [ MIDDLEWARE = [

@ -30,6 +30,9 @@ urlpatterns = [
# 教师端口 # 教师端口
path('', include("teacher_client.urls")), path('', include("teacher_client.urls")),
# 学生端口
path('', include("student_client.urls"))
] ]
handler500 = login.views.server_error handler500 = login.views.server_error
Loading…
Cancel
Save