Ejemplo n.º 1
0
 def execute(self):
     params = ParamUtil(request)
     pid = params.safeGetIntParam("pid")
     unitService = __spring__.getBean("unitService")
     unitlist = unitService.getChildUnitListByParenId(pid,[False])
     json = "["
     jsonData = JSONObject()
     for u in unitlist:
         jsonData.put("NodeId",str(u.unitId))
         jsonData.put("LinkText",u.unitTitle + u"(" + u.siteTitle + u")")
         jsonData.put("LinkTitle",u.siteTitle)
         jsonData.put("LinkHref","transfer.py?unitName=" + u.unitName)
         if u.hasChild:
             jsonData.put("ChildCount","1")
         else:
             jsonData.put("ChildCount","0")
         json += jsonData.toString() + ","
     if json.endswith(","):
         json = json[0:len(json)-1]
     json += "]"
     response.setCharacterEncoding("UTF-8")
     response.setContentType("text/plain")
     response.getWriter().write(json)
Ejemplo n.º 2
0
    def execute(self):
        evaluationService = __spring__.getBean("evaluationService")
        evaluationPlanId = self.params.safeGetIntParam("evaluationPlanId")
        evaluationPlan = evaluationService.getEvaluationPlanById(
            evaluationPlanId)
        if evaluationPlan == None:
            self.addActionError(u"不能加载评课活动,无法进行评课。")
            return self.ERROR
        if evaluationPlan.enabled == False:
            self.addActionError(u"该评课活动没有启用,无法进行评课。")
            return self.ERROR
        #判断是否过期
        beginDate = evaluationPlan.startDate
        endDate = evaluationPlan.endDate
        nowDate = Date()
        if beginDate.compareTo(nowDate) > -1 or endDate.compareTo(nowDate) < 1:
            self.addActionError(u"该评课活动日期已过,无法进行评课。")
            return self.ERROR

        if request.getMethod() == "POST":
            fieldcount = self.params.safeGetIntValues("fieldcount")
            title = self.params.safeGetStringParam("titleName")
            teacherName = self.params.safeGetStringParam("teacherName")
            metaGradeId = self.params.getIntParamZeroAsNull("gradeId")
            metaSubjectId = self.params.getIntParamZeroAsNull("subjectId")

            if title == "" or teacherName == "":
                self.addActionError(u"请输入评课名称和授课人。")
                return self.ERROR

            content = ""
            for num in fieldcount:
                fname = self.params.safeGetStringParam("fieldname" + str(num))
                fconntent = self.params.safeGetStringParam("fieldcontent" +
                                                           str(num))
                if fname != "":
                    content += "{" + JSONObject.toString(fname,
                                                         fconntent) + "},"
            if content != "":
                if content.endswith(","):
                    content = content[0:len(content) - 1]
                content = "[" + content + "]"

            templateId = self.params.safeGetIntParam("templateId")
            evaluationContent = EvaluationContent()
            evaluationContent.setTitle(title)
            evaluationContent.setCourseTeacherName(teacherName)
            evaluationContent.setPublishUserId(self.loginUser.userId)
            evaluationContent.setPublishUserName(self.loginUser.trueName)
            evaluationContent.setMetaSubjectId(metaSubjectId)
            evaluationContent.setMetaGradeId(metaGradeId)
            evaluationContent.setEvaluationPlanId(evaluationPlanId)
            evaluationContent.setEvaluationTemplateId(templateId)
            evaluationContent.setPublishContent(content)
            evaluationService.saveOrUpdateEvaluationContent(evaluationContent)
            response.sendRedirect("evaluations.py")

        if self.params.existParam("templateId"):
            templateId = self.params.safeGetIntParam("templateId")
            template = evaluationService.getEvaluationTemplateById(templateId)
            evaluationPlan = evaluationService.getEvaluationPlanById(
                evaluationPlanId)
            if evaluationPlan == None:
                self.addActionError(u"不能加载评课活动,无法进行评课。")
                return self.ERROR
            if template == None:
                self.addActionError(u"不能加载评课模板,无法进行评课。")
                return self.ERROR
            self.putSubjectList()
            self.putGradeList()
            request.setAttribute("template", template)
            request.setAttribute("evaluationPlan", evaluationPlan)
            return "/WEB-INF/ftl/evaluation/evaluation_content_edit.ftl"

        else:
            qry = EvaluationTemplateQuery(
                "et.evaluationTemplateId, et.evaluationTemplateName")
            qry.enabled = True
            template_list = qry.query_map(qry.count())
            if len(template_list) < 1:
                self.addActionError(u"当前没有模板可供选择,无法进行评课。")
                return self.ERROR
            elif len(template_list) == 1:
                response.sendRedirect(
                    "evaluation_content_edit.py?evaluationPlanId=" +
                    str(evaluationPlanId) + "&templateId=" +
                    str(template_list[0]["evaluationTemplateId"]))
            else:
                request.setAttribute("template_list", template_list)
                request.setAttribute("evaluationPlanId", evaluationPlanId)
                return "/WEB-INF/ftl/evaluation/evaluation_content_edit_select_template.ftl"
Ejemplo n.º 3
0
    def execute(self):
        evaluationPlanId = self.params.getIntParam("evaluationPlanId")
        if evaluationPlanId == 0:
            self.addActionError(u"缺少评课Id。")
            return self.ERROR
        evaluationPlan = self.evaluationService.getEvaluationPlanById(
            evaluationPlanId)
        if evaluationPlan == None:
            self.addActionError(u"没有找到该评课。")
            return self.ERROR

        #判断是否过期,过期的按照完成状态来显示
        #print "evaluationPlanId="+str(evaluationPlanId)

        beginDate = evaluationPlan.startDate
        endDate = evaluationPlan.endDate
        nowDate = Date()
        if beginDate.compareTo(nowDate) > -1 or endDate.compareTo(nowDate) < 1:
            self.finish = 1
        request.setAttribute("finish", self.finish)

        if self.finish == 0:
            if self.loginUser == None:
                errDesc = u"请先<a href='login.jsp'>登录</a>,然后才能进行评课"
                response.getWriter().write(errDesc)
                return

        request.setAttribute("evaluationPlan", evaluationPlan)

        plantemplate_list = self.evaluationService.getEvaluationTemplates(
            evaluationPlanId)
        request.setAttribute("plantemplate_list", plantemplate_list)

        video_list = self.evaluationService.getVideosAuditState(
            evaluationPlanId)
        resource_list = self.evaluationService.getResourcesAuditState(
            evaluationPlanId)
        request.setAttribute("video_list", video_list)
        request.setAttribute("resource_list", resource_list)

        metaSubjectId = evaluationPlan.metaSubjectId
        metaGradeId = evaluationPlan.metaGradeId
        self.subject = self._get_subj_svc().getSubjectByMetaData(
            metaSubjectId, metaGradeId)
        self.grade = self._get_subj_svc().getGrade(metaGradeId)
        if self.subject != None:
            msubjName = self.subject.subjectName
        if self.grade != None:
            gradeName = self.grade.gradeName
        request.setAttribute("msubjName", msubjName)
        request.setAttribute("gradeName", gradeName)

        #print "request.getMethod()="+request.getMethod()

        if request.getMethod() == "POST":
            templateId = self.params.getIntParam("tempId")
            print "templateId=" + str(templateId)
            field_list = self.evaluationService.getEvaluationTemplateFields(
                templateId)
            content = ""
            for f in field_list:
                fname = self.params.safeGetStringParam("fieldname" +
                                                       str(f.fieldsId))
                fconntent = self.params.safeGetStringParam("fieldcontent" +
                                                           str(f.fieldsId))
                if fname != "":
                    content += "{" + JSONObject.toString(fname,
                                                         fconntent) + "},"
            if content != "":
                if content.endswith(","):
                    content = content[0:len(content) - 1]
                content = "[" + content + "]"
            #保存评课内容
            evaluationContent = EvaluationContent()
            evaluationContent.setPublishUserId(self.loginUser.userId)
            evaluationContent.setPublishUserName(self.loginUser.trueName)
            evaluationContent.setEvaluationPlanId(evaluationPlanId)
            evaluationContent.setEvaluationTemplateId(templateId)
            evaluationContent.setPublishContent(content)
            self.evaluationService.saveOrUpdateEvaluationContent(
                evaluationContent)

        content_list = self.evaluationService.getEvaluationContents(
            evaluationPlanId)
        request.setAttribute("content_list", content_list)
        return "/WEB-INF/ftl/evaluation/evaluation_content.ftl"