Пример #1
0
    def post(self):
        gp, uid = is_loged(self)
        if gp == 's':
            content = self.get_argument('content')
            submitName = self.get_argument('submitName')

            # 生成idhomework
            import random

            idHomework = uid + str(random.randint(99, 1000))
            while True:
                # 获取idhomework的值直到获取到数据库中与其他记录不冲突为止
                if not get_homework(idHomework):
                    break
                idHomework = uid + str(random.randint(99, 1000))

            # 删除文件夹下所有相同id的文件
            delete_updated('homework', idHomework)

            self.clear_cookie('content')
            self.clear_cookie('submitName')
            self.clear_cookie('hid')
            self.clear_cookie('frontal')
            self.clear_cookie('top')

            self.set_secure_cookie('content', base64.encodestring(content.encode('utf8')))  # 命名简单加密后加载到cookie中保存
            self.set_secure_cookie('submitName', base64.encodestring(submitName.encode('utf8')))
            self.set_secure_cookie('hid', idHomework)
            self.render('stu_step2.html', id=uid, active='dsh', active_slide='mcs')
Пример #2
0
    def get(self, hid, *args, **kwargs):
        gp, uid = is_loged(self)
        if gp == 's':
            # 仅学生可以删除自己的作业..?
            homework = get_homework(hid)

            if not homework:
                self.render('error.html', title=None, content="作业不存在", icon='ion-sad', active='dsh', id=uid)

            else:
                try:
                    if homework['type'] == 'pic':
                        # 作业是图片类型
                        from submitAssignment import delete_updated
                        delete_updated('homework',hid)
                        delete_homework(hid,uid)

                    else:
                        delete_homework(hid,uid)

                    self.redirect('/dash/myHomework')

                except Exception as e:
                    print e

        else:
            self.redirect('/404')
Пример #3
0
 def get(self, hid):
     gp, uid = is_loged(self)
     if gp == 't':
         h = get_homework(hid)
         comment = html2Text(h['comment'])
         self.render('teacher_cmt_homework.html', id=uid, active='dsh', active_slide='cmt', hid=hid, comment=comment)
     else:
         self.redirect('/404')
Пример #4
0
    def get(self, hid):
        gp, uid = is_loged(self)

        if gp == 't':

            self.clear_cookie('Iid')
            self.set_secure_cookie('Iid',hid)

            h = get_homework(hid)
            comment = h['comment']
            self.render('teacher_cmt_homework.html', id=uid, active='dsh', active_slide='cmt', hid=hid, comment=comment)

        else:
            self.redirect('/404')
Пример #5
0
    def get(self, hid, *args, **kwargs):
        gp, uid = is_loged(self)

        homework = get_homework(hid)

        if not homework:
            self.render('error.html', title=None, content="作业不存在", icon='ion-sad', active='dsh', id=uid)

        else:
            if homework['type'] == 'pic':
                # 作业是图片类型

                path = get_file_path(hid)

                if len(path) != 3:
                    # 没有获得三个文件
                    self.render('error.html', title=None, content=None, icon='ion-sad', active='dsh', id=uid)
                else:

                    fname = []
                    for p in path:
                        f = p.split('/')[-1]
                        if f.split('.')[-1] in {'jpg', 'jpeg', 'png', 'gif', 'JPEG', 'JPG', 'tiff', 'tif', 'raw'}:
                            fname.append(f)

                    if len(fname) != 3:
                        # 没有获得三个图片文件
                        self.render('error.html', title=None, content=None, icon='ion-sad', active='dsh', id=uid)

                    else:
                        if gp == 's':
                            self.render('stu_homework_once.html', homework=homework, id=uid, active='dsh',
                                        active_slide='hmwk', front=fname[0], portrait=fname[1], top=fname[2])
                        elif gp == 't':
                            self.render('teacher_view_homework.html', homework=homework, id=uid, active='dsh',
                                        active_slide='cmt', front=fname[0], portrait=fname[1], top=fname[2])
            else:
                # video类型作业
                if gp == 's':
                    self.render('stu_homework_once.html', homework=homework, id=uid, active='dsh', active_slide='hmwk')
                elif gp == 't':
                    self.render('teacher_view_homework.html', homework=homework, id=uid, active='dsh',
                                active_slide='cmt')
Пример #6
0
    def post(self, *args, **kwargs):
        gp, uid = is_loged(self)
        if gp == 's':

            # 生成idhomework
            import random

            idHomework = uid + str(random.randint(99, 1000))
            while True:
                # 获取idhomework的值直到获取到数据库中与其他记录不冲突为止
                if not get_homework(idHomework):
                    break
                idHomework = uid + str(random.randint(99, 1000))

            name = self.get_argument('submitName').encode('utf-8')
            content = self.get_argument('content').encode('utf-8')

            try:
                submit_homework_vedio(idHomework, uid, content, name)
                self.render('error.html', title="提交成功", content='作业提交成功', icon='ion-checkmark-circled', id=uid,
                            active='dsh')
            except Exception as e:
                print e