Compare commits
No commits in common. 'a280b2c96b56d849231aac581638ec46ea1e7da3' and '54bdbccdaa4d8f902edbc31fbddadc82e4a14b99' have entirely different histories.
a280b2c96b
...
54bdbccdaa
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class StudentClientConfig(AppConfig):
|
||||||
|
name = 'student_client'
|
Binary file not shown.
@ -0,0 +1,3 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
@ -0,0 +1,11 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from django.urls import path
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
app_name = 'student_client'
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
|
||||||
|
path("student_client/", views.student_client, name = "student_client")
|
||||||
|
|
||||||
|
]
|
@ -0,0 +1,7 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
|
||||||
|
def student_client(request):
|
||||||
|
"""学生端口"""
|
||||||
|
if request.method == "GET":
|
||||||
|
return render(request, "student_client.html")
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,14 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
def random_num():
|
||||||
|
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
|
||||||
|
'a', 'b', 'c', 'd', 'e', 'f',
|
||||||
|
'g', 'h', 'i', 'j', 'k', 'l',
|
||||||
|
'm', 'n', 'o', 'p', 'q', 'r',
|
||||||
|
's', 't', 'u', 'v', 'w', 'x',
|
||||||
|
'y', 'z']
|
||||||
|
temp = random.sample(L, 5)
|
||||||
|
a, b, c, d, e = temp
|
||||||
|
code = str(a)+str(b)+str(c)+str(d)+str(e)
|
||||||
|
return code
|
Binary file not shown.
@ -0,0 +1,17 @@
|
|||||||
|
from django.utils.deprecation import MiddlewareMixin
|
||||||
|
from django.shortcuts import HttpResponse, redirect
|
||||||
|
|
||||||
|
|
||||||
|
class AuthMiddleware(MiddlewareMixin):
|
||||||
|
|
||||||
|
def process_request(self, request):
|
||||||
|
# 首先排除那些不需要登录的urls
|
||||||
|
if request.path_info == '/' or request.path_info == '/register/' or request.path_info == '/dologin/':
|
||||||
|
return None
|
||||||
|
# 获取当前访问用户登录时存入的session信息
|
||||||
|
username = request.session.get('username')
|
||||||
|
password = request.session.get('password')
|
||||||
|
# 若不为空,则已经登录
|
||||||
|
if username and password:
|
||||||
|
return None
|
||||||
|
return HttpResponse('请登录')
|
@ -0,0 +1,36 @@
|
|||||||
|
# Generated by Django 3.1.4 on 2022-04-14 11:45
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('teacher_client', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='classTable',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=32, verbose_name='姓名')),
|
||||||
|
('id_number', models.CharField(max_length=32, verbose_name='学号/教师编号')),
|
||||||
|
('phone', models.CharField(max_length=32, unique=True, verbose_name='手机')),
|
||||||
|
('classCode', models.CharField(default='', max_length=6, verbose_name='加课码')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='teacherClass',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=32, verbose_name='姓名')),
|
||||||
|
('id_number', models.CharField(max_length=32, verbose_name='学号/教师编号')),
|
||||||
|
('classCode', models.CharField(default='', max_length=20, verbose_name='加课码')),
|
||||||
|
('classname', models.CharField(default='', max_length=20, verbose_name='课程名')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='questionBank',
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,26 @@
|
|||||||
|
# Generated by Django 3.1.4 on 2022-04-15 09:36
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('teacher_client', '0002_auto_20220414_1945'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='questionBank',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('qus_imfomation', models.CharField(max_length=1000, verbose_name='题目信息')),
|
||||||
|
('qus_A', models.CharField(max_length=1000, verbose_name='选项A')),
|
||||||
|
('qus_B', models.CharField(max_length=1000, verbose_name='选项B')),
|
||||||
|
('qus_C', models.CharField(max_length=1000, verbose_name='选项C')),
|
||||||
|
('qus_D', models.CharField(max_length=1000, verbose_name='选项D')),
|
||||||
|
('qus_ans', models.CharField(max_length=100, verbose_name='答案')),
|
||||||
|
('que_classcode', models.CharField(max_length=10, verbose_name='所属班级')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.1.4 on 2022-04-15 09:55
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('teacher_client', '0003_questionbank'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='questionbank',
|
||||||
|
name='que_classcode',
|
||||||
|
field=models.CharField(max_length=1000, verbose_name='所属班级'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='questionbank',
|
||||||
|
name='qus_ans',
|
||||||
|
field=models.CharField(max_length=1000, verbose_name='答案'),
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.1.4 on 2022-04-15 12:25
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('teacher_client', '0004_auto_20220415_1755'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='questionbank',
|
||||||
|
name='que_time',
|
||||||
|
field=models.CharField(default='', max_length=200, verbose_name='存入时间'),
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,26 @@
|
|||||||
|
# Generated by Django 3.1.4 on 2022-04-15 14:51
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('teacher_client', '0005_questionbank_que_time'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='testQuestionBank',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('qus_imfomation', models.CharField(max_length=1000, verbose_name='题目信息')),
|
||||||
|
('qus_A', models.CharField(max_length=1000, verbose_name='选项A')),
|
||||||
|
('qus_B', models.CharField(max_length=1000, verbose_name='选项B')),
|
||||||
|
('qus_C', models.CharField(max_length=1000, verbose_name='选项C')),
|
||||||
|
('qus_D', models.CharField(max_length=1000, verbose_name='选项D')),
|
||||||
|
('qus_ans', models.CharField(max_length=1000, verbose_name='答案')),
|
||||||
|
('test_code', models.CharField(max_length=1000, verbose_name='所属班级')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.1.4 on 2022-04-16 02:52
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('teacher_client', '0006_testquestionbank'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='testquestionbank',
|
||||||
|
name='test_time',
|
||||||
|
field=models.CharField(default='', max_length=200, verbose_name='考试时间'),
|
||||||
|
),
|
||||||
|
]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,6 +1,45 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
# class questionBank(models.Model):
|
||||||
|
# """用于存储题目数据"""
|
||||||
|
|
||||||
|
|
||||||
|
class teacherClass(models.Model):
|
||||||
|
"""记录班级加课码"""
|
||||||
|
name = models.CharField(max_length=32, verbose_name="姓名", blank=False, null=False)
|
||||||
|
id_number = models.CharField(max_length=32, verbose_name="学号/教师编号", blank=False, null=False)
|
||||||
|
classCode = models.CharField(max_length=20, verbose_name="加课码", default='')
|
||||||
|
classname = models.CharField(max_length=20, verbose_name="课程名", default='')
|
||||||
|
|
||||||
|
|
||||||
|
class classTable(models.Model):
|
||||||
|
"""班级表"""
|
||||||
|
name = models.CharField(max_length=32, verbose_name="姓名", blank=False, null=False)
|
||||||
|
id_number = models.CharField(max_length=32, verbose_name="学号/教师编号", blank=False, null=False)
|
||||||
|
phone = models.CharField(max_length=32, verbose_name="手机", unique=True, blank=False, null=False)
|
||||||
|
classCode = models.CharField(max_length=6, verbose_name="加课码", default='')
|
||||||
|
|
||||||
|
|
||||||
class questionBank(models.Model):
|
class questionBank(models.Model):
|
||||||
"""用于存储题目数据"""
|
"""用于保存用户上传提交的题目"""
|
||||||
|
qus_imfomation = models.CharField(max_length=1000, verbose_name="题目信息", blank=False, null=False)
|
||||||
|
qus_A = models.CharField(max_length=1000, verbose_name="选项A", blank=False, null=False)
|
||||||
|
qus_B = models.CharField(max_length=1000, verbose_name="选项B", blank=False, null=False)
|
||||||
|
qus_C = models.CharField(max_length=1000, verbose_name="选项C", blank=False, null=False)
|
||||||
|
qus_D = models.CharField(max_length=1000, verbose_name="选项D")
|
||||||
|
qus_ans = models.CharField(max_length=1000, verbose_name="答案", blank=False, null=False)
|
||||||
|
que_classcode = models.CharField(max_length=1000, verbose_name="所属班级", blank=False, null=False)
|
||||||
|
que_time = models.CharField(max_length=200, verbose_name="存入时间", default="")
|
||||||
|
|
||||||
|
|
||||||
|
class testQuestionBank(models.Model):
|
||||||
|
"""考试信息表"""
|
||||||
|
qus_imfomation = models.CharField(max_length=1000, verbose_name="题目信息", blank=False, null=False)
|
||||||
|
qus_A = models.CharField(max_length=1000, verbose_name="选项A", blank=False, null=False)
|
||||||
|
qus_B = models.CharField(max_length=1000, verbose_name="选项B", blank=False, null=False)
|
||||||
|
qus_C = models.CharField(max_length=1000, verbose_name="选项C", blank=False, null=False)
|
||||||
|
qus_D = models.CharField(max_length=1000, verbose_name="选项D")
|
||||||
|
qus_ans = models.CharField(max_length=1000, verbose_name="答案")
|
||||||
|
test_code = models.CharField(max_length=1000, verbose_name="所属班级", blank=False, null=False)
|
||||||
|
test_time = models.CharField(max_length=200, verbose_name="考试时间", default='')
|
@ -0,0 +1,47 @@
|
|||||||
|
*{
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
.page {
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
/* top: 400px; */
|
||||||
|
left: 40px;
|
||||||
|
}
|
||||||
|
.all{
|
||||||
|
width: 100%;
|
||||||
|
/* width: 100px; */
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
/* left: 30px; */
|
||||||
|
/* justify-content: center; */
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
/*偷懒才用的id*/
|
||||||
|
#inputs input{
|
||||||
|
display: inline-block;
|
||||||
|
width: 100px;
|
||||||
|
height: 50px;
|
||||||
|
background-color: white;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
.info {
|
||||||
|
position: relative;
|
||||||
|
left: 100px;
|
||||||
|
}
|
||||||
|
#table{
|
||||||
|
display: inline-block;
|
||||||
|
width: 90%;
|
||||||
|
}
|
||||||
|
tr{
|
||||||
|
width: 100%;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
td{
|
||||||
|
text-align: center;
|
||||||
|
/* width: 50%; */
|
||||||
|
width: 200px;
|
||||||
|
height: 10vh;
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
@ -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,120 @@
|
|||||||
|
*{
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
/* 全局字体大小 */
|
||||||
|
font-size: 18px;
|
||||||
|
|
||||||
|
}
|
||||||
|
.page {
|
||||||
|
display: inline-block;
|
||||||
|
/*position: fixed;*/
|
||||||
|
display: block;
|
||||||
|
position: fixed;
|
||||||
|
width: 340px;
|
||||||
|
left: 8px;
|
||||||
|
top: 5px;
|
||||||
|
/* width: auto; */
|
||||||
|
height: auto;
|
||||||
|
/*border-style:solid;*/
|
||||||
|
/*border-width: 2px;*/
|
||||||
|
/*border-color:aqua;*/
|
||||||
|
padding-top: 5px;
|
||||||
|
padding: 5px;
|
||||||
|
/* background-color: red; */
|
||||||
|
}
|
||||||
|
/*.set_time {*/
|
||||||
|
/* display: flex;*/
|
||||||
|
/* display: block;*/
|
||||||
|
/* top: auto;*/
|
||||||
|
/* margin: 10px;*/
|
||||||
|
|
||||||
|
/*}*/
|
||||||
|
.set_time {
|
||||||
|
display: block;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.set_time input {
|
||||||
|
font-size: 20px;
|
||||||
|
width: 300px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: white;
|
||||||
|
border-bottom-color:black ;
|
||||||
|
/* 点击后无边框 */
|
||||||
|
outline:none;
|
||||||
|
}
|
||||||
|
.page1 {
|
||||||
|
border-style:solid;
|
||||||
|
border-width: 2px;
|
||||||
|
border-color:aqua;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.page a {
|
||||||
|
display: inline-block;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 24px;
|
||||||
|
line-height: 50px;
|
||||||
|
text-align: center;
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
margin: 5px;
|
||||||
|
background-color: rgb(246, 224, 224);
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-color: aquamarine
|
||||||
|
}
|
||||||
|
.page a:hover {
|
||||||
|
/* 鼠标移动到时的改变颜色 */
|
||||||
|
background-color: #5096f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.line {
|
||||||
|
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
position: fixed;
|
||||||
|
left: 368px;
|
||||||
|
width: 6px;
|
||||||
|
height: 600px;
|
||||||
|
border-radius: 6px;
|
||||||
|
background-color:rgb(129, 122, 122);
|
||||||
|
}
|
||||||
|
.test {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
/* position: fixed; */
|
||||||
|
left: 408px;
|
||||||
|
height: auto;
|
||||||
|
/* height: 1000px; */
|
||||||
|
/* background-color: pink;*/
|
||||||
|
}
|
||||||
|
ul {
|
||||||
|
list-style-type:armenian;
|
||||||
|
}
|
||||||
|
ul .ques {
|
||||||
|
position: relative;
|
||||||
|
left: 1px;
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
position: relative;
|
||||||
|
left: 20px;
|
||||||
|
/* 取消小圆点 */
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
.write {
|
||||||
|
/* 设置下划线 */
|
||||||
|
width: 300px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: white;
|
||||||
|
border-bottom-color:black ;
|
||||||
|
/* 点击后无边框 */
|
||||||
|
outline:none;
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
/* .write:hover{
|
||||||
|
border-style: solid;
|
||||||
|
border-color: white;
|
||||||
|
border-bottom-color:black ;
|
||||||
|
} */
|
@ -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; */
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form action="{% url 'teacher_client:classSet'%}" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
班级名:<input type="text" name="classname" placeholder="班级名称">
|
||||||
|
<input type="submit" value="提交">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,110 @@
|
|||||||
|
{% load static %}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<!-- {% load static %} -->
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
<!-- <link rel="stylesheet" href="{% static 'css/henyeqi.css' %}"> -->
|
||||||
|
<link rel="stylesheet" href="{% static 'css/stud.css' %}">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<div class="page">
|
||||||
|
<div class="page1">
|
||||||
|
{% if single_choice %}
|
||||||
|
单选题<br>
|
||||||
|
{% for counter in single_choice %}
|
||||||
|
<a href="#0{{ forloop.counter }}"><span>{{ forloop.counter }}</span></a>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% if multiple_choice %}
|
||||||
|
<br>多选题<br>
|
||||||
|
{% for counter in multiple_choice %}
|
||||||
|
<a href="#1{{ forloop.counter }}"><span>{{ forloop.counter }}</span></a>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% if gap_filling %}
|
||||||
|
<br>填空题<br>
|
||||||
|
{% for counter in gap_filling %}
|
||||||
|
<a href="#2{{ forloop.counter }}"><span>{{ forloop.counter }}</span></a>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<span class="set_time">
|
||||||
|
时间:<input type="text" name="test_time" placeholder="输入考试时间,例如 2:30">
|
||||||
|
</span>
|
||||||
|
<span>是否决定发布测试?</span><br>
|
||||||
|
<input type="submit" value="发布测试">
|
||||||
|
{% if TEST_CODE %}
|
||||||
|
本场考试的考试码为:{{ TEST_CODE }}
|
||||||
|
{% endif %}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="line"></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="test">
|
||||||
|
<form action="">
|
||||||
|
<table >
|
||||||
|
|
||||||
|
<!-- 单选 -->
|
||||||
|
{# {% for student in student_page.object_list %} #}
|
||||||
|
{% if single_choice %}
|
||||||
|
一、单选<br><br>
|
||||||
|
{% for single in single_choice %}
|
||||||
|
<ul id="0{{ forloop.counter }}">
|
||||||
|
<li class="ques"><label>{{ forloop.counter }}、(单选){{ single.qus_imfomation }}</label></li>
|
||||||
|
<li><label><input type="radio" name="choose{{ forloop.counter }}" value="A">{{ single.qus_A }}</label></li>
|
||||||
|
<li><label><input type="radio" name="choose{{ forloop.counter }}" value="B">{{ single.qus_B }}</label></li>
|
||||||
|
<li><label><input type="radio" name="choose{{ forloop.counter }}" value="C">{{ single.qus_C }}</label></li>
|
||||||
|
<li><label><input type="radio" name="choose{{ forloop.counter }}" value="D">{{ single.qus_D }}</label></li>
|
||||||
|
</ul>
|
||||||
|
<br>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<!-- 多选 -->
|
||||||
|
{# {% for student in student_page.object_list %} #}
|
||||||
|
{% if multiple_choice %}
|
||||||
|
<br>二、多选<br><br>
|
||||||
|
{% for multiple in multiple_choice %}
|
||||||
|
<ul id="1{{ forloop.counter }}">
|
||||||
|
<li class="ques"><label>{{ forloop.counter }}、(多选){{ multiple.qus_imfomation }}</label></li>
|
||||||
|
<li><label><input type="checkbox" name="choose{{ forloop.counter }}" value="A">{{ multiple.qus_A }}</label></li>
|
||||||
|
<li><label><input type="checkbox" name="choose{{ forloop.counter }}" value="B">{{ multiple.qus_B }}</label></li>
|
||||||
|
<li><label><input type="checkbox" name="choose{{ forloop.counter }}" value="C">{{ multiple.qus_C }}</label></li>
|
||||||
|
<li><label><input type="checkbox" name="choose{{ forloop.counter }}" value="D">{{ multiple.qus_D }}</label></li>
|
||||||
|
</ul>
|
||||||
|
<br>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<!-- 填空 -->
|
||||||
|
{# {% for student in student_page.object_list %} #}
|
||||||
|
{% if gap_filling %}
|
||||||
|
<br>三、填空题<br><br>
|
||||||
|
{% for gap in gap_filling%}
|
||||||
|
<ul id="2{{ forloop.counter }}">
|
||||||
|
<li class="ques"><label>{{ forloop.counter }}、(填空){{ gap.qus_imfomation }}</label></li>
|
||||||
|
<!-- <li><label><input type="text" name="choose" value="dhsaujdh">A.jshduse</label></li> -->
|
||||||
|
<li><label><input type="text" class="write" name="choose" placeholder="在此处作答"></label></li>
|
||||||
|
</ul>
|
||||||
|
<br>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,7 +1,255 @@
|
|||||||
from django.shortcuts import render
|
from django.http import HttpResponse
|
||||||
|
from django.shortcuts import render, redirect
|
||||||
|
from .models import teacherClass, classTable, questionBank, testQuestionBank
|
||||||
|
from .common import createCode
|
||||||
|
import json, time
|
||||||
|
from openpyxl import load_workbook
|
||||||
|
|
||||||
|
TEST_CODE = 1000
|
||||||
|
|
||||||
|
|
||||||
|
def get_code():
|
||||||
|
code = createCode.random_num()
|
||||||
|
return code
|
||||||
|
|
||||||
|
|
||||||
def teacher_client(request):
|
def teacher_client(request):
|
||||||
"""教师服务端"""
|
"""教师服务端"""
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
return render(request, 'teacher_client.html')
|
username = request.session.get('username')
|
||||||
|
password = request.session.get('password')
|
||||||
|
print(username, password)
|
||||||
|
|
||||||
|
if username and password:
|
||||||
|
|
||||||
|
teacherID = request.session.get('id_number')
|
||||||
|
classCODE = request.session.get('classcode')
|
||||||
|
|
||||||
|
classname = []
|
||||||
|
classcode = []
|
||||||
|
|
||||||
|
select_teacher_client_teacherclass = 'select id, id_number, classname, classcode ' \
|
||||||
|
'from teacher_client_teacherclass ' \
|
||||||
|
'where id_number = ' + str(teacherID)
|
||||||
|
|
||||||
|
temp_RawQuerySetClass = teacherClass.objects.raw(select_teacher_client_teacherclass)
|
||||||
|
|
||||||
|
for cc in temp_RawQuerySetClass:
|
||||||
|
classname.append(cc.classname)
|
||||||
|
classcode.append(cc.classcode)
|
||||||
|
|
||||||
|
classnum = len(classname)
|
||||||
|
|
||||||
|
str1 = '('
|
||||||
|
for temp in classcode:
|
||||||
|
str1 = str1 + "'" + temp + "'" + ","
|
||||||
|
str1 = str1.strip(',')
|
||||||
|
str1 += ')'
|
||||||
|
select_teacher_client_classtable = 'select id, name, id_number, phone, classcode ' \
|
||||||
|
'from teacher_client_classtable ' \
|
||||||
|
'where classcode in ' + str1
|
||||||
|
|
||||||
|
temp_RawQuerySetStudent = classTable.objects.raw(select_teacher_client_classtable)
|
||||||
|
Sname = []
|
||||||
|
Sno = []
|
||||||
|
Sphone = []
|
||||||
|
|
||||||
|
for ss in temp_RawQuerySetStudent:
|
||||||
|
Sname.append(ss.name)
|
||||||
|
Sno.append(ss.id_number)
|
||||||
|
Sphone.append(ss.phone)
|
||||||
|
res = []
|
||||||
|
for i in range(len(Sname)):
|
||||||
|
res.append([Sname[i], Sno[i], Sphone[i]])
|
||||||
|
|
||||||
|
return render(request, 'teacher_client.html',
|
||||||
|
{'classname': json.dumps(classname), 'res': json.dumps(res), 'classcode': classcode,
|
||||||
|
"student": temp_RawQuerySetStudent, 'username': username,
|
||||||
|
"class": temp_RawQuerySetClass}, )
|
||||||
|
else:
|
||||||
|
return redirect("http://127.0.0.1:8000/")
|
||||||
|
|
||||||
|
|
||||||
|
def classSet(request):
|
||||||
|
if request.method == "GET":
|
||||||
|
return render(request, "createClass.html")
|
||||||
|
classname = request.POST.get('classname')
|
||||||
|
request.session['classname'] = classname
|
||||||
|
if classname != '':
|
||||||
|
# global CLASS_ID
|
||||||
|
# CLASS_ID += 1
|
||||||
|
code = get_code()
|
||||||
|
request.session['code'] = code
|
||||||
|
username = request.session.get('username')
|
||||||
|
id_number = request.session.get('id_number')
|
||||||
|
teacherClass.objects.create(name=username, id_number=id_number, classCode=code, classname=classname)
|
||||||
|
return redirect("teacher_client:teacher_client")
|
||||||
|
else:
|
||||||
|
return HttpResponse("请输入班级名")
|
||||||
|
|
||||||
|
|
||||||
|
def file_muti(request):
|
||||||
|
"""用于教师端文件上传"""
|
||||||
|
file_object = request.FILES.get('exc')
|
||||||
|
now_time = time.time()
|
||||||
|
wb = load_workbook(file_object)
|
||||||
|
sheet = wb.worksheets[0]
|
||||||
|
|
||||||
|
for row in sheet.iter_rows(min_row=2):
|
||||||
|
# for temp in range(7):
|
||||||
|
# print(row[temp].value)
|
||||||
|
qus_imfomation = row[0].value
|
||||||
|
qus_A = row[1].value
|
||||||
|
qus_B = row[2].value
|
||||||
|
qus_C = row[3].value
|
||||||
|
qus_D = row[4].value
|
||||||
|
qus_ans = row[5].value
|
||||||
|
que_classcode = row[6].value
|
||||||
|
questionBank.objects.create(qus_imfomation=qus_imfomation, qus_A=qus_A, qus_B=qus_B, qus_C=qus_C, qus_D=qus_D, qus_ans=qus_ans, que_classcode=que_classcode, que_time=now_time)
|
||||||
|
return redirect('teacher_client:teacher_client')
|
||||||
|
|
||||||
|
|
||||||
|
def radix_sort(array):
|
||||||
|
"""基数排序"""
|
||||||
|
max_num = max(array)
|
||||||
|
place = 1
|
||||||
|
while max_num >= 10 ** place:
|
||||||
|
place += 1
|
||||||
|
for i in range(place):
|
||||||
|
buckets = [[] for _ in range(10)]
|
||||||
|
for num in array:
|
||||||
|
radix = int(num / (10 ** i) % 10)
|
||||||
|
buckets[radix].append(num)
|
||||||
|
j = 0
|
||||||
|
for k in range(10):
|
||||||
|
for num in buckets[k]:
|
||||||
|
array[j] = num
|
||||||
|
j += 1
|
||||||
|
return array
|
||||||
|
|
||||||
|
|
||||||
|
def binary_search(alist, data):
|
||||||
|
"""二分查找"""
|
||||||
|
n = len(alist)
|
||||||
|
first = 0
|
||||||
|
last = n - 1
|
||||||
|
if data > alist[-1]:
|
||||||
|
return alist[-1]
|
||||||
|
while first <= last:
|
||||||
|
mid = (last + first) // 2
|
||||||
|
if alist[mid] > data:
|
||||||
|
last = mid - 1
|
||||||
|
elif alist[mid] < data:
|
||||||
|
first = mid + 1
|
||||||
|
else:
|
||||||
|
return data
|
||||||
|
if abs(alist[first] - data) > abs(alist[first-1] - data):
|
||||||
|
return alist[first-1]
|
||||||
|
return alist[first]
|
||||||
|
|
||||||
|
|
||||||
|
def test_release(request):
|
||||||
|
"""用于习题发布"""
|
||||||
|
if request.method == "GET":
|
||||||
|
global TEST_CODE
|
||||||
|
TEST_CODE += 1
|
||||||
|
|
||||||
|
# 从前端获取一个考试时间 #
|
||||||
|
# test_time = request.POST.get('test_time')
|
||||||
|
|
||||||
|
time_list = []
|
||||||
|
time_select = "select id, que_time " \
|
||||||
|
"from teacher_client_questionbank"
|
||||||
|
time_res = questionBank.objects.raw(time_select)
|
||||||
|
|
||||||
|
for temp in time_res:
|
||||||
|
if temp.que_time not in time_list:
|
||||||
|
time_list.append(temp.que_time)
|
||||||
|
time_list = [float(x) for x in time_list]
|
||||||
|
time_list = radix_sort(time_list)
|
||||||
|
print(time_list)
|
||||||
|
target_time = binary_search(time_list, time.time())
|
||||||
|
questionSelect = "select id, qus_imfomation, " \
|
||||||
|
"qus_A, qus_B, qus_C, qus_D, " \
|
||||||
|
"qus_ans, " \
|
||||||
|
"que_classcode " \
|
||||||
|
"from teacher_client_questionbank " \
|
||||||
|
"where que_time =" + str(target_time)
|
||||||
|
temp_RawQuerySetquestion = questionBank.objects.raw(questionSelect)
|
||||||
|
single_choice = []
|
||||||
|
multiple_choice = []
|
||||||
|
gap_filling = []
|
||||||
|
for temp in temp_RawQuerySetquestion:
|
||||||
|
temp_classcode = temp.que_classcode
|
||||||
|
if temp.qus_ans is None:
|
||||||
|
gap_filling.append(temp)
|
||||||
|
elif len(temp.qus_ans) == 1:
|
||||||
|
single_choice.append(temp)
|
||||||
|
else:
|
||||||
|
multiple_choice.append(temp)
|
||||||
|
|
||||||
|
# testQuestionBank.objects.create(qus_imfomation=temp.qus_imfomation, qus_A=temp.qus_A, qus_B=temp.qus_B,
|
||||||
|
# qus_C=temp.qus_C, qus_D=temp.qus_D, qus_ans=temp.qus_ans,
|
||||||
|
# test_code=TEST_CODE, test_time=test_time)
|
||||||
|
|
||||||
|
total_number = len(gap_filling) + len(multiple_choice) + len(single_choice)
|
||||||
|
total_list = [x + 1 for x in range(total_number)]
|
||||||
|
single_choice_number = len(single_choice)
|
||||||
|
multiple_choice_number = len(multiple_choice)
|
||||||
|
gap_filling_number = len(gap_filling)
|
||||||
|
|
||||||
|
return render(request, "test.html", {"total_num": total_number,
|
||||||
|
"total_list": total_list,
|
||||||
|
"single_choice": single_choice,
|
||||||
|
"multiple_choice": multiple_choice,
|
||||||
|
"gap_filling": gap_filling,
|
||||||
|
"ClassCode": temp_classcode,
|
||||||
|
"TEST_CODE": TEST_CODE,
|
||||||
|
"single_choice_number": single_choice_number,
|
||||||
|
"multiple_choice_number": multiple_choice_number,
|
||||||
|
"gap_filling_number": gap_filling_number
|
||||||
|
})
|
||||||
|
|
||||||
|
# 从前端获取一个考试时间 #
|
||||||
|
test_time = request.POST.get('test_time')
|
||||||
|
#
|
||||||
|
time_list = []
|
||||||
|
time_select = "select id, que_time " \
|
||||||
|
"from teacher_client_questionbank"
|
||||||
|
time_res = questionBank.objects.raw(time_select)
|
||||||
|
|
||||||
|
for temp in time_res:
|
||||||
|
if temp.que_time not in time_list:
|
||||||
|
time_list.append(temp.que_time)
|
||||||
|
time_list = [float(x) for x in time_list]
|
||||||
|
time_list = radix_sort(time_list)
|
||||||
|
print(time_list)
|
||||||
|
target_time = binary_search(time_list, time.time())
|
||||||
|
questionSelect = "select id, qus_imfomation, " \
|
||||||
|
"qus_A, qus_B, qus_C, qus_D, " \
|
||||||
|
"qus_ans, " \
|
||||||
|
"que_classcode " \
|
||||||
|
"from teacher_client_questionbank " \
|
||||||
|
"where que_time =" + str(target_time)
|
||||||
|
temp_RawQuerySetquestion = questionBank.objects.raw(questionSelect)
|
||||||
|
for temp in temp_RawQuerySetquestion:
|
||||||
|
temp_classcode = temp.que_classcode
|
||||||
|
testQuestionBank.objects.create(qus_imfomation=temp.qus_imfomation,qus_A=temp.qus_A, qus_B=temp.qus_B, qus_C=temp.qus_C, qus_D=temp.qus_D,qus_ans=temp.qus_ans,test_code=TEST_CODE, test_time=test_time)
|
||||||
|
return HttpResponse("发布成功")
|
||||||
|
# total_number = len(gap_filling) + len(multiple_choice) + len(single_choice)
|
||||||
|
# total_list = [x+1 for x in range(total_number)]
|
||||||
|
# single_choice_number = len(single_choice)
|
||||||
|
# multiple_choice_number = len(multiple_choice)
|
||||||
|
# gap_filling_number = len(gap_filling)
|
||||||
|
#
|
||||||
|
# return render(request, "test.html", {"total_num": total_number,
|
||||||
|
# "total_list": total_list,
|
||||||
|
# "single_choice": single_choice,
|
||||||
|
# "multiple_choice": multiple_choice,
|
||||||
|
# "gap_filling": gap_filling,
|
||||||
|
# "ClassCode": temp_classcode,
|
||||||
|
# "test_time": test_time,
|
||||||
|
# "single_choice_number": single_choice_number,
|
||||||
|
# "multiple_choice_number": multiple_choice_number,
|
||||||
|
# "gap_filling_number": gap_filling_number
|
||||||
|
# })
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue