def uploadData(teachingid, dataurl): now = utils.getNow() try: teaching = Teaching.objects.filter(id=teachingid).update(dataurl=dataurl, updatetime=now) except: return None else: return teaching
def updateExperimentTamplate(experimentid, templateid): now = utils.getNow() try: experiment = Experiment.objects.filter(id=experimentid).update(templateid=templateid, updatetime=now) except: return None else: return experiment
def updateExperimentdescription(experimentid,experimentdescription): now = utils.getNow() try: experiment = Experiment.objects.filter(id=experimentid).update(desc=experimentdescription, updatetime=now) except: return None else: return True
def addTeaching(experimentid, deadline, teacherid, point, remark, dataurl, stulisturl, templateid, videos): now = utils.getNow() teaching = Teaching(experimentid=experimentid, deadline=deadline, teacherid=teacherid, point=point, remark=remark, dataurl=dataurl, stulisturl=stulisturl, templateid=templateid, videos=videos, status=CONSTANTS.TEACHING_IS_RUNNING, isdelete=CONSTANTS.ISDELETE_NOT, createtime=now, updatetime=now) teaching.save() return teaching.id
def updateExperimentVideos(experimentid, videos): now = utils.getNow() try: experiment = Experiment.objects.filter(id=experimentid).update(videos=videos, updatetime=now) except: return None else: return experiment
def addAdmin(teacherid): now = utils.getNow() admin = Admin(teacherid=teacherid, isdelete=CONSTANTS.ISDELETE_NOT, createtime=now, updatetime=now) admin.save() return admin.id
def updateTeachingVideoById(teachingid, videos): now = utils.getNow() try: teaching = Teaching.objects.filter(id=teachingid).update(videos=videos, updatetime=now) except: return None else: return teaching
def uploadTemplate(teachingid, templateid): now = utils.getNow() try: teaching = Teaching.objects.filter(id=teachingid).update(templateid=templateid, updatetime=now) except: return None else: return teaching
def resetPassword(teacherid): try: teacher = Teacher.objects.filter(id=teacherid, isdelete=CONSTANTS.ISDELETE_NOT).update( password=CONSTANTS.DEFUALT_PASSWORD, updatetime=utils.getNow()) except: return None else: return teacher
def addStudent(name, number, filterinfoid): now = utils.getNow() student = Student(name=name, number=number, filterinfoid=filterinfoid, createtime=now, isdelete=CONSTANTS.ISDELETE_NOT, updatetime=now) student.save() return student.id
def saveVideo(name, url, experimentid): now = utils.getNow() video = Video(name=name, url=url, experimentid=experimentid, isdelete=CONSTANTS.ISDELETE_NOT, createtime=now, updatetime=now) video.save() return video.id
def addFilterInfo(registyear, major, classname): now = utils.getNow() filterinfo = FilterInfo(registyear=registyear, major=major, classname=classname, isdelete=CONSTANTS.ISDELETE_NOT, createtime=now, updatetime=now) filterinfo.save() return filterinfo.id
def addReport(teachingid, stunid): now = utils.getNow() report = Report(stuid=stunid, teachingid=teachingid, score=0, status=CONSTANTS.REPORT_STATUS_PENDING, isdelete=CONSTANTS.ISDELETE_NOT, createtime=now, updatetime=now) report.save() return report.id
def updateTeachingDeadlineById(teachingid, deadline): now = utils.getNow() if now > deadline: status = CONSTANTS.TEACHING_IS_STOP else: status = CONSTANTS.TEACHING_IS_RUNNING try: teacher = Teaching.objects.filter(id=teachingid).update(deadline=deadline, status=status, updatetime=now) except: return None else: return teacher
def editpassword(request): teacherid = utils.getCookie(request, "teacherid") if (teacherid is None) or teacherid == "": responseReturn = Response(-2, "请登录") return HttpResponse(responseReturn.__str__()) newpwd = utils.getParam(request, "newpwd") oldpwd = utils.getParam(request, "oldpwd") teacher = TeacherService.getTeacherById(teacherid) if oldpwd != teacher.password: responseReturn = Response("-1", "原密码输入有误") return HttpResponse(responseReturn) teacher.password = newpwd teacher.updatetime = utils.getNow() result = TeacherService.editPassword(teacherid, newpwd) if result is not None: responseReturn = Response(None, None) else: responseReturn = Response("-1", "网络忙,请稍后重试!") response = HttpResponse(responseReturn.__str__()) return response
def addTemplate(experimentid, templateurl): now = utils.getNow() template = Template(experimentid=experimentid, url=templateurl, isdelete=CONSTANTS.ISDELETE_NOT, createtime=now, updatetime=now) template.save() return template.id
def addTeacher(name, number): now = utils.getNow() teacher = Teacher(name=name, number=number, password=CONSTANTS.DEFUALT_PASSWORD, isdelete=CONSTANTS.ISDELETE_NOT, createtime=now, updatetime=now) teacher.save() return teacher.id
def scoreReport(reportid, score): report = Report.objects.filter(id=reportid).update( score=score, status=CONSTANTS.REPORT_STATUS_SCORE, updatetime=utils.getNow()) return report
def submintReport(reportid, filename): report = Report.objects.filter(id=reportid).update( url=filename, status=CONSTANTS.REPORT_STATUS_SUBMIT, updatetime=utils.getNow()) return report