def UpdateProblem(request): if 'course' not in request.session.keys(): messages.success(request, "先选择课程") return HttpResponseRedirect("/teacher/") Map = {} coursename = request.session['course'] if request.method == "POST": query = request.POST.get('query') update = request.POST.get('update') if query != None: optionproblem = request.POST.get('optionproblem') problem = coursedb.Get_Course_Problem(coursename) Map['problem'] = problem Map['knowledges'] = knowledgedb.Get_Course_Knowledge(coursename) Map['optionproblem'] = knowledgedb.Get_a_Course_Problem( coursename, optionproblem) Map['knowledge'] = knowledgedb.Get_Knowledge_BY_Problem( coursename, optionproblem) Map['table'] = GetTable1("", coursename) return render(request, 'problem.html', Map) elif update != None: optionproblem = request.POST.get('optionproblem') score = request.POST.get('score') problem_detail = request.POST.get('problem_detail') knowledges = request.POST.getlist('knowledges') if score == "" or score == None: score = 0 if optionproblem != None and score != None: coursedb.Add_Course_Problem1(coursename, optionproblem, score, problem_detail) knowledgedb.DelProblemKnowledge(coursename, optionproblem) for item in knowledges: knowledgedb.Add_Problem_Knowledge(coursename, optionproblem, item) return HttpResponseRedirect('/problem/')
def GetTable(a, coursename): knowledges = knowledgedb.Get_Course_Knowledge(coursename) all = [] ID = 1 for item in knowledges: now = [] now.append(ID) now.append(item) now.append(knowledgedb.Get_Knowledge_Score(coursename, item)) s = "" problem = knowledgedb.Get_Problem_BY_Knowledge(coursename, item) first = True for tmp in problem: if first: first = False else: s += ', ' s += tmp now.append(s) ID += 1 all.append(now) ans = [] for every in all: if a in every[1] or a in every[2]: ans.append(every) return ans
def Problem(request): if 'course' not in request.session.keys(): messages.success(request, "先选择课程") return HttpResponseRedirect("/teacher/") Map = {} coursename = request.session['course'] problem = coursedb.Get_Course_Problem(coursename) Map['problem'] = problem Map['knowledges'] = knowledgedb.Get_Course_Knowledge(coursename) if len(problem) != 0: Map['optionproblem'] = knowledgedb.Get_a_Course_Problem( coursename, problem[0][0]) Map['knowledge'] = knowledgedb.Get_Knowledge_BY_Problem( coursename, problem[0][0]) Map['table'] = GetTable1("", coursename) if request.method == "POST": if request.POST.get('problem') != None: Map['table'] = GetTable1(request.POST.get('problem'), coursename) return render(request, 'problem.html', Map)
def Knowledge(request): if 'course' not in request.session.keys(): messages.success(request, "先选择课程") return HttpResponseRedirect("/teacher/") Map = {} coursename = request.session['course'] knowledge = knowledgedb.Get_Course_Knowledge(coursename) Map['knowledge'] = knowledge Map['problems'] = coursedb.Get_Course_Problem(coursename) if len(knowledge) != 0: Map['problem'] = knowledgedb.Get_Problem_BY_Knowledge( coursename, knowledge[0]) Map['optionknowledge'] = knowledgedb.Get_a_Course_Knowledge( coursename, knowledge[0]) Map['table'] = GetTable("", coursename) if request.method == "POST": if request.POST.get('knowledge') != None: Map['table'] = GetTable(request.POST.get('knowledge'), coursename) return render(request, 'knowledge.html', Map)
def UpdateKnowledge(request): if 'course' not in request.session.keys(): messages.success(request, "先选择课程") return HttpResponseRedirect("/teacher/") Map = {} coursename = request.session['course'] if request.method == "POST": #a = request.POST.getlist('problems') query = request.POST.get('query') update = request.POST.get('update') if query != None: optionknowledge = request.POST.get('optionknowledge') knowledge = knowledgedb.Get_Course_Knowledge(coursename) Map['knowledge'] = knowledge Map['problems'] = coursedb.Get_Course_Problem(coursename) problem = knowledgedb.Get_Problem_BY_Knowledge( coursename, optionknowledge) Map['problem'] = problem Map['optionknowledge'] = knowledgedb.Get_a_Course_Knowledge( coursename, optionknowledge) #return HttpResponse(Map['knowledge_detail']) Map['table'] = GetTable("", coursename) return render(request, 'knowledge.html', Map) elif update != None: optionknowledge = request.POST.get('optionknowledge') knowledge_detail = request.POST.get('knowledge_detail') problems = request.POST.getlist('problems') if optionknowledge != None and knowledge_detail != None and problems != None: knowledgedb.Add_Course_Knowledge(coursename, optionknowledge, knowledge_detail) knowledgedb.DelKnowledgeProblem(coursename, optionknowledge) for item in problems: knowledgedb.Add_Problem_Knowledge(coursename, item, optionknowledge) return HttpResponseRedirect('/knowledge/')
def StudentID(request, studentid): if 'course' not in request.session.keys(): messages.success(request, "先选择课程") return HttpResponseRedirect("/teacher/") Map = {} coursename = request.session['course'] thisstudent = studentdb.Get_Student_information(studentid) student = [] student.append(thisstudent.studentid) student.append(thisstudent.studentname) student.append(thisstudent.email) student.append(thisstudent.phone) student.append(thisstudent.sex) thisstudentscore = studentdb.Get_Student_Course(studentid, coursename) thisstudentproblem = coursedb.Get_Course_Problem(coursename) table = [] ID = 1 for i in range(len(thisstudentproblem)): now = [] now.append(ID) now.append(thisstudentscore[1][i][0]) tmp = knowledgedb.Get_Knowledge_BY_Problem(coursename, thisstudentscore[1][i][0]) ccc = "" first = True for cnt in tmp: if first: first = False else: ccc += "," ccc += cnt now.append(ccc) now.append(thisstudentscore[1][i][1]) now.append(thisstudentproblem[i][2]) ID += 1 table.append(now) Map['sum'] = thisstudentscore[0] Map['table'] = table Map['student'] = student table1 = [] knowledge = knowledgedb.Get_Course_Knowledge(coursename) ID = 1 for item in knowledge: now = [] now.append(ID) ID += 1 now.append(item) tmp = knowledgedb.Get_Problem_BY_Knowledge(coursename, item) ccc = "" first = True for cnt in tmp: if first: first = False else: ccc += "," ccc += cnt now.append(ccc) now.append( knowledgedb.Get_Knowledge_Score_Student(coursename, item, studentid)) now.append(knowledgedb.Get_Knowledge_Score(coursename, item)) table1.append(now) Map['table1'] = table1 return render(request, 'student.html', Map)