示例#1
14
 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')
示例#2
0
 def get(self):
     gp, uid = is_loged(self)
     print uid
     if uid == str(int(1e6)):
         self.render("admin.html", temp=getTempUser(), active="none")
     else:
         self.redirect("/404")
示例#3
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 't':
         self.render('teacher_my_notifications.html', id=uid, active='dsh', active_slide='ntfc',
                     info=get_teacher_notif(uid))
     else:
         self.redirect('/404')
示例#4
0
 def get(self):
     gp, uid = is_loged(self)
     print uid
     if uid == str(int(1e6)):
         self.render('admin.html', temp=getTempUser(), active='none')
     else:
         self.redirect('/404')
示例#5
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 's':
         self.render('stu_message.html', id=uid, message=get_all_notif(), comments=get_all_comments(uid),
                     active='dsh', active_slide='msg')
     else:
         self.redirect('/404')
    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
示例#7
0
 def get(self, tp_id):
     gp, uid = is_loged(self)
     try:
         if uid == str(int(1e6)):
             returned = authNewUser(tp_id)
             if returned == "success":
                 self.render('error.html',
                             title='认证成功',
                             content='新用户授权成功',
                             icon='ion-checkmark-circled',
                             active='',
                             id=uid)
             elif returned == 'fail':
                 self.render('error.html',
                             title='认证失败',
                             content='新用户授权失败',
                             icon='ion-close-circled',
                             active='',
                             id=uid)
         else:
             print uid
             self.redirect('/404')
     except:
         self.render('error.html',
                     title=None,
                     content='出错啦',
                     icon='ion-alert-circled',
                     active='none',
                     id=uid)
示例#8
0
    def post(self, *args, **kwargs):
        """教师新增课程"""

        gp, uid = is_loged(self)

        if gp == 't':
            cid = self.get_argument('cid')
            year = self.get_argument('year')
            start_week = int(self.get_argument('sw'))
            end_week = int(self.get_argument('ew'))

            if end_week > 20 or end_week < start_week or not (0 < start_week < 18):
                self.render('error.html', title='输入错误', content='周数输入有误<br><br>请重新输入', icon='ion-alert-circled',
                            active='dsh', id=uid)
            elif get_course(cid) is not None:
                self.render('error.html', title='输入错误', content='课序号已经存在<br><br>请删除相应课程后在进行创建新课程的操作',
                            icon='ion-alert-circled', active='dsh', id=uid)
            else:
                try:
                    new_course(uid, cid, year, str(start_week), str(end_week))
                    self.render('error.html', title='操作成功', content='课程创建成功', icon='ion-checkmark-circled',
                                active='dsh', id=uid)
                except Exception as e:
                    print e
                    self.render('error.html', title=None, content=None, icon='ion-bug', active='dsh', id=uid)
示例#9
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 't':
         self.render('teacher_commenting.html', id=uid, active='dsh', active_slide='cmt',
                     homework=get_teacher_homework(uid))
     else:
         self.redirect('/404')
示例#10
0
    def post(self, *args, **kwargs):
        gp, uid = is_loged(self)
        if gp == 't':
            content = self.get_argument('content')
            title = self.get_argument('title')

            if len(title) > 50:
                self.render('error.html', title=None, content='标题过长<br>请重新输入', icon='ion-alert-circled', active='ntfc',
                            id=uid)
            else:

                from postingInfo import infoIdState
                idInfo = infoIdState(self)

                try:
                    if not publish_notif(uid, idInfo, content, title):
                        self.render('error.html', title='通知发布成功', content='成功发布了一条课程通知', icon='ion-checkmark-circled',
                                    active='dsh', id=uid)
                        self.clear_cookie('Iid')
                    else:
                        print 'teacher not exist'
                        self.clear_cookie('Iid')
                except Exception as e:
                    self.clear_cookie('Iid')
                    print e
示例#11
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 't':
         self.render('teacher_my_students.html', id=uid, active='dsh', active_slide='allstu',
                     stu=get_my_student(uid))
     else:
         self.redirect('/404')
示例#12
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(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')
示例#13
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')
示例#14
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 's':
         # 判断是否登陆
         cid = get_student_course(uid)
         if not cid:
             # 数据库中没有课程号记录
             self.render('error.html',
                         title=None,
                         content='提交作业要先录入课程号哦',
                         icon='ion-happy',
                         active='',
                         id=uid)
         else:
             self.render('stu_submit_vedio.html',
                         id=uid,
                         active='dsh',
                         active_slide='mcs')
     else:
         self.render('error.html',
                     title=None,
                     content='提交作业要先登陆哦',
                     icon='ion-happy',
                     active='',
                     id=uid)
示例#15
0
    def post(self):
        gp, uid = is_loged(self)
        if gp == 't':
            Iid = infoIdState(self)
            fname = self.request.files['upload'][0].filename

            import os
            dirpath = os.path.dirname(__file__)[:-8] + 'static/notif/'

            # 生成pic文件名
            import random
            filename = Iid + str(random.randint(99, 1000)) +'.'+ fname.split('.')[-1]
            while True:
                cmd = 'find %s -name "%s"' % (dirpath,clean(filename))
                if not commands.getstatusoutput(cmd)[1]:
                    break
                filename = Iid + str(random.randint(99, 1000)) + fname.split('.')[-1]

            f = self.request.files['upload'][0].body

            savefile = open(dirpath+filename,'w')
            savefile.write(f)
            savefile.close()

            callback = self.get_argument('CKEditorFuncNum')

            self.write('''
                <script type="text/javascript">
                    window.parent.CKEDITOR.tools.callFunction("%s","%s",'');
                </script>
                ''' % (callback,'/static/notif/'+filename))
示例#16
0
    def get(self, cid, *args, **kwargs):

        gp, uid = is_loged(self)
        if gp == 's':
            if not get_course(cid):
                # 如果课序号不存在
                self.render('error.html',
                            title=None,
                            content="课程不存在",
                            icon='ion-sad',
                            active='dsh',
                            id=uid)
            else:
                try:
                    set_course(uid, cid)
                    self.render('error.html',
                                title="录入成功",
                                content="课程号录入成功",
                                icon='ion-checkmark-circled',
                                active='dsh',
                                id=uid)
                except Exception as e:
                    print e

        else:
            self.redirect('/404')
示例#17
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
                        from models.security import clean
                        delete_updated(clean(hid))
                        delete_homework(hid, uid)
                    else:
                        delete_homework(hid, uid)

                    self.redirect('/dash/myHomework')

                except Exception as e:
                    print e

        else:
            self.redirect('/404')
示例#18
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')
示例#19
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 't':
         self.render('teacher_publish_notif.html', id=uid, active='dsh', active_slide='ntfc', n_title=None,
                     content=None, act='pub')
     else:
         self.redirect('/404')
示例#20
0
    def post(self, *args, **kwargs):
        gp, uid = is_loged(self)
        if gp == 's':
            fname = self.request.files['profile'][0].filename
            if not extensionJudge(fname, uid, self):

                hid = self.get_secure_cookie('hid')

                if self.get_secure_cookie('frontal') == '1' and self.get_secure_cookie('submitName') is not None \
                        and self.get_secure_cookie('top') == '1' and hid is not None:
                    # 判断是否已经完成了之前的提交步骤

                    f = self.request.files['profile'][0].body
                    saveFile(fname, hid, f, 'profile')

                    try:
                        content = base64.decodestring(self.get_secure_cookie('content'))
                        submitName = base64.decodestring(self.get_secure_cookie('submitName'))
                        print content, submitName
                        submit_homework(hid, uid, content, submitName)

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

                        self.render('error.html', title="提交成功", content='作业提交成功', icon='ion-checkmark-circled', id=uid,
                                    active='dsh')
                    except Exception as e:
                        print e
                else:
                    self.render('error.html', title=None, content='请按顺序交作业哦', icon='ion-happy', active='dsh', id=uid)
示例#21
0
    def post(self, *args, **kwargs):
        gp, uid = is_loged(self)
        if gp == 's':
            fname = self.request.files['frontal'][0].filename
            if not extensionJudge(fname, uid, self):

                hid = self.get_secure_cookie('hid')

                if self.get_secure_cookie('submitName') != '' and hid != '':
                    # 判断是否已经完成了之前的提交步骤
                    f = self.request.files['frontal'][0].body

                    saveFile(fname, hid, f, 'frontal')

                    self.set_secure_cookie('frontal', '1')
                    self.render('stu_step3.html',
                                id=uid,
                                active='dsh',
                                active_slide='mcs')

                else:
                    self.render('error.html',
                                title=None,
                                content='请按顺序交作业哦',
                                icon='ion-happy',
                                active='dsh',
                                id=uid)
示例#22
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 't':
         self.clear_cookie('Iid')
         self.render('teacher_publish_resource.html', id=uid, active='dsh', active_slide='ntfc', r_content=None,
                     r_title=None, act='pub')
     else:
         self.redirect('/404')
示例#23
0
    def get(self):
        gp, uid = is_loged(self)

        if gp == 't':
            self.render('teacher_edit_course.html', id=uid, active='dsh', active_slide='mycourse',
                        course=get_teacher_course(uid), delete=get_teacher_course_delete(uid))
        else:
            self.redirect('/404')
示例#24
0
    def get(self, *args, **kwargs):

        gp, uid = is_loged(self)
        if gp == 's':
            course = get_all_course()
            self.render('stu_set_course.html', active='dsh', active_slide='mcs', course=course)

        else:
            self.redirect('/404')
示例#25
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 't':
         self.render('teacher_publish_entrence.html',
                     id=uid,
                     active='dsh',
                     active_slide='ntfc')
     else:
         self.redirect('/404')
示例#26
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 't':
         self.render(
             'teacher_publish_entrence.html',
             id=uid,
             active='dsh',
             active_slide='ntfc')
     else:
         self.redirect('/404')
示例#27
0
 def post(self, hid):
     gp, uid = is_loged(self)
     if gp == 't':
         comment = self.get_argument('comment')
         try:
             update_comment(hid, comment)
             self.render('error.html', title='评价成功', content='您对这次作业已经评价过了!', icon='ion-checkmark-circled',
                         active='dsh', id=uid)
         except Exception as e:
             print(e)
示例#28
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 't':
         self.render('teacher_my_students.html',
                     id=uid,
                     active='dsh',
                     active_slide='allstu',
                     stu=get_my_student(uid))
     else:
         self.redirect('/404')
示例#29
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 't':
         self.render('teacher_my_notifications.html',
                     id=uid,
                     active='dsh',
                     active_slide='ntfc',
                     info=get_teacher_notif(uid))
     else:
         self.redirect('/404')
示例#30
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 's':
         self.render('stu_homework.html',
                     homework=get_my_homework(uid),
                     id=uid,
                     active='dsh',
                     active_slide='hmwk')
     else:
         self.redirect('/404')
示例#31
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 't':
         self.render('teacher_commenting.html',
                     id=uid,
                     active='dsh',
                     active_slide='cmt',
                     homework=get_teacher_homework(uid))
     else:
         self.redirect('/404')
示例#32
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 's':
         self.render('stu_message.html',
                     id=uid,
                     message=get_all_notif(),
                     comments=get_all_comments(uid),
                     active='dsh',
                     active_slide='msg')
     else:
         self.redirect('/404')
示例#33
0
    def get(self,iid):
        gp, uid = is_loged(self)

        if gp == 't':
            try:
                delete_notif(iid,uid)
                self.redirect('/dash/notifications')
            except Exception as e:
                print e
        else:
            self.redirect('/')
示例#34
0
    def get(self, *args, **kwargs):

        gp, uid = is_loged(self)
        if gp == 's':
            course = get_all_course()
            self.render('stu_set_course.html',
                        active='dsh',
                        active_slide='mcs',
                        course=course)

        else:
            self.redirect('/404')
示例#35
0
    def get(self):
        gp, uid = is_loged(self)

        if gp == 't':
            self.render('teacher_edit_course.html',
                        id=uid,
                        active='dsh',
                        active_slide='mycourse',
                        course=get_teacher_course(uid),
                        delete=get_teacher_course_delete(uid))
        else:
            self.redirect('/404')
示例#36
0
 def get(self, *args, **kwargs):
     gp, uid = is_loged(self)
     if gp == 's':
         # 判断是否登陆
         cid = get_student_course(uid)
         if not cid:
             # 数据库中没有课程号记录
             self.render('error.html', title=None, content='提交作业要先录入课程号哦', icon='ion-happy', active='', id=uid)
         else:
             self.render('stu_submit_vedio.html', id=uid, active='dsh', active_slide='mcs')
     else:
         self.render('error.html', title=None, content='提交作业要先登陆哦', icon='ion-happy', active='', id=uid)
示例#37
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')
示例#38
0
 def post(self, hid):
     gp, uid = is_loged(self)
     if gp == 't':
         comment = self.get_argument('comment')
         try:
             update_comment(hid, comment)
             self.render('error.html',
                         title='评价成功',
                         content='您对这次作业已经评价过了!',
                         icon='ion-checkmark-circled',
                         active='dsh',
                         id=uid)
         except Exception as e:
             print(e)
示例#39
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')
示例#40
0
    def get(self,iid):
        gp, uid = is_loged(self)

        if gp == 't':
            try:
                delete_notif(iid,uid) # 删除记录
                from submitAssignment import delete_updated
                delete_updated('notif',iid) # 删除文件

                self.redirect('/dash/notifications')

            except Exception as e:
                print e
        else:
            self.redirect('/')
示例#41
0
    def get(self, infoId, *args, **kwargs):
        gp, uid = is_loged(self)

        if gp == 't':

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

            info = get_info(infoId)
            content = info['detail']
            title = info['t‎itle']

            self.render('teacher_publish_notif.html', id=uid, active='dsh', active_slide='ntfc', n_title=title,
                        content=content, act='edit')

        else:
            self.redirect('/404')
示例#42
0
    def get(self, cid, *args, **kwargs):

        gp, uid = is_loged(self)
        if gp == 's':
            if not get_course(cid):
                # 如果课序号不存在
                self.render('error.html', title=None, content="课程不存在", icon='ion-sad', active='dsh', id=uid)
            else:
                try:
                    set_course(uid, cid)
                    self.render('error.html', title="录入成功", content="课程号录入成功", icon='ion-checkmark-circled',
                                active='dsh', id=uid)
                except Exception as e:
                    print e

        else:
            self.redirect('/404')
示例#43
0
 def get(self, tp_id):
     gp, uid = is_loged(self)
     try:
         if uid == str(int(1e6)):
             returned = authNewUser(tp_id)
             if returned == "success":
                 self.render(
                     "error.html", title="认证成功", content="新用户授权成功", icon="ion-checkmark-circled", active="", id=uid
                 )
             elif returned == "fail":
                 self.render(
                     "error.html", title="认证失败", content="新用户授权失败", icon="ion-close-circled", active="", id=uid
                 )
         else:
             print uid
             self.redirect("/404")
     except:
         self.render("error.html", title=None, content="出错啦", icon="ion-alert-circled", active="none", id=uid)
示例#44
0
    def post(self, *args, **kwargs):
        gp, uid = is_loged(self)
        if gp == 't':
            content = self.get_argument('content')
            title = self.get_argument('title')

            if len(title) > 50:
                self.render('error.html', title=None, content='标题过长<br>请重新输入', icon='ion-alert-circled', active='ntfc',
                            id=uid)
            else:
                idInfo = generateInfoid()

                try:
                    publish_res(uid, idInfo, content, title)
                    self.render('error.html', title='资源发布成功', content='成功发布了一条课程资源', icon='ion-checkmark-circled',
                                active='ntfc', id=uid)
                except Exception as e:
                    print e
示例#45
0
    def post(self, *args, **kwargs):
        gp, uid = is_loged(self)
        if gp == 's':
            fname = self.request.files['profile'][0].filename
            if not extensionJudge(fname, uid, self):

                hid = self.get_secure_cookie('hid')

                if self.get_secure_cookie('frontal') == '1' and self.get_secure_cookie('submitName') is not None \
                        and self.get_secure_cookie('top') == '1' and hid is not None:
                    # 判断是否已经完成了之前的提交步骤

                    f = self.request.files['profile'][0].body
                    saveFile(fname, hid, f, 'profile')

                    try:
                        content = base64.decodestring(
                            self.get_secure_cookie('content'))
                        submitName = base64.decodestring(
                            self.get_secure_cookie('submitName'))
                        print content, submitName
                        submit_homework(hid, uid, content, submitName)

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

                        self.render('error.html',
                                    title="提交成功",
                                    content='作业提交成功',
                                    icon='ion-checkmark-circled',
                                    id=uid,
                                    active='dsh')
                    except Exception as e:
                        print e
                else:
                    self.render('error.html',
                                title=None,
                                content='请按顺序交作业哦',
                                icon='ion-happy',
                                active='dsh',
                                id=uid)
示例#46
0
    def post(self, *args, **kwargs):
        """教师新增课程"""

        gp, uid = is_loged(self)

        if gp == 't':
            cid = self.get_argument('cid')
            year = self.get_argument('year')
            start_week = int(self.get_argument('sw'))
            end_week = int(self.get_argument('ew'))

            if end_week > 20 or end_week < start_week or not (0 < start_week <
                                                              18):
                self.render('error.html',
                            title='输入错误',
                            content='周数输入有误<br><br>请重新输入',
                            icon='ion-alert-circled',
                            active='dsh',
                            id=uid)
            elif get_course(cid) is not None:
                self.render('error.html',
                            title='输入错误',
                            content='课序号已经存在<br><br>请删除相应课程后在进行创建新课程的操作',
                            icon='ion-alert-circled',
                            active='dsh',
                            id=uid)
            else:
                try:
                    new_course(uid, cid, year, str(start_week), str(end_week))
                    self.render('error.html',
                                title='操作成功',
                                content='课程创建成功',
                                icon='ion-checkmark-circled',
                                active='dsh',
                                id=uid)
                except Exception as e:
                    print e
                    self.render('error.html',
                                title=None,
                                content=None,
                                icon='ion-bug',
                                active='dsh',
                                id=uid)
示例#47
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')
示例#48
0
    def post(self, *args, **kwargs):
        gp, uid = is_loged(self)
        if gp == 's':
            fname = self.request.files['frontal'][0].filename
            if not extensionJudge(fname, uid, self):

                hid = self.get_secure_cookie('hid')

                if self.get_secure_cookie('submitName') != '' and hid != '':
                    # 判断是否已经完成了之前的提交步骤
                    f = self.request.files['frontal'][0].body

                    saveFile(fname, hid, f, 'frontal')

                    self.set_secure_cookie('frontal', '1')
                    self.render('stu_step3.html', id=uid, active='dsh', active_slide='mcs')

                else:
                    self.render('error.html', title=None, content='请按顺序交作业哦', icon='ion-happy', active='dsh', id=uid)
示例#49
0
    def post(self, infoId, *args, **kwargs):
        gp, uid = is_loged(self)
        if gp == 't':
            content = self.get_argument('content')
            title = self.get_argument('title')

            if len(title) > 50:
                self.render('error.html', title=None, content='标题过长<br>请重新输入', icon='ion-alert-circled', active='ntfc',
                            id=uid)
            else:
                if not get_info(infoId):
                    self.render('error.html', title=None, content='通知不存在', icon='ion-sad', active='dsh', id=uid)
                else:
                    try:
                        if not update_notif(infoId, content, title):
                            self.render('error.html', title='通知更新成功', content='成功更新了一条课程通知', icon='ion-checkmark-circled',
                                        active='dsh', id=uid)
                        else:
                            print 'teacher not exist'
                    except Exception as e:
                        print e
示例#50
0
 def get(self, cid):
     gp, uid = is_loged(self)
     if gp == 't':
         self.write('haha')  # 测试消息
     else:
         self.redirect('/404')
示例#51
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')
示例#52
-28
    def get(self, infoId, *args, **kwargs):
        gp, uid = is_loged(self)

        if gp == 't':
            info = get_info(infoId)
            content = html2Text(info['detail'])
            title = info['t‎itle']

            self.render('teacher_publish_resource.html', id=uid, active='dsh', active_slide='ntfc', r_title=title,
                        r_content=content, act='edit')
        else:
            self.redirect('/404')