Beispiel #1
0
def adminlogin(request):
    superuser = superadmin.user
    superpwd = superadmin.password

    adminid = utils.getParam(request, "adminid")
    adminpwd = utils.getParam(request, "adminpwd")

    if superuser == adminid and superpwd == adminpwd:
        responseReturn = Response(None, None)
        response = HttpResponse(responseReturn.__str__())
        utils.setCookie(response, "issuperadmin", "1")
        utils.setCookie(response, "adminid", "0")
        utils.setCookie(response, "adminname", str("superadmin"))
        return response
    teacher = TeacherService.getTeacherByNumAndPwd(adminid, adminpwd)
    if teacher is None:
        responseReturn = Response("-1", "用户名或密码错误")
        return HttpResponse(responseReturn.__str__())
    admin = AdminService.getAdminByTeacherId(teacher.id)
    if admin is not None:
        responseReturn = Response(None, None)
        response = HttpResponse(responseReturn.__str__())
        utils.setCookie(response, "issuperadmin", "0")
        utils.setCookie(response, "adminid", str(admin.id))
        utils.setCookie(response, "adminname", teacher.name)
        return response
    else:
        responseReturn = Response("-1", "登录失败")
        return HttpResponse(responseReturn.__str__())
Beispiel #2
0
def getStudentByFilterInfoId(request):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    filterid = utils.getParam(request, "filterid")
    if (filterid == "" or filterid is None):
        responseReturn = Response(-1, "请选择班级!")
        return HttpResponse(responseReturn.__str__())
    filterinfo = FilterInfoService.getFilterInfoById(filterid)
    if filterinfo is None:
        responseReturn = Response(-1, "班级不存在!")
        return HttpResponse(responseReturn.__str__())
    studentList = StudentService.getStudentListByFilterInfo(filterid)
    if studentList is None:
        responseReturn = Response(-1, "此班级没有学生!")
        return HttpResponse(responseReturn.__str__())
    studentDictList = []
    for student in studentList:
        dict = model_to_dict(student)
        del dict["isdelete"]
        del dict["createtime"]
        del dict["updatetime"]
        dict["registyear"] = filterinfo.registyear
        dict["major"] = filterinfo.major
        dict["classname"] = filterinfo.classname
        studentDictList.append(dict)
    studentDictListStr = json.dumps(studentDictList, ensure_ascii=False)
    responseReturn = Response(None, None)
    responseReturn.setRes(studentDictListStr)
    return HttpResponse(responseReturn.__str__())
Beispiel #3
0
def deleteTeachingByid(request):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    teachingid = utils.getParam(request, "teachingid")
    TeachingService.deleteTeachingByid(teachingid)
    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Beispiel #4
0
def resetTeacherPwd(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    teacherid = utils.getParam(request, "teacherid")
    TeacherService.resetPassword(teacherid)
    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Beispiel #5
0
def deleteStudentByid(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    stuid = utils.getParam(request, "studentid")
    StudentService.deleteStudent(stuid)
    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Beispiel #6
0
def updateTeachingDeadline(request):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    teachingid = utils.getParam(request, "teachingid")
    deadlinestr = utils.getParam(request, "deadline") + " 00:00:00"
    deadline = datetime.datetime.strptime(deadlinestr, "%Y-%m-%d %H:%M:%S")
    TeachingService.updateTeachingDeadlineById(teachingid, deadline)
    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Beispiel #7
0
def deleteTeacherByid(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    teacherid = utils.getParam(request, "teacherid")
    count = TeachingService.getCountByTea(teacherid)
    if count > 0:
        responseReturn = Response("-1", "该教师下有未删除的实验教学")
        return HttpResponse(responseReturn.__str__())
    TeacherService.deleteTeacher(teacherid)
    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Beispiel #8
0
def stulogin(request):
    stunum = utils.getParam(request, "stuid")
    stuname = utils.getParam(request, "stuname")
    student = StudentService.getStudentByNumAndName(stuname, stunum)
    if student != None:
        responseReturn = Response(None, None)
        response = HttpResponse(responseReturn.__str__())
        utils.setCookie(response, "stuid", str(student.id))
        utils.setCookie(response, "stuname", student.name)
        utils.setCookie(response, "stunum", student.number)
        return response
    else:
        responseReturn = Response("-1", "登录失败")
        return HttpResponse(responseReturn.__str__())
Beispiel #9
0
def teacherlogin(request):
    number = utils.getParam(request, "teaid")
    passwd = utils.getParam(request, "passwd")
    teacher = TeacherService.getTeacherByNumber(number)
    if (teacher is None) or (teacher.password != passwd):
        responseReturn = Response("-1", "登录失败")
        return HttpResponse(responseReturn.__str__())
    else:
        responseReturn = Response(None, None)
        response = HttpResponse(responseReturn.__str__())
        utils.setCookie(response, "teacherid", str(teacher.id))
        utils.setCookie(response, "teachernumber", teacher.number)
        utils.setCookie(response, "teachername", teacher.name)
        return response
Beispiel #10
0
def scoreReport(request):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    reportid = utils.getParam(request, "reportid")
    scorestr = utils.getParam(request, "score")
    if scorestr == "" or scorestr == "0":
        responseReturn = Response(-1, "打分异常")
        response = HttpResponse(responseReturn.__str__())
        return response
    score = int(scorestr)
    ReportService.scoreReport(reportid, score)
    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Beispiel #11
0
def updateTeachingVideo(request):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    teachingid = utils.getParam(request, "teachingid")
    videos = utils.getParam(request, "videos")
    if teachingid == "" or teachingid is None:
        responseReturn = Response(-1, "操作有误,请重试")
        return HttpResponse(responseReturn.__str__())
    if videos == "" or videos is None:
        responseReturn = Response(-1, "更换的视频不能为空")
        return HttpResponse(responseReturn.__str__())
    TeachingService.updateTeachingVideoById(teachingid, videos)
    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Beispiel #12
0
def getListTemplate(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        return getloginResponse(request)
    type = utils.getParam(request, "type")
    if type is None or type == "":
        responseReturn = Response("-1", "!")
        return HttpResponse(responseReturn.__str__())
    templateaddr = ""
    filename = ""
    if type == CONSTANTS.ADD_USER_TYPE_STUDENT:
        templateaddr = CONSTANTS.ADDUSERTEMPLATEURL_PRE + "student.xlsx"
        filename = "学生名单模板"
    elif type == CONSTANTS.ADD_USER_TYPE_TEACHER:
        templateaddr = CONSTANTS.ADDUSERTEMPLATEURL_PRE + "teacher.xlsx"
        filename = "教师名单模板"
    elif type == CONSTANTS.ADD_USER_TYPE_ADMIN:
        templateaddr = CONSTANTS.ADDUSERTEMPLATEURL_PRE + "admin.xlsx"
        filename = "管理员名单模板"
    if os.path.exists(templateaddr) != True:
        return HttpResponse("未找到文件")
    file = open(templateaddr, "rb")
    response = FileResponse(file)
    response['Content-Type'] = 'application/octet-stream'
    response['Content-Disposition'] = 'attachment;filename="%s"' % (
        urlquote(filename + '.xlsx'))
    return response
Beispiel #13
0
def uploadData(request):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    teachingid = utils.getParam(request, "teachingid")
    file = request.FILES.get('file', None)
    if file is None:
        return HttpResponse(
            "<script>if(confirm('上传的文件为空')){history.go(-1);location.reload()}else{history.go(-1);location.reload()}</script>"
        )
    filename = file.name
    filesuffix = os.path.splitext(filename)[1]
    if filesuffix != ".xsl" and filesuffix != ".xlsx":
        return HttpResponse(
            "<script>if(confirm('实验数据必须为excel')){history.go(-1);location.reload()}else{history.go(-1);location.reload()}</script>"
        )
    filename = str(uuid.uuid1()) + filesuffix
    fp = open(os.path.join(CONSTANTS.DATAURL_PRE, filename), 'wb+')
    for chunk in file.chunks():  # 分块写入文件
        fp.write(chunk)
    fp.close()
    TeachingService.uploadData(teachingid, filename)
    return HttpResponse(
        "<script>if(confirm('上传成功')){history.go(-1);location.reload()}else{history.go(-1);location.reload()}</script>"
    )
Beispiel #14
0
def updateExperimentTemplate(request):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    experimentid = utils.getParam(request, "experimentid")
    file = request.FILES.get('file', None)
    if file is None:
        return HttpResponse(
            "<script>if(confirm('上传的文件为空')){history.go(-1);location.reload()}else{history.go(-1);location.reload()}</script>"
        )
    filename = file.name
    filesuffix = os.path.splitext(filename)[1]
    if filesuffix != ".doc" and filesuffix != ".docx":
        return HttpResponse(
            "<script>if(confirm('模板必须为word格式')){history.go(-1);location.reload()}else{history.go(-1);location.reload()}</script>"
        )
    filename = str(uuid.uuid1()) + filesuffix
    fp = open(os.path.join(CONSTANTS.TEMPLATEURL_PRE, filename), 'wb+')
    for chunk in file.chunks():  # 分块写入文件
        fp.write(chunk)
    fp.close()
    templateid = TemplateService.addTemplate(experimentid, filename)
    ExperimentService.updateExperimentTamplate(experimentid, templateid)
    return HttpResponse(
        "<script>if(confirm('上传成功')){history.go(-1);location.reload()}else{history.go(-1);location.reload()}</script>"
    )
Beispiel #15
0
def addTeacher(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    teachernum = utils.getParam(request, "teachernum")
    teachername = utils.getParam(request, "teachername")
    if (teachername == "" or teachernum == ""):
        responseReturn = Response("-1", "填写的信息不能为空!")
        return HttpResponse(responseReturn.__str__())
    teacher = TeacherService.getTeacherByNumber(teachernum)
    if teacher is not None:
        responseReturn = Response("-1", "此教师已经存在!")
        return HttpResponse(responseReturn.__str__())
    TeacherService.addTeacher(teachername, teachernum)
    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Beispiel #16
0
def addStudent(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    studentnum = utils.getParam(request, "studentnum")
    studentname = utils.getParam(request, "studentname")
    filterinfoid = utils.getParam(request, "filterinfoid")
    if (studentname == "" or studentnum == "" or filterinfoid == ""):
        responseReturn = Response("-1", "填写的信息不能为空!")
        return HttpResponse(responseReturn.__str__())
    student = StudentService.getStudentByNum(studentnum)
    if student is not None:
        responseReturn = Response("-1", "此学生已经存在!")
        return HttpResponse(responseReturn.__str__())

    StudentService.addStudent(studentname, studentnum, filterinfoid)
    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Beispiel #17
0
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
Beispiel #18
0
def deleteAdminByid(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    issuperadmin = utils.getCookie(request, "issuperadmin")
    if issuperadmin != "1" or issuperadmin is None:
        responseReturn = Response("-1", "您不是超级管理员,没有删除管理员的权限!")
        return HttpResponse(responseReturn.__str__())
    deleteadminid = utils.getParam(request, "adminid")
    deleteAdmin = AdminService.getAdminById(deleteadminid)
    count = TeachingService.getCountByTea(deleteAdmin.teacherid)
    if count > 0:
        responseReturn = Response("-1", "该教师下有未删除的实验教学")
        return HttpResponse(responseReturn.__str__())
    admin = AdminService.deleteAmin(deleteadminid)
    if admin is None:
        responseReturn = Response("-1", "删除失败!")
        return HttpResponse(responseReturn.__str__())
    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Beispiel #19
0
def updateExperimentVideo(request):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    experimentid = utils.getParam(request, "experimentid")
    videos = utils.getParam(request, "videos")
    if (experimentid is None) or experimentid == "":
        responseReturn = Response(-1, "请重新选择实验!")
        return HttpResponse(responseReturn.__str__())
    if (videos is None) or videos == "":
        responseReturn = Response(-1, "修改视频异常!")
        return HttpResponse(responseReturn.__str__())
    experiment = ExperimentService.updateExperimentVideos(
        experimentid, videos)
    if experiment is None:
        responseReturn = Response(-1, "网络异常,请重试!")
        return HttpResponse(responseReturn.__str__())

    responseReturn = Response(0, "修改成功!")
    return HttpResponse(responseReturn.__str__())
Beispiel #20
0
def uploadVideo(request):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    experimentid = utils.getParam(request, "experimentid")
    file = request.FILES.get('file', None)
    name = utils.getParam(request, "name")
    if experimentid == "":
        responseReturn = Response(-1, "请选择实验!")
        return HttpResponse(responseReturn.__str__())
    if file is None:
        responseReturn = Response(-1, "上传文件为空!")
        return HttpResponse(responseReturn.__str__())
    filename = file.name
    filesuffix = os.path.splitext(filename)[1]
    if filesuffix != ".mp4" and filesuffix != ".rmvb":
        responseReturn = Response(-1, "视屏格式应为MP4、rmvb!")
        return HttpResponse(responseReturn.__str__())
    filename = str(uuid.uuid1()) + filesuffix
    fp = open(os.path.join(CONSTANTS.EXPERIMENTVIDEOURL_PRE, filename), 'wb+')
    for chunk in file.chunks():  # 分块写入文件
        fp.write(chunk)
    fp.close()
    videoid = VideoService.saveVideo(name, filename, experimentid)
    if videoid is None:
        responseReturn = Response(-1, "上传失败,请重试!")
        return HttpResponse(responseReturn.__str__())
    video = {"id": videoid, "name": name, "url": filename}
    responseReturn = Response(None, None)
    responseReturn.setRes(json.dumps(video))
    return HttpResponse(responseReturn.__str__())
Beispiel #21
0
def addFilterInfo(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    registyear = utils.getParam(request, "registyear")
    major = utils.getParam(request, "major")
    classname = utils.getParam(request, "classname")
    if registyear is None or registyear == "":
        responseReturn = Response(-1, "请输入入学年份~")
        return HttpResponse(responseReturn.__str__())

    if major is None or major == "":
        responseReturn = Response(-1, "请输入专业~")
        return HttpResponse(responseReturn.__str__())

    if classname is None or classname == "":
        responseReturn = Response(-1, "请输入班级~")
        return HttpResponse(responseReturn.__str__())

    filterinfo = FilterInfoService.getFilterInfo(registyear, major, classname)
    if filterinfo is None:
        filterinfoid = FilterInfoService.addFilterInfo(registyear, major,
                                                       classname)
        responseReturn = Response(None, None)
        return HttpResponse(responseReturn.__str__())
    else:
        responseReturn = Response(-1, "已有此班级,请重新输入~")
        return HttpResponse(responseReturn.__str__())
Beispiel #22
0
def delFilterInfo(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())

    filterid = utils.getParam(request, "filterid")
    if filterid == "" or filterid is None:
        responseReturn = Response(-1, "请选择一个班级")
        return HttpResponse(responseReturn.__str__())

    filterinfo = FilterInfoService.getFilterInfoById(filterid)
    if filterinfo is None:
        responseReturn = Response(-1, "此班级不存在~")
        return HttpResponse(responseReturn.__str__())

    count = StudentService.getCountStudentByFilterInfo(filterid)
    if count > 0:
        responseReturn = Response(-1, "该班级下还有同学,不能删除哦~")
        return HttpResponse(responseReturn.__str__())

    filterdelinfo = FilterInfoService.delFilterInfo(filterid)
    if filterdelinfo is None:
        responseReturn = Response(-1, "删除失败,请重试!")
        return HttpResponse(responseReturn.__str__())

    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Beispiel #23
0
def addAdmin(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    teachernum = utils.getParam(request, "teachernum")
    teachername = utils.getParam(request, "teachername")
    if (teachername == "" or teachernum == ""):
        responseReturn = Response("-1", "填写的信息不能为空!")
        return HttpResponse(responseReturn.__str__())
    teacher = TeacherService.getTeacherByNumber(teachernum)
    if teacher is None:
        teacherid = TeacherService.addTeacher(teachername, teachernum)
        teacher = TeacherService.getTeacherById(teacherid)
    if teacher.name != teachername:
        responseReturn = Response("-1", "教师姓名与教师编号不符,请确认!")
        return HttpResponse(responseReturn.__str__())
    admin = AdminService.getAdminByTeacherId(teacher.id)
    if admin is not None:
        responseReturn = Response("-1", "此教师已经设置过管理员!")
        return HttpResponse(responseReturn.__str__())
    adminid = AdminService.addAdmin(teacher.id)
    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Beispiel #24
0
def getStudentListByExcel(filename):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    studentlist = []
    book = xlrd.open_workbook(CONSTANTS.STUDENTLISTURL_PRE + filename)
    sheet0 = book.sheet_by_index(0)
    nrows = sheet0.nrows  # 获取行总数
    for i in range(nrows):
        if i == 0:
            continue
        row_data = sheet0.row_values(i)
        student = {
            "name": sheet0.cell_value(i, 0),
            "number": str(int(sheet0.cell_value(i, 1))),
        }
        studentlist.append(student)
    return studentlist
Beispiel #25
0
def addexperiment(request):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    experimentid = utils.getParam(request, "experimentid")
    deadlinestr = utils.getParam(request, "deadline") + " 00:00:00"
    templatetype = utils.getParam(request, "templatetype")
    videotype = utils.getParam(request, "videotype")
    datatype = utils.getParam(request, "datatype")
    videoids = utils.getParam(request, "videos")
    point = utils.getParam(request, "point")
    remark = utils.getParam(request, "remark")
    studentids = utils.getParam(request, "studentids")
    '''
        获得实验详情
    '''
    experiment = ExperimentService.getExperimentById(experimentid)
    if experiment is None:
        responseReturn = Response(-1, "选择实验异常!")
        return HttpResponse(responseReturn.__str__())
    try:
        deadline = datetime.datetime.strptime(deadlinestr, "%Y-%m-%d %H:%M:%S")
    except:
        responseReturn = Response(-1, "请选择报告提交截止日期!")
        return HttpResponse(responseReturn.__str__())
    '''
        获得模板
    '''
    if templatetype == "1":
        templateid = experiment.templateid
    else:  # 文件上传
        templatefile = request.FILES.get('templatefile', None)
        if templatefile is None:
            responseReturn = Response(-1, "请选择你要上传的模板文件!")
            return HttpResponse(responseReturn.__str__())
        filename = templatefile.name
        filesuffix = os.path.splitext(filename)[1]
        if filesuffix != ".doc" and filesuffix != ".docx":
            responseReturn = Response(-1, "模板必须为word格式!")
            return HttpResponse(responseReturn.__str__())
        filename = str(uuid.uuid1()) + filesuffix
        fp = open(os.path.join(CONSTANTS.DATAURL_PRE, filename), 'wb+')
        for chunk in templatefile.chunks():  # 分块写入文件
            fp.write(chunk)
        fp.close()
        templateid = TemplateService.addTemplate(experimentid, filename)
    '''
        获得视频
    '''
    if videotype == "1":
        videos = experiment.videos
    else:
        videos = videoids
    '''
        获得实验数据
    '''
    if datatype == "1":  # 稍后上传
        dataurl = "none"
    else:  # 上传实验数据
        datafile = request.FILES.get('datafile', None)
        if datafile is None:
            responseReturn = Response(-1, "请选择你要上传的实验数据!")
            return HttpResponse(responseReturn.__str__())
        filename = datafile.name
        filesuffix = os.path.splitext(filename)[1]
        if filesuffix != ".xsl" and filesuffix != ".xlsx":
            responseReturn = Response(-1, "实验数据必须为excel!")
            return HttpResponse(responseReturn.__str__())
        filename = str(uuid.uuid1()) + filesuffix
        fp = open(os.path.join(CONSTANTS.DATAURL_PRE, filename), 'wb+')
        for chunk in datafile.chunks():  # 分块写入文件
            fp.write(chunk)
        fp.close()
        dataurl = filename
    '''
        获得学生名单
    '''
    studentidList = studentids.split(",")
    # 添加
    teachingid = TeachingService.addTeaching(int(experimentid), deadline,
                                             teacherid, point, remark, dataurl,
                                             "", templateid, videos)
    if teachingid is None:
        responseReturn = Response(-1, "添加失败,请重试")
        return HttpResponse(responseReturn.__str__())
    for id in studentidList:
        studentobj = None
        studentobj = StudentService.getStudentById(id)
        if studentobj is None:
            TeachingService.deleteTeachingByid(teachingid)
            responseReturn = Response(-1, "选择学生异常,请重试!")
            return HttpResponse(responseReturn.__str__())
        ReportService.addReport(teachingid, studentobj.id)

    responseReturn = Response(0, "添加成功!")
    return HttpResponse(responseReturn.__str__())