259 lines
8.5 KiB
Python
259 lines
8.5 KiB
Python
import json
|
|
import time
|
|
|
|
from django.shortcuts import render
|
|
from server.models import Task,StudentandTercher,Comment,Liuyan,CooperationMind,Jiaoben
|
|
from server_auth.models import MindUser
|
|
|
|
def front_comment(type):
|
|
front_datas = []
|
|
if len(type) == 0:
|
|
return front_datas
|
|
for i in range(len(type)):
|
|
front_data = f"""
|
|
<div class="rating">
|
|
<h1>{type[i]}</h1>
|
|
<input type="radio" name="rating{i}" id="5{i}" value="5" />
|
|
<label for="5{i}"><i class="icon ion-md-star-outline"></i></label>
|
|
<input type="radio" name="ratin{i}" id="4{i}" value="4" />
|
|
<label for="4{i}"><i class="icon ion-md-star-outline"></i></label>
|
|
<input type="radio" name="rating{i}" id="3{i}" value="3" />
|
|
<label for="3{i}"><i class="icon ion-md-star-outline"></i></label>
|
|
<input type="radio" name="rating{i}" id="2{i}" value="2" />
|
|
<label for="2{i}"><i class="icon ion-md-star-outline"></i></label>
|
|
<input type="radio" name="rating{i}" id="1{i}" value="1" />
|
|
<label for="1{i}"><i class="icon ion-md-star-outline"></i></label>
|
|
</div>"""
|
|
front_datas.append(front_data)
|
|
return front_datas
|
|
def to_dashboard(request):
|
|
"""
|
|
主界面
|
|
"""
|
|
jiaoben = Jiaoben.objects.order_by('id').last().jiaoben
|
|
param = {"page": "b9b101e","jiaoben": jiaoben}
|
|
return render(request, "html/dashboard.html", param)
|
|
|
|
def to_baiban(request):
|
|
"""
|
|
协作白板
|
|
"""
|
|
test_date = request.GET.get('test')
|
|
param = {"page": "share",
|
|
"path": test_date}
|
|
return render(request, "html/baiban.html", param)
|
|
|
|
def to_pinglun(request):
|
|
user = request.user
|
|
test_date = request.GET.get('id')
|
|
comment_list = Comment.objects.filter(pinglun_id=test_date) # 从数据库找出该文章的评论数据对象
|
|
comment_type = CooperationMind.objects.get(id=test_date).comment_type # 找出对应的comment_type字段
|
|
front_code = front_comment((json.loads(comment_type))['type'])
|
|
param = {"path": test_date,
|
|
"comment_list": comment_list,
|
|
"front_code": front_code}
|
|
print(test_date)
|
|
return render(request, "html/commont.html", param)
|
|
|
|
def to_admin(request):
|
|
username = request.user
|
|
# supper = MindUser.objects.filter(username=username).type_t_or_s
|
|
try:
|
|
if username.type_t_or_s == 3:
|
|
datas = MindUser.objects.filter(type_t_or_s=2)
|
|
return render(request, "html/admin.html",{"datas":datas})
|
|
else:
|
|
return render(request, "html/dashboard.html")
|
|
except:
|
|
return render(request, "html/dashboard.html")
|
|
def to_share(request):
|
|
"""
|
|
分享页面
|
|
"""
|
|
param = {"page": "share"}
|
|
return render(request, "html/dashboard.html", param)
|
|
|
|
def to_echarts(request):
|
|
"""
|
|
图表页面
|
|
"""
|
|
param = {"page": "share"}
|
|
return render(request, "html/echats.html", param)
|
|
def to_chat_room(request):
|
|
"""
|
|
聊天室页面
|
|
"""
|
|
param = {"page": "chat_room",
|
|
"username":request.user.username}
|
|
return render(request, "html/wechat_2.html", param)
|
|
def to_rengwu(request):
|
|
"""
|
|
任务列表
|
|
"""
|
|
tasks = Task.objects.all() # 查询所有的任务
|
|
return render(request, "html/rengwu.html", {'tasks': tasks})
|
|
|
|
def to_kecheng(request):
|
|
"""
|
|
课程列表
|
|
"""
|
|
user = request.user
|
|
kechengs = StudentandTercher.objects.all() # 查询所有的任务
|
|
xiaozu = MindUser.objects.get(username=user).select_xiaozu
|
|
kz = MindUser.objects.get(username=user).select_class
|
|
xiaozu = json.loads(xiaozu)['xiaozu']
|
|
kc = json.loads(kz)['class']
|
|
test = zip(kc,xiaozu)
|
|
it3 = []
|
|
for it1,it2 in test:
|
|
it3.append(str(it1) + "课程" + str(it2) + "小组")
|
|
return render(request, "html/kecheng.html", {'kechengs': kechengs,"select":it3})
|
|
|
|
def to_write(request):
|
|
"""
|
|
协同编辑页面
|
|
"""
|
|
param = {"page": "write"}
|
|
return render(request, "html/write_2.html", param)
|
|
|
|
def to_star(request):
|
|
"""
|
|
收藏页面
|
|
"""
|
|
param = {"page": "star"}
|
|
return render(request, "html/dashboard.html", param)
|
|
|
|
|
|
def to_recycle(request):
|
|
"""
|
|
回收站
|
|
"""
|
|
param = {"page": "recycle"}
|
|
return render(request, "html/dashboard.html", param)
|
|
|
|
|
|
def to_detail(request):
|
|
"""
|
|
详情页面
|
|
"""
|
|
param = {'id': request.GET.get('id')}
|
|
return render(request, "html/detail.html", param)
|
|
|
|
def to_qunti(request):
|
|
"""
|
|
详情页面
|
|
"""
|
|
import re
|
|
import random
|
|
def remove_digits(s):
|
|
return re.sub(r'\d+', '', s)
|
|
param = {'id': request.GET.get('id')}
|
|
name = CooperationMind.objects.get(id=request.GET.get('id')).coop_mind_name
|
|
kecheng = json.loads(CooperationMind.objects.get(id=request.GET.get('id')).belong_to)
|
|
# 获取Student的所有记录
|
|
student = []
|
|
data = []
|
|
data_time = []
|
|
xyz = []
|
|
xyz2 = []
|
|
all_student = MindUser.objects.all()
|
|
# 遍历所有记录
|
|
for stu in all_student:
|
|
class_name = json.loads(stu.select_class)['class']
|
|
xiaozu = json.loads(stu.select_xiaozu)['xiaozu']
|
|
test = zip(class_name, xiaozu)
|
|
# xiaozu = MindUser.objects.get(username=username).select_xiaozu
|
|
# kz = MindUser.objects.get(username=username).select_class
|
|
# xiaozu = json.loads(xiaozu)['xiaozu']
|
|
# kc = json.loads(kz)['class']
|
|
# test = zip(kc, xiaozu)
|
|
# it3 = []
|
|
# for it1, it2 in test:
|
|
# it3.append(str(it1) + "课程" + str(it2) + "小组")
|
|
it3 = []
|
|
for it1, it2 in test:
|
|
it3.append(str(it1) + "第" + str(it2) + "小组")
|
|
if name in it3:
|
|
student.append(stu.username)
|
|
data.append([random.uniform(110,150),random.uniform(100,150),random.uniform(100,150)])
|
|
data_time.append([random.uniform(10,20),random.uniform(20,40),random.uniform(40,60),random.uniform(60,80),random.uniform(80,100)])
|
|
xyz.append(random.uniform(300,800))
|
|
xyz2.append(random.uniform(200,600))
|
|
sui1 = []
|
|
sui2 = []
|
|
sui3 = []
|
|
sui4 = []
|
|
sui5 = []
|
|
sui6 = []
|
|
sui7 = []
|
|
sui8 = []
|
|
sui9 = []
|
|
for i in range(len(student)):
|
|
sui1.append(random.uniform(200, 600))
|
|
sui2.append(random.uniform(100, 400))
|
|
sui3.append(random.uniform(300, 700))
|
|
sui4.append(random.uniform(200, 600))
|
|
sui5.append(random.uniform(500, 900))
|
|
sui6.append(random.uniform(700, 600))
|
|
sui7.append(random.uniform(200, 300))
|
|
sui8.append(random.uniform(600, 900))
|
|
sui9.append(random.uniform(100, 200))
|
|
|
|
|
|
print(remove_digits(kecheng['belong'][0]))
|
|
datas = zip(student,data)
|
|
datas2 = zip(student,data)
|
|
datas3 = zip(student,xyz,xyz2)
|
|
datas4 = zip(student,data_time)
|
|
student2 = student[:]
|
|
student3 = student[:]
|
|
random.shuffle(student2)
|
|
random.shuffle(student3)
|
|
|
|
student4 = zip(student,student3)
|
|
|
|
return render(request, "html/echats.html", {"param":param,"name":name,"student":student,"datas":datas,"datas2":datas2,"datas3":datas3,"student4"
|
|
:student4,"sui1":sui1,"sui2":sui2,"sui3":sui3,"sui4":sui4,"sui5":sui5,"sui6":sui6,"sui7":sui7,"sui8":sui8,"sui9":sui9,"datas4":datas4})
|
|
|
|
|
|
def share_to_detail(request):
|
|
"""
|
|
详情页面
|
|
"""
|
|
param = {'h': request.GET.get('h'), 'u': request.GET.get('u')}
|
|
return render(request, "html/detail.html", param)
|
|
|
|
def teacher_login(request):
|
|
"""
|
|
详情页面
|
|
"""
|
|
param = {'id': request.GET.get('id')}
|
|
return render(request, "html/login.html", param)
|
|
|
|
def to_information(request):
|
|
"""
|
|
个人信息页面
|
|
"""
|
|
param = {"page": "recycle"}
|
|
username = request.user
|
|
datas = MindUser.objects.filter(username=username)
|
|
xiaozu = MindUser.objects.get(username=username).select_xiaozu
|
|
kz = MindUser.objects.get(username=username).select_class
|
|
xiaozu = json.loads(xiaozu)['xiaozu']
|
|
kc = json.loads(kz)['class']
|
|
test = zip(kc, xiaozu)
|
|
it3 = []
|
|
for it1, it2 in test:
|
|
it3.append(str(it1) + "课程" + str(it2) + "小组")
|
|
|
|
return render(request, "html/informations.html", {"datas":datas,"it3":it3})
|
|
|
|
def to_liuyan(request):
|
|
"""
|
|
留言板页面
|
|
"""
|
|
# param = {"page": "recycle"}
|
|
datas = MindUser.objects.all()
|
|
liuyans = Liuyan.objects.filter(liuyan_id=request.user.id)
|
|
return render(request, "html/liuyan.html", {"datas":datas,"liuyans":liuyans})
|