def v_completedexp(request): stuid = utils.getCookie(request, "stuid") if (stuid is None) or stuid == "": return getloginResponse(request) stuname = utils.getCookie(request, "stuname") page = utils.getParam(request, "page") if (page is None) or page == "": page = 1 else: page = int(page) count = TeachingService.getCountPageByStu(stuid, CONSTANTS.TEACHING_IS_STOP) countpage = 0 i = 0 if count > 0: if count % 10 > 0: i = 1 countpage = count / 10 + i teachingRunList = TeachingService.getTeachingByStu(stuid, CONSTANTS.TEACHING_IS_STOP, page) experimentList = ExperimentService.getAllExperiment() # 获取用于菜单的实验列表 experimentMenuList = [] for experiment in experimentList: experimentTemp = experiment.copy() experimentName = experimentTemp["name"] if len(experimentName) > 8: experimentName = experimentName[0:10] + "..." experimentTemp["name"] = experimentName experimentMenuList.append(experimentTemp) teachingCount = getTeachingCount(stuid) return render(request, "completedexp.html", {"teachingList": teachingRunList, "countpage": countpage, "experimentMenuList": experimentMenuList, "experimentList": experimentList, "teachingCount": teachingCount, "stuname": stuname})
def getTeachingCount(stuid): runCount = TeachingService.getCountPageByStu(stuid, CONSTANTS.TEACHING_IS_RUNNING) stopCount = TeachingService.getCountPageByStu(stuid, CONSTANTS.TEACHING_IS_STOP) teachingCount = {"runCount": runCount, "stopCount": stopCount} return teachingCount